<!-- Begin
/*----------------------------------------------------------------------------------------
|
|        Menu Script by Josh Miller
|        written for City of Elmira Website
|        @ http://www.cityofelmira.net
|
-------------------------------------------------------------------------------------------*/ 

//Get the title to determine what page the user is viewing
x=document.title;                                                       	//get the title and store as a string in x
x=x.toLowerCase();                                                        	//make the whole title lower case
y=x.lastIndexOf(' ');                                                		//find the last space in the title and store in y
y=y+1;                                                                      //add 1 to y to find the letter after the last space
z=x.length;                                                                 //get the length of the whole string and store in z
page=x.substring(y,z);                                                		//store in page the last word of the html page's title

function indexmainnav(){
	document.write("<img src='../index/pics/index_left_top.jpg'>");
	document.write("<table border='0' cellpadding='0' cellspacing='4' width='154'>														");
	document.write("<tr><td><img src='../index/pics/dot.gif' width='5' height='5' border='0'></td></tr>											");
    for (i=1; i<indextitle.length; i++){
		if(page==indexcheck[i]){
			document.write("<tr><td align='left'><span class='navhilite'>"+indextitle[i]+"</span></td></tr>								");
        }
        else{
			document.write("<tr><td align='left'><a href='"+indexlinks[i]+"' class='leftmenu' onmouseover=\"popUp('HM_Menu"+i+"',event)\" onmouseout=\"popDown('HM_Menu"+i+"')\">"+indextitle[i]+"</a></td></tr>");
		}  
	}
	if(page!=indexcheck[0]){
		document.write("<tr><td align='left'><br><a href='"+indexlinks[0]+"' class='leftmenu'>"+indextitle[0]+"</a></td></tr>						");
	}
	document.write("</table>");
}

function printPets(){
	feature=[Math.ceil(Math.random()*(pet.length-1))]
	document.write("	<table border='0' cellpadding='2' cellspacing='0' width='190'><tr>");
	document.write("	<tr><td align='center'><a href='../shelter/adoption.html?"+feature+"' border='0'><img src='../shelter/pets/"+pet[feature][pic]+".jpg' width='150' height='150' border='0' alt='Click here for information about adopting me.'><br>	");
	document.write("	<table border='0' cellpadding='0' cellspacing='0' width='150'><tr>	");
	if(pet[feature][name]!=""){
		document.write("	<td><span class='righttext'>Name:</span></td><td><span class='footer'>"+pet[feature][name]+"</span></td></tr><tr>	");
	}
	document.write("	<td><span class='righttext'>Case#:</span></td><td><span class='righttext'>"+pet[feature][Case]+"</span></td></tr><tr>	");
	document.write("	<td><span class='righttext'>Sex:</span></td><td><span class='righttext'>"+pet[feature][gender]+"</span></td></tr><tr>	");
	document.write("	<td><span class='righttext'>Born:</span></td><td><span class='righttext'>"+pet[feature][age]+"</span></td></tr><tr>	");
	document.write("	<td><img src='pics/dot.gif' width='5' height='5' border='0' alt=''></td></tr></table></table>");
}

function printParks(){
	fpark=[Math.round(Math.random()*(park.length-1))]
	fparkpic=[Math.ceil(Math.random()*(park[fpark][picts]))]
	document.write("        <table border='0' cellpadding='0' cellspacing='0' width='150'>        ");
    document.write("        <tr><td align='left'><a href='../dps/park_"+park[fpark][sname]+".html' border='0'><img src='../dps/parks/"+park[fpark][sname]+fparkpic+".jpg' width='150' height='113' border='0' alt='"+park[fpark][lname]+"'><br>        ");
    document.write("        <tr><td class='righttext'><b><a href='../dps/park_"+park[fpark][sname]+".html'>"+park[fpark][lname]+"</a></b></td></tr>        ");
    document.write("        <tr><td class='righttext'>"+park[fpark][descr]+"</td></tr>        ");
	document.write("		</table>");
}

function validateCalendarEvent(theForm){
	eventName=theForm.eventName.value;
	if (eventName == ""){
		alert("Your event must have a name to submit it to the Community Calendar.");
		theForm.eventName.focus();
		return (false);
	}
	eventDate=theForm.eventDate.value;
	if (eventDate == ""){
		alert("Your event must have a date to submit it to the Community Calendar.");
		theForm.eventDate.focus();
		return (false);
	}
	else{
		MonthFlag=0
		if	(eventDate.indexOf("January") 	>-1 ){MonthFlag++}
		if	(eventDate.indexOf("February") 	>-1 ){MonthFlag++}
		if	(eventDate.indexOf("March") 	>-1 ){MonthFlag++}
		if	(eventDate.indexOf("April") 	>-1 ){MonthFlag++}
		if	(eventDate.indexOf("May") 		>-1 ){MonthFlag++}
		if	(eventDate.indexOf("June") 		>-1 ){MonthFlag++}
		if	(eventDate.indexOf("July") 		>-1 ){MonthFlag++}
		if	(eventDate.indexOf("August") 	>-1 ){MonthFlag++}
		if	(eventDate.indexOf("September") >-1 ){MonthFlag++}
		if	(eventDate.indexOf("October") 	>-1 ){MonthFlag++}
		if	(eventDate.indexOf("November") 	>-1 ){MonthFlag++}
		if	(eventDate.indexOf("December") 	>-1 ){MonthFlag++}
		if  (MonthFlag==0){
			alert("The date of your event is in the wrong format- correct the format or click select to find the date.")		
			theForm.eventDate.focus();
			return (false);
		}
	}
	eventDesc=theForm.eventDesc.value;
	if (eventDesc == ""){
		alert("You must include a description to submit your event to the Community Calendar.");
		theForm.eventDesc.focus();
		return (false);
	}
	contactName=theForm.contactName.value;
	if (contactName == ""){
		alert("You must include the name of a contact to submit your event to the Community Calendar.");
		theForm.contactName.focus();
		return (false);
	}
	contactEmail=theForm.contactEmail.value;
	contactPhone=theForm.contactPhone.value;
	if ((contactEmail == "") && (contactPhone=="")){
		alert("You must include the contact's email address or phone number to submit your event to the Community Calendar.");
		theForm.contactEmail.focus();
		return (false);
	}
	if (contactPhone!=""){
		if(contactPhone.length!=10){
			alert("The phone number is incomplete or in the wrong format.  Please correct this to submit the form.  Use 10 digits with the Area Code.  Example: 6077345825 not (607) 734-5825.");
			theForm.contactPhone.focus();
			return (false);
		}
		else{
			a1=contactPhone.substring(0,3)
			a2=contactPhone.substring(3,6)
			a3=contactPhone.substring(6,10)
			phone= "(" +a1+ ") " +a2+ "-" + a3
			theForm.contactPhone.value=phone
		}
	}
	from=theForm.from.value;
	if (from == ""){
		alert("You must include your name to submit your event.  This information is not published on the website.");
		theForm.from.focus();
		return (false);
	}
	email=theForm.replyto.value;
	if (email == ""){
		alert("You must include your email address to submit your event.  This information is not published on the website.");
		theForm.replyto.focus();
		return (false);
	}
	temp=email.indexOf('@',0);
	if (temp<0){
		alert("There is a problem with your email address.  Please retype it.");
		theForm.replyto.focus();
		return (false);
	}
	agree=theForm.agree.value;
	if (agree == ""){
		alert("You must agree to the terms and conditions to submit your event.");
		theForm.agree.focus();
		return (false);
	}
	return (true);
}//end validate function


// Original JavaScript code by Duncan Crombie: dcrombie at chirp.com.au
// Please acknowledge use of this code by including this header.

var cook = document.cookie;

function getCookie(name){							 // use: getCookie("name");
	var index = cook.indexOf(name + "=");
    if (index == -1) return null;
    index = cook.indexOf("=", index) + 1;
    var endstr = cook.indexOf(";", index);
    if (endstr == -1) endstr = cook.length;
    return unescape(cook.substring(index, endstr));
}

var today = new Date();
var expiry = new Date(today.getTime() + 90 * 24 * 60 * 60 * 1000); // plus 28 days

function setCookie(name, value) { 					// use: setCookie("name", value);
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString()+"path=\"/\"";
    cook = document.cookie; // update cook
}

function displaySurvey(){
	if (!getCookie("survey6")){
		printSurvey();
	}
}

function printSurvey(){
/*	resolution=screen.width+" x "+screen.height+" x "+screen.colorDepth+" bit";
	browser=navigator.appName+" "+navigator.appVersion;
	document.write("<tr><td valign='top' align='left' colspan='3' class='rightbar'>Take the Mini Survey!</td></tr>");
	document.write("<tr><td width='2' valign='top' align='left'></td>");
	document.write("<td width='190' valign='top' align='center' class='righttext'>");
	document.write("<form action='../scripts/minisurvey.asp' name='minisurvey' onsubmit='surveydone()'>");
	document.write("	<input type='hidden' value='"+resolution+"' name='resolution'>        								");
	document.write("	<input type='hidden' value='"+browser+"' name='browser'>        									");
	document.write("<table border='0' cellpadding='0' cellspacing='0' width='185'>");
	document.write("<tr><td colspan='2'><b>Do you use the <a href='../index/calendar.html'>Community Calendar</a> to find out what's going on in Elmira?</b></td></tr>");
	document.write("<tr><td><input type='radio' value='Frequently' name='survey'></td><td>Frequently</td></tr>");
	document.write("<tr><td><input type='radio' value='Sometimes' name='survey'></td><td>Sometimes</td></tr>");
	document.write("<tr><td><input type='radio' value='Once or twice' name='survey'></td><td>Once or twice</td></tr>");
	document.write("<tr><td><input type='radio' value='Never' name='survey'></td><td>Never</td></tr>");
	document.write("<tr><td colspan='2' align='center'><input type='submit' name='submitButtonName' value='Vote'></td></tr></table></form>");
	document.write("</td>");
	document.write("<td width='2' valign='top' align='left'></td></tr>");
*/
}

function surveydone(){
	setCookie("survey6",1);
}

//-->
