function WriteLayer(ID,parentID,sText) { 
 if (document.layers) { 
   var oLayer; 
   if(parentID){ 
     oLayer = eval('document.' + parentID + '.document.' + ID + '.document'); 
   }else{ 
     oLayer = document.layers[ID].document; 
   } 
   oLayer.open(); 
   oLayer.write(sText); 
   oLayer.close(); 
 } 
 else if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") { 
   document.getElementById(ID).innerHTML = sText; 
 } 
 else if (document.all) document.all[ID].innerHTML = sText 
} 


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function SetLayerPos() { 
  var i,x,y,obj,args=SetLayerPos.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { x=args[i+1];y=args[i+2];
    if (obj.style) { obj=obj.style; }
    obj.left=x; obj.top=y;}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function HH_Gojump(targetframe,page,selObj,filter){ //v3.0

eval(targetframe+".location='"+page+"?"+php_XSID+"&"+filter+"="+selObj.options[selObj.selectedIndex].value+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0

  xwin=window.open(theURL,winName,features);
  xwin.focus();
}

function reanchor(URLStr) { 

location.href=URLStr; 
if (parent.document.getElementById("InfoViewer"+php_ThisThumbsUniqueID))
{
 parent.document.getElementById("InfoViewer"+php_ThisThumbsUniqueID).scrollTop = "0";
}
if (parent.document.getElementById("SmallInfoViewer"+php_ThisThumbsUniqueID))
{
 parent.document.getElementById("SmallInfoViewer"+php_ThisThumbsUniqueID).scrollTop = "0";
}
if (parent.document.getElementById("PicViewer"+php_ThisThumbsUniqueID))
{
 parent.document.getElementById("PicViewer"+php_ThisThumbsUniqueID).scrollTop = "0";
 parent.document.getElementById("PicViewerFrame"+php_ThisThumbsUniqueID).scrollTop = "0";
}
}

function reanchorinfo(URLStr) { 

location = URLStr; 
if (typeof parent.document.getElementById("InfoViewer"+php_ThisThumbsUniqueID) != "undefined")
{
 parent.document.getElementById("InfoViewer"+php_ThisThumbsUniqueID).scrollTop ="0";
}
if (typeof parent.document.getElementById("SmallInfoViewer"+php_ThisThumbsUniqueID) != "undefined")
{
 parent.document.getElementById("SmallInfoViewer"+php_ThisThumbsUniqueID).scrollTop ="0";
}
}

function redirectextra(URLStr,Extra) { 

if (Extra == '')
{location = URLStr+'.php?'+php_XSID}
else
{location = URLStr+'.php?'+php_XSID+Extra} 
;

}

function OrderItem(BookID) {
location = 'book_detail.php?'+php_XSID+'&BookID='+BookID;  
}

function redirectextra_mainpanel(URLStr,Extra) { 

if (Extra == '')
{top.MainPanel.document.location = URLStr+'.php?'+php_XSID}
else
{top.MainPanel.document.location = URLStr+'.php?'+php_XSID+Extra} 
;

}

function redirect(URLStr,Anchor) { 

if (Anchor == '')
{location = URLStr+'.php?'+php_XSID}
else
{location = URLStr+'.php?'+php_XSID+'#'+Anchor} 
;
}

function redirect2(URLStr, event1) { 

location = URLStr+'.php?'+php_XSID+'&event='+event1}


function redirect3(URLStr) { 

location = URLStr+'.php?'+php_XSID+'&PageID='+php_PageID; }

if (typeof novalidate=="undefined")
{
var novalidate;
}


function MM_validateForm() { //v4.0
if (novalidate == 1)
{
 var errors = '';
 document.MM_returnValue = (errors == '');
 novalidate = 0;
}
else
{	
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nnm=val.name; nm=nnm.replace(/_/gi, " "); if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

}

function HH_jumpMenuNew(page,selObj,filter){ //v3.0
eval("location='" + page + "?"+php_XSID+"&"+filter+"="+selObj.options[selObj.selectedIndex].value+"'");
}

function dosearch(){
      document.form1.dosearchswitch.value='yes';
      document.form1.submit();
}

function submitform(form){
   eval("document."+form+".submit()");
}

function submitformfake(form){
   eval("document."+form+".FakeSubmitButton.click()");
}

function StartFocus(){

	var ns4 = (document.layers)? true:false;
    var ie4 = (document.all)? true:false;

    if(ie4)
	{
	if (document.form1)
     {
	  if (document.form1.SearchText)
	  {
	  document.form1.SearchText.focus();
	  }
     }
	}
    
	if(ns4)
	{
	if (document.form1)
	 {
      if (document.form1.SearchText)
	  {
	  document.form1.SearchText.focus();
	  }
     }
	}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function BlankMain(page) 
{ 
 if (typeof page != 'undefined') 
 {
	top.MainPanel.document.location  = page+'.php?'+php_XSID; 
 }
 else
 {	
	top.MainPanel.document.location  = 'page199.php?'+php_XSID; 
 }
}

function printPage() { print(document); }

function openPopup (imageURL, caption) {

  var windowTop = 100;
  var windowLeft = 100;
  var defaultWidth = 730;
  var defaultHeight = 532;
  var onLoseFocusExit = false;
  var undefined;

  var Options = "width=" + defaultWidth + ",height=" + defaultHeight + ",top=" + windowTop + ",left=" + windowLeft + ",scrollbars=yes,resizable=yes";
  
  var myScript = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
    "&lt;html&gt;\n" + 
    "&lt;head&gt;\n" + 
    "&lt;title&gt;" + caption + "&lt;/title&gt;\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n<meta http-equiv=\"Content-Language\" content=\"en-gb\">\n&lt;script language=\"JavaScript\" type=\"text/javascript\"&gt;\nfunction resizewindow () {\n  var width = document.myimage.width;\n  var height = document.myimage.height;\n";
  
  if (navigator.appName.indexOf("Netscape") != -1) {  
    myScript = myScript +  "  window.innerHeight = height;\n  window.innerWidth = width;\n";
  }
   
  else if (navigator.appName.indexOf("Opera") != -1) {
    myScript = myScript +  "  window.resizeTo (width+12, height+31);\n";
  }
  
  else if (navigator.appName.indexOf("Microsoft") != -1) { 
    myScript = myScript + "  window.resizeTo (width+12, height+59);\n";
  }
  
  else {
    myScript = myScript + "  window.resizeTo (width+14, height+34);\n";
  }
      
  myScript = myScript + "}\nwindow.onload = resizewindow;\n&lt;/script&gt;\n&lt;/head&gt;\n&lt;body ";
    
  if (onLoseFocusExit) {myScript = myScript + "onblur=\"self.close()\" ";}
    
  myScript = myScript + "style=\"margin: 0px; padding: 0px;\">\n<img src=\"" + imageURL + "\" alt=\"" + caption + "\" title=\"" + caption + "\" name=\"myimage\">\n&lt;/body&gt;\n&lt;/html&gt;\n";
      
        
  var imageWindow = window.open("","imageWin",Options);
  imageWindow.document.write (myScript);
  imageWindow.document.close ();
  if (window.focus) imageWindow.focus();
  
  imageWindow.focus();

  return false;
}


