/*----------------------------------------------------------------------------------------
|
|        Open Cases Script by Josh Miller
|        written for City of Elmira Website
|        @ http://www.cityofelmira.net
|
-------------------------------------------------------------------------------------------*/ 
<!-- Begin
casedate=new Array()
casenumb=new Array()
casetitl=new Array()
casetext=new Array()
casestat=new Array()
casefile=new Array()
x=0;Open=0;Closed=1;

casedate[x]=new Date("5/11/2006")
casenumb[x]= "04-12640"
casetitl[x]= "Wanted Sex Offender"
casetext[x]= "The Elmira Police Department Detective Bureau is asking the public's help in locating Ralph C. Stilson, a 46 year old level # 3 sex offender. Stilson's prior address was at 316 West Gray Street Apt # 7A Elmira, New York 14901. If you have any information regarding Stilson's whereabouts, please contact Sgt Bruce Hall at the Elmira Police Department Detective Bureau at 607-737-5617 or send an e-mail to bhall@cityofelmira.net. All calls will be kept confidental. "
casestat[x]= "Open"
casefile[x]= "<img src='../police/cases/stilson.jpg' border='1'>"
x++

casedate[x]=new Date("10/8/2004")
casenumb[x]= "04-10439"
casetitl[x]= "Attempted Robbery in Park"
casetext[x]= "Suspect rode up to elderly victim walking in Eldridge Park and demanded money and car keys. Suspect threatened the use of a gun, however, none was displayed. Suspect rode off towards skate park after a civilian came to victim's aid. Suspect is described as a teenaged black male wearing a white shirt, blue jeans and a white coat wrapped around waist. Last seen riding a bicycle towards the skate park in Eldridge Park. Anyone with information regarding this case is asked to call Inv. Wesley Dibble at 607-737-5616 or complete the form below. "
casestat[x]= "Open"
casefile[x]= ""//"<img src='../police/cases/.jpg border='1'>"
x++

casedate[x]=new Date("10/3/2004")
casenumb[x]= "04-10244"
casetitl[x]= "Robbery"
casetext[x]= "Suspect entered victim's apartment and robbed her of money after displaying a small, silver, revolver handgun. Suspect is described as a light skinned black male, 5'8\", 200 lbs, stocky build, thin moustache, with shoulder length dred locks. Suspect was wearing dark sunglasses, knit hat, and tan colored t-shirt. Suspect was last seen in the area of 152 W 5th St. Elmira. Anyone with information regarding this case is asked to call Inv. Wesley Dibble at 607-737-5616 or complete the form below."
casestat[x]= "Open"
casefile[x]= ""//"<img src='../police/cases/.jpg border='1'>"
x++

casedate[x]=new Date("4/11/2002")
casenumb[x]= "02-3322"
casetitl[x]= "Robbery at Sunoco on Walnut and Second Street"
casetext[x]= "On 4/11/02, at approximately 8:45am, an unknown white male entered John Cox Mobil at the corner of Walnut St. and W. 2nd St. White male was wearing a \"CarHart\" style coat with the hood over his head. White male was in his 20's in age and had a thick mustache. He had on green pants. White male displayed a handgun and demanded money. White male then left running west down W. Second St. and then south on Grove St. It is believed that this white male entered a residence in the area of Grove and W. First St. He has never been found. "
casestat[x]= "Open"
casefile[x]= ""//"<img src='../police/cases/.jpg border='1'>"
x++

casedate[x]=new Date("11/08/2003")
casenumb[x]= "03-10722"
casetitl[x]= "Robbery at Sunoco Station at Main and Second"
casetext[x]= " On 11/08/2003 at or about 5:20am, an unidentified white male with brown hair and medium build, in his mid thirties, wearing glasses entered the store. The male approached the clerk and appeared to want to purchase a candy bar. As the clerk attempted to make the sale, the male jumped over the counter, struck the clerk in the face knocking the clerk down, and began taking money from the register. The male then ran with the money in a westerly direction from the store to the area of 111 Columbia St. The male was wearing blue jeans and a red or burgundy jacket over a tan plaid shirt. The male was wearing glasses at the time and appeared to have a slight moustache. Anyone with information pertaining to this case is asked to Contact Sgt. Robert Smallcomb at (607) 737-5612 or fill out the form below."
casestat[x]= "Open"
casefile[x]= "<img src='../police/cases/03-10722a.jpg' border='1'>&nbsp;&nbsp;&nbsp;<img src='../police/cases/03-10722b.jpg' border='1'><br>Surveilance photos of the robbery."
x++

casedate[x]=new Date("10/27/04")
casenumb[x]= "04-11111"
casetitl[x]= "Armed Robbery"
casetext[x]= "On Tuesday, 10/26/04, at approximately 11:30pm, a woman walking on Grove St. near W. Water St. was jumped from behind by two unknown black males. The woman was beaten and her purse was stolen. A witness observed the two black males running across W. Water St. after the robbery. One was carrying a handgun. This same black male carrying the gun appeared to have some type of \"branding\" mark in the form of a design on his forearm. Neither black male has been identified at this time. Anyone with information pertaining to this case is asked to Contact Investigator Bill Wood at (607) 737-5618 or fill out the form below."
casestat[x]= "Open"
casefile[x]= ""//"<img src='../police/cases/.jpg border='1'>"
x++

casedate[x]=new Date("March 19, 2006")
casenumb[x]= "06-2473 "
casetitl[x]= "Fire Investigation"
casetext[x]= "A fire was reported at 362 W. Church St. on 3/19/2006 at about 11:50pm. Anyone with information pertaining to this case is asked to Contact Sgt. Bruce Hall at (607) 737-5617 or fill out the form below. "
casestat[x]= "Open"
casefile[x]= ""//"<img src='../police/cases/.jpg border='1'>"
x++


//**********************************************************************************************************************************



function startCases(){
	var url=document.location.toString();				//parse the url to determine the state requested
	urlLength=url.length;							
	y=url.lastIndexOf("html");				
	y=y+4;	
	var params=url.substring(y,urlLength);
	if( params==""){									//if no state, then display the next month of events
		printCaseList("Open")
	}
	else{
		state=params.substring(1,3);				
		if (state=="id"){								//if the state is id, then print the event with the id
			id=params.substring(4,params.length);
			printCase(id)
		}
		else if (state=="st"){							//if the state is preview, then preview the number of days requested
			printReleases(store, byTitle, flag)
		}
		else if (state=="ty"){							//if the state is preview, then preview the number of days requested
			printReleases(store, byType, flag)
		}
		else{
			printCaseList("Open")
		}
	}
}



function printCaseList(str){
	store=new Array(); counter=0;
	for (i=0; i<casedate.length; i++){
		if(casestat[i]==str){
			store[counter]=i
			counter++
		}
	}
	document.write("The following cases are considered open and under investigation by the Detective Bureau. If you have any information regarding these cases, please contact us by using the contact information included in each case.<br><br>")
	store.sort(sortByCaseNumber)
	document.write("<table width='95%' cellpadding='0' cellspacing='2' border='0'>")
	document.write("<tr><td colspan='3' bgcolor='#000000'><img src='../index/pics/dot.gif' height='2'></td></tr>")
	if (store.length==0){
		document.write("<tr><td>There are no open cases available at this time<td></tr>")
	}
	for (i=0; i<store.length; i++){
		document.write("<tr><td valign='top' class='smalltext'><a href='cases.html?id="+store[i]+"' class='release'>"+casetitl[store[i]]+"</a></td>")
		document.write("<td valign='top' width='80' class='smalltext'>"+casenumb[store[i]]+"</td>")
		document.write("</tr><tr><td colspan='3' bgcolor='#000000'><img src='../index/pics/dot.gif' height='1'></td></tr>")
	}
	document.write("</table>")
}

function printCase(id){
	document.write("<span class='subtitle'>"+casetitl[id]+"</span><br>")
	document.write("<span class='smalltext'>Case Number: "+casenumb[id]+"</span><br>")
	document.write("<span class='smalltext'>"+formatDate(casedate[id])+"</span><br>")
	if(casefile[id]!=""){
		document.write("<table border='0' cellpadding='1' cellspacing='0' width='424'><tr>");
		document.write("<tr><td align='center'>"+casefile[id]+"</td></tr></table>")
	}
	document.write("<br>"+casetext[id]+"</span><br><br><br>")
	document.write("<form name='cases' action='case_tip.asp' method='get' onsubmit=\"return validateCase(this)\">");
	document.write("<table border='0' cellpadding='1' cellspacing='0' width='424'><tr>");
	document.write("<tr><td valign='top' colspan='3' class='subtitle'>Submit Information about this Case<input type='hidden' value='Tip: Case Number "+casenumb[id]+"' name='subject'></td></tr>");
	document.write("<tr><td valign='middle' class='casesheader'>Your Name</td><td valign='top' colspan='2' class='smalltext'><input type='text' name='from' size='24' class='casesfields'>  optional</td></tr>");
	document.write("<tr><td valign='middle' class='casesheader'>Your Email Address</td><td valign='top' colspan='2' class='smalltext'><input type='text' name='replyto' size='24' class='casesfields'> optional</td></tr>");
	document.write("<tr><td valign='middle' class='casesheader'>Your Phone Number</td><td valign='top' colspan='2' class='smalltext'><input type='text' name='phone' size='24' class='casesfields'> optional</td></tr>");
	document.write("<tr><td valign='top' class='casesheader'>Information</td><td valign='top' colspan='2' class='smalltext'></td></tr>");
	document.write("<tr><td valign='top' colspan='3'><textarea name='info' cols='40' rows='4'></textarea></td></tr>");
	document.write("<tr><td valign='top' colspan='3' align='center'><input type='submit' name='Submit' value='Submit'></td></tr>");
	document.write("<tr><td valign='top'><img src='pics/dot.gif' width='140' height='1' border='0'></td><td valign='top' width='128'><img src='pics/dot.gif' width='128' height='1' border='0'></td><td valign='top'><img src='pics/dot.gif' width='80' height='1' border='0'></td></tr>");
	document.write("</table></form>");
	document.write("<span class='subtitle'>All Available Open Cases</span><br>")
	printCaseList("Open")
}

function validateCase(theForm){
	
	msg=theForm.info.value
	msg=msg.toLowerCase()
	flag1=msg.indexOf("caglar");
	flag2=msg.indexOf("singletary")
	if ((flag1>-1) || (flag2>-1)){
		alert("This action is not permitted due to continued abuse.  If you feel like you are being harrassed, go to the Police Department and file a police report.  This email is considered harrassment and will no longer be tolerated.  Continued abuse of this and any of the forms on the City of Elmira website is subject to criminal prosecution for harrassment.")
		return(false);
		window.close();
	}
	if(msg==""){
		alert("You must provide information to submit a tip.");
		return (false);
	}
	return true;
}


function sortByCaseNumber(A,B){
	//post:	returns 1 if A is bigger than B
	//		returns -1 if A is smaller than B
	//		returns 0 if A is the same as B
	a=casenumb[A]
	b=casenumb[B]
	a=a.toLowerCase();									//set a and b to lowercase for comparison
	b=b.toLowerCase();
	result=new Array()									//store the result of the letter by letter comparison
	for (i=0; i<a.length; i++){							//for each character in the string
		if(a.charCodeAt(i)>b.charCodeAt(i)){			//if the unicode value of a is greater than b
			result[i]=1									//then store 1 in the result array
		}	//end if								
		else if (a.charCodeAt(i)<b.charCodeAt(i)){		//if the unicode value of a is less than b
			result[i]=-1								//then store -1 in the result array
		}	//end else if
		else if (a.charCodeAt(i)==b.charCodeAt(i)){		//if the unicode value of a is the same as b
			result[i]=0									//then store 0 in the result array
		}	//end else if
	}//end for loop
	g=0													//set g to 0 for a counter variable
	flag=0												//set the flag to 0 - assume they are the same word until proven otherwise
	while (flag==0 && g<result.length-1){				//while the flag proves they are still the same, and the result array has values
		test=result[g]									//assign test the value to be tested from the result array
		if(test==-1){									//if the result array is storing -1 then		
			flag=1										//change the flag
			Result=-1									//and store -1 to return to the function
		}	//end if				
		else if (test==1){								//if the result array is storing +1 then
			flag=1										//change the flag
			Result=1									//and store 1 to return to the function
		}	//end if else
		else if (test==0){								//if the result array is storing 0
			flag=0										//do not change the flag- the words may still be the same- check the rest of the result array
		}	//end if else								
		g++
	}	//end while
	if(flag==0){															//if the flag is still 0, the words are similar or the same: eg: Josh and Joshua
		if (a.length-b.length < 0){											//if the length of b is longer, then 
			Result=-1														//store -1 to return to the function
		}	//end if
		else if (b.length-a.length < 0){									//if the length of a is longer
			Result=1														//store 1 to return to the function
		}	//end else if													
		else if (a.length-b.length == 0){									//if the lengths are the same, it is the same word: eg: Josh and Josh
			Result=0														//store 0 to return to the function
		}	//end else if
	}
	return Result;															//return the stored Result to the function
}


function formatDate(date){
	Day=date.getDate()
	Mont=date.getMonth()
	Year=date.getYear()
	return addZero((Mont+1))+"-"+addZero(Day)+"-"+Year
}

function addZero(x){
	if(x<10){return "0"+x}
	else{return x}
}//end addZero function



// End -->

