// m2 07/25/08 /police/js/vehiclereport.js for 
//              /police/forms/inoperable.shtml

// adapts: Arthur Wang  06/04/11 /police/js/communications.js for /police/about/dispatcher/contact.shtml 

function validate(frm) {
var themessage = "You are required to complete the following fields: ";

if (frm.Number1.value=="") {
themessage = themessage + " - Number";
}
if (frm.Street1.value=="") {
themessage = themessage + " -  Street ";
}

if (frm.Zipcode1.value=="") {
themessage = themessage + " -  Zip Code ";
}

if (frm.VehicleType1.value=="") {
	 themessage = themessage + " - Vehicle Type ";
	}
	
if (frm.Color1.value=="") {
	 themessage = themessage + " - Vehicle Color ";
	}	
		
	
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
frm.submit();
}
else {
alert(themessage);
return false;
   }
}

//Character count for Message Field
function LimitThis() {
	var maxLength=1500;
	var myObject=event.srcElement;
	if (myObject.value.length==maxLength*1) return false;
}

function CountThis(visCnt) { 
	var myObject=event.srcElement;
	if (myObject.value.length>maxLength*1) myObject.value=myObject.value.substring(0,maxLength*1);
	if (visCnt) visCnt.innerText=maxLength-myObject.value.length;
	
}
  

// Hide and Show for additional div fields on /72hr.shtml
function changeDiv(the_div)
{
  var the_style = getStyleObject(the_div);
 // alert("the style is " + the_style);
  if (the_style != false)
  {
	if (the_style.display == 'none'){
	the_style.display = 'block';
	}else{
	the_style.display = 'none';
	}
  }
}

function getStyleObject(objectId) {
  if (document.getElementById && document.getElementById(objectId)) {
    return document.getElementById(objectId).style;
  } else if (document.all && document.all(objectId)) {
    return document.all(objectId).style;
  } else {
    return false;
  }
}

// Open text field for "Other" option on drop-down list
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function toggleField(field) {

var fld = field.name
var num = Right(fld, 1)
var other = document.getElementById('Other'+num);
(field.value == "Other") ? other.style.display = 'inline' : other.style.display = 'none';
} 


