var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);




// Preload 'PleaseWait' image
imageObj = new Image();
imageObj.src="images/loader.gif" 

// ** FrameBuster **
if( window!= window.top ) { top.location.href = location.href; }



function testSessionCookie () {
  document.cookie ="testSessionCookie=Enabled";
  if (getCookieValue ("testSessionCookie")=="Enabled")
    return true
  else
    return false;
}

function setBookPageCookie (pageCode) {
  //alert("bookPageCookie="+pageCode)
  document.cookie ="bookPageCookie="+pageCode;
}  

function getCookieValue (cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else return false;
}



function setHourGlass()
{
   //document.body.style.cursor = "wait";
   //document.getElementById('body').style.cursor = "wait";
}   

function popwin(url,w,h)
{
fpwin = window.open(url,"mywin","WIDTH="+w+", HEIGHT="+h+", TOP=1, LEFT=1,SCROLLBARS=YES,RESIZABLE=YES,STATUS=NO,TOOLBAR=NO,MENUBAR=YES");
if (fpwin.opener == null) fpwin.opener = window;
    window.fpwin.focus();
}

function popWin(url,w,h)
{
fpwin = window.open(url,"mywin","WIDTH="+w+", HEIGHT="+h+", TOP=1, LEFT=1,SCROLLBARS=YES,RESIZABLE=YES,STATUS=NO,TOOLBAR=NO,MENUBAR=YES");
if (fpwin.opener == null) fpwin.opener = window;
    window.fpwin.focus();
}

function popWinX(url,w,h)
{
fpwinX = window.open(url,"winX","WIDTH="+w+", HEIGHT="+h+", TOP=1, LEFT=1,SCROLLBARS=YES,RESIZABLE=YES,STATUS=NO,TOOLBAR=NO,MENUBAR=YES");
if (fpwinX.opener == null) fpwinX.opener = window;
    window.fpwinX.focus();
}

function popWait(url,w,h)
{
var Lp=(screen.width/2)-150;
var Tp=200;
fpwait = window.open(url,"mywin","dependent=yes, WIDTH="+w+", HEIGHT="+h+", TOP="+Tp+", LEFT="+Lp+",SCROLLBARS=NO,RESIZABLE=NO,STATUS=NO,TOOLBAR=NO,MENUBAR=NO");
if (fpwait.opener == null) fpwait.opener = window;
    window.fpwait.focus();
}

function popPDF(page)
{ 
var w=(screen.width)-15;
var h=(screen.height)-150;
OpenWin = this.open(page, "dpWin", "dependent=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width="+w+",height="+h); 
} 

function popFile(url)
{ 
var w=(screen.width)-15;
var h=(screen.height)-150;
OpenWin = this.open(url, "popWin", "dependent=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width="+w+",height="+h); 
} 

function getElementWidth(id) {
  if (NS4) {
      return eval(id).clip.width; }
  else{
      return document.getElementById(id).clientWidth; }
}


function goCenter(w,h)
{
var sw=screen.width/2;
var sh=screen.height/2;
window.moveTo((sw-w/2),(sh-h/2));
}


function checkForIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function setWait()
{
// Preload 'PleaseWait' image
imageObj = new Image();
//imageObj.src="images/wait.gif"    
imageObj.src="images/loader.gif"    

//document.body.style.cursor = "wait";
//var ctl=document.getElementById('waitWatch');
//ctl.src="images/loader.gif";

//var winInHt=window.innerHeight? window.innerHeight : Math.max(document.body.clientHeight, document.documentElement.clientHeight)
//alert(winInHt)

//var isIE = (document.all) ? true : false;
//if(isIE){
//   var ypos=window.event.y+window.event.offsetY;
//   document.getElementById('plsWait').style.top=ypos.toString();
//   window.status="ypos:"+ypos
//   }

window.setTimeout('do_setSrc()',2)  //5
//window.setTimeout('do_setSrc()',10)  //200
document.body.style.cursor = "wait";
window.status="";

}

function do_setSrc()
{
var ctl=document.getElementById('waitWatch');
//ctl.src="images/wait.gif";
//ctl.src="images/loader.gif";
document.getElementById('plsWait').style.visibility="visible";
}

function unSetWait()
{
document.getElementById('plsWait').style.visibility="hidden";
document.body.style.cursor="default";
window.status="";
}
 









//============================
//Persistent Cookie functions
//============================

function SetDiskCookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function DeleteDiskCookie( name, path, domain ) {
// this deletes the cookie when called
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}




