
// JavaScript Document
var viewportwidth;
var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
if (typeof window.innerWidth != 'undefined')
{
	viewportwidth = window.innerWidth,
	viewportheight = window.innerHeight
	}
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
{
	viewportwidth = document.documentElement.clientWidth,
	viewportheight = document.documentElement.clientHeight
	}
 
 // older versions of IE
 
else
{
	viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}

//get URL Vars
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
 
    return vars;
}


//Document Stuff
$(document).ready(function(){
							var headerWidth = $('#branding').width();
							var showLogoWidth = $('.showLogo').width();
							var headerString = $('#branding').html();
							var headerBreak = headerString.indexOf("<br>");
							//alert(headerString);
							if ((headerWidth > 470 && showLogoWidth >= 160) || headerBreak > -1){
								headerAllow = 629-showLogoWidth;
								$('#branding').css('width',headerAllow).css('padding','0.5em 0.3em 0.5em 0.3em ').css('font-size','23px').find('span').css('line-height','1em');
							}
							$('#ShortFormLink').attr("href","resources/php/shortForm.php");
						   $('.demoLink').click(function(){
														 alert("Sorry, this function is disabled in the Demo");
														 });
						   $("ul.nav li ul").parent().wrap("<span></span>");
						   $("ul.nav span li").click(function(){
															  $(".visibleSubNav").removeClass("visibleSubNav").hide();
															  $(this).parent().find("ul").addClass("visibleSubNav").show();
															  });
						   if (viewportheight < 557) {
							   $(document).scrollTo('#MainContent');
							   };
							
							$('#Step1Button').click(function(){
								$('#Step1Arrow, #Step3Arrow').fadeTo('',.5);
								$('#Step2Arrow').fadeTo('',1);
								$('#StepStartArrow').fadeTo('',.5);
							});
							$('#ShortFormLink').click(function(){
								//$('#Step1Arrow, #Step2Arrow').fadeTo('',.5);
								//$('#Step3Arrow').fadeTo('',1);
								$('#StepStartArrow').hide();
							});
							$('#Step3Button').click(function(){
								$('#Step1Arrow, #Step2Arrow, #Step3Arrow').hide();
							});
							$('#ShortFormLink').colorbox({width:"50%", height:"480px", iframe:true});
							   
						   });
						   
//Trigger From I Frames StartHereHint;
function startHereTriggered() {
			//alert("Play First Video");
			//$('#Step1Arrow, #Step2Arrow, #Step3Arrow').fadeIn();
			//$('#Step2Arrow, #Step3Arrow').fadeTo('',.5);
			//$('#StepStartArrow').fadeIn();
			var infoForm = getUrlVars();
			
			if (!infoForm[1]){
				$("#Step1Button").contents().replaceWith("<img id='StepStartArrow' src='img/startHere.png' />");
			}
			
		}
		
function openShortForm(){
	//alert("Fill Out Form");
	$.fn.colorbox({href:'resources/php/shortForm.php',width:"50%", height:"480px",open:true, iframe:true});
	//$('#StepStartArrow').hide();
	$("#StepStartArrow").replaceWith("Start Here");
	//$('#Step1Arrow, #Step2Arrow').fadeTo('',.5);
	//$('#Step3Arrow').fadeTo('',1);
}
