/////// Gestion des cookies
if (!Utils) 
    var Utils = {};

// Cet objet contient 2 mèthodes pour lire et écrire des cookies en JavaScript

Utils.Cookies = {
    // setValue(name, value[, seconds, path, domain, secure])
    setValue: function(name, value) {
        var argv = arguments;
        var argc = arguments.length;
        if( argc > 2 ){
            var cdate = new Date();
            var expires = new Date(cdate.getTime() + (argv[2]*1000));
        }else{
            var expires = null;
        }
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape(value)
            + ((expires == null) ? "" : ("; expires=" + expires.toGMTString()))
            + ((path == null) ? ("; path=/" ) : ("; path=" + path))
            + ((domain == null) ? "" : ("; domain=" + domain))
            + ((secure == true) ? "; secure" : "");
    },
    // getValue(name)
    getValue: function(name) {
        if( document.cookie ){
            var arg = name + '=';
            var i = 0;

            while( i < document.cookie.length ){
                var j = i + arg.length;
                if( document.cookie.substring(i, j) == arg ){
                    var endstr = document.cookie.indexOf(';', j);
                    if( endstr == -1 )
                        endstr = document.cookie.length;
                   return unescape(document.cookie.substring(j, endstr));
                }
                i = document.cookie.indexOf(' ', i) + 1;
                if( i == 0 ) 
                    break;
            }
        }
        return null;
    } 
}

function ecrisCookie(Chrono, ref) {
	var ValCook = Utils.Cookies.getValue('xywdbox');
	var TabVal;
	if (ValCook== null) {
		ValCook = Chrono;	
	}
	else {
		TabVal = ValCook.split(';');
		if (TabVal.length == 10) {
			TabVal.shift(); // supprime premier element
		}
		TabVal.push(Chrono); // ajoute le nouveau chrono en fin de liste
		ValCook = TabVal.join(';');
	}


Utils.Cookies.setValue('xywdbox', ValCook, 31536000);
//alert(Utils.Cookies.getValue('xywdbox'));
//location = '/wdbox/pagescli/chemise/DETAIL.asp?num='+Chrono+'&maref='+ref;
location = '/wdbox/pagescli/chemise/detail_'+ref+'_'+Chrono+'.htm';
}

function LitCookie() {
	MonUrl = Utils.Cookies.getValue('xywdbox');
	if (MonUrl == null) {
		location = "/wdBox/ASPGlobal/wdb_getp.asp?sDossier=EspacePC&sPage=sitesecuindex";
	}
	else {
	location = MonUrl;
	}
}

function CacheSelection() {
	MonUrl = Utils.Cookies.getValue('xywdbox');
	if (MonUrl == null) {
		document.getElementById("mesinfohistorique").style.display = "none";
	}

}

function LitClient() {
		MonNom = Utils.Cookies.getValue('Nomclient');
		if (MonNom!=null) { return MonNom;} else { return ""}
}

function EcrisClient(ValClient) {
	ValClient = ValClient.replace(/Monsieur/, "Mr.");
	ValClient = ValClient.replace(/Madame/, "Mme.");	
	ValClient = ValClient.replace(/Mademoiselle/, "Mlle.");	
	Utils.Cookies.setValue('Nomclient', ValClient, 31536000);
}