function getQueryVariable(variable){
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
}

if (document.location.href.match("novem_ref=")) {
    var _novemToday = new Date();
    _novemToday.setTime(_novemToday.getTime());
    var _novemCookieExpire = new Date(_novemToday.getTime() + (86400 * 30 * 1000)).toGMTString();
    document.cookie = 'novem_ref=1; expires=' + _novemCookieExpire + ' +0100; path=/';
}
if (document.location.href.match("coop_ref=")) {
    var id_coop=getQueryVariable("coop_ref");
	var _coopToday = new Date();
    _coopToday.setTime(_coopToday.getTime());
    var _coopCookieExpire = new Date(_coopToday.getTime() + (86400 * 30 * 1000)).toGMTString();
	if(id_coop=='4'){
		var pwid=getQueryVariable("pwid");
		document.cookie = 'coop_ref'+id_coop+'=1; expires=' + _coopCookieExpire + ' +0100; path=/';
		document.cookie = 'pwid='+pwid+'; expires=' + _coopCookieExpire + ' +0100; path=/';		
	}
    
}
