

<!--
// browser test:
agent = navigator.userAgent
browserVer = 2
if (agent.indexOf("a/3",6) == -1) {browserVer = 2}
else {browserVer = 1}
if (navigator.appVersion.charAt(0)>=3) {browserVer = 1}

// preload universal images:
if (browserVer == 1) {
nav1 = new Image(120,21);
nav1.src = "/images/nav/nav1_on.gif";
nav1off = new Image(120,21);
nav1off.src = "/images/nav/nav1_off.gif";
nav2 = new Image(120,21);
nav2.src = "/images/nav/nav2_on.gif";
nav2off = new Image(120,21);
nav2off.src = "/images/nav/nav2_off.gif";
nav3 = new Image(120,21);
nav3.src = "/images/nav/nav3_on.gif";
nav3off = new Image(120,21);
nav3off.src = "/images/nav/nav3_off.gif";
nav4 = new Image(120,21);
nav4.src = "/images/nav/nav4_on.gif";
nav4off = new Image(120,21);
nav4off.src = "/images/nav/nav4_off.gif";
nav5 = new Image(120,21);
nav5.src = "/images/nav/nav5_on.gif";
nav5off = new Image(120,21);
nav5off.src = "/images/nav/nav5_off.gif";
nav6 = new Image(120,21);
nav6.src = "/images/nav/nav6_on.gif";
nav6off = new Image(120,21);
nav6off.src = "/images/nav/nav6_off.gif";
nav7 = new Image(120,21);
nav7.src = "/images/nav/nav7_on.gif";
nav7off = new Image(120,21);
nav7off.src = "/images/nav/nav7_off.gif";
}
function hiLite(imgDocID,imgObjName) {
// manages mouseOver animations
//   imgDocID - the name or number of the document image to be replaced
//   imgObjName - the name of the image object to be swapped in

if (browserVer == 1) {
document.images[imgDocID].src = eval(imgObjName + ".src")
}}


function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}


function submitForm(){

    var errMessage = '';

// required field:

      if (isBlank(document.MyContact.RequestorName.value)){
        errMessage = errMessage + 'First Name is required\n';
    }
    

      if (isBlank(document.MyContact.Email.value)){
        errMessage = errMessage + 'Email is required\n';
    }


    
  	if (!isEmail(document.MyContact.Email.value)){
		errMessage = errMessage + 'Email Address is not valid.\n';
	}  
    

    //print out errors or submit        
    if (errMessage!=""){
        alert(errMessage);
    }
    else {
    	document.MyContact.submit();
    }
       
       
       
             
}



function isEmail(strEmail)
{


 if(strEmail.length > 4)
 {
 strEmail = strEmail.toLowerCase();
 
  var at = strEmail.indexOf("@"); 
  if((at > 1) && (at==strEmail.lastIndexOf("@")))
     {
     if ((strEmail.indexOf("@") > 1))
	  {
	   var dot = strEmail.lastIndexOf(".");
	   if ((dot>4) && ((dot-at)>2) && ((strEmail.length-dot)>2))
		   {
		    return true; // valid!
		   }
	  }  
    }
 }
 return false;
}

function showHide(div){
    //document.all[div].style     
    obj = document.getElementById(div).style   
    // If Style.Display is Block (Visible) then set it to None (Not-Visible) 
	if(obj.display=='block'){
        obj.display='none';
    }
   // Else set Style.Display to Block (Visible) 
	else {
        obj.display='block';
    }
}

function DoShow(div){
    obj = document.getElementById(div).style;
    obj.display='block';
}


function DoHide(div){
    obj = document.getElementById(div).style;
    obj.display='none';
}

function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('MainImage').src = whichpic.href;
  document.location.href = "#top"
  return false;
 } else {
  return true;
 }
}

function ImageCloseup(ThisImageID){
	var ThisImgSRC = document.images[ThisImageID].src
	
	var newURL = '/image.asp?FileName=' + ThisImgSRC
	newWindow=window.open(newURL, "ImageWindow", "toolbar=no,status=no,location=no,menubar=no,left=10,top=10,width=820,height=560,scrollbars=yes,resizable=yes");
	newWindow.focus();
}



function submitResForm(){

    var errMessage = '';

// required field:

      if (isBlank(document.AddEdit.RequestorName.value)){
        errMessage = errMessage + 'Name is required.\n';
    }
       if (isBlank(document.AddEdit.Email.value)&&isBlank(document.AddEdit.Phone.value)){
        errMessage = errMessage + 'Please provide a phone number, an email address or both.\n';
    }   
  	if (!isBlank(document.AddEdit.Email.value)){
  		if (!isEmail(document.AddEdit.Email.value)){
			errMessage = errMessage + 'Email Address is not valid.\n';
		}  
	}
	
	if ((document.AddEdit.RequestType.value=="R")){

	       if (isBlank(document.AddEdit.RentalStartDate.value)){
	        errMessage = errMessage + 'Rental Start Date is required for Rental Requests.\n';
	    	  }   


	   	  if (!isBlank(document.AddEdit.RentalStartDate.value)){
		    	if (!isDate(document.AddEdit.RentalStartDate.value)){
				errMessage = errMessage + 'Rental Start Date must be in MM/DD/YYYY format!.\n';
			}
		}	
	      
	       if (isBlank(document.AddEdit.RentalEndDate.value)){
	        errMessage = errMessage + 'Rental End Date is required for Rental Inquiries or Hold Requests.\n';
	    	  }   
	    	  
	    	  if (!isBlank(document.AddEdit.RentalEndDate.value)){
		    	if (!isDate(document.AddEdit.RentalEndDate.value)){
				errMessage = errMessage + 'Rental End Date must be in MM/DD/YYYY format!.\n';
			}
		}

    	  }   
	
  	if (!isBlank(document.AddEdit.RentalStartDate.value)&&!isBlank(document.AddEdit.RentalEndDate.value)){
			if (isDate(document.AddEdit.RentalStartDate.value)&&isDate(document.AddEdit.RentalEndDate.value)){

				dt1=getDateObject(document.AddEdit.RentalStartDate.value,"/");
				dt2=getDateObject(document.AddEdit.RentalEndDate.value,"/");
					if(dt1>=dt2){
						errMessage = errMessage + 'Rental End Date must be AFTER the Rental Start Date.\n';
					}
			}
			else
			{
				if (!isDate(document.AddEdit.RentalStartDate.value)){
					errMessage = errMessage + 'Rental Start Date must be in MM/DD/YYYY format!.\n';
				}
				
				if (!isDate(document.AddEdit.RentalEndDate.value)){
					errMessage = errMessage + 'Rental End Date must be in MM/DD/YYYY format!.\n';
				}
				
			}
	}
	
    //print out errors or submit        
    if (errMessage!=""){
        alert(errMessage);
    }
    else {
    	document.AddEdit.submit();
    }
 }     



function getDateObject(dateString,dateSeperator)
{
	//This function return a date object after accepting 
	//a date string ans dateseparator as arguments
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;

	//extract day portion
	curPos=dateString.indexOf(sepChar);
	//cDate=dateString.substring(0,curPos);
	cMonth=dateString.substring(0,curPos);
	
	if (cMonth > 0){
		cMonth = (cMonth - 1);
	}
	
	//extract month portion				
	endPos=dateString.indexOf(sepChar,curPos+1);			
	
	//cMonth=dateString.substring(curPos+1,endPos);
	cDate=dateString.substring(curPos+1,endPos);

	//extract year portion				
	curPos=endPos;
	endPos=curPos+5;			
	cYear=curValue.substring(curPos+1,endPos);
	
	//Create Date Object
	dtObject=new Date(cYear,cMonth,cDate);	
	return dtObject;
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
	//		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
	//	alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
	//	alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
	//	alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
	//	alert("Please enter a valid date")
		return false
	}
return true
}

// -->
