function check(){
  
if((document.form1.name.value)=="")
 {
       alert("Please Enter First Name");
		document.form1.name.value = "";
		document.form1.name.focus();
		return false;
 }

if((document.form1.txtEmail.value)=="")
 {
       alert("Please Enter Email Address");
		document.form1.txtEmail.value = "";
		document.form1.txtEmail.focus();
		return false;
 }
    return true;
 }
 
function EmailValid(frm) 
{
	var emailStr;	
	
	emailStr=frm.value;

	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	
	if (matchArray==null)
	 {
			alert("Invalid Email Address");
			frm.value="";
			frm.focus();
			return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	if (user.match(userPat)==null)
	 {
		alert("Invalid Email Address");
		frm.value="";
		frm.focus();
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{
    		
	 	 for (var i=1;i<=4;i++) 
		 {
	    		if (IPArray[i]>255) 
				{
					alert("Invalid Email Address");
					frm.value="";
					frm.focus();
					return false;	
	   		 	}
    	}
    		return true;
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) 
	{
				alert("Invalid Email Address");
				frm.value="";
				frm.focus();
				return false;	
	}

	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
	{
				alert("Invalid Email Address");
				frm.value="";
				frm.focus();
				return false;	
	}

	if (len<2) 
	{
   		var errStr="Invalid Email Address";
				alert(errStr);
				frm.value="";
				frm.focus();
				return false;	
	}
	           return true;
	}
	
	
	
function ValidateForm(theForm) {
	if (theForm.name_text.value==""){
		alert("Please Enter Your Name")
		theForm.name_text.focus()
		return false
	}
	if (theForm.church_text.value==""){
		alert("Please Enter Church Name")
		theForm.church_text.focus()
		return false
	}
	if (theForm.city_name.value==""){
		alert("Please Enter City Name")
		theForm.city_name.focus()
		return false
	}
	if (theForm.state_name.value==""){
		alert("Please Select a State")
		theForm.state_name.focus()
		return false
	}
	//if (theForm.occasion_text.value==""){
		//alert("Please Enter The Occasion")
		//theForm.occasion_text.focus()
		//return false
	//}
	
	if (theForm.LC_text_hidden.value == "false" && theForm.CR_text_hidden.value == "false" && theForm.WR_text_hidden.value == "false"){
		alert("Please choose Lectionary/Cultural Resources/Worship Resources")
		theForm.LC_text.focus()
		return false
	}
	
	if (theForm.desc_text.value==""){
		alert("Anything else you want to share such as number of people saved, healed, how the lectionary has helped your preaching or teaching, etc.")
		theForm.desc_text.focus()
		return false
	}
	if (theForm.captcha_key_string.value==""){
		alert("ENTER captcha!")
		theForm.captcha_key_string.focus()
		return false
	}
	if (theForm.captcha_key_string.value != theForm.captcha_key_result.value){
		alert("WRONG captcha!")
		theForm.captcha_key_string.focus()
		return false
	}
	return true;
}

function TestVal(theVal) {
	//alert(theVal.value);
	document.form1.testiType.value = theVal.value;
	if( theVal.value == "VIDEO") {
		document.getElementById("video_info").style.display = "";
		document.getElementById("video_info1").style.display = "";
	} else {
		document.getElementById("video_info").style.display = "none";
		document.getElementById("video_info1").style.display = "none";
	}
}

function theChk1(theVal) {
	
	if(theVal.checked == true) {
		document.form1.LC_text_hidden.value = true;
	} else {
		document.form1.LC_text_hidden.value = false;
	}
}
function theChk2(theVal) {
	
	if(theVal.checked == true) {
		document.form1.CR_text_hidden.value = true;
	} else {
		document.form1.CR_text_hidden.value = false;
	}
}
function theChk3(theVal) {
	
	if(theVal.checked == true) {
		document.form1.WR_text_hidden.value = true;
	} else {
		document.form1.WR_text_hidden.value = false;
	}
}

function viewMusic(mObj) {
		document.getElementById(mObj).style.display = "";
	}
	function viewVideo(objVid) {
		var openWin = window.open ("videos.html#"+objVid, objVid, "location=0,status=0,scrollbars=0,width=640,height=480,left=300,top=200");
		if (window.focus) {openWin.focus()}
		return false;
	}
	
function MyVideo1(objVid) {
	var openWin = window.open ("page.html", "VIDEO", "location=0,status=0,scrollbars=0,width=680,height=520,left=300,top=100");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo2(objVid) {
	var openWin = window.open ("page1.html", "VIDEO", "location=0,status=0,scrollbars=0,width=350,height=280,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo3(objVid) {
	var openWin = window.open ("page2.html", "VIDEO", "location=0,status=0,scrollbars=0,width=350,height=280,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo4(objVid) {
	var openWin = window.open ("page3.html", "VIDEO", "location=0,status=0,scrollbars=0,width=350,height=280,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo5(objVid) {
	var openWin = window.open ("page4.html", "VIDEO", "location=0,status=0,scrollbars=0,width=350,height=280,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo6(objVid) {
	var openWin = window.open ("page5.html", "VIDEO", "location=0,status=0,scrollbars=0,width=350,height=280,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo7(objVid) {
	var openWin = window.open ("page6.html", "VIDEO", "location=0,status=0,scrollbars=0,width=350,height=300,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo8(objVid) {
	var openWin = window.open ("page7.html", "VIDEO", "location=0,status=0,scrollbars=0,width=530,height=430,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function MyVideo9(objVid) {
	var openWin = window.open ("page8.html", "VIDEO", "location=0,status=0,scrollbars=0,width=350,height=300,left=300,top=200");
	if (window.focus) {openWin.focus()}
	return false;
}
function check() 
{
	if(document.form1.txtChurchName.value == ""){
		alert("Please Enter Church Name");
		document.form1.txtChurchName.focus();
		return false;
	}
	if(document.form1.txtPastorName.value == ""){
		alert("Please Enter Pastor Name");
		document.form1.txtPastorName.focus();
		return false;
	}
	if(document.form1.txtProgCoOrd.value == ""){
		alert("Please Enter Project Coordinator Name");
		document.form1.txtProgCoOrd.focus();
		return false;
	}
	if(document.form1.txtCity.value == ""){
		alert("Please Enter City");
		document.form1.txtCity.focus();
		return false;
	}
	if(document.form1.txtState.value == ""){
		alert("Please Enter State");
		document.form1.txtState.focus();
		return false;
	}
    return true;
}

function openPopupWin(urlvid) {
	
	window.open('staging/PIVideos/'+urlvid,'welcome','width=401,height=316,menubar=no,status=yes,location=no,toolbar=no,scrollbars=no,top=100,left=250');
	//alert(urlvid);
}

function ValidateSearchForm(theForm) {
	if(theForm.quicksearch.value == "" || theForm.quicksearch.value == "KEYWORD"){
		alert("Blank KEYWORD");
		theForm.quicksearch.focus();
		return false;
	}
	if(theForm.bible[0].checked == true) {
		theForm.action = "http://www.biblegateway.com/quicksearch/";
		theForm.target = "_blank";
		//return false;	
	}
	if(theForm.bible[1].checked == true) {
		theForm.action = "searchresults.asp";
		theForm.target = "_self";
		//return false;	
	}
	return true;	
}
function showHint(str)
{
if(str == "low") {
	document.getElementById("audioOff").style.display = "none";
	document.getElementById("audioOn").style.display = "";
} else {
	document.getElementById("audioOff").style.display = "";
	document.getElementById("audioOn").style.display = "none";
}
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","2.asp?q="+str,true);
xmlhttp.send();
}
