

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 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
}

// -->
