String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}


function make_login_url() {

    if (document.incident_login.incidentId.value.trim() == "") {
        alert("You must enter a report ID");
    }
    else {
        loc = document.incident_login.action;
        loc = loc + "/";
        loc = loc + document.incident_login.incidentId.value;
        document.location = loc;        
    }
}


function autosize(t) {
a = t.value.split('\n');
b=1;
for (x=0;x < a.length; x++) {
 if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
 }
b+= a.length;
 t.rows = b;
}

function addWho(divToShow, divToHide, removeDivToHide) 
{
  MM_changeProp(divToShow,'','height','auto','DIV');
  MM_changeProp(divToShow,'','visibility','visible','DIV');
  MM_changeProp(divToHide,'','visibility','hidden','DIV');
  
  if (removeDivToHide != null)
  	MM_changeProp(removeDivToHide,'','visibility','hidden','DIV');
}

function removeWho(divToHide, divToShow, removeDivToShow) 
{
  MM_setTextOfTextfield('first_name_' + divToHide,'','');
  MM_setTextOfTextfield('last_name_' + divToHide,'','');
  MM_setTextOfTextfield('title_' + divToHide,'','');
  MM_setTextOfTextfield('desc_' + divToHide,'','');
  MM_changeProp(divToHide,'','height','0px','DIV');
  MM_changeProp(divToHide,'','visibility','hidden','DIV');
  MM_changeProp(divToShow,'','visibility','visible','DIV');
  
  if (removeDivToShow != null)
  	MM_changeProp(removeDivToShow,'','visibility','visible','DIV');
}


function other_assoc(t) {
  if(t.selectedIndex == 8){
    MM_changeProp('other_assoc','','visibility','visible','DIV');
  } else {
    MM_changeProp('other_assoc','','visibility','hidden','DIV');
	  
  }
}

function show_where(show){
    if (hide_where_on_campus) {
       MM_changeProp('whereTextArea', '', 'visibility', 'hidden', 'DIV');
       MM_changeProp('whereTextArea', '', 'height', '0px', 'DIV');
    }
    else 
    {
        MM_changeProp('whereTextArea', '', 'visibility', 'visible', 'DIV');
        MM_changeProp('whereTextArea', '', 'height', 'auto', 'DIV');
    }

  if(show == true)
  { 
    MM_changeProp('where_campus','','visibility','visible','DIV');
    MM_changeProp('where_campus','','height','auto','DIV');
    MM_changeProp('where_off_campus','','visibility','hidden','DIV');
    MM_changeProp('where_off_campus','','height','0','DIV');
    MM_changeProp('where_expanded_campus_div','','visibility','visible','DIV');
    MM_changeProp('where_expanded_campus_div','','height','auto','DIV');

  } 
  else 
  {
    MM_changeProp('where_off_campus','','visibility','visible','DIV');	  
    MM_changeProp('where_off_campus','','height','auto','DIV');
    MM_changeProp('where_campus','','visibility','hidden','DIV');
    MM_changeProp('where_campus','','height','0','DIV');
    MM_changeProp('where_expanded_campus_div','','visibility','hidden','DIV');
    MM_changeProp('where_expanded_campus_div','','height','0','DIV');
    MM_changeProp('whereTextArea', '', 'visibility', 'visible', 'DIV');
    MM_changeProp('whereTextArea', '', 'height', 'auto', 'DIV');
    MM_changeProp('campus_other', '', 'visibility', 'hidden', 'DIV');
  }

}

function check_campus_other(t){
    if (t.options[t.selectedIndex].text == "Other") {
        MM_changeProp('campus_other', '', 'visibility', 'visible', 'DIV');
        MM_changeProp('campus_other', '', 'height', 'auto', 'DIV');
    }
    else {
        MM_changeProp('campus_other', '', 'visibility', 'hidden', 'DIV');
        MM_changeProp('campus_other', '', 'height', '0px', 'DIV');
    }
}  

function previous_submit(show) 
{
  if(show == true)
  { 
    MM_changeProp('previously_submitted_reason','','visibility','visible','DIV');
    MM_changeProp('previously_submitted_reason','','height','auto','DIV');
  } 
  else 
  {
    MM_changeProp('previously_submitted_reason','','visibility','hidden','DIV');	  
    MM_changeProp('previously_submitted_reason','','height','0px','DIV');
  }
}

function other_howoften(t) {
  if(t.selectedIndex == 7){
    MM_changeProp('other_howoften','','visibility','visible','DIV');
  } else {
    MM_changeProp('other_howoften','','visibility','hidden','DIV');
	  
  }
}

function check_urgency(t) 
{
  if(t.selectedIndex == 4)
  {
    alert("If this is a true emergency, dial 911 for immediate assistance.");
  }
}

function other_authority(t) {
  if(t.selectedIndex == 4){
    MM_changeProp('other_authority','','visibility','visible','DIV');
  } else {
    MM_changeProp('other_authority','','visibility','hidden','DIV');
	  
  }
  
  if(t.selectedIndex == 1){
    MM_changeProp('authority_who','','visibility','visible','DIV');
    MM_changeProp('authority_who','','height','auto','DIV');
  } else {
    MM_changeProp('authority_who','','visibility','hidden','DIV');
    MM_changeProp('authority_who','','height','0','DIV');
  }
}

function other_coverup(t) {
  if(t.selectedIndex == 4){
    MM_changeProp('other_coverup','','visibility','visible','DIV');
  } else {
    MM_changeProp('other_coverup','','visibility','hidden','DIV');
	  
  }
}




function addWebLink(divToShow, divToHide, removeDivToHide) 
{
  MM_changeProp(divToShow,'','height','auto','DIV');
  MM_changeProp(divToShow,'','visibility','visible','DIV');
  MM_changeProp(divToHide,'','visibility','hidden','DIV');
  
  if (removeDivToHide != null)
  	MM_changeProp(removeDivToHide,'','visibility','hidden','DIV');
}

function removeWebLink(divToHide, divToShow, removeDivToShow) 
{
  MM_setTextOfTextfield('url_' + divToHide,'','');
  MM_changeProp(divToHide,'','height','0px','DIV');
  MM_changeProp(divToHide,'','visibility','hidden','DIV');
  MM_changeProp(divToShow,'','visibility','visible','DIV');
  
  if (removeDivToShow != null)
  	MM_changeProp(removeDivToShow,'','visibility','visible','DIV');
}

function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}
function MM_setTextOfTextfield(objId,x,newText) { //v9.0
  with (document){ if (getElementById){
    var obj = getElementById(objId);} if (obj) obj.value = newText;
  }
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}


