function saveCookie(name, value)
{
	//	The new piece of the cookie
	var cookie	= name + ":" + value;
	
	//	Set the cookie to expire in 30 days
	var date	= new Date();
	date.setTime( date.getTime() + (30*24*60*60*1000) );
	
	var expires = "expires=" + date.toGMTString();
	
	//	Look for other pieces of the cookie that need to be preserved
	var nameEQ	= "JesseJane=";
	var catCol	= name + ":";
	var parts	= document.cookie.split(';');
	
	for(var i = 0; i < parts.length; i++)
	{
		var part	= parts[i];
		
		while( part.charAt(0) == ' ' )
			part	= part.substring(1, part.length);
		
		if( part.indexOf(nameEQ) == 0 )
		{
			var temp	= part.split('=');
			var pieces	= temp[1].split(',');
			
			for( var j = 0; j < pieces.length; j++ )
			{
				var piece	= pieces[j];
				
				//	Save this piece if it's not the same as the one currently being saved
				if( piece.indexOf( catCol ) != 0 ) cookie += "," + piece;
			}
			
			break;
		}
	}
	
	//	Set the cookie
	document.cookie	= "JesseJane=" + cookie + "; " + expires + "; path=/; domain=.jessejane.com";
}

//	Ratings
	var ratingStarZero		= "/images/stars/zero.png";
	var ratingStarHalf		= "/images/stars/half.png";
	var ratingStarFull		= "/images/stars/full.png";
	var ratingStarSelected	= "/images/stars/selected.png";
	
	var currentStarSet		= "";
	var currentStarSettings	= new Object();
	currentStarSettings[1]	= "";
	currentStarSettings[2]	= "";
	currentStarSettings[3]	= "";
	currentStarSettings[4]	= "";
	currentStarSettings[5]	= "";
	
	function ratingStarOver(starSet, num)
	{
		//	Local vars
		var i	= 0;
		var img	= null;
		
		//	If working on a new star set, move the old one back to its
		//	original settings before proceeding
		if( currentStarSet != "" &&
			currentStarSet != starSet )
		{
			for( i = 1; i <= 5; i++ )
			{
				img		= document.getElementById( currentStarSet + '_' + i );
				img.src	= currentStarSettings[ i ];
			}
		}
		
		//	If working on a new star set, save the new settings for the
		//	current set
		if( currentStarSet != starSet )
		{
			//	Save the new current
			currentStarSet	= starSet;
			
			for( i = 1; i <= 5; i++ )
			{
				img					= document.getElementById( starSet + '_' + i );
				currentStarSettings[ i ]	= img.src;
			}
		}
		
		//	Swap out the necessary images to the rollover
		for( i = 1; i <= 5; i++ )
		{
			img		= document.getElementById(starSet+'_'+i);
			
			if( i <= num )
					img.src	= ratingStarSelected;
			else	img.src	= ratingStarZero;
		}
	}
	function ratingStarOut(starSet, num)
	{
		//	Local vars
		var i	= 0;
		var img	= null;
		
		//	Swap out the un-included stars back to their original src
		for( i = 5; i > 0; i-- )
		{
			img		= document.getElementById( starSet + '_' + i );
			img.src	= currentStarSettings[ i ];
		}
	}
	function rateVideo(starSet, num, item_id, item_type_id)
	{
		// build array of the params to pass via ajax
		var params = { 
			item_id: 		item_id,
			item_type_id: 	item_type_id,
			num: 			num
		};
		
		var ratingDiv	= document.getElementById(starSet+'_DIV');
		
		ratingDiv.innerHTML	= "Saving...";
		
		var newStars	= "";
		
		for( var i = 1; i <= 5; i++ )
		{
			currentStarSettings[ i ]	= ( i <= num ? ratingStarSelected : ratingStarZero );
			newStars					+= '<a href="javascript:rateVideo(\'' + starSet + '\', ' + i + ', ' + item_id + ', ' + item_type_id +')" onMouseOver="ratingStarOver(\'' + starSet + '\',' + i + ')" onMouseOut="ratingStarOut(\'' + starSet + '\',' + i + ')"><img id="' + starSet + '_' + i + '" src="' + ( i <= num ? ratingStarSelected : ratingStarZero ) + '" border="0" /></a>';
		}
		
		ratingDiv.innerHTML	= newStars;
				
		// ajax request to remove movie
		$.get( "/ratings.php?a=add", params );
		
	}