// JavaScript Document
$(function() {
	$("#notyourcountry").click(function(){
	if($(".countrylist").is(":hidden")){
	$(".countrylist").fadeIn();
	}else{
	$(".countrylist").fadeOut();}
	});
	
	$("#notyourcountryhdr").click(function(){
	if($(".countrylisthdr").is(":hidden")){
	$(".countrylisthdr").fadeIn();
	}else{
	$(".countrylisthdr").fadeOut();}
	});
});

function setCookie(c_name,value,expiredays) {
	
	pathArray = window.location.pathname.split( '/' );
	var uri = '';
	for(i=0;i<pathArray.length;i++) {
		if(i != 0) {
			if(pathArray[i] != '') {
				var newPath = pathArray[i].replace('-us','');
				var newPath = newPath.replace('-ca','');
				var newPath = newPath.replace('-nz','');
				uri += '/'+newPath+'-'+value;
			}
		}
	}	
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toUTCString())+ "; domain=results.com";
	url="http://"+value+".results.com"+uri;
	document.location =url;
}

function setCookie_event(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toUTCString())+ "; domain=results.com";
url="http://"+value+".results.com/events_"+value;
document.location =url;
}

function checkCookie_events()
{
country=getCookie('country');
if (country!=null && country!=""){
url="http://"+country+".results.com/events_"+country;
curUrl=location.href;
if(url!=curUrl){
document.location =url;
}
else{return;}
  }
else 
  {return;}
}

function checkCookie()
{
country=getCookie('country');
if (country!=null && country!=""){
url="http://"+country+".results.com/";
curUrl=location.href;
if(url!=curUrl){
document.location =url;
}
else{return;}
  }
else 
  {return;}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}
