// JavaScript Document

function toggleLayer( whichLayer, slidesData, containerElem )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';

  vis.display = (vis.display==''||vis.display=='block')?'none':'block';

  var winsize = WinSize() ;
  var scrollpos = getScrollXY() ;

  var shade = document.getElementById( 'shade' );
  if(  vis.display=='block' ){
	  shade.style.width	  = document.body.offsetWidth + "px" ;
	  shade.style.height  = document.body.offsetHeight + "px" ;
	  shade.style.display = "block"; 
  }else{
	  shade.style.display = "none"; 
  }

	// have to display the div befor you can get its hieght
  var DivHeight = document.getElementById( whichLayer ).offsetHeight;
  var DivWidth = document.getElementById( whichLayer ).offsetWidth;

  elem.style.left = ((winsize[0]/2)+scrollpos[0])-(DivWidth/2) + "px" ;
  if( elem.style.left < 0 )
	  elem.style.left = 0 ;
  elem.style.top = ((winsize[1]/2)+scrollpos[1])-(DivHeight/2) + "px" ;
  if( elem.style.top < 0 )
	  elem.style.top = 0 ;
	  
  if(  vis.display=='block' && containerElem!=null  )
     myShow = new Slideshow(containerElem, slidesData, { delay: 5000, duration: 1500, captions: true, controller: true });
  else
     myShow.destroy('empty') ;
}	

function WinSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  return [ myWidth, myHeight ];
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}



function toggleBaloon( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';

  var scrollpos = getScrollXY() ;
  var winsize = WinSize() ;

  vis.display = (vis.display==''||vis.display=='block')?'none':'block';

	// have to display the div befor you can get its hieght
  var DivHeight = document.getElementById( whichLayer ).offsetHeight;
  var DivWidth = document.getElementById( whichLayer ).offsetWidth;

  elem.style.left = ((winsize[0]/2)+scrollpos[0])-(DivWidth/2) + "px" ;
  elem.style.top = ((winsize[1]/2)+scrollpos[1])-(DivHeight/2) + "px" ;
}	


/*
function toggleLayerOpacity( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];

  vis = elem.style ;

//  top = (cursorY - 100) ;
//  left = (cursorX - 100) ;
//  if( top < 0 ) top = 0 ;
//  if( left < 0 ) left = 0 ;

  elem.style.top = cursorY + "px" ;
  elem.style.left = cursorX + "px" ;

// if the style.display value is blank we try to figure it out here
  if( vis.display=='' && elem.offsetWidth != undefined && elem.offsetHeight!=undefined ){
//    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
    if( elem.offsetWidth!=0 && elem.offsetHeight!=0 )
	  vis.display = 'block' ;
	else
	  vis.display = 'none';
  }

//  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  if( vis.display==''||vis.display=='block' )
  	vis.display = 'none' ;
  else	
  	vis.display = 'block' ;

  modal = document.getElementById( 'modal' );
  if(  vis.display=='block' ){
	 modal.style.display = "block"; 
     opacity( "page", 100, 25, 500 ) ;
  }else{
     opacity( "page", 25, 100, 500 ) ;
	 modal.style.display = "none"; 
  }
}	

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
} 
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}


*/

/*
function getXY(e) {
    e = e || window.event;

	if (e.pageX || e.pageY) {
        x = e.pageX;
        y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
  
    cursorX = x;
    cursorY = y;
}

<!--        Script by hscripts.com          -->
<!--        copyright of HIOX INDIA         -->
<!-- more scripts @ http://www.hscripts.com -->
window.onload = init;
var cursorX = 0 ;
var cursorY = 0 ;
function init() {
  if (window.Event) {
    document.captureEvents(Event.MOUSEMOVE);
  }
  document.onmousemove = getXY;
}

function OthergetXY(e) {
  var cursor = {x:0, y:0};
  x = (window.Event) ? e.pageX : event.clientX;
  y = (window.Event) ? e.pageY : event.clientY;

//  id = document.getElementById( "cursorx" )
//  id.value = x;
//  id = document.getElementById( "cursory" )
//  id.value = y;
  cursorX = x;
  cursorY = y;
}
<!-- Script by hscripts.com -->

function CursorAlert()
{
  alert( "X " + cursorX + " Y " + cursorY ) ;
} 
*/


