function get_ref(){
	var ckstring = document.cookie, ckind = ckstring.indexOf("refer="),
	ck = (ckind != -1 ? ckstring.slice(ckind+6):'');
	return ck
}

function WM_imageSwap(daImage, daSrc){
	var objStr,obj;
	if(document.images){
		if (typeof daImage == 'string') {
			objStr = 'document.' + daImage;
			obj = eval(objStr);
			obj.src = daSrc;
		} else if ((typeof daImage == 'object') && daImage && daImage.src) {
			daImage.src = daSrc;
		}
	}
}

function opw(w,h,winX,x,y){return window.open('',winX,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h+',top='+y+',left='+x);}
function mrw(w,h,winX){
	var x = (screen.width) ? (screen.width-w)/2 : 0;
	var y = (screen.height) ? (screen.height-h)/2 : 0;
	var win = opw(w,h,winX,x,y);
	if (win.resizeTo) win.resizeTo(w,h);
	if (win.moveTo) win.moveTo(x,y);
	if (win.innerHeight && (win.innerHeight != h || win.innerWidth != w) ) {
		win.close();
		win = opw(w,h,winX,x,y);
	}
	return win;
}
function open_window(url,w,h,winX,isimg){		
	if(isimg){
		w-=20;h-=20;
		var win=mrw(w+10,h+49,winX);
		win.document.open();
		win.document.write(
			'<html><head><title></title><meta http-equiv="imagetoolbar" content="no"></head>'+
			'<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">'+
			'<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%"><tr>'+
			'<td align="center" valign="middle"><img src="'+url+'" alt="" width="'+w+'" height="'+h+'" border="0"></td>'+
			'</tr></table></body></html>'
		);
		win.document.close();
	} else{
		url=url?url:'/index.html';
		winX=winX?winX:'Window';
		w=w?w+10:600;
		h=h?h+40:300;
		var win=mrw(w,h,winX);
		win.location = url;
	}
	if(win.window.focus){win.window.focus();}
}
//****************
var pp_w=500,pp_h=500;
function show_pp(a,b,ppm){
	if(ppm){
		var w=mrw(pp_w,pp_h,'Window');
		w.location=a+'/pp'+b;
		w.opnr = window.opnr?window.opnr:window;
	} else{
		if(window.opener && window.opener!=window) 
		  window.opnr = window.opener.opnr?window.opener.opnr:window.opener;
		if(window.opnr)
		  window.opnr.location.href=a+window.opnr.pgnm+b;
		else 
		  alert('Sorry, feature is not supported by your browser.');  
	}
}
/*
function print(url) {
	var w=640;
	var h=480;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	win = window.open(url,'print','toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition);
	if(win.window.focus){win.window.focus();}
}
*/

/***/
function setCookie(name, value, expires, path, domain, secure){
	document.cookie= name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function getCookie(name){
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));	
}
function clearCookie(name){
	setCookie(name,"",-1);
}

function rand(num)
{
	return Math.floor(Math.random()*num)+1
}
