
/* - addCookie.js - */
function createCookie(name,value,days,newLocation) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
        
        if(newLocation){
           //alert(newLocation+' cookie:'+document.cookie);
           window.location = newLocation;
        }
}
function createCookies(name,value,days,newLocation,name2,value2,days2,newLocation2) {
        //alert("deleting cookie: "+name);
        //alert("deleting cookie: "+name2);
        createCookie(name,"",-1);
        createCookie(name2,"",-1);

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
        
        if(newLocation){
           //alert(newLocation+' cookie:'+document.cookie);
           window.location = newLocation;
        }
        
       if (days2) {
		var date = new Date();
		date.setTime(date.getTime()+(days2*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name2+"="+value2+expires+"; path=/";
        
        if(newLocation2){
           //alert(newLocation2+' cookie:'+document.cookie);
           window.location = newLocation;
        }
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

