﻿<!--
// © 2005 City of Las Vegas | All Rights Reserved | Use only with permission //
// All Contents of this Website are the property of the City of Las Vegas //
// http://www.LasVegasNevada.gov //
// Miscellanous Scripts

//------------
// WINDOW OPENERS
//------------
function ContactWin(URL) { //v2.0
 this.open(URL,'','width=640,height=490,scrollbars=yes,resizable=no,left=75,top=75');
}

//------------
// SHOW HIDE LAYERS
//------------
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//------------
// DROP-DOWN JUMP MENU
//------------
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//------------
// CHANGE OBJECTS PROPERTIES
//------------
function ChangeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false){
      eval("obj."+theProp+"="+theValue);
      }
    else {
  eval("obj."+theProp+"='"+theValue+"'");
 }
  }
}
function Highlight(objName) {
 
 var default_color = '#293b65';
 var obj;
 var linkname;
 var i=0;
 
 for( i=1;i<=10;i++) {
  linkName = 'bldpermit' + i; 
  obj = MM_findObj(linkName);
  obj.style.color = default_color;
 }
 for( i=1;i<=10;i++) {
  linkName = 'buspermit' + i;
  obj = MM_findObj(linkName);
  obj.style.color = default_color;
 }
 for( i=1;i<=10;i++) {
  linkName = 'respermit' + i;
  obj = MM_findObj(linkName);
  obj.style.color = default_color;
 }
 obj = MM_findObj(objName);   
 obj.style.color = 'red';
 
}
//------------
// JUMP TO DATE
//------------
// Used for the "Find Meetings" page. When the user enters the page, the "Viewer" will automatically jump down to the section based upon date.
function JumpToDate(){
 var d = new Date()
 var url = '#' + d.getFullYear() + '-' + (d.getMonth() + 1); // month 0 [zero] is january
 //alert("this is where we're at: " + d.getFullYear() + "-" + (d.getMonth() + 1));
 window.location = url;
}

//------------
// FORM HANDLER PULL-DOWNS
//------------
function formHandler2(){
    var URL = document.form2.videos2.options[document.form2.videos2.selectedIndex].value;
    window.location.href = URL;
}
function formHandler3(){
    var URL = document.form3.videos3.options[document.form3.videos3.selectedIndex].value;
    window.location.href = URL;
}
function formHandlerSp(){
    var URL = document.spanishForm.spanish.options[document.spanishForm.spanish.selectedIndex].value;
    window.location.href = URL;
}

//------------
// FORM VALIDATION
//------------

// phone number - strip out delimiters and check for 10 digits
function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
   form1.Phone.focus();
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.\n";
    form1.Phone.focus();
    }
    if (!(stripped.length <= 10)) {
 error = "The phone number is not valid.\n";
 form1.Phone.focus();
    } 
return error;
}

// email
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
   form1.Email.focus();
}
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    form1.Email.focus();
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
    form1.Email.focus();
       }
    }
return error;    
}

// Corporation - For Corporate Challenge form
function checkCorp (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a Corporation.\n";
   form1.Corporation.focus();
} 
return error;
}

// Captain - For Corporate Challenge form
function checkCaptain (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a Captain.\n";
   form1.Captain.focus();
} 
return error;
}

// -->