var perload_img = new Array();
function formSubmit()
{ 
  var err = '';
  
  var mand = new Array('fname','lname','email','password','repassword','streetadd','city','zip','valided','email','email');
  
  for(var i=0; i<mand.length; i++)
  {
	  var val = document.getElementById(mand[i]).value;
	  if (val == '') {
		err += 'Fill in '+ mand[i] +' field \n';
	  }
  }
  if(err == ''){
	 if(document.getElementById('password').value != document.getElementById('repassword').value )
	  err +='Does Not Match Password';
  }
  
  if(err == ''){
	err = emailCheck('email');
	 if(err == true){ 
		 document.GCOrderForm.submit(); 
		 return true;
	 }
  }
  
  if(err != ''){
	  alert(err);
	  return false;
  }
 
}




function isEmptyValidation(id)
{

  var val = document.getElementById(id).value;
  if (val == '') {
     alert('This field is required !!!');
	 return false;
  }
  
}

function confirm_delete()
{
	var val;
	val = confirm("Do you want to delete?");
	return val;
}




function loadXMLDocCity(){

	xmlhttp= (window.XMLHttpRequest ? new XMLHttpRequest(): ((window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null) );
	xmlhttp.onreadystatechange = state_change
	xmlhttp.open("POST",'getCityState.php',true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send('state='+document.form1.state.value);
}


function emailCheck(id) { 
  var err = '';
  var emailStr = document.getElementById(id).value;
  var checkTLD=1;
  var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
  var emailPat=/^(.+)@(.+)$/;
  var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
  var validChars="\[^\\s" + specialChars + "\]";
  var quotedUser="(\"[^\"]*\")";
  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
  var atom=validChars + '+';
  var word="(" + atom + "|" + quotedUser + ")";
  var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
  var matchArray=emailStr.match(emailPat);

  if (matchArray==null) {
    err = "Email address seems incorrect (check @ and .'s)";
    return err;
  }
  var user=matchArray[1];
  var domain=matchArray[2];

  for (i=0; i<user.length; i++) {
    if (user.charCodeAt(i)>127) {
     err ="Ths username contains invalid characters.";
     return err;
    }
  }

  for (i=0; i<domain.length; i++) { 
   if (domain.charCodeAt(i)>127) {
     err ="Ths domain name contains invalid characters.";
     return err;
   }
  }


  if (user.match(userPat)==null) {
    err = "The username doesn't seem to be valid.";
    return err;
  }

  var IPArray=domain.match(ipDomainPat);
  if (IPArray!=null) {
   for (var i=1;i<=4;i++) {
      if (IPArray[i]>255) {
         err = "Destination IP address is invalid!";
         return err;
      }
   }
  return true;
  }

 
  var atomPat=new RegExp("^" + atom + "$");
  var domArr=domain.split(".");
  var len=domArr.length;
  for (i=0;i<len;i++) {
   if (domArr[i].search(atomPat)==-1) {
      err = "The domain name does not seem to be valid.";
      return err;
   }
  }

  if (checkTLD && domArr[domArr.length-1].length!=2 && 
   domArr[domArr.length-1].search(knownDomsPat)==-1) {
   err = "The address must end in a well-known domain or two letter " + "country." ;
   return err;
  }

  if (len<2) {
   err = "This address is missing a hostname!";
   return err;
  }

 return true;
}


function check_date(fld) {
	
  
    var mo, day, yr;
    var entry = fld.value;
    var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
    var reShort = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/;
    var valid = (reLong.test(entry)) || (reShort.test(entry));
    if (valid) {
        var delimChar = (entry.indexOf("/") != -1) ? "/" : "-";
        var delim1 = entry.indexOf(delimChar);
        var delim2 = entry.lastIndexOf(delimChar);
        mo = parseInt(entry.substring(0, delim1), 10);
        day = parseInt(entry.substring(delim1+1, delim2), 10);
        yr = parseInt(entry.substring(delim2+1), 10);
        // handle two-digit year
        if (yr < 100) {
            var today = new Date( );
			// get current century floor (e.g., 2000)
            var currCent = parseInt(today.getFullYear( ) / 100) * 100;
			// two digits up to this year + 15 expands to current century
            var threshold = (today.getFullYear( ) + 15) - currCent;
            if (yr > threshold) {
                yr += currCent - 100;
            } else {
                yr += currCent;
            }
        }
        var testDate = new Date(yr, mo-1, day); //alert();
        if (testDate.getDate( ) == day) { 
            if (testDate.getMonth( ) + 1 == mo) {
				var curDate;
                curDate = new Date();
				curDate.setDate(curDate.getDate( ) - 1);
				if(testDate < curDate){
				   alert("You cannot select previous date.");
				   return false;
				}
				if (testDate.getFullYear( ) == yr) {
                    // fill field with database-friendly format
                    fld.value = mo + "/" + day + "/" + yr;
                    return true;
                } else {
                    alert("Invalid year entry.");
                }
            } else {
                alert("Invalid month entry.");
            }
        } else {
            alert("Invalid date entry.") ;
        }
    } else {
        alert("Incorrect date format. Enter as mm/dd/yyyy.");
    }
    return err;
}


function chcek_float(e)
{
		
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
		if (e.keyCode < 46 || e.keyCode >57 ) 
		{ 
			e.returnValue = false;
		}
	}
	else
	{

		if ( e.which < 46 || e.which >57 ) 
		{
			if ( e.which != 8 ) e.preventDefault();
		}
	}

}


function chcek_numeric(e)
{
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
		if (e.keyCode < 47 || e.keyCode >57 ) 
		{ 
			e.returnValue = false;
		}
	}
	else
	{

		if ( e.which < 47 || e.which >57 ) 
		{
			if ( e.which != 8 ) e.preventDefault();
		}
	}

}

function freset()
{
   document.getElementById('femail').value = '';
   document.getElementById('fname').value = '';
   document.getElementById('nemail').value = '';
   document.getElementById('comm').value = '';

}

function sreset()
{
   document.getElementById('schedule_name').value = '';
   document.getElementById('schedule_email').value = '';
   document.getElementById('schedule_phone').value = '';
   document.getElementById('comments').value = '';

}

function display_image(large,dir)
{
	//alert(large+'--'+dir)
	document.getElementById('image').src = './properties_pic_large/'+dir+'/'+large; 
	document.getElementById('map').href = './properties_pic_large/'+dir+'/'+large; 
}




function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



 
 
 
 
 
 
 
 
 
 