// JavaScript Document
//jquery load
var bNoSet = false;
$(function(){
		
		//if(!bNoSet)
		//	$("#content").css("height", $("#rightcol").height()+"px"); //set height of content area
		
		try{$("#header").click(function(){document.location.href="index.htm"});}catch(e){} //header is link
		
		try{$("input[type=text],textarea").focus(function(){this.select();}); } catch(e){}//onfocus select of input fields and text areas
		
		$("#btnContinue").click(function(){if(checkAndOpen($("#contactform"), false)) doContinue();});
		   
});

function doContinue(){
	//$("#tblForm").hide();
	$("#tblSubmit").show();
}

function doReset(){
	//document.forms[0].reset();
	location.reload();
}

//form check and open new window
function checkAndOpen(frm, bOpenWin)
{
	var requiredfields = $("#requiredFields") ? $("#requiredFields").val().split(",") : null;
	
	if(!!requiredfields){
		var fld; 
		for(var i=0;i<requiredfields.length;i++)
		{
			fld = $("[name="+requiredfields[i]+"]");
			if(!fld.val() || fld.val() == "none selected")
			{
				alert("Please fill in the required information.");
				fld[0].focus();
				return false;f
			}
		}
	}
	
	if(bOpenWin != false){
		//check to see that capcha field is visible, else show it
		if($("#tblSubmit").is(':hidden')) { 
			doContinue();
			return false;
		}
		
		//open window
		window.open("",frm.target,"width=250,height=200,toolbar=0");
		window.setTimeout(doReset, 2000);
	}
	
	return true;
}
