﻿//global functions
function gd( o ){return document.getElementById( o );}

//Navigation controls
startList = function() {
if (document.all && document.getElementById) {
	navRoot = document.getElementById("nav");
	for ( i = 0; i < navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
					this.parentNode.className+=" sfhover";
				}
			node.onmouseout=function() {
					this.parentNode.className=this.className.replace(" sfhover", "");
				}
			}
		}
	}
}
window.onload = startList;

//homepage news and events tab controls
function toggleHomeNews( t )
{
    if( t == "events" )
    {
        gd("homeNewsBox").style.display = "none";
        gd("homeEventsBox").style.display = "block";
    }
    else if( t == "news" )
    {
        gd("homeEventsBox").style.display = "none";
        gd("homeNewsBox").style.display = "block";
    }
}

//media box controls
function toggleMediaView( o, b )
{
    gd('mediaVideo').style.display = 'none';
    gd('mediaDailyCam').style.display = 'none';
    gd('mediaLiveCam').style.display = 'none';
    gd(o).style.display = 'block';
    
    gd('mediaNavVideo').className = '';
    gd('mediaNavDailyCam').className = '';
    gd('mediaNavLiveCam').className = '';
    gd(b).className = 'active';
    if( o == 'mediaVideo' )
    {
        gd('mediaBoxNav').style.backgroundPosition = 'top';
    }
    if( o == 'mediaDailyCam' )
    {
        gd('mediaBoxNav').style.backgroundPosition = 'center';
    }
    if( o == 'mediaLiveCam' )
    {
        gd('mediaBoxNav').style.backgroundPosition = 'bottom';
    }
}

//functions for controling the rotation on the hompage where the heor images rotate
//homepage requires: setTimeout('prepRotator();', 10);
function prepRotator()
{
	var imgcase = document.getElementById( 'HeroImageCase' );
	var c = imgcase.getElementsByTagName('img');
	var g = new Array();
	var j = 0;
	for( var i = 0; i < c.length; i++ )
	{
	    if(c[i].getAttribute("name") == "heroImage")
	    {
	        g[j++] = c[i];
	    }
	}
	for( var i = 0; i < g.length; i++ )
	{
	     g[i].id = "HeroImage_" + i;
		 g[i].style.display = (i == 0) ? "block" : "none";
		 g[i].style.position = 'absolute';
	}
	setTimeout('rotateHeroes('+0+','+g.length+');', 10000);
}

function rotateHeroes( i, maxi )
{
	new Effect.toggle( "HeroImage_" + i, 'appear', {queue: 'start', delay: 0.5} );
	i++;
	if( i >= maxi ){i = 0;}
	new Effect.toggle( "HeroImage_" + i, 'appear', {queue: 'start', delay: 0.5} );
	//var n = i;
	setTimeout('rotateHeroes('+i+','+maxi+');', 10000);
	//setTimeout('rotateHeroes2('+n+');', 2000);
}
function rotateHeroes2( i )
{
	new Effect.toggle( "HeroImage_" + i, 'appear', {queue: 'start'} );
}

//empty brochure fields
function emptyBrochureFields()
{
    gd('ctl00_PageContent_txtFName').value = '';
    gd('ctl00_PageContent_txtLName').value = '';
    gd('ctl00_PageContent_txtAddress').value = '';
    gd('ctl00_PageContent_txtAddress2').value = '';
    gd('ctl00_PageContent_txtCity').value = '';
    gd('ctl00_PageContent_txtState').value = '';
    gd('ctl00_PageContent_txtZip').value = '';
    gd('ctl00_PageContent_txtCountry').value = '';
    gd('ctl00_PageContent_txtEmail').value = '';
    gd('ctl00_PageContent_txtPhone').value = '';
    gd('ctl00_PageContent_txtFax').value = '';
}

//functions for controling the rotation on the hompage where the heor images rotate
//homepage requires: setTimeout('prepRotator();', 10);
function prepFooterRotator( o, m, s )
{
	var imgcase = document.getElementById( o );
	var c = imgcase.getElementsByTagName('a');
	var g = new Array();
	var j = 0;
	for( var i = 0; i < c.length; i++ )
	{
	    if(c[i].getAttribute("name") == "rotateImg")
	    {
	        c[i].setAttribute("name", "");
	        g[j++] = c[i];
	    }
	}
	if( g.length <= m ) {return 0;};
	for( var i = 0; i < g.length; i++ )
	{
	     g[i].id = s + "_" + i;
		 g[i].style.display = (i < m) ? "block" : "none";
	}
	setTimeout("rotateFooter("+0+","+g.length+",'"+s+"',"+m+");",7500);
	setTimeout("rotateFooter2("+0+","+g.length+",'"+s+"',"+m+");",6200);
}

function rotateFooter( i, maxi, s, m )
{
	i=i+m;
	if( i > maxi ) { i = (i-maxi); }
	var n = i;
	for(var j = 0; j < m; j++)
	{
	    if((i+j) >= maxi){i = 0-j;}
	    new Effect.toggle(s+"_"+(i+j),'appear',{queue: 'start'});
	}
	
	setTimeout("rotateFooter("+i+","+maxi+",'"+s+"',"+m+");",7500);
	setTimeout("rotateFooter2("+n+","+maxi+",'"+s+"',"+m+");",6200);
}

function rotateFooter2( i, maxi, s, m )
{
	for(var j = 0; j < m; j++)
	{
	    if((i+j) >= maxi){i = 0-j;}
	    new Effect.toggle(s+"_"+(i+j),'appear',{queue: 'start'});
	}
}

function togTMedia( o )
{
    if( o == "videoBox" )
    {
        document.getElementById('videoSnack').style.display = "block";
        document.getElementById('picBox').style.display = "none";
        document.getElementById('ctl00_MediaBox1_VideoBTN').style.backgroundPosition = "bottom";
        document.getElementById('ctl00_MediaBox1_PicBTN').style.backgroundPosition = "top";
    }
    else
    {
        document.getElementById('videoSnack').style.display = "none";
        document.getElementById('picBox').style.display = "block";
        document.getElementById('ctl00_MediaBox1_VideoBTN').style.backgroundPosition = "top";
        document.getElementById('ctl00_MediaBox1_PicBTN').style.backgroundPosition = "bottom";
    }
}