// PanicPage v4.0 script (C) 2005 Panic, Inc.
// Home page functions.
// 
// Please contact us if you need to use this code. Not to be used without express written permission.
//
// 05/11/05 - Updating metrics for new page sizes
//            Adding language checking code
//
// 06/23/05 - Remove help tag code
//            Added live downloading

var isNav4, isIE4, isMac, isNav6;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isNav4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) != 5) ? true : false
  isNav6 = (navigator.userAgent.indexOf("Netscape")>-1 && parseInt(navigator.appVersion) == 5) ? true : false
  isMozilla = navigator.userAgent.indexOf("Gecko")>-1;
	isIE4  = (navigator.appName.indexOf("Microsoft") != -1) ? true : false
  isMac  = (navigator.platform.indexOf("Mac") != -1) ? true : false
}

var oldX, oldY, movingStatus, what, clickURL, helpUp, theLayer;

function winDeal(what) {

   if (isNav4 || isNav6) {
     if (isNav6) {
       theObj = document.getElementById(what);
       if (theObj.style.visibility == "hidden" || theObj.style.visibility == "") {
         theObj.style.visibility = "visible";
       } else {
         theObj.style.visibility = "hidden";
       }
     }
   }
   else {
     if (document.all[what].style.visibility == "hidden" || document.all[what].style.visibility == "") {
       document.all[what].style.visibility = "visible";
     } else {
       document.all[what].style.visibility = "hidden";
     }
   }
}

var yWin;

function doDown(e) {
	if(isNav4 || isNav6 || isMozilla){
    	theTarget = e.target;
  	}else{
    	theTarget = window.event.srcElement;
  	}
		
	if(theTarget.name!='imgScrollButton')return
	
	if(document.getElementById('ScrollButton').offsetTop==0){
  	if(isNav4 || isNav6 || isMozilla){
    	yWin = e.pageY;
  	}else{
   	 	yWin = window.event.clientY;
  	}
		InitialiseScroll();
	}else{
		if(isNav4 || isNav6){
			yWin = e.clientY-oldY;
		}else if(isMozilla){
			yWin += e.layerY-oldY;
		}else{
			yWin+=window.event.offsetY-oldY;
		}
		
	}
  
  if (theTarget.name && theTarget != "") {
    if (!isNav4) {
      if (isNav6||isMozilla) theLayer = document.getElementById('ScrollButton');

      if (isNav4 || isNav6 || isMozilla) {
        yCoord = e.layerY;
      }else{
        if (isMac) {
          yCoord = window.event.offsetY;
        }else{
          yCoord = window.event.offsetY;
        }
      }
			
      if (isNav4 || isNav6 || isMozilla) {
        theButton = e.which;
      }
      else {
        theButton = event.button;
      }
			
      if (theButton == 1) {
        movingStatus = "drag";

	     if (isNav4 || isNav6) { 
  	     document.captureEvents(Event.MOUSEMOVE);
         if (isNav6) oldY = e.clientY
       }else if(isMozilla){
				 oldY=e.layerY;
				}else{
	       	oldY=window.event.offsetY;
       }
	    document.onmousemove = drag;
	     
        return false;
      }
    }
  }
}

function db(txt){
	document.getElementById('MenuBar').innerHTML=txt
}

function drag(e) {
  if (movingStatus == "drag") {
		var newtop;
    if (isNav4 || isNav6 || isMozilla) {
      if (isNav6){
				newtop=e.clientY - yWin;
				if(newtop>=0){
					theLayer.style.top =  newtop+'px';
				}
			}
			if(isMozilla){
				newtop=e.clientY-yWin;
				if(newtop<0)newtop=0;
				if(newtop>ScrollBarScrollHeight)newtop=ScrollBarScrollHeight;
				document.getElementById('ScrollButton').style.top  = newtop+'px';
				
			}
    }else{
      if(isMac){
        document.all['ScrollButton'].style.pixelTop  = window.event.clientY - yWin;
      }else{
        newtop=window.event.clientY -yWin;
				if(newtop<0)newtop=0;
				if(newtop>document.all['ScrollBar'].offsetHeight-document.all['ScrollButton'].offsetHeight)newtop=document.all['ScrollBar'].offsetHeight-document.all['ScrollButton'].offsetHeight;
				document.all['ScrollButton'].style.pixelTop  = newtop;
      }
    }
		
		ScrollPos=newtop/ButtonPixelsPerPercent;
		document.getElementById('Scrolling').style.top=(0-ScrollPos*PagePixelsPerPercent)+OriginalTop+'px'

    return false;
  }
}

function doUp(e) {
  movingStatus = "false";
  document.onmousemove = null;
  return false;
}

document.onmousedown=doDown;
document.onmouseup=doUp;
