
//this displays div if it's hidden and hides it if it's displayed
function showHideDiv(divName) {
	if (document.getElementById(divName).style.display=="block") {
		document.getElementById(divName).style.display="none";		
	} else {
		document.getElementById(divName).style.display="block";

	}
}

// shows div
function showDiv(divName) {
		document.getElementById(divName).style.display="block";
		if ((document.getElementById('topLink')  != "undefined" )&&(navigator.appName!="Microsoft Internet Explorer")&&(divName=='homeMenu1'||divName=='homeMenu2')) {
			document.getElementById('topLink').style.display="none";
		} 				
}

// hides div
function hideDiv(divName) {
		document.getElementById(divName).style.display="none";
		if (( document.getElementById('topLink') != "undefined" )&&(navigator.appName!="Microsoft Internet Explorer")&&(divName=='homeMenu1'||divName=='homeMenu2')) {
			document.getElementById('topLink').style.display="block";
		} 				
}

function hideHector() {
	document.getElementById('footerHector').style.display="none";
	document.getElementById('footerHectorDown').style.display="none";
	document.getElementById('footerHectorHidden').style.display="block";
	document.getElementById('footerHectorUp').style.display="block";
}

function showHector() {
	document.getElementById('footerHector').style.display="block";
	document.getElementById('footerHectorDown').style.display="block";
	document.getElementById('footerHectorHidden').style.display="none";
	document.getElementById('footerHectorUp').style.display="none";
}

submitted=0;

function submitForm(formName) {

	if (submitted==0) {
		submitted=1;
		document.getElementById(formName).submit();
	}

}

var vis=false;

function grayOut(options) {
	
   if (vis==true) {
		vis=false;   
   } else {
		vis=true;   
   }
  // 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 || 70;
  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) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //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=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';                          
  } else {
     dark.style.display='none';
  }
}

function stopYTMovie() {
	document.getElementById('ytplayer').pauseVideo();
}

function startYTMovie() {
	document.getElementById('ytplayer').playVideo();
}

function onYouTubePlayerReady(playerId) {
      ytplayer = document.getElementById("ytplayer");
    }

function resizeBGHome() {
	jQuery.noConflict();
	(function($) {
		var theWindow        = $(window),
		$bg              = $("#mainContentBG1"),
		$bg2			 = $("#mainContentBG2"),
		$bg3			 = $("#mainContentBG3"),
		$bg4			 = $("#mainContentBG4"),
		$bgArea			 = $("#mainContent"),
		aspectRatio      = $bg.width() / ($bg.height());
		origWidth		 = 1145;
		origHeight		 = 882;
		windowWidth = $(window).width();
		windowHeight = $(window).height();
		$("div#mainContent").css('height',$(window).height());
		if ( ($bgArea.width() / $bgArea.height()) < aspectRatio ) {
			$bg
				.removeClass()
				.addClass('bgheight');
				currentWidth = ($(window).height() * origWidth / origHeight);
				$bg.css('top',0);
				$bg.css('left',($(window).width()-currentWidth)/2);
				$bg2.removeClass()
				$bg2.addClass('bgheight');
				$bg2.css('top',0);
				$bg2.css('left',($(window).width()-currentWidth)/2);
				$bg3.removeClass()
				$bg3.addClass('bgheight');
				$bg3.css('top',0);
				$bg3.css('left',($(window).width()-currentWidth)/2);
				$bg4.removeClass()
				$bg4.addClass('bgheight');
				$bg4.css('top',0);
				$bg4.css('left',($(window).width()-currentWidth)/2);
		} else {
			$bg
				.removeClass()
				.addClass('bgwidth');
				currentHeight = ($(window).width() * origHeight / origWidth);
				$bg.css('left',0);
				$bg.css('top',($(window).height()-currentHeight)/2);
				$bg2.removeClass();
				$bg2.addClass('bgwidth');
				$bg2.css('left',0);
				$bg2.css('top',($(window).height()-currentHeight)/2);
				$bg3.removeClass();
				$bg3.addClass('bgwidth');
				$bg3.css('left',0);
				$bg3.css('top',($(window).height()-currentHeight)/2);
				$bg4.removeClass();
				$bg4.addClass('bgwidth');
				$bg4.css('left',0);
				$bg4.css('top',($(window).height()-currentHeight)/2);
		}
	})(jQuery); 
}

function resizeBG() {
	jQuery.noConflict();
	(function($) {
		var theWindow        = $(window),
		$bg              = $("#mainContentBG1"),
		$bgArea			 = $("#mainContent"),
		aspectRatio      = $bg.width() / ($bg.height());
		origWidth		 = 1145;
		origHeight		 = 882;
		$("div#mainContent").css('height',$(window).height());
		if ( ($bgArea.width() / $bgArea.height()) < aspectRatio ) {
			$bg
				.removeClass()
				.addClass('bgheight');
				currentWidth = ($(window).height() * origWidth / origHeight);
				$bg.css('top',0);
				$bg.css('left',($(window).width()-currentWidth)/2);
		} else {
			$bg
				.removeClass()
				.addClass('bgwidth');
				currentHeight = ($(window).width() * origHeight / origWidth);
				$bg.css('left',0);
				$bg.css('top',($(window).height()-currentHeight)/2);
		}
	})(jQuery); 
}

function resizeContentContainer() {
	jQuery.noConflict();
	(function($) {
		var theWindow        = $(window),
		$container              = $("#mainContentContainer"),
		$content			 = $("#mainContentMiddle");
		$container.css('height',$(window).height()-200);
		$content.css('height',$(window).height()-260);
	})(jQuery); 
}

currentImage = 1;
maxImage = 4;
function cycleImage() {
	if (currentImage == maxImage) {
		nextImage = 1;	
	} else {
		nextImage = currentImage + 1;	
	}
	$('mainContentBG'+currentImage).fx = $('mainContentBG'+currentImage).effect('opacity', {duration: 2000}).start(0);
	$('mainContentBG'+nextImage).fx = $('mainContentBG'+nextImage).effect('opacity', {duration: 2000}).start(1);	
		
	currentImage=nextImage;
	setTimeout('cycleImage()',15000);	
}

toggle = false;
openNumber = '';

function slideMenu(number) {
	jQuery.noConflict();
		if (!toggle) {
		(function($) {
			toggle = true;
			setTimeout("toggle = false;",750);
			if (openNumber == '') {
				openNumber = number;	
				$("#menu"+number).slideToggle('750');
			} else if (openNumber == number) {
				openNumber = '';
				$("#menu"+number).slideToggle('750');
			} else if (openNumber != number) {
				$("#menu"+openNumber).slideToggle('750');
				setTimeout("slideMenu("+number+");",800);
				openNumber = '';
			}
		})(jQuery); 
	}
}

function resizeDiv() 
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	
	myWidth = window.innerWidth;
	
	myHeight = window.innerHeight + window.scrollMaxY;
	myOffset = (window.pageYOffset+50);
	
	/*myHeight = (document.body.offsetHeight>document.body.scrollHeight)? document.body.offsetHeight : document.body.scrollHeight;*/
	
	//+document.body.scrollHeight
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.body.offsetHeight;
	myHeight = document.body.offsetHeight;
	myOffset = (document.documentElement.scrollTop+50);	
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.offsetHeight;
	myHeight = document.body.offsetHeight;
	myOffset = (document.body.scrollTop+50);	
  }
  
 	myHeight= (document.body.offsetHeight>document.body.scrollHeight)? document.body.offsetHeight : document.body.scrollHeight;
	document.getElementById("overlayDiv").style.height=myHeight + "px";
	// if IE 7+, Firefox
	if (typeof document.body.style.maxHeight != "undefined")
	{
		document.getElementById("overlayDiv").style.height=(myHeight+17) + "px";
		if (navigator.appVersion.indexOf("MSIE 7.")==-1) {
			document.getElementById("overlayDiv").style.height=(myHeight) + "px";
		}
	}
	else
	{
		// IE 6 or older
		document.getElementById("overlayDiv").style.height=(myHeight*1.5) + "px";
	}
	
	document.getElementById("overlayDiv").style.width="100%";
	document.getElementById("overlayDiv").style.display="block";
}
