/*JUMP TO BOXES*/
//Various
function jumpMenu(){
location=document.jumpto.menu.options[document.jumpto.menu.selectedIndex].value;
}
function jumpMenu2(){
location=document.jumpto2.menu2.options[document.jumpto2.menu2.selectedIndex].value;
}

//Jump to Page
function launch(form) {
 i=form.archive.selectedIndex
 if (i != 0) {
  location.href=form.archive.options[form.archive.selectedIndex].value;
 }
 return false;
}

/*POP UP WINDOWS*/
//Function to show popup alert message
//Various
function showalert(message) {
	alert(message);
}

//Check Radio Buttons
function CheckRadio(field,count)
{	
	if(count == 1)
	{
		if(field.checked == true)
          {
              	return false;
          }	
	}
	else
	{
		for(var i=0; i<count; i++)
     	{	
			if(field[i].checked == true)
          	{
               	return false;
          	}
     	}
	}
     return true;
}

//Function to create waterhouse popup window
//http://www.bouldercolorado.gov/index.php?option=com_content&task=view&id=2759&Itemid=2039
function CreateWaterHouseWindow()
{
     newWindow=window.open("www/publicworks/utilities/waterwatch/houseview.html","newpage", "toolbar=no,width=1000,height=750,status=yes,scrollbars=yes,resize=yes,menubar=yes");
}

//Function to create water calculator popup window
//http://www.bouldercolorado.gov/index.php?option=com_content&task=view&id=2759&Itemid=2039
function CreateWaterCalculatorWindow()
{
     newWindow=window.open("www/publicworks/utilities/waterwatch/calculator.html","newpage", "toolbar=no,width=650,height=750,status=no,scrollbars=yes,resize=yes,menubar=yes");
}

//Function to create softball message popup
//http://www.bouldercolorado.gov/index.php?option=com_content&task=view&id=1467&Itemid=972
function CreateSoftballWindow()
{
     newWindow=window.open("www/parksrecreation/softball_message.htm","newfile","toolbar=no,width=350,height=350,status=no,scrollbars=yes,resize=yes,menubar=no");
}


//Function used to trim text
function TextCounter(field,number)
{
	//if too long...trim it!
	if (field.value.length > number)
	{
		field.value = field.value.substring(0, number);
			
	}
}	

//Function to remove commas
function removecommas(fieldname) {
fieldname.value=fieldname.value.replace(/,/g,"");
fieldname.value=fieldname.value.replace(/"/g,"");
}

/*PAGE SPECIFIC SCRIPTS*/
//Image Swap Array
var maps=new Array();
      //http://www.bouldercolorado.gov/index.php?option=com_content&task=view&id=486&Itemid=1661
	  maps[0]='images/departments/Transportation_Master_Plan/org_chart/council_over.gif';
      maps[1]='images/departments/Transportation_Master_Plan/org_chart/tab_over.gif';
      maps[2]='images/departments/Transportation_Master_Plan/org_chart/oversight_over.gif';
      maps[3]='images/departments/Transportation_Master_Plan/org_chart/public_over.gif';
      maps[4]='images/departments/Transportation_Master_Plan/org_chart/staff_over.gif';
      maps[5]='images/departments/Transportation_Master_Plan/org_chart/tmp_over.gif';
	  maps[6]='images/departments/Transportation_Master_Plan/Invest_chart/current-over.gif';
      maps[7]='images/departments/Transportation_Master_Plan/Invest_chart/TMP_Investment_Packages.gif';
      maps[8]='images/departments/Transportation_Master_Plan/Invest_chart/TMP_Investment_Packages.gif';
      maps[9]='images/departments/Transportation_Master_Plan/Invest_chart/action-over.gif';
      maps[10]='images/departments/Transportation_Master_Plan/Invest_chart/vision-over.gif';
      maps[11]='images/departments/Transportation_Master_Plan/Invest_chart/this_year-over.gif';
	  //http://www.bouldercolorado.gov/index.php?option=com_content&task=view&id=4967&Itemid=2081
	  maps[13]='images/departments/Utilities/Boulder_Natural_Hazards/hazards.gif';
      maps[14]='images/departments/Utilities/Boulder_Natural_Hazards/lightning.gif';
      maps[15]='images/departments/Utilities/Boulder_Natural_Hazards/wildfire.gif';
      maps[16]='images/departments/Utilities/Boulder_Natural_Hazards/drought.gif';
      maps[17]='images/departments/Utilities/Boulder_Natural_Hazards/wind.gif';
      maps[18]='images/departments/Utilities/Boulder_Natural_Hazards/geohazards.gif';
	  maps[19]='images/departments/Utilities/Boulder_Natural_Hazards/blizzard.gif';
	  maps[20]='images/departments/Utilities/Boulder_Natural_Hazards/flood.gif';
	  maps[21]='images/departments/Utilities/Boulder_Natural_Hazards/hail.gif';


onload=function() {
  var elem=document.getElementsByTagName('area');
	for(h=0;h<elem.length;h++) {
   elem[h].onmouseover=function() { 
	document.getElementById('imagepic').src=maps[this.id.split('-')[1]];
	}
  }	
}


//Function to change images on the TMP
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		brd2_org_chart_01_brd2_org_chart_07_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_01-brd2_org_.gif");
		brd2_org_chart_05_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_05-over.gif");
		brd2_org_chart_06_brd2_org_chart_07_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_06-brd2_org_.gif");
		brd2_org_chart_06_brd2_org_chart_05_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_06-brd2_o-11.gif");
		brd2_org_chart_06_brd2_org_chart_09_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_06-brd2_o-12.gif");
		brd2_org_chart_06_brd2_org_chart_14_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_06-brd2_o-13.gif");
		brd2_org_chart_06_brd2_org_chart_12_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_06-brd2_o-14.gif");
		brd2_org_chart_06_brd2_org_chart_18_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_06-brd2_o-15.gif");
		brd2_org_chart_07_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_07-over.gif");
		brd2_org_chart_09_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_09-over.gif");
		brd2_org_chart_12_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_12-over.gif");
		brd2_org_chart_14_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_14-over.gif");
		brd2_org_chart_18_over = newImage("images/departments/Transporation_Master_Plan/org_chart/brd2_org_chart_18-over.gif");
		preloadFlag = true;
	}
}

//Functions for Case Status
//http://www.bouldercolorado.gov/index.php?option=com_content&task=view&id=5211&Itemid=2180
function checkEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
formCheck()  //submit the form
return false 
}
else{
return true 
}

}

function formCheck() 
{
   if(document.form1.CaseNumber.value != "")
   		{
      document.form2.CaseNumber.value = document.form1.CaseNumber.value;
	  document.form2.submit();
		}
	  else
	  	{
	  alert("You must include a case number");
   		}

}