

function formSubmit()
{
document.form1.submit();
}


function isEmptyValidation(id)
{

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



function emailCheck(id) {
  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) {
    alert("Email address seems incorrect (check @ and .'s)");
    return false;
  }
  var user=matchArray[1];
  var domain=matchArray[2];

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

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


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

  var IPArray=domain.match(ipDomainPat);
  if (IPArray!=null) {
   for (var i=1;i<=4;i++) {
      if (IPArray[i]>255) {
         alert("Destination IP address is invalid!");
         return false;
      }
   }
  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) {
      alert("The domain name does not seem to be valid.");
      return false;
   }
  }

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

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

 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.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 false;
}


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 img_ref(st)
{
	var browserName=navigator.appName; 
	var ob = document.getElementById(st);
	var rd = document.getElementById('redraw');
	if (browserName != "Microsoft Internet Explorer")	{

		var val = document.getElementById('dum');
		val.value = parseInt(val.value) + 1;
		ob.innerHTML = '<img src="contact.ins/verify-img.php?' + val.value + '" alt="Please Wait..." />';
	}
	else {

		ob.innerHTML = '<img src="contact.ins/verify-img.php" alt="Please Wait..." />';
	}
}

function submit_request() { 

 var from_name = document.getElementById('from_name').value;
 var subject = document.getElementById('subject').value;
 var from_email = document.getElementById('from_email').value;
 var f_body = document.getElementById('f_body').value;
 var img_text = document.getElementById('img_text').value;
 
 if ( (from_name == '') || (subject == '') || (from_email == '') || (f_body == '')|| (img_text == '') ) { 
   alert('Required Value Missing. Fill up All the field and try again.');
   return;
 }
 
 var stremail = from_email;
 var emailchar = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
 if (!(emailchar.test(stremail))) {
   alert('Invalid E-Mail Address. Please check the E-Mail Address and try again.');
   return;
 }
 
 
 req_res = (window.XMLHttpRequest ? new XMLHttpRequest(): ((window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null) );
 if (req_res) { 
    document.getElementById('msg11').innerHTML = '<img src="./images/email_2.gif" border="0" />';
	req_res.onreadystatechange = state_change;
    req_res.open("POST",'emailsend.php',true);
	req_res.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	req_res.send('from_name='+from_name+'&subject='+subject+'&f_body='+f_body+'&from_email='+from_email+'&img_text='+img_text);
 }

} // end function

function state_change() {
 if ( req_res.readyState == 4 ) {
    if (req_res.status == 200) {
       if(req_res.responseText == 'done') {
		 document.getElementById('from_name').value = ''; 
		 document.getElementById('subject').value ='';
		 document.getElementById('from_email').value = '';
		 document.getElementById('f_body').value = '';
		 document.getElementById('img_text').value = '';
         document.getElementById('msg11').innerHTML = '<div id="Flash" class="good">Your Mail Send Successfully.</div>';
	   }
	   else{
         document.getElementById('msg11').innerHTML = '<div id="Flash" class="bad">Invalid Information.</div>';   
	   }
	  
	}
 }	
}



function formSubmit()
{
document.form1.submit();
}


