// JScript File
 
 //getMap.aspx.cs
  var flag = false;
 
  function getDrivingDirection(strlat, strlng, strprId)
  {
    getmap(strlat,strlng, strprId);
    setTimeout('MatchDivSize()',7000);
  } 

  //<![CDATA[
 function getmap(strlat, strlng, strprId)
 {
    if (GBrowserIsCompatible()) {
        var divdirectionfrm = document.getElementById('divdirectionfrm');
        var map = new GMap2(document.getElementById("divprmap"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        map.addControl(new GSmallMapControl);
        map.addControl(new GMapTypeControl);
        var zipcode = document.getElementById('zipcode');
        var fromAddress = "";
        if (zipcode.value.lenght == 0)
        {
            alert("You did not enter zipcode. Please enter the required information");
            zipcode.focus();
        }
        else
            fromAddress = zipcode.value;
     
        var toAddress = strlat + ", " + strlng;
     
        var directionPanel = document.getElementById('divdrivingdirections');
            directionPanel.innerHTML= "";
        var directions = new GDirections(map,directionPanel);    
        var query = "from: " + toAddress  + " to: " + fromAddress;   
        GEvent.addListener(directions, "error", function(x) {
            alert('You did not enter zipcode or the wrong zip is provided. Please enter the required information');
             window.location.href="http://elias.hlddev.com/getmap.aspx?id=" + strprId;
         });

        directions.load(query);
        document.forms[0].reset();
      }
      
      flag = true;
 }
   //]]> 
function ClearForm()
{
    document.forms[0].reset();
}
function contact(){
    	var name = document.getElementById('name');
	    var address = document.getElementById('address');     	   
	    var phone = document.getElementById('phone');
	    var emailadd = document.getElementById('ctl00_ContentPlaceHolder1_emailadd');
        var questions = document.getElementById('ctl00_ContentPlaceHolder1_questions');
	    var NameField = document.getElementById('spName');
	    var EmailField =document.getElementById('spEmail');
	    var CommentField=document.getElementById('spQuestions');
	    var phoneField = document.getElementById('spPhone');
        var ErrorMessage = document.getElementById('ErrorMessage');
	    
        var boolOnFlag=false;
        ErrorMessage.innerHTML= "";
        if(!name.value.length>0){
            NameField.style.color='#f7941d';
            //ErrorMessage.innerHTML +="*&nbsp;Please provide your Name.<br />";
            boolOnFlag = true;
        }
        else {
            //ErrorMessage.innerHTML="";
            NameField.style.color='#1B3765';
        }
        if(!phone.value.length>0) {
        phoneField.style.color='#f7941d';
        boolOnFlag = true;
        }
        else {
        phoneField.style.color ='#1B3765'; 
        }
        
        
        if(!emailadd.value.length>0){
            EmailField.style.color='#f7941d';
            //ErrorMessage.innerHTML +="*&nbsp;Please provide your Email Address.<br />";
            boolOnFlag = true;
        }
        else if(!emailadd.value.match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g )){
            EmailField.style.color='#f7941d';
            ErrorMessage.innerHTML +="Email Address provided is not in correct format.<br />";
            boolOnFlag = true;
        }
        else{
            ErrorMessage.innerHTML="";
            EmailField.style.color='#1B3765';

        }
        if(!questions.value.length>0){
            CommentField.style.color='#f7941d';
           // ErrorMessage.innerHTML+="*&nbsp;Give us your comment.<br />";
            boolOnFlag = true;
        }
        else {
            //ErrorMessage.innerHTML="";
            CommentField.style.color='#1B3765';
        }
        
        if(!boolOnFlag)
           loadXMLDocContact("/get.aspx?action=contact&name=" + name.value + '&address=' + address.value + '&phone=' + phone.value + '&emailadd=' + emailadd.value + '&questions=' + questions.value);
        else
        {
            ErrorMessage.innerHTML +="Fields with asterisk(*) are required.";
        }
        return false;  
}

    function loadXMLDocContact(url, postinfo)
    {
      xmlcontacthttp=null;
      if (window.XMLHttpRequest) xmlcontacthttp=new XMLHttpRequest();// code for Mozilla, etc.
      else if (window.ActiveXObject) xmlcontacthttp=new ActiveXObject("Microsoft.XMLHTTP");// code for IE
      if (xmlcontacthttp!=null) 
      {
        xmlcontacthttp.open("POST",url,true);
        xmlcontacthttp.onreadystatechange=update_state_Contact;
        xmlcontacthttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        xmlcontacthttp.send(url);
      } else {alert("Your browser does not support XMLHTTP.");}
   }

    function update_state_Contact() {
    if (xmlcontacthttp.readyState==4) { if (xmlcontacthttp.status==200) {
        document.getElementById('name').value="";
	    document.getElementById('address').value="";;     	   
	    document.getElementById('phone').value="";;
	    document.getElementById('ctl00_ContentPlaceHolder1_emailadd').value="";;
        document.getElementById('ctl00_ContentPlaceHolder1_questions').value="";;
	    document.getElementById('spName').value="";;
	    document.getElementById('spEmail').value="";;
	    var CommentField=document.getElementById('spQuestions').value="";;
    var lblContact=document.getElementById('ErrorMessage');    
    lblContact.innerHTML="Thank you for Inquiring. Your message has been send.";
  } else{alert("Problem retrieving XML data: " + xmlcontacthttp.responseText);} }
}




// get the subnav content 
function getdivContent(intID)
{
	var divBio = document.getElementById('ctl00_ContentPlaceHolderMainContent_divSubNavContent');
	divBio.innerHTML = "getting info...";
	loadXMLContent('/get.aspx?action=getdivContent&id=' + intID);
 }
 
function loadXMLContent(url) {
xmlupdatehttp=null;
if (window.XMLHttpRequest) xmlupdatehttp=new XMLHttpRequest();// code for Mozilla, etc.
else if (window.ActiveXObject) xmlupdatehttp=new ActiveXObject("Microsoft.XMLHTTP");// code for IE 5/6
if (xmlupdatehttp!=null) {
  xmlupdatehttp.onreadystatechange=updatedivContent_state_Change;
  xmlupdatehttp.open("GET",url,true);
  xmlupdatehttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlupdatehttp.send(null);
  } else {alert("Your browser does not support XMLHTTP.");}
}

function updatedivContent_state_Change() {
  if (xmlupdatehttp.readyState==4) { if (xmlupdatehttp.status==200) {
     document.getElementById('ctl00_ContentPlaceHolderMainContent_divSubNavContent').innerHTML=xmlupdatehttp.responseText;
    
  } else{alert("Problem retrieving XML data: " + xmlupdatehttp.responseText);} }
}
