// getPageScroll()
// Returns array with x,y page scroll values.
// Code from - quirksmode.org
var c;
var si, so; //intervals

function getPageScroll(){
    var yScroll, xScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft;
    }
    arrayPageScroll = new Array('',yScroll,xScroll) 
    return arrayPageScroll;
}

// getPageSize()
// Returns array with page width, height and window width, height
// Code from - quirksmode.org

function getPageSize(){	
    var xScroll, yScroll;	

    if (window.innerHeight && window.scrollMaxY) {	
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
	
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }		

    // for small pages with total height less then height of the viewport

    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport

    if(xScroll < windowWidth){	
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    return arrayPageSize;
}

function getScrollerWidth() {
    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.top = '-1000px';
    scr.style.left = '-1000px';
    scr.style.width = '100px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';

    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '200px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.offsetWidth;
    // Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.offsetWidth;

    // Remove the scrolling div from the doc
    document.body.removeChild(
    document.body.lastChild);

    // Pixel width of the scroller
    //return (wNoScroll - wScroll);
return 0


}


function doResize() {
  overlay_banner = document.getElementById("overlay_banner");
  c = document.getElementById('subcontent');
  overlay_banner.style.width = '100%';

  var arrayPageSize = getPageSize();

  
  overlay_banner.style.height = arrayPageSize[1] + 'px';
  overlay_banner.style.width = '100%';
  
  c.style.left = (arrayPageSize[2]/2)-(c.offsetWidth/2)+"px";
}

function doScroll() {
  var arrayPageScroll = getPageScroll();
  c = document.getElementById('subcontent');
  c.style.top =  arrayPageScroll[1] + 100 + 'px';
}

function fadeIn (){

  if (document.all) toggleSelects('hidden');

  var arrayPageSize = getPageSize();

  overlay_banner = document.createElement("div");
  overlay_banner.id = 'overlay_banner';
  
  setOpacity(overlay_banner,75);
  
  document.body.appendChild(overlay_banner);
  
  var pageHeight = document.body.scrollHeight;
  var pageWidth = document.body.scrollWidth;

  overlay_banner.style.height = pageHeight + 'px';
  overlay_banner.style.width = pageWidth + 'px';
  
  var BoxHolder = document.createElement("div");
  document.body.appendChild(BoxHolder);
  BoxHolder.innerHTML = '';
}


function fadeOut () {    
  c.style.display = 'none';
  overlaybanner = $("overlay_banner");
  overlaybanner.style.display = 'none';
  
}


function toggleSelects(state) {
  selects = document.getElementsByTagName('select');
  for (i=0;i<selects.length;i++) selects[i].style.visibility = state;
}

function startSlide(direction, el) {

  var arrayPageSize = getPageSize();
  var arrayPageScroll = getPageScroll();
  
  if (direction=='down') {
    
    c = document.getElementById(el);
    
    c.style.top =  ((c.offsetHeight * -1) + arrayPageScroll[1]) + 'px';
    c.style.left = (arrayPageSize[2]/2)-(c.offsetWidth/2)+"px";
    si = setInterval("slideIn()",25);
  } else {
    so = setInterval("slideOut()",25);
  }
}

function slideIn(container,direction) {
  var arrayPageScroll = getPageScroll();
  ct = parseInt(c.style.top)
  ct < (arrayPageScroll[1] + 100) ? c.style.top = (ct + 30) + 'px' : clearInterval(si);
 
}

function slideOut(container) {
  var arrayPageScroll = getPageScroll();
  ct = parseInt(c.style.top);    
  if (ct > (c.offsetHeight * -1) + arrayPageScroll[1]) {
    c.style.top = (ct-30) + 'px'
  } else {
    clearInterval(so);
    toggleSelects('visible');
    fadeOut();
  }
}

