// JAVASCRIPT

function checkthis()
	{
	var text = "";
	var temp = "";

	if(document.getElementById('textEmail').value=="")
		{
		alert('Please enter your email address');
		return false;
		}
	text = document.getElementById('textEmail').value;
	temp = text.search(/\@lbschools\.net/i);
		if(temp < 0)
		{
		alert("\n\nLBUSD email addresses only, please.");
		return false;
		}
	else
		{
		window.open("", "enotify", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,height=300,width=400");
	//	document.getElementById("textEmail").value="";
		return true;
		}
	}

function changeVisibility(obj)
	{
	temp = obj;
	if(document.getElementById(temp).style.visibility == "visible")
		{
		document.getElementById(temp).style.visibility = "hidden";
		}
		else
		{
		document.getElementById(temp).style.visibility = "visible";
		}
	}


// ==================================================================================================================================
// SWITCH VISIBLE DIVS
// ==================================================================================================================================

/*   SWITCHDIVS: Switches visible divs, and arrows if requested
     divs must be named "div1, div2, div3, etc."

     Parameters:
     wo = the number of the div to change
     hm = how many divs there are, total
*/

function switchDivs(wo,hm)
	{
	howmany=hm;
	whichone=wo;

	// reset all
	for(x=1;x<howmany+1;x++)
		{
		temp="div" + x;
		document.getElementById(temp).style.display="none";
		}

	// set specified div and arrow (if requested)
	temp="div" + whichone;
	document.getElementById(temp).style.display="block";
	}

// ==================================================================================================================================
// DOORHANGER COMPLAINT FORM --------------------------------------------------------------------------------------------------------
// ==================================================================================================================================

function checkForm(theForm)
	{

	var whereplaced = document.getElementById("radioWhereplaced").value;

	// WHERE WAS THE VEHICLE PARKED

	if(whereplaced == "vehicle")
		{
		temp=document.getElementById("_textareaWhereparked").value;
		temp=stripSpaces(temp);
		if(temp=="")
			{
			alert("Please enter the location where you were parked.\n\nFor example, a street address, intersection, or parking lot, etc.")
			document.getElementById("_textareaWhereparked").focus();
			return(false);
			}
		}

	// ADVERTISER NAME

	temp=document.getElementById("_textAdvertiser").value;
	temp=stripSpaces(temp);
	if(temp=="")
		{
		alert("Please enter the name of the advertiser.")
		document.getElementById("_textAdvertiser").focus();
		return(false);
		}

	// ADVERTISER CONTACT

	temp=document.getElementById("_textPhone").value + document.getElementById("_textEmail").value + document.getElementById("_textWebsite").value + document.getElementById("_textStreetaddress").value + document.getElementById("_textCity").value + document.getElementById("_textState").value + document.getElementById("_textZip").value;
	temp=stripSpaces(temp);
	if(temp=="")
		{
		alert("Please enter at least one way to contact the advertiser \n(phone, address, email or website).")
		document.getElementById("_textPhone").focus();
		return(false);
		}

	// FREQUENCY, HAD SIGN OUT, ETC.

	if(whereplaced == "home")
		{
		tempyes=document.getElementById("radioYes").checked;
		tempno=document.getElementById("radioNo").checked;
		temp=tempyes + tempno
		if(temp == 0)
			{
			document.getElementById("radioYes").focus();
			alert("Select:\n\n    YES if you had a \"No Advertising\" sign posted, or\n    NO if you did not.");
			return(false)
			}
		temp="";
	
		temp=document.getElementById("_checkDontKnow").checked;
		if(temp==true)
			{
			return(true);
			}
	
		temp=document.getElementById("_selectfrequency").value;
		if(temp=="select frequency")
			{
			alert("Please select from both \"How often\" drop-down lists, \nor check \"Don't know\".")
			document.getElementById("_selectfrequency").focus();
			return(false);
			}
		temp=document.getElementById("_selectperiod").value;
		if(temp=="select period")
			{
			alert("Please select from both \"How often\" drop-down lists, \nor check \"Don't know\".")
			document.getElementById("_selectperiod").focus();
			return(false);
			}
		}

	return(true);
	}

// ==================================================================================================================================
// CHECK SIGN REQUEST FORM ----------------------------------------------------------------------------------------------------------
// ==================================================================================================================================

function checkForm2(theForm)
	{
	doorcheck=document.getElementById("_checkDoorhanger").checked;
	fencecheck=document.getElementById("_checkFencesign").checked;
	if(doorcheck==false && fencecheck==false)
		{
		alert("Please select a door sign or a fence sign, or both.");
		document.getElementById("_checkDoorhanger").focus();
		return(false);
		}
	temp=document.getElementById("_textName").value;
	if(temp=="")
		{
		alert("Please enter your name.")
		document.getElementById("_textName").focus();
		return(false);
		}
	temp=document.getElementById("_textStreetaddress2").value;
	if(temp=="")
		{
		alert("Please enter your street address.")
		document.getElementById("_textStreetaddress2").focus();
		return(false);
		}

	temp=document.getElementById("_textCity2").value;
	if(temp=="")									// CHECK CITY EMPTY
		{
		alert("Please enter your city.")
		document.getElementById("_textCity2").focus();
		return(false);
		}
	// city NOT empty; check long beach or seal beach
	temp2=temp;
	temp=stripSpaces(temp);
	temp=temp.toLowerCase();
	if(temp != "longbeach" && temp != "sealbeach")				//QUALIFYING CITY, PROCEED
		{
		alert("Sorry.\n\nThe City of Long Beach does not provide\nthis service in " + temp2 + ".");
		document.getElementById("_textCity2").value="";
		document.getElementById("_textCity2").focus();
		return(false);
		}

	temp=document.getElementById("_textZipcode").value;
	if(temp=="")
		{
		alert("Please enter your zip code.")
		document.getElementById("_textZipcode").focus();
		return(false);
		}

	return(true);
	}

// ==================================================================================================================================
// HELPERS --------------------------------------------------------------------------------------------------------------------------
// ==================================================================================================================================

	function stripSpaces (InString) 
		{
		OutString="";
		for (Count=0; Count < InString.length; Count++)
			{
			TempChar=InString.substring (Count, Count+1);
			if (TempChar!=" ")
				OutString=OutString+TempChar;
			}
		return (OutString);
		}

	function leftString (InString, num)
		{
		OutString=InString.substring (InString, num);
		return (OutString);
		}

	function rightString (InString, num)
		{
		OutString=InString.substring (InString.length-num, InString.length);
		return (OutString);
		}


