// Place your application-specific JavaScript functions and classes here

$(document).ready(function(){
	
	function adjustSideBorders(){
		if($(".contentWrapper").height() > 520){
			if($(".contentWrapper").height() > 530 && $(".contentWrapper").height() < 550)
			{
				$("#leftBorderTop").height($(".contentWrapper").height()-(540-(550-$(".contentWrapper").height())));
				$("#rightBorderTop").height($(".contentWrapper").height()-(540-(550-$(".contentWrapper").height())));
			}
			else
			{
				$("#leftBorderTop").height($(".contentWrapper").height()-540);
				$("#rightBorderTop").height($(".contentWrapper").height()-540);
			}
		}
		else
		{
			$("#leftBorderTop").height($(".contentWrapper").height()-510);
			$("#rightBorderTop").height($(".contentWrapper").height()-510);
		}
		
	}
	adjustSideBorders();	//fix side border height

	function hideSubNav(){
		$(this).children(".secondaryMenuOptions").hide();
	}


	$(".mainMenuOptionBox").each(function(){
		 
			//height fix for longer menu title, only for IE
			if($(this).attr("id") == "menuOption3"){
				if(!jQuery.support.cssFloat){
					$(this).children("img").height(43);
					$(this).children("img").width(150);
				}
			}
			
		
		$(this).hover(
			function(){
				$(this).children(".secondaryMenuOptions").show();
			},
			function(){
				$(this).children(".secondaryMenuOptions").hide();
			}
		);
		
	});
	
	if(hasTertiaryNav == 'No')
	{
		var cssObj = {
			'padding-top' : '40px',
			'min-height' : '465px'
		};

		$(".interiorSectionA").css(cssObj);
	}
	/*
		$("#has_3rd_nav").each(function(){
				
				$(this).hover(
					function(){
						$(this).children(".tertiaryMenuOptions").show();
					},
					function(){
						$(this).children(".tertiaryMenuOptions").hide();
					}	
				);
		});
	*/		
});

function togglePhone(){
	$("#phone-required").toggle();
}

function PopHere(prPage)
	{
                if(prPage != "" && prPage != " ")
		        legend2 = window.open(prPage,"ph2","toolbar=no,directories=no,menubar=no,screenX=0,screenY=0,scrollbars=1,left=0,top=0,width=720,height=500")
                else
                        return false;
	}

function checkRequiredFields(){
	var output = "<h3>Submission Errors</h3><ul>";
        var errs = "";

	if($("#fname").attr("value") == "")
		errs += "<li>Please enter your first name</li>";

	if($("#lname").attr("value") == "")
		errs += "<li>Please enter your last name</li>";

	if($("#email").attr("value") == "")
		errs += "<li>Please enter your email address</li>";

	if($("#phone").attr("value") == "" && $("#phone-required").css("display") != 'none')
		errs += "<li>Please enter your phone number to be contacted</li>";	

	output += errs + "</ul>";

	if(errs.length > 0)
	{
		$("#error-display").html(output);
		return false;
	}
	
	return true;
}