function isEmpty(txtField)
{
	txtField = txtField.replace(/^\s*|\s*$/,"");
	if (txtField == "") 
	{
	  return true;
	}
	else 
	{
	  return false;
	}
}

function textEntryCounter() 
	{
		if(document.frmRequest != null)
		{
	   	if (document.frmRequest.txtEntry.value.length > 1000) // if too long...trim it!
	   		document.frmRequest.txtEntry.value = document.frmRequest.txtEntry.value.substring(0, 1000);
	   	// otherwise, update 'characters left' counter
	   	else 
	   	document.frmRequest.remLen.value = 1000 - document.frmRequest.txtEntry.value.length;
	  }
	}
	
function checkPrayerForm(form)
{ 
	  
if (isEmpty(form.txtName.value) || form.txtName.value == " ") {
alert("Please enter your name (or anonymous), so we can pray for you by name.");
form.txtName.focus();
form.txtName.select();
return false;}

if (isEmpty(form.txtEntry.value) || form.txtEntry.value == " ") {
alert("Please enter a request or praise.");
form.txtEntry.focus();
form.txtEntry.select();
return false;}

if(form.txtEmail.value != "")
{
  if(!checkMail(form.txtEmail.value))
  {
    form.txtEmail.focus();
    form.txtEmail.select();
    return false;
  }
}

return true;
}

function checkBidForm(form)
{
  
/*if (isEmpty(form.First_Name.value) || form.First_Name.value == " ") {
alert("Please enter your first name.");
form.First_Name.focus();
form.First_Name.select();
return false;}

if (isEmpty(form.Last_Name.value) || form.Last_Name.value == " ") {
alert("Please enter your last name.");
form.Last_Name.focus();
form.Last_Name.select();
return false;
}

if (isEmpty(form.Email.value))
{
alert("Please enter your email address.");
form.Email.focus();
form.Email.select();
return false;}

if (isEmpty(form.Email2.value))
{
alert("Please retype your email address.");
form.Email2.focus();
form.Email2.select();
return false;}


if(form.Email.value != "")
{
  if(!checkMail(form.Email.value))
  {
    alert("Please enter your email address.");
    form.Email.focus();
    form.Email.select();
    return false;
  }
}

if(form.Email2.value != "")
{
  if(!checkMail(form.Email2.value))
  {
    alert("Please retype your email address.");
    form.Email2.focus();
    form.Email2.select();
    return false;
  }
}

if(form.Email.value != form.Email2.value)
{
  alert("Please verify your email address in both boxes.");
  form.Email.focus();
  form.Email.select();
  return false;
}

myString = form.bidder_id.value;
strlength = myString.length;

if (isEmpty(form.bidder_id.value) || form.bidder_id.value == " " || (strlength < 6 || strlength > 10)) {
alert("Please enter your bidder id.");
form.bidder_id.focus();
form.bidder_id.select();
return false;}
*/

if (isEmpty(form.bid.value) || form.bid.value == " " || form.bid.value == "000.00" || isNaN(form.bid.value)) {
alert("Please enter your bid.");
form.bid.focus();
form.bid.select();
return false;}

if (parseFloat(form.bid.value) < parseFloat(form.highbid.value) + 1.00) {
alert("Please enter a higher bid (in increments of whole dollars) than the current bid of " + form.highbid.value + ".");
form.bid.focus();
form.bid.select();
return false;}

if (parseFloat(form.bid.value) <= parseFloat(form.highbid.value)) {
alert("Please enter a higher bid than the current bid of " + form.highbid.value + "." + "yourbid: " + form.bid.value);
form.bid.focus();
form.bid.select();
return false;}

/*
if(form.accept.checked == false)
{
  alert("Please read and accept the terms and conditions.");
  form.accept.focus();
  form.accept.select();
  return false;
}
*/
return true;
}

function checkRegForm(form)
{
  
if (isEmpty(form.FirstName.value) || form.FirstName.value == " ") {
alert("Please enter your first name.");
form.FirstName.focus();
form.FirstName.select();
return false;}

if (isEmpty(form.LastName.value) || form.LastName.value == " ") {
alert("Please enter your last name.");
form.LastName.focus();
form.LastName.select();
return false;
}

if (isEmpty(form.Email1.value))
{
alert("Please enter your email address.");
form.Email1.focus();
form.Email1.select();
return false;}

if (isEmpty(form.Email2.value))
{
alert("Please retype your email address.");
form.Email2.focus();
form.Email2.select();
return false;}


if(form.Email1.value != "")
{
  if(!checkMail(form.Email1.value))
  {
    alert("Error in your email address.  Please check and reenter.");
    form.Email1.focus();
    form.Email1.select();
    return false;
  }
}

if(form.Email2.value != "")
{
  if(!checkMail(form.Email2.value))
  {
    alert("Error in your retyping email address.  Please check and reenter.");
    form.Email2.focus();
    form.Email2.select();
    return false;
  }
}

if(form.Email1.value != form.Email2.value)
{
  alert("Please verify your email address in both boxes.");
  form.Email1.focus();
  form.Email1.select();
  return false;
}

if (isEmpty(form.Address1.value) || form.Address1.value == " ") {
alert("Please enter your address.");
form.Address1.focus();
form.Address1.select();
return false;
}

if (isEmpty(form.City.value) || form.City.value == " ") {
alert("Please enter your city.");
form.City.focus();
form.City.select();
return false;
}

if (isEmpty(form.State.value) || form.State.value == " " || form.State.value == "zz") {
alert("Please select your state.");
//form.State.focus();
//form.State.select();
return false;
}

if (isEmpty(form.Zip.value) || form.Zip.value == " ") {
alert("Please enter your zip code.");
form.Zip.focus();
form.Zip.select();
return false;
}

myString = form.UserName.value;
strlength = myString.length;

if (isEmpty(form.UserName.value) || form.UserName.value == " " || (strlength < 6 || strlength > 10)) {
alert("Please enter your user name.");
form.UserName.focus();
form.UserName.select();
return false;}

if (isEmpty(form.Password1.value))
{
alert("Please enter your password.");
form.Password1.focus();
form.Password1.select();
return false;}

if (isEmpty(form.Password2.value))
{
alert("Please retype your password.");
form.Password2.focus();
form.Password2.select();
return false;}

if(form.Password1.value != form.Password2.value)
{
  alert("Please verify your password in both boxes.");
  form.Password1.focus();
  form.Password1.select();
  return false;
}
if(form.accept.checked == false)
{
  alert("Please read and accept the terms and conditions.");
  form.accept.focus();
  form.accept.select();
  return false;
}
return true;
}

function prayit()
{
  document.liftitupform.submit;
	alert ("Thank you for praying!");
	return;
}
  
function praiseit()
{
  document.liftitupform.submit;
	alert ("Thank you for joining in praise to God!");
	return;
}
	  
function openPrayer(id)
{
	strLink = "prayerentryxl.php?id=" + id; 
	
	//IE
	var strWindow = window.open(strLink, null, 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=400,top=100,left=100');
	
	//NS
	//var strWindow = window.open(strLink, prayerxl, 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=400,top=100,left=100');
}

 function openGuestmap()
{
	strLink = "../guestmap/index.php"; 
	var strWindow = window.open(strLink, 'guestmap', 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=750,height=575,top=25,left=25');
}

function openWinSml(strLink,strName) 
	{
		strLink = strLink + '.html';
		var strWindow = window.open(strLink, strName, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=350,top=25,left=25')
	}	

function openWin(strLink,strName) 
	{
		strLink = strLink + '.html';
		var strWindow = window.open(strLink, strName, 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=675,height=450,top=25,left=25')
	}	
		
function openPrayers() 
{
	strName = 'PrayerData';
	strLink = 'flash/prayerdata.xml';
	var strWindow = window.open(strLink, strName, 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=675,height=450,top=25,left=25')
}	

function checkSubscribeForm(form)
{
  
  if(!checkMail(form.txtEmailAddr.value))
  {
    form.txtEmailAddr.focus();
    form.txtEmailAddr.select();
    return false;
  }
  return true;
  
}  
 
function checkMail(emailaddr)
{
	
	var x = emailaddr;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) 
	{
	  return true;
	}
	else 
	{
	  alert('It appears you have given an incorrect email address:\n' + emailaddr);
	  return false;
	}
}
