// Common JScript source code
var isNav = (navigator.appName.indexOf("Netscape") != -1);
var isIE = (navigator.appName.indexOf("Microsoft") != -1);

function winPop(winName, winSrc, winWidth, winHeight, scroll, menubar, toolbar) {
	if (!scroll) { scroll = 'no' }
	//if (isNav) {winTop = window.screenY+100; winLeft = window.screenX+50; };
	//if (isIE) {winTop = window.screenTop+25; winLeft = window.screenLeft+50; };
	var winLeft = (screen.width-winWidth)/2;
	var winTop = (screen.height-winHeight)/2;
	wname=window.open(winSrc, winName, "menubar="+menubar+",toolbar="+toolbar+
	",resizable=yes,scrollbars="+scroll+",width="+winWidth+
	",height="+winHeight+",top="+winTop+",left="+winLeft);
}

function showModal(winName, winSrc, winWidth, winHeight) {
	if (isIE) {
		var params = "dialogWidth:" + winWidth + "px; dialogHeight:" + winHeight + "px; center:yes; status:no";
		var x = window.showModalDialog(winSrc,"",params);
	} else {
		var winLeft = (screen.width-winWidth)/2;
		var winTop = (screen.height-winHeight)/2;
		var params = "menubar=0,toolbar=0"+
			",resizable=0,scrollbars=0,width="+winWidth+
			",height="+winHeight+",top="+winTop+",left="+winLeft+
			",modal=yes";
		var x = window.open(winSrc,winName,params);
	}
}

function SetCookie(CookieName,Key,Val,Expires,Path,Domain,Secure) {
	if (Expires) {
		var expire = new Date();
		expire.setTime(expire.getTime() + Expires*24*60*60*1000);
		Expires = expire.toUTCString();
	}
	var Cookie = document.cookie;
	x = CookieName + "=";
	CookieStart = Cookie.indexOf(x);
	if (CookieStart == -1) {
		Cookie = CookieName + "=" + Key + "=" + escape(Val);
	} else {
		CookieStart
		CookieEnd = Cookie.indexOf(";",CookieStart);
		if (CookieEnd == -1) {
			CookieEnd = Cookie.length;
		}
		Cookie = Cookie.substring(CookieStart,CookieEnd);
		x = Key + "=";
		KeyStart = Cookie.indexOf(x);
		if (KeyStart == -1) {
			Cookie += "&" + Key + "=" + escape(Val);
		} else {
			KeyStart = KeyStart;
			KeyEnd = Cookie.indexOf("&",KeyStart);
			if (KeyEnd == -1) {
				KeyEnd = Cookie.length;
			}
			x = Cookie.substring(KeyStart,KeyEnd);
			y = Key + "=" + escape(Val);
			Cookie = Cookie.replace(x,y);
		}
	}
	Cookie += ((!Expires) ? "" : ("; Expires=" +
	Expires)) +
	((!Path) ? "" : ("; Path=" + Path)) +
	((!Domain) ? "" : ("; Domain=" + Domain)) +
	((!Secure) ? "" : "; Secure");
	document.cookie = Cookie;
}
function RemoveCookie(CookieName,Key,Path) {
	//alert("RemoveCookie() called.");
	if (Key) {
		var Cookie = document.cookie;
		x = CookieName + "=";
		CookieStart = Cookie.indexOf(x);
		if (CookieStart == -1) {
			return;
		} else {
			//CookieStart
			CookieEnd = Cookie.indexOf(";",CookieStart);
			if (CookieEnd == -1) {
				CookieEnd = Cookie.length;
			}
			Cookie = Cookie.substring(CookieStart,CookieEnd);
			x = Key + "=";
			KeyStart = Cookie.indexOf(x);
			if (KeyStart == -1) {
				return;
			} else {
				//KeyStart
				KeyEnd = Cookie.indexOf("&",KeyStart);
				if (KeyEnd == -1) {
					KeyEnd = Cookie.length;
				}
				//alert(Cookie.charAt(KeyStart-1));
				if (Cookie.charAt(KeyStart-1) == "&") {
					KeyStart = KeyStart - 1;
				}
				x = Cookie.substring(KeyStart,KeyEnd+1);
				Cookie = Cookie.replace(x,"");
				Cookie += ((!Path) ? "" : ("; Path=" + Path));
				document.cookie = Cookie;
			}			
		}	
	} else {
		SetCookie(CookieName,"Remove","Remove",-1);
	}
}
function GetCookie(CookieName,Key) {
	Cookie = document.cookie;
	CookieArray = Cookie.split("; ");
	for(i=0; i<CookieArray.length; i++) {
		if (CookieArray[i].substr(0,CookieName.length) == CookieName) {
			KeysArray = CookieArray[i].substr(CookieName.length+1).split("&");
			for(k=0; k<KeysArray.length; k++) {
				if (KeysArray[k].substr(0,Key.length) == Key) {
					value = KeysArray[k].substr(Key.length+1);
					return unescape(unescape(value));
				}
			}
		}
	} 
	return null;
}

function swapImg(x,imgSrc) {
	document.getElementById(x).src = imgSrc;
}

