function addDays(myDate,days) 
{
    return new Date(myDate.getTime() + days*24*60*60*1000);
}

function setCookie(name, value, days)
{
	if(value == "")
	{
		var the_value = "true";
	}
	else
	{
		var the_value = value;
	}
	var the_date = addDays(new Date(), days);
	var the_cookie_date = the_date.toGMTString();
	var the_cookie = name + " = " + the_value;
	the_cookie = the_cookie + ";path=/;expires=" + the_cookie_date;
	//alert(the_cookie);
	document.cookie = the_cookie;
}

function getCookie(cookiename)
{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}



// THIS SCRIPT DOES THE DOUBLE SWAP (CLOSES THE POP-UP, CHANGES THE PARENT)
// USAGE: <A HREF="#" onClick="DoubleSwap('http://www.domain.com')">text link</A>
function DoubleSwap(URL)
{
	window.opener.location = URL;
	window.close();
}

// THIS SCRIPT RUNS THE POPUP WINDOWS
// USAGE: <a href="javascript:NewWindow('page.html', 'nameOfWindow', 500, 300, 1, 1)">Text Link</a>
function NewWindow(url, myname, w, h, scroll, resize) 
{
	winprops = 'height='+h+',width='+w+',top=10,left=10,scrollbars='+scroll+',resizable='+resize+',toolbar=0'
	win = window.open(url, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}



function change(id, newClass) {
identity=document.getElementById(id);
identity.className=newClass;
}
