function popup_image(i_path,i_desc) 
{
	var open_path = '/crave/image.htm?path='+i_path;

	if (typeof(i_desc) != "undefined") 
	{
		open_path = open_path + '&desc='+i_desc;
	}
	pop = window.open(open_path,'Popup','toolbar=0,location=no,directories=0,status=0,scrollbars=yes,resizable=yes');
	if (navigator.appName == 'Netscape') 
	{
		pop.focus();
	}
}

function addTag(id) 
{
	var tagFormDiv = document.getElementById("craveTags-" + id);
	tagFormDiv.style.display = "block";
}

function closeTagsForm(id)
{
	var tagFormDiv = document.getElementById("craveTags-" + id);
	tagFormDiv.style.display = "none";

	var e = document.getElementById('tagListLoading-' + id);
  	if(e != null) e.innerHTML = "&nbsp;";
}

var ajax_tag= new sack();

function postTagsLoading(){
	var tagCurrentPostID = document.getElementById("tagCurrentPostID");
	id =  tagCurrentPostID.value;

	var e = document.getElementById('tagListLoading-' + id);
  	e.style.display="inline";
	e.innerHTML = "Saving tags...";
}

function postTagsCompleted(){
	var tagCurrentPostID = document.getElementById("tagCurrentPostID");
	id =  tagCurrentPostID.value;

	var e = document.getElementById('tagListLoading-' + id);
  	e.innerHTML = "Tags have been saved...";

	var craveTagsInput = document.getElementById("craveTagsInput-" + id);
	var craveTagsInputVal = craveTagsInput.value;
	var trimedVal = craveTagsInputVal.replace(/^\s+|\s+$/g, '') ;

	var postTagLabel = document.getElementById("postTagLabel-"+ id);

	if(trimedVal == "")
	{
		postTagLabel.innerHTML = "Enter your tags below. Use commas to separate tags.";
	} else
	{
		postTagLabel.innerHTML = "Here are your tags. Edit or add new ones below. Use commas to separate tags.";
	}

	setTimeout("closeTagsForm(" + id + ")", 1600);
}

function doPostTags(id)
{
	var craveTagsInput = document.getElementById("craveTagsInput-" + id);
	var tagCurrentPostID = document.getElementById("tagCurrentPostID");

	tagCurrentPostID.value = id;

	ajax_tag.setVar("user_tags", craveTagsInput.value);
	ajax_tag.setVar("blogpost_id", id);

	ajax_tag.setVar("post_action", "post_tags");
			
	ajax_tag.requestFile = "/cnet/2009/crave/templates/tag_list.htm";
	ajax_tag.method = "POST";
	ajax_tag.element = 'tagList-' + id;

	ajax_tag.onLoading = postTagsLoading;
	ajax_tag.onCompletion = postTagsCompleted;

	ajax_tag.runAJAX();
}

function toggleCraveShare(id)
{
	var shareDiv = document.getElementById("craveShareDiv-" + id);

	if(shareDiv.style.display == "none" || shareDiv.style.display == "" || shareDiv.style.display == null)
	{
		shareDiv.style.display = "block";
	} else
	{
		shareDiv.style.display = "none";
	}
}


function toggleArchive(id)
{
	var archiveDiv = document.getElementById("achiveYear-" + id);
	var archiveToggleButton = document.getElementById("archiveToggleButton-" + id);

	if(archiveDiv.style.display == "none" || archiveDiv.style.display == "" || archiveDiv.style.display == null)
	{
		archiveDiv.style.display = "block";
		archiveToggleButton.src = "/cnet/2007/i/crv/_collapse.gif";
	} else
	{
		archiveDiv.style.display = "none";
		archiveToggleButton.src = "/cnet/2007/i/crv/_expand.gif";
	}
}