///////////////// Exit Pop Under Advertisement Section //////////////////

//This method is used to create a UTC Date String corresponding to the 
//expiry date of the cookie (so that the advertisement does pop every
//x days.
//UTC stands for "Universal Time Convention" and according to NetScape has replaced 
//GMT as the standard method of referencing time on the Internet.
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,duration){
	document.cookie=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
	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));
}

//Algorithm: If the cookie is not set yet, try to set it, if cookies are enabled, pop the advertsisment
//Otherwise, do not pop the advertisement, cause somebody who does not have cookies enabled would see
//the advertisement at every visit on kitco.com

function KitcoIndex(mypage,myname){
 win = null;
 w = 800;
 h = 530;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
if(screen.width==800){
settings ='height='+h+',width='+w+',top=0,left=0,scrollbars=no,noresible'
win = window.open("gold_currency/"+mypage,myname,settings);
}else{
settings 
='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,noresible'
win = window.open("gold_currency/"+ mypage,myname,settings);
}
if(win.window.focus){win.window.focus();}
}

				function exitpopunder()
{
if(!getcookie('Media2')) {
if(setcookie('Media2','waspoped',2).length > 0) {
window.open('http://www.kitco.com/scripts/count/count_db.pl?id=77770','Media2','toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=1,width=400,height=400');
this.focus();
}	}	}
 
 
 
//				function exitpopunder()
 //		    {
 //			 if(!getcookie('DinesCHGold')) {
// 				if(setcookie('DinesCHGold','waspoped',2).length > 0) {
//		 			window.open('http://www.kitco.com/scripts/count/count_db.pl?id=67870','DinesCHGold','toolbar=0,directories=0,menubar=0//,scrollbars=0,resizable=1,width=400,height=400');
 //		 		}	 }	}




