﻿function contentResize(off, sdiv) {

    var winWidth, winHeight, d = document;
    if (typeof window.innerWidth != 'undefined') {
        winWidth = window.innerWidth;
        winHeight = window.innerHeight;
    } else {
        if (d.documentElement &&
  typeof d.documentElement.clientWidth != 'undefined' &&
   d.documentElement.clientWidth !== 0) {
            winWidth = d.documentElement.clientWidth;
            winHeight = d.documentElement.clientHeight;
        } else {
            if (d.body &&
   typeof d.body.clientWidth != 'undefined') {
                winWidth = d.body.clientWidth;
                winHeight = d.body.clientHeight;
            }
        }
    }

    document.getElementById(sdiv).style.height = (winHeight - off) + 'px'

}


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

function loadBody(){
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
}


// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s



function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  
  doScroll();
  
  return true
}

var mouseX=0;
var inmove=0;
var currentpos=10;

function startScroll(){

    var winWidth, winHeight, d = document;
    if (typeof window.innerWidth != 'undefined') {
        winWidth = window.innerWidth;
        winHeight = window.innerHeight;
    } else {
        if (d.documentElement &&
  typeof d.documentElement.clientWidth != 'undefined' &&
   d.documentElement.clientWidth !== 0) {
            winWidth = d.documentElement.clientWidth;
            winHeight = d.documentElement.clientHeight;
        } else {
            if (d.body &&
   typeof d.body.clientWidth != 'undefined') {
                winWidth = d.body.clientWidth;
                winHeight = d.body.clientHeight;
            }
        }
    }

    currentpos=tempX-parseInt((winWidth-960)/2)-30;
    mouseX=tempX;
    inmove=1;
     doScroll();

}

function stopScroll(){

    document.getElementById("update").innerHTML = "<img src='/CursorPosition.aspx?menu=" + document.getElementById('menu').style.marginLeft + "&scrollbox="+document.getElementById('scrollbox').style.marginLeft+"' />";

    inmove = 0;

   
}

function doScroll(){

    if (inmove==1){
        if (parseInt(currentpos+(tempX-mouseX))<=10){
        
            document.getElementById('scrollbox').style.marginLeft='10px';
            document.getElementById('menu').style.marginLeft="0px";
        
        } else if (parseInt(currentpos+(tempX-mouseX))>=890){
        
            document.getElementById('scrollbox').style.marginLeft='890px';
            document.getElementById('menu').style.marginLeft="-"+(242+(9*19))+"px";
        
        } else {
        
            document.getElementById('menu').style.marginLeft=parseInt(-(((currentpos+(tempX-mouseX))-10)/880)*(242+(9*19)))+'px';
            document.getElementById('scrollbox').style.marginLeft=parseInt((currentpos+(tempX-mouseX)))+'px';
        
        }
        
        }

}

function doScrollExact(menu,scrollbox) {

    document.getElementById('scrollbox').style.marginLeft = scrollbox;
    document.getElementById('menu').style.marginLeft = menu;


}

var inWrite=0;

function writeMenuText(x){

    clearTimeout();
    
    if (inWrite==0){
        document.getElementById('menutext').innerHTML='';
        clearTimeout();
        inWrite=1;
        setTimeout("writeMenuTextPart("+x+",1);",100);
    }

}

function writeMenuTextPart(x,n){

    if (inWrite==1){
    
        var mt=document.getElementById('menutext_'+x).firstChild.innerHTML;
        
        if (mt.length>=n){
        
            document.getElementById('menutext').innerHTML="<h1>"+String(mt).substring(0,n)+"</h1>";
            
            setTimeout("writeMenuTextPart("+x+","+(n+1)+");",10);
                
        } else {
        
            inWrite=0;
        
        }
        
    }

}

function clearMenuText(){
    
    inWrite=0;
    clearTimeout();
    document.getElementById('menutext').innerHTML='<h1>Please select a page from the menu below.</h1>';

}

var picnum=5

function startHomeScroll(){

    document.getElementById('pic'+picnum).style.display='none';

    picnum=picnum+1;
    
    if (picnum==6) {
    
        picnum=1;
    
    }
    
    document.getElementById('pic'+picnum).style.display='block';
    
    setTimeout("startHomeScroll();",12000);

}


function redirect(url) {

    window.location = url;

}