// JS Shared across all co-brands
function writit(text,id)
{
	var x; 

	if (document.getElementById)
	{
		x = document.getElementById(id);
		if ( x != null ) {
			x.innerHTML = '';
			x.innerHTML = text;
		}
	}
	else if (document.all)
	{
		x = document.all[id];
		if ( x != null ) {
			x.innerHTML = text;
		}
	}
}

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}

function centeredPopup(page,popWidth,popHeight,options) {
  var top=(screen.height-popHeight)/2;
  var left=(screen.width-popWidth)/2;
  window.open(page,"centerPopup","top="+top+",left="+left+",width="+popWidth+",height="+popHeight+","+options);
}

function isStringEmpty(StrInput) {
	var i, taille = StrInput.length;

	if (0 >= taille) return true;

	for (i = 0; i<taille; i++)
		if (' ' != StrInput.charAt(i)) return false;

	return true;
}

// US Cookies
function USGet_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function USSet_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function USDelete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());

var todays_date = new Date(today.getYear(),today.getMonth(),today.getDate(),0,0,0);
var expires_date = new Date(todays_date.getTime() + (8 * 7 * 86400000));

function USstoreMasterCookie() {
    if (!USGet_Cookie('MasterCookie'))
        USSet_Cookie('MasterCookie','MasterCookie');
}

function USstoreIntelligentCookie(name,value) {
    if (USGet_Cookie('MasterCookie')) {
        var IntelligentCookie = USGet_Cookie(name);
        if ((!IntelligentCookie) || (IntelligentCookie != value)) {
            USSet_Cookie(name,value,expires_date);
            var IntelligentCookie = USGet_Cookie(name);
            if ((!IntelligentCookie) || (IntelligentCookie != value))
                USDelete_Cookie('MasterCookie');
        }
    }
}

var USCookie_src_loaded = true;

