// JavaScript Document
function showPhoto(photo, title, subtext) {
	document.getElementById('image_src').src = photo;
	document.getElementById('image_title').innerHTML = title;
	document.getElementById('image_overlay').style.visibility = 'visible';
	grayOut(true);	
}
function closePhoto() {
	document.getElementById('image_overlay').style.visibility = 'hidden';
	grayOut(false);	
}
function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 75;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
 
 update_size(dark);
 
 // Calculate the page width and height 
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=1;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.display='block';                          
  } else {
     dark.style.display='none';
  }
}

function update_size(dark) {

if( document.body && document.body.scrollWidth ) {
		var actualWidth = document.body.scrollWidth;
        var pageWidth = document.body.scrollWidth+'px';
    } else if( document.body.offsetWidth ) {
      var actualWidth = document.body.offsetWidth;
	  var pageWidth = document.body.offsetWidth+'px';
    } else {
       var pageWidth='100%';
    } 

var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
	myHeight = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  var pageHeight = myHeight + "px";

  dark.style.width= pageWidth;
  dark.style.height= pageHeight;
  
  
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop  ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop  ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }

  	dark.style.top = scrOfY +'px';
	document.getElementById('image_overlay').style.top = (scrOfY+25)+'px';
	document.getElementById('image_overlay').style.left = (actualWidth/2 - 300) +'px';
}

function toggle(service_id) {
	if (service_id.style.display=='none')	
	{
		service_id.style.display='';
	}
	else
	{
		service_id.style.display='none';
	}
}

function toggle_map(name) {
	
	document.getElementById('overview').style.display='none';
	document.getElementById('local').style.display='none';
	document.getElementById('showHide').style.display='none';

	if (name=='overview')
	{
		document.getElementById('overview').style.display='';
		document.getElementById('showHide').style.display='';
	}
	else if (name=='local')
	{
		document.getElementById('local').style.display='';
		document.getElementById('showHide').style.display='';
	}
}