// You should NOT have to any script below //
var expDays = 90;

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function getDomain(){
var sld="";
var tld="";
var domarr = window.location.hostname.split(".");
if(domarr.length < 2) {
var domain = window.location.hostname;
}else{
domarr.reverse();
tld = domarr[0];
if(tld.length < 3){
if(domarr[1] != 'd56' && (domarr[1] == 'co' || domarr[1] == 'com' || domarr[1] == 'org' || domarr[1] == 'net' || domarr[1].length < 4)){
if(domarr.length >= 3) {
tld = domarr[1]+'.'+domarr[0];
sld = domarr[2];
var domain = sld+'.'+tld;
}else{
var domain = window.location.hostname;
}
} else {
tld = domarr[0];
sld = domarr[1];
var domain = window.location.hostname;
}
}else{
tld = domarr[0];
sld = domarr[1];
var domain = sld+'.'+tld;
}
}
//alert('tld='+tld+'\nsld='+sld+'\ndomain='+domain);
return domain;
}
function SetCookie(c_name,value)
{
var exdate=new Date();
var path = '/';
var domain = getDomain();
exdate.setDate(exdate.getDate()+expDays);
cookietoset=c_name+ "=" +escape(value)+
";expires="+exdate.toGMTString()+
"; path=" + path +
"; domain=" + domain;
document.cookie = cookietoset;
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function getUrlVars() {
var map = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
map[key] = value;
});
return map;
}
function checkHome(sitecode, redirPage){
getDomain();
urlvars = getUrlVars();
gohome = 0;
if(urlvars['sc'] != null) {
	SetCookie('worldwide','1');
	window.location.href = redirPage;
	gohome = 1;
} else {
j = GetCookie('worldwide');
k = GetCookie('__utmc');
if(j == null && k == null) {
	SetCookie('worldwide','1');
	window.location.href = 'http://www.enesco.com/?site=' + sitecode;
} else {
	window.location.href = redirPage;
}
 gohome = 2;
}
}
