var map = new String();
var dtext;
var arrMapMarkers = new Array();

   var blueMarker = new GIcon();
      blueMarker.image = "bluemarker.png";
      blueMarker.iconSize = new GSize(15, 12);
      blueMarker.iconAnchor = new GPoint(5, 1);
      blueMarker.infoWindowAnchor = new GPoint(1, 5);

    var redMarker =  new GIcon(blueMarker);
      redMarker.image = "redmarker.png";
    var greenMarker =  new GIcon(blueMarker);
      greenMarker.image = "greenmarker.png";
    var yellowMarker =  new GIcon(blueMarker);
      yellowMarker.image = "yellowmarker.png";
    var orangeMarker = new GIcon(blueMarker);
      orangeMarker.image = "orangemarker.png";

      var orangeMarkerf = new GIcon(blueMarker);
      	orangeMarkerf.image = "orangemarkerf.png";     	
    var blueMarkerf = new GIcon(blueMarker);
      	blueMarkerf.image = "bluemarkerf.png";      	
     var greenMarkerf = new GIcon(blueMarker);
      	greenMarkerf.image = "greenmarkerf.png";
     var redMarkerf = new GIcon(blueMarker);
      	redMarkerf.image = "redmarkerf.png";
     var yellowMarkerf = new GIcon(blueMarker);
      	yellowMarkerf.image = "yellowmarkerf.png";
      	
     
var help = ["<p>Five points for each of the following requirements imposed as an absolute condition of access to any of the information:</p><ul><li>Disclosure of requester's identity</li><li>Disclosure of requester's affiliation or employer</li><li>Disclosure of requester's purpose for requesting the information</li><li>Requirement to fill out a form disclosing any such information</li></ul><p>By law, these requirements may not be imposed as preconditions for access to any of the information requested in this audit.  Auditors were instructed by Californians Aware that normal human curiosity was not to be held against the department, and so when an information officer or employee asked about such particulars, the auditor was to determine if a refusal to supply them would disqualify him or her from receiving the requested information.</p>",
			"<p>The audit tested the ready availability of the statement of economic interest filed by the \"commander or senior officer\" at each sheriff's or police department office (CHP offices were not asked for this record). All sheriffs (as elected officials), many police chiefs and certain other ranking officers are required to file and update these statements, as are other local elected and appointed officials.</p><p> The statements alert the public to the official's major financial and property holdings so that conflicts of interests are deterred or at least readily detected. (See sample form at <a href='http://www.fppc.ca.gov/forms/Form700-04-05.pdf' target='_blank'>http://www.fppc.ca.gov/forms/Form700-04-05.pdf</a> as well as \"CHP officer scrutinized,\" Sacramento Bee, January 5, <a href='http://www.sacbee.com/111/story/103276.html' target='_blank'>http://www.sacbee.com/111/story/103276.html</a>)a. While city and county officials must file their Form 700s with the city or county clerk, this audit assumes that they would keep a copy on hand within the department.</p>",
			"<p>The audit tested the ready availability of information at sheriff's and police departments about certain crimes of high public interest within a two-week period from approximately 30 to 15 days before the auditor's visit. The crimes specified were burglary, armed robbery and sexual assault. Although these categories were not defined with precise Penal Code references (which ordinary citizens would not use in any event), almost no agencies treated the request as too vague to satisfy.</p> <p>Scoring: Aside from testing whether the request was honored at all, and how soon (two points deducted if the information took longer than three days to produce), the audit measured how much information was initially made available, without having to ask for further details. If an item of information pertinent to a reported crime was never presented despite being classified as disclosable under the California Public Records Act -- a description of \"property involved\" in a burglary, for example -- one point was deducted.</p><p> Accordingly, if the only crime information produced in response to a request was a minimal log or index listing only dates and types of crime, for example, this disclosure would not earn nearly as many points as one indicating, as the request specified, \"all details that the public has a right to see.\" </p><p>These are, in the words of Government Code Section 6254, subdivision (f), paragraph (2), \"the time, date, and location of occurrence, the time and date of the report, the name and age of the victim\" (other than certain sex or abuse crime victims), \"the factual circumstances surrounding the crime or incident, and a general description of any injuries, property, or weapons involved.\"</p>",
			"<p>The audit tested the ready availability of information at sheriff's and police departments about arrests made from November 1 to the December 4 audit day in connection with the reported crimes from early November (above).</p> <p>Scoring: Often there were few or no arrests, and here, as throughout the audit, if the response was that no such records exist, the auditor took the agency at its word and no points were deducted. But as with the crime information, if legally disclosable details were not presented in the first response, one</p> <p>point was deducted for each one missing. Those details, in the words of Government Code Section 6254, subdivision (f), paragraph (1), are:</p> <ul><li>the full name and occupation of every individual arrested by the agency</li><li> the individual's physical description including date of birth, color of eyes and hair, sex, height and weight</li><li> the time and date of arrest </li><li>the time and date of booking</li><li> the location of the arrest</li><li> the factual circumstances surrounding the arrest</li><li> the amount of bail set</li><li> the time and manner of release or the location where the individual is currently being held</li><li>all charges the individual is being held upon, including any outstanding warrants from other jurisdictions and parole or probation holds.</li></ul></p>",
			"<p>The audit tested the ready availability of periodic reports showing how much money a sheriff's or police department received as a byproduct of seizing cash and property in connection with drug law enforcement operations. The information is made public by Health and Safety Code Section 11495, subdivision (a), which states:</p><p>The funds received by the law enforcement agencies under Section 11489 shall be deposited into an account maintained by the Controller, county auditor, or city treasurer. These funds shall be distributed to the law enforcement agencies at their request. The Controller, auditor, or treasurer shall maintain a record of these disbursements which records shall be open to public inspection, subject to the privileges contained in Sections 1040, 1041, and 1042 of the Evidence Code.</p><p>Under Health and Safety Code Section 11489 a portion of any court-declared forfeited cash or property proceeds not reverting to the \"bona fide or innocent purchaser, conditional sales vendor, or mortgagee of the property\" goes to one or more local law enforcement agencies that participated in the seizure. And of this share, under Section 11489, 15 percent is to be set aside \"for the sole purpose of funding programs designed to combat drug abuse and divert gang activity, and shall wherever possible involve educators, parents, community-based organizations and local businesses, and uniformed law enforcement officers. Those programs that have been evaluated as successful shall be given priority.\"</p><p>As stated by former Attorney General Bill Lockyer,</p><p>The goal of asset forfeiture is to remove the profits from those who benefit from illegal drug trade. Illegal drug trafficking diverts money from lawful commerce to illegal activity. While drug seizures and arrests present a temporary setback for drug traffickers, asset forfeiture is effective in permanently taking away proceeds from these traffickers and diminishes their ability to continue the illegal enterprise. Asset forfeiture proceeds are used to fund education and drug abuse prevention programs. The law also permits law enforcement agencies to use the proceeds of forfeiture to purchase safe, more effective equipment that they otherwise could not afford. Thus, law enforcement is able to convert criminal profits into supplemental funding to inhibit the illegal drug trade.</p>",
			"<p>The audit tested the ready availability of information required to be reported to the Attorney General concerning the death of a person while in custody of a sheriff's or police department or a CHP station. Government Code Section 12525 states,</p><p><i>In any case in which a person dies while in the custody of any law enforcement agency . . . in this state, the law enforcement agency . . . shall report in writing to the Attorney General, within 10 days after the death, all facts in the possession of the law enforcement agency or agency in charge of the correctional facility concerning the death. These writings are public records within the meaning of subdivision (d) of Section 6252 of the California Public Records Act . . ., are open to public inspection pursuant to Sections 6253, 6256, 6257, and 6258. Nothing in this section shall permit the disclosure of confidential medical information that may have been submitted to the Attorney General's office in conjunction with the report . . .</i></p>",
			"<p>The audit tested the ready availability of information showing the base pay or pay range for each sworn officer rank in a sheriff's or police department or CHP office. Since no exemption from the California Public Records Act exists for such information, it is subject to disclosure.</p>",		
			"<p>The audit tested the ready availability of information showing the complete package of salary and benefits available to the department's commanding officer. The California Public Records Act states in Government Code Section 6254.8:</p><p><i>Every employment contract between a state or local agency and any public official or public employee is a public record which is not subject to the provisions of Sections 6254 and 6255.</i></p><p>As with general officer salary schedules, information on the top officer's compensation is of public interest if for no other reason than to evaluate how it compares with those in comparable positions elsewhere. Some responses argued that their commanding officer (a sheriff, for example) was strictly speaking not employed by contract, but others did not insist on this technicality and provided apparently full compensation details.</p>",
			"<p>The auditors asked for copies of these records to allow Californians Aware to study (and later report on) departments' and CHP offices' policies on what information will be made available to the news media, to the general public otherwise, or both. Also of interest to CalAware are the fees charged for copies of either miscellaneous records in general or the \"reports\" prepared for those involved in accidents or suffering loss as crime victims -- reports needed for submittal to insurance carriers. These fees will also be the subject of a future CalAware report.</p>"
];
function browserDiff(){

	if(document.getElementById && !document.all)
	{//firefox

		document.getElementById('mapinstwrap').style.width = 215 + 'px';
	//	document.getElementById('mapinst').style.height = 130 + 'px';
		document.getElementById('infoBox').style.marginTop = -13 + 'px';
		document.getElementById('infoBoxWrap').style.width = 290 + 'px';
		document.getElementById('listWrap').style.width = 320 + 'px';
	}
	else if(document.all)
	{//ie5.5+

		document.getElementById('mapinstwrap').style.width = 280 + 'px';
		document.getElementById('infoBoxWrap').style.width = 300 + 'px';
	}
	
	else if (window.opera)
	{//opera

	//	document.getElementById('mapinst').style.width = 600 + 'px';
	}
document.getElementById('mapinstwrap').innerHTML = showInst;
}

function loadPoint(tPoint){
	var pt = new GPoint(parseFloat(tPoint.longitude), parseFloat(tPoint.latitude));
	if(tPoint.mapgrade=="A"){
		if(tPoint.narrative)
			var tm = blueMarkerf;	
		else
			var tm = blueMarker;
	}
	else if(tPoint.mapgrade=="B"){
		if(tPoint.narrative)
			var tm = greenMarkerf;	
		else
			var tm = greenMarker;
	}
	else if(tPoint.mapgrade=="C"){
		if(tPoint.narrative)
			var tm = yellowMarkerf;	
		else
			var tm = yellowMarker;
	}
	else if(tPoint.mapgrade=="D"){
		if(tPoint.narrative)
			var tm = orangeMarkerf;	
		else
			var tm = orangeMarker;
	}
	else if(tPoint.mapgrade=="F"){
		if(tPoint.narrative)
			var tm = redMarkerf;	
		else
			var tm = redMarker;
	}
	var marker = new GMarker(pt, tm);
	
	marker.point = tPoint;
	
	
	var htext = '<strong>Agency: </strong>' + tPoint.name + "<br /><strong>Address: </strong>" + tPoint.address + ", " + tPoint.city +  "<br /><strong>Grade: </strong>"+tPoint.grade + " (" + tPoint.totalscore + "/100 points)"; 

	if(tPoint.narrative != null){
		htext+= '<p style=\'text-align:center;\'><a style=\'font-size:larger; font-weight:bold;\' href=\'#\' onclick=\'document.getElementById("listwrap").innerHTML =  "'+String(tPoint.narrative) + '"  ;\'>Read narrative</a></p>';
		}
	
	htext += "<br /> <strong>Penalties:</strong> <ul>"
	if(parseInt(tPoint.reqid) < 0)
		htext+= "<li><a href=\"#\" onclick=\"showHelp(0);\">Demanded identification:</a> " + tPoint.reqid; +'</li>';
	if(parseInt(tPoint.form700) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(1);\'>Form 700 disclosure:</a> ' + tPoint.form700 + '</li>';
	if(parseInt(tPoint.crimeinfo) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(2);\'>Crime info disclosure:</a> ' + tPoint.crimeinfo + '</li>';
	if(parseInt(tPoint.arrestinfo) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(3);\'>Arrest info disclosure:</a> ' + tPoint.arrestinfo + '</li>';
	if(parseInt(tPoint.asset) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(4);\'>Asset forfeiture records:</a> ' + tPoint.asset + '</li>';
	if(parseInt(tPoint.custodydeath) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(5);\'>Death in custody reports:</a> ' + tPoint.custodydeath + '</li>';
	if(parseInt(tPoint.salary) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(6);\'>Officer salary schedule:</a> ' + tPoint.salary + '</li>';		
	if(parseInt(tPoint.contract) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(7);\'>Commanding officer\'s contract:</a> ' + tPoint.contract + '</li>';		
	if(parseInt(tPoint.victimreport) < 0)
		htext+= '<li><a href=\'#\' onclick=\'showHelp(8);\'>Crime victim\'s report fee policy:</a> ' + tPoint.victimreport + '</li>';

	htext+='</ul>';
	htext +=  '<br /><strong>Auditor: </strong>'+marker.point.auditor + ' from ' + marker.point.newsorg;

	function gotoPoint(){
		marker.openInfoWindowHtml(htext);
		map.panTo(pt);

	}
	
	GEvent.addListener(marker, 'click', gotoPoint);	
	map.addOverlay(marker);	
	
}
/*
function changeBox(ttext){
		document.getElementById('mapinstwrap').innerHTML = ttext;	
		document.getElementById('listwrap').style.paddingTop = '5px';
		document.getElementById('listwrap').style.paddingBottom = '5px';
		document.getElementById('listwrap').style.width = '250px';
		document.getElementById('consoleBox').innerHTML = ttext;
}
*/


function hideInstructions(){
//document.getElementById('mapinst').style.visibility = "hidden";
document.getElementById('mapinstwrap').innerHTML = hideInst ;	
document.getElementById('mapinstwrap').style.paddingTop = '0px';
document.getElementById('mapinstwrap').style.paddingBottom= '0px';
document.getElementById('mapinstwrap').style.width = 'auto';

}
function showInstructions(){
//document.getElementById('mapinst').style.visibility = "hidden";
document.getElementById('mapinstwrap').innerHTML = showInst;	
document.getElementById('mapinstwrap').style.paddingTop = '5px';
document.getElementById('mapinstwrap').style.paddingBottom = '5px';
document.getElementById('mapinstwrap').style.width = '250px';
}

function showHelp(num){

	document.getElementById('listwrap').innerHTML = help[num];
	
}
function showNarrative(ttx){

	document.getElementById('listwrap').innerHTML = ttx;
	
}


var isMonthsShowing = true;
function hideShowMonths(){
	isMonthsShowing =!isMonthsShowing;
	if(isMonthsShowing){
		document.getElementById('consoleBox').style.visibility = "visible";
		document.getElementById('showMonths').style.visibility = "hidden";
	}
	else{
		document.getElementById('consoleBox').style.visibility = "hidden";	
		document.getElementById('showMonths').style.visibility = "visible";		
	}
}

var showInst = '<p> Click on the markers to see how well a department handled records requests. You can click and drag on the map to move it around and zoom using the navigation controls in the upper left-hand corner.<br /> 	<p>Markers with a black dot inside have narratives of the auditors\' experiences.</p> <p>A=<img src="bluemarker.png" /> B=<img src="greenmarker.png" /> C=<img src="yellowmarker.png" /> D=<img src="orangemarker.png" /> F=<img src="redmarker.png" /> <a href="javascript:hideInstructions()"><br />hide instructions</a></p>';
var hideInst = '<a href="#" onclick="showInstructions(); return false;">show instructions</a>';


function init(){

	
		if(GBrowserIsCompatible()){
			map = new GMap2(document.getElementById("map"));
			var loc = new GLatLng(38.5632, -121.4004);
			map.setCenter(loc, 8);
			map.addControl(new GLargeMapControl());		
	
			
			for(id in markers){
				loadPoint(markers[id]);
			
			}
			document.getElementById('mapinstwrap').innerHTML = showInst;
		}
				

		browserDiff();	
			
}

window.onload = init;
window.onunload = GUnload;
window.onresize =  browserDiff;