function refreshimg()
{
	//alert("test");
	//Get a reference to CAPTCHA image
	img = document.getElementById('captcha_img'); 
	//Change the image
	img.src = 'http://www.dotcominfoway.com/components/com_chronocontact/create_image.php?' + Math.random();
}
function showUser(str)
{ 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
//alert(xmlhttp);
xmlhttp.onreadystatechange=function()
  {
  	//  alert(xmlhttp);
//alert(xmlhttp.responseText);
  if (xmlhttp.readyState==4 )
    {
    	//alert(xmlhttp.responseText);
  
    if(xmlhttp.responseText == "Correct")
    {
    		document.ChronoContact_quick_form_portfolio.submit();
    	var c="correct";
    	return c;
	}
	else
	{ 
		alert("You have entered wrong security code. Please enter correct code. Click OK to re-enter.");
			img = document.getElementById('captcha_img'); 
	 img.src = "http://www.dotcominfoway.com/components/com_chronocontact/create_image.php?random="+Math.random()
			document.ChronoContact_quick_form_portfolio.chrono_verification.focus();
			document.ChronoContact_quick_form_portfolio.chrono_verification.select();
			
		// document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
		   var c="incorrect";
    	return c;
}
    }
  }

xmlhttp.open("GET","http://www.dotcominfoway.com/components/com_chronocontact/get.php?q="+str,true);
xmlhttp.send();
 
}


function resetValues(what) {
 document.ChronoContact_quick_form_portfolio.name.value="Name";
 document.ChronoContact_quick_form_portfolio.email.value="E-Mail";
 document.ChronoContact_quick_form_portfolio.website1.value="Website";
 document.ChronoContact_quick_form_portfolio.requirement.value="Requirement";
 document.ChronoContact_quick_form_portfolio.chrono_verification.value="";
  return false;
 }
  function hasNumbers(t)
{
return /\d/.test(t);
}

function ltrim(s)
{
	var l=0;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	return s.substring(l, s.length);
}

function verif_mail() 
{
	var id = document.ChronoContact_quick_form_portfolio.email.value;
	if(id == "")  
	{
	alert("Please enter valid email id (example@example.com). Click OK to re-enter");
	document.ChronoContact_quick_form_portfolio.email.select();
	return false;
	}
	  
	var apos=id.indexOf("@");
	var lpos=id.lastIndexOf("@");
	var dotpos=id.lastIndexOf(".");
	var id_len=id.length;
	//alert(dotpos);
	var dif=id_len-dotpos;
	//alert(dif);
	
	
	if(dif<3 || dif>5)
	{
	alert("Please enter valid email id (example@example.com). Click OK to re-enter");
	document.ChronoContact_quick_form_portfolio.email.select();
	return false;
	}
	
	if(apos!=lpos)
	{
	alert("Please enter valid email id (example@example.com). Click OK to re-enter");
	document.ChronoContact_quick_form_portfolio.email.select();
	return false;
	}
	
	if (apos<1||dotpos-apos<2) 
	  {
		alert("Please enter valid email id (example@example.com). Click OK to re-enter");
		document.ChronoContact_quick_form_portfolio.email.select();
		return false;
	  }
	  
	for(i=0;i<=dotpos;i++)
	{
		var str=id;
		var ch=str.substring(i,i+1);
		
		if(ch==' ' || ch==';' || ch==',' || ch=='!' || ch=='#' || ch=='$' || ch=='%' || ch=='^' || ch=='&' || ch=='*' )
		{
			alert("Please enter valid email id (example@example.com). Click OK to re-enter");
			document.ChronoContact_quick_form_portfolio.email.select();
			return false;
		}
	}
	var str=id.substring(dotpos+1,id_len);
	//alert(str);
	
		for (var i = 0; i < str.length; i++) 
		{
			var ch = str.substring(i, i + 1);
		//alert(ch)
			//if ( ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && (ch == '.')) 
			if(ch==1 || ch==2 || ch==3 || ch==4 || ch==5 || ch==6 || ch==7 || ch==8 || ch==9 || ch==0 || ch==';' || ch=='$' || ch=='@' || ch=='*' || ch=='^' || ch=='&' || ch=='%' ||ch=='#')
			//if((ch < "0" || "9" < ch))
			{
				alert("Please enter valid email id (example@example.com). Click OK to re-enter");
				document.ChronoContact_quick_form_portfolio.email.select();
				return false;
			}
		}
	return true;
	}
	
	
function checkfirstemptyspace(Field)
	{
		var ivalue =" ";
	//	var ivalue ="*|,\":~&-=<>''![]{}`\';^_?()@$#+/.%\\";
		
			if (ivalue.indexOf(Field.substring(0,1)) != -1)
			{
				alert ("Empty space is not allowed in the begining of the Name. Click OK to re-enter.");
			return false;
			}
			
		return true;
	}

function checkfirstspecials(Field)
	{
		var isplvalue = "*|,\":~&-=<>''![]{}`\';^_?()@$#+/.%\\";
		if (isplvalue.indexOf(Field.substring(0,1)) != -1)
			{
			alert ("Special character not allowed in the begining of the Requirement. Click OK to re-enter.");
			return false;
			}
		return true;
	}

function checkform()
{
	var checknum=/^([0-9]+)$/;
		var checkchar=/^([a-zA-Z ]+)$/;
		var checksp=/^([a-zA-Z0-9.+():,-\/ ]+)$/;
		var emailadd = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		var invalid = " ";
		var name=ltrim(document.ChronoContact_quick_form_portfolio.name.value);
		
		if (name == "Name")
			{
			alert("Please enter your name. Click OK to re-enter");
			document.ChronoContact_quick_form_portfolio.name.focus();
			document.ChronoContact_quick_form_portfolio.name.select();
			return false;
			}
			if (document.ChronoContact_quick_form_portfolio.name.value == 0)
			{
			alert("Please enter valid name. Click OK to re-enter");
			document.ChronoContact_quick_form_portfolio.name.focus();
			document.ChronoContact_quick_form_portfolio.name.select();
			return false;
			}
		if (!checkfirstemptyspace(name))
			{
			document.ChronoContact_quick_form_portfolio.name.focus();
			document.ChronoContact_quick_form_portfolio.name.select();
			return false;
			}
		  var iChars = "|*&\"";

  for (var i = 0; i < document.ChronoContact_quick_form_portfolio.name.value.length; i++) {
  	if (iChars.indexOf(document.ChronoContact_quick_form_portfolio.name.value.charAt(i)) != -1) {
  	alert ("Special characters are not allowed in the name field.Click OK to re-enter ");
  	document.ChronoContact_quick_form_portfolio.name.focus();
			document.ChronoContact_quick_form_portfolio.name.select();
  	return false;
  	}
  }
	
			if(hasNumbers(name))
{
        alert('Please enter a valid name. Click OK to re-enter');
        	document.ChronoContact_quick_form_portfolio.name.focus();
			document.ChronoContact_quick_form_portfolio.name.select();
			return false;
}
		
		if (document.ChronoContact_quick_form_portfolio.email.value=="" || document.ChronoContact_quick_form_portfolio.email.value=="E-Mail")
{
		alert("Please enter your email id. Click OK to re-enter.");

		document.ChronoContact_quick_form_portfolio.email.focus();

		return false;
	}

if (document.ChronoContact_quick_form_portfolio.email.value==0)
{
	alert("Please enter valid email id (example@example.com). Click OK to re-enter");
	document.ChronoContact_quick_form_portfolio.email.focus();
	document.ChronoContact_quick_form_portfolio.email.select();
	return false;
}


var email = document.ChronoContact_quick_form_portfolio.email.value;
// var filter = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/;
var filter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
 if (!filter.test(email)) {
 alert('Please enter valid email id (example@example.com). Click OK to re-enter');
 document.ChronoContact_quick_form_portfolio.email.focus();
 document.ChronoContact_quick_form_portfolio.email.select();
 return false;
 }
 
 			var explodestring=document.ChronoContact_quick_form_portfolio.website1.value.split("."); 
   			if (explodestring[1]=="google" || explodestring[1]=="yahoo" || explodestring[1]=="bing" || explodestring[0]=="google" || explodestring[0]=="yahoo" || explodestring[0]=="bing" || explodestring[1]=="GOOGLE" || explodestring[1]=="YAHOO" || explodestring[1]=="BING" || explodestring[0]=="GOOGLE" || explodestring[0]=="YAHOO" || explodestring[0]=="BING") 
			{
			alert("Please enter your valid website.");
			document.ChronoContact_quick_form_portfolio.website1.focus();
			document.ChronoContact_quick_form_portfolio.website1.select();
			return false;
			}
		if (document.ChronoContact_quick_form_portfolio.requirement.value == "Requirement") 
			{
			alert("Please enter your requirements. Click OK to re-enter.");
			document.ChronoContact_quick_form_portfolio.requirement.focus();
			document.ChronoContact_quick_form_portfolio.requirement.select();
			return false;
			}
			
				if (document.ChronoContact_quick_form_portfolio.requirement.value == 0) 
			{
			alert("Please enter valid requirements. Click OK to re-enter.");
			document.ChronoContact_quick_form_portfolio.requirement.focus();
			document.ChronoContact_quick_form_portfolio.requirement.select();
			return false;
			}
	/* if (!checkfirstemptyspace(document.ChronoContact_quick_form_portfolio.requirement.value))
			{
			document.ChronoContact_quick_form_portfolio.requirement.focus();
			document.ChronoContact_quick_form_portfolio.requirement.select();
			return false;
			}	 */
	
			if (document.ChronoContact_quick_form_portfolio.chrono_verification.value == '')
			{
			alert("Please enter Security Code. Click OK to re-enter.");
			document.ChronoContact_quick_form_portfolio.chrono_verification.focus();
			document.ChronoContact_quick_form_portfolio.chrono_verification.select();
			return false;
			} 
			
//alert("We value the interest you have taken in our services. We will attend to your query at the earliest and get back to you within 2 business day");	
document.ChronoContact_quick_form_portfolio.submit();

}
	

