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,s,r){return window.open('',winX,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+(s || 0)+',resizable='+(r || 0)+',width='+w+',height='+h+',top='+y+',left='+x);}
function mrw(w,h,winX,src,rsz){
	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,src,rsz);
	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,w,h,scr,rsz){ //path, doc name, print ver, width, height, scroll, resize
	if(ppm){
		pp_w = w || pp_w;
		pp_h = h || pp_h;
		var w=mrw(pp_w,pp_h,'Window',scr || 0,rsz || 0);
		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 setMainLocation() {
	var u=document.navform.sel.options[document.navform.sel.selectedIndex].value;
	var i=u.indexOf('*');
	var ut=u.substring(0,i);
	var uh=u.substring(i+1,255);
	if(!uh)return;
//	var w=window.parent||window;
	var w=window;
	if(ut)w.open(uh,ut);else w.location=uh;		
}

function wesc(s){
	var r='',j,c,n,hh=[0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'];
	for(j=0;j<s.length;j++){		
		n=s.charCodeAt(j);
		r+= n>127 || n>=97 && n<=122 || n==95 || n>=65 && n<=90 || n>=48 && n<=57 ? s.charAt(j) : '%'+hh[Math.floor(n/16)]+hh[Math.floor(n%16)]
	}
	return r;
}
