

// Global Constants
var COOKIE_NAME = 'FBN';




//If cookie is set, try to load the selected image. 
function updateFlash()
{
	

	var flashCookie = getcookie(COOKIE_NAME);

	if(!flashCookie) {
			
			 setcookie(COOKIE_NAME,1);
			 return 1;
			 
				
	}
	else {
		
		  return 2;
		
	
			
					
	}
	

}
//This function will open a pop-up window depending on which Chart is currently Selected.
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// STANDARD COOKIE FUNCTIONS 
//////////////////////////////////////////////////////////////////////////////////////////////////////////

function getexpirydate(nodays)
{
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);	//computation is done in milliseconds
	UTCstring = Today.toUTCString();
	return UTCstring;
}

//escape method here is used to replace special characters by corresponding HEX values
function setcookie(name,value)
{
	document.cookie=name+"="+escape(value);
	return getcookie(name); 		//we return getcookie here to be sure cookies are enabled on that computer		
}




//The function is passed one parameter cookiename. This is the cookie we want to retrieve. 
//We use document.cookie to retrieve all the cookie/value pairs set for our domain. The 
//function indexOf(cookiename) finds the position in the string of the first occurrence of 
//the cookiename we are looking for. If the string is not found index1 is set to -1. If it 
//doesn't find it an empty string is returned. If it finds the cookie it searches for the 
//first occurrence of ";" starting from the position of index1.The final line extracts the 
//cookie value as a substring of cookiestring and then uses unescape to translate any hex 
//coded characters back into a readable form
function getcookie(cookiename)
{	
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") {
		return ""; 
	}		
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1)	{
		index2=cookiestring.length;
	}	
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}