function setCookie(name, value, days)

{

	if (typeof days!="undefined"){ //if set persistent cookie

		var expireDate = new Date()

		expireDate.setDate(expireDate.getDate()+days)

		document.cookie = name+"="+value+"; path=/; expires="+expireDate.toGMTString()

	}

	else //else if this is a session only cookie

		document.cookie = name+"="+value+"; path=/"

}



function getCookie(Name)

{ 

	var re=new RegExp(Name+"=[^;]*", "i"); //construct RE to search for target name/value pair

	if (document.cookie.match(re)) //if cookie found

		return document.cookie.match(re)[0].split("=")[1] //return its value

	return null

}



var winHandle;



function popupWindow( winID, url, winTitle )

{

    setCookie( 'pop-cmd', '');	// default to no reload command

    winHandle=dhtmlwindow.open(winID, "iframe", url, winTitle, "width=660px,height=490px,resize=1,scrolling=1,center=1")



	winHandle.onclose=function()

	{

		var popreload = getCookie('pop-cmd');

		if( popreload == 'reload' )

		{

			var popurl = getCookie('pop-url');

			var title = getCookie('pop-title');

//			alert('Reloading to url: ' + popurl + ' title: ' + title);



			setCookie( 'pop-cmd', 'false');	// default to no reload required

			winHandle.load("iframe", popurl, title);		// re-load current window with new page

			return false;

		}

		else if( popreload == 'open' )

		{

			var popurl = getCookie('pop-url');

			var target = getCookie('pop-target');

//			alert('Opening new url: ' + popurl + ' target: ' + target);

			setCookie( 'pop-cmd', '');		// default to no reload command

		    var winNew = window.open( popurl, target ); // open the new window 

		}



//        alert('pop-cmd was false - closing popup window');

		return true;

	}

}



function setActiveLoginTab() {

	document.getElementById('loginLinkLeft').style.fontWeight = 'normal';

	document.getElementById('loginLinkLeft').style.color = 'black';

}



function setTabLeftInactive() {

	document.getElementById('tabLeft').style.backgroundImage = 'url("../pics/layout/login/loginTabLeftInactive.gif")';

	document.getElementById('tabRight').style.backgroundImage = 'url("../pics/layout/login/loginTabRightActive.gif")';

	

	document.getElementById('loginLinkRight').style.fontWeight = 'bold';

	document.getElementById('loginLinkRight').style.color = 'black';

	

	document.getElementById('loginLinkLeft').style.fontWeight = 'bold';

	document.getElementById('loginLinkLeft').style.color = '#660000';

}



function setTabRightInactive() {

	document.getElementById('tabRight').style.backgroundImage = 'url("../pics/layout/login/loginTabRightInactive.gif")';

	document.getElementById('tabLeft').style.backgroundImage = 'url("../pics/layout/login/loginTabLeftActive.gif")';

	

	document.getElementById('loginLinkLeft').style.fontWeight = 'bold';

	document.getElementById('loginLinkLeft').style.color = 'black';

	

	document.getElementById('loginLinkRight').style.fontWeight = 'bold';

	document.getElementById('loginLinkRight').style.color = '#660000';

}

