function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function linkOnClick()
{
  var h = this.href;
  var action = true;
  var x = readCookie('affiliate');

 if (x === "miniclip") {

		if ((h.indexOf("http://www.clubpenguin.com/") != -1) || (h.indexOf("http://sandbox01.www.clubpenguin.com/") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://community.clubpenguin.com/blog/") != -1) || (h.indexOf("http://sandbox01.community.clubpenguin.com/blog/") != -1)) 
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://support.clubpenguin.com/help/") != -1) || (h.indexOf("http://sandbox01.support.clubpenguin.com/help/") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://community.clubpenguin.com/") != -1) || (h.indexOf("http://sandbox01.community.clubpenguin.com/") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://www.clubpenguin.com/parents/") != -1) || (h.indexOf("http://sandbox01.www.clubpenguin.com/parents/") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://secure.clubpenguin.com/membership") != -1) || (h.indexOf("http://sandbox01.secure.clubpenguin.com/membership") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://www.clubpenguin.com/company/index.htm") != -1) || (h.indexOf("http://sandbox01.www.clubpenguin.com/company/index.htm") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://www.clubpenguin.com/terms.htm") != -1) || (h.indexOf("http://sandbox01.www.clubpenguin.com/terms.htm") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://www.clubpenguin.com/privacy.htm") != -1) || (h.indexOf("http://sandbox01.www.clubpenguin.com/privacy.htm") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://support.clubpenguin.com/help/contact/") != -1) || (h.indexOf("http://sandbox01.support.clubpenguin.com/help/contact/") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://www.clubpenguin.com/sitemap.htm") != -1) || (h.indexOf("http://sandbox01.www.clubpenguin.com/sitemap.htm") != -1))
  	{  
    		window.open(h); action = false; 
  	} 
		else if ((h.indexOf("http://www.clubpenguin.com/parents/player_safety.htm") != -1) || (h.indexOf("http://sandbox01.www.clubpenguin.com/parents/player_safety.htm") != -1))
  	{  
    		window.open(h); action = false; 
  	} 																		
  	return action; 
 }
}