//// check length of textarea
  function maxLength(field,maxChars)
 {
       if(field.value.length >= maxChars) {
          event.returnValue=false; 
          alert("Not more than " +maxChars + " chars allowed.");
          return false;
       }
 }  

 function maxLengthPaste(field,maxChars)
 {
       event.returnValue=false;
       if((field.value.length +  window.clipboardData.getData("Text").length) > maxChars) {
         alert("Not more than " +maxChars + " chars allowed.");
         return false;
       }
       event.returnValue=true;
 }

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkmail(e){
var returnval=emailfilter.test(e.value);
return returnval;
}

function IsNumeric(yrValue) {
	  var checkOK = "0123456789.";
      var checkStr = yrValue;
      var allValid = true;
      var decPoints = 0;
      var allNum = "";
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
        if (ch == ".")
        {
          allNum += ".";
          decPoints++;
        }
        else if (ch != ",")
          allNum += ch;
      }
      if (!allValid)
      {
        return (false);
      }

      if (decPoints > 1)
      {
        return (false);
      }
     return(true);
	}

function ShowError(elementID,elementTitle){
	var errorImg='<img src="_assets/images/error.png" align="middle" />';
	document.getElementById("lbl"+elementID).style.color='red';
	document.getElementById("lbl"+elementID).title=elementTitle;
	document.getElementById("img"+elementID).innerHTML=errorImg;
	}

function ResetError(elementID){	
	document.getElementById("lbl"+elementID).style.color='#666666';
	document.getElementById("lbl"+elementID).title='';
	document.getElementById("img"+elementID).innerHTML='';
	}

function CheckForValid_SalesSupport(theForm) 
	{	
		var retVal=true;
		if(theForm.txtName.value=="") {
			ShowError('Name','Required Field Missing\n A Full Name is required.');
			retVal=false; }
		else 
			ResetError('Name');

		if(theForm.txtEmail.value=="") {
			ShowError('Email','Required Field Missing\n A Email ID is required.');
			retVal=false; }
		else 
			if(checkmail(theForm.txtEmail)==false) {
				ShowError('Email','Required Field Missing\n Invalid Email ID.');
				retVal=false; }
			else 
				ResetError('Email');

		if(theForm.txtContact.value=="") {
			ShowError('Contact','Required Field Missing\n A Contact Number is required.');
			retVal=false; }
		else 
			ResetError('Contact');

		if(theForm.cboDepartment.value=="0") {
			ShowError('Department','Required Field Missing\n A Department is required.');
			retVal=false; }
		else 
			ResetError('Department');

		if(theForm.cboType.value=="0") {
			ShowError('Type','Required Field Missing\n A Type is required.');
			retVal=false; }
		else 
			ResetError('Type');

		if(theForm.txtMessage.value=="") {
			ShowError('Message','Required Field Missing\n A Message is required.');
			retVal=false; }
		else 
			ResetError('Message');
		
		if(retVal==false)
			alert("Please fill the * Required Fields");
		else
			alert("Thank you for your interest. An Absolute Software Solutions’ should be contacting you shortly.");
		return(retVal);
	}


function CheckForValid_FreeQuote(theForm) 
	{
		var retVal=true;
		if(theForm.txtName.value=="") {
			ShowError('Name','Required Field Missing\n A Full Name is required.');
			retVal=false; }
		else 
			ResetError('Name');

		if(theForm.txtEmail.value=="") {
			ShowError('Email','Required Field Missing\n A Email ID is required.');
			retVal=false; }
		else 
			if(checkmail(theForm.txtEmail)==false) {
				ShowError('Email','Required Field Missing\n Invalid Email ID.');
				retVal=false; }
			else 
				ResetError('Email');

		if(theForm.txtContact.value=="") {
			ShowError('Contact','Required Field Missing\n A Contact Number is required.');
			retVal=false; }
		else 
			ResetError('Contact');

		if(theForm.txtproject.value=="") {
			ShowError('project','Required Field Missing\n A Describe your project as thoroughly as possible is required.');
			retVal=false; }
		else 
			ResetError('project');

		//if(theForm.txtpages.value !=""){
		//	if(!IsNumeric(theForm.txtpages.value)){
		//		ShowError('pages','Required Field Missing \n Invalid in Approximate number of web pages.');
		//		retVal=false;}
		// }
		// else
		//    ResetError('pages');

		if(retVal==false)
			alert("Please fill the * Required Fields");
		else		
			alert("Thank you for your interest. An Absolute Software Solutions’ should be contacting you shortly.");
			//return(false);
			//windows.location.href = "index.html"	
		return(retVal);

	}

function CheckForValid_ContactUS(theForm) 
	{
		var retVal=true;
		if(theForm.txtName.value=="") {
			ShowError('Name','Required Field Missing\n A Full Name is required.');
			retVal=false; }
		else 
			ResetError('Name');

		if(theForm.txtDesignation.value=="") {
			ShowError('Designation','Required Field Missing\n A Designation is required.');
			retVal=false; }
		else 
			ResetError('Designation');

		if(theForm.txtCompany.value=="") {
			ShowError('Company','Required Field Missing\n A Company is required.');
			retVal=false; }
		else 
			ResetError('Company');

		/*if(theForm.txtAddress1.value=="") {
			ShowError('Address1','Required Field Missing\n A Address 1 is required.');
			retVal=false; }
		else 
			ResetError('Address1');*/

		if(theForm.txtCity.value=="") {
			ShowError('City','Required Field Missing\n A City is required.');
			retVal=false; }
		else 
			ResetError('City');

		if(theForm.txtPincode.value=="") {
			ShowError('Pincode','Required Field Missing\n A Pin/Zip Code is required.');
			retVal=false; }
		else 
			if(!IsNumeric(theForm.txtPincode.value)) {
				ShowError('Pincode','Required Field Missing \n Invalid in Pin/Zip Code.');
				retVal=false; }
			else
				ResetError('Pincode');

/*		if(theForm.txtCountry.value=="") {
			ShowError('Country','Required Field Missing\n A Country is required.');
			retVal=false; }
		else 
			ResetError('Country');*/

		if(theForm.txtPhoneNo.value=="") {
			ShowError('PhoneNo','Required Field Missing\n A Phone no. is required.');
			retVal=false; }
		else 
			ResetError('PhoneNo');

		/*if(theForm.txtFax.value=="") {
			ShowError('Fax','Required Field Missing\n A Fax is required.');
			retVal=false; }
		else 
			ResetError('Fax');*/

		if(theForm.txtEmail.value=="") {
			ShowError('Email','Required Field Missing\n A Email ID is required.');
			retVal=false; }
		else 
			if(checkmail(theForm.txtEmail)==false) {
				ShowError('Email','Required Field Missing\n Invalid Email ID.');
				retVal=false; }
			else 
				ResetError('Email');

		if (theForm.txtComments.value=="") {
			ShowError('Comments','Required Field Missing\n A Comments is required.');
			retVal=false; }
		else 
			ResetError('Comments');
			
		if(retVal==false)
		{
		alert("Please fill the *Required Fields");
		}
		else
		{
		alert("Thank you for your interest. An Absolute Software Solutions’ should be contacting you shortly.");
		}
		return(retVal);
	}