// JavaScript Document
function newsletter_validate(thisform)
{
with (thisform)
	{

	if(email.value=="Your E-mail Address")email.value="";
	if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}

	if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}

		thisform.submit();
		return false;
	}
}

function newsletter_name_validate(thisform,action)
{document.newsletter_form.newsletter_type.value=action; 
with (thisform)
	{//this form starts here
      
	if(fname.value=="Name")fname.value="";
	if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false)
		{			
			fname.focus();
			return false;
		}
		
		if(email.value=="Email Address")email.value="";
		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}			
		if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}
        
		thisform.submit();
		return false;

	}//thisform ends here

}

function quick_contact_validate(thisform)
{//function starts here


	with (thisform)
	{//thisform starts here
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false)
		{			
			fname.focus();
			return false;
		}

		if(emptyvalidation(phone,"Woops! You forgot to fill in your Phone Number")==false)
		{			
			phone.focus();
			return false;
		}
		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}

		if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}

		if(emptyvalidation(domain,"Woops! You forgot to fill in your Domain Name")==false)
		{			
			domain.focus();
			return false;
		}

		if(emptyvalidation(budget,"Woops! You forgot to fill in your Budget")==false)
		{			
			budget.focus();
			return false;
		}

		if(emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false)
		{			
			comments.focus();
			return false;
		}

		if(emptyvalidation(verify_digit,"Woops! You forgot to enter the Verification Code")==false)
		{			
			verify_digit.focus();
			return false;
		}
		
		if(newsletter.checked == true)
			newsletter.value = 1;
		else
			newsletter.value = 0;
		
		document.getElementById("button_show_hide").innerHTML='<img  src="http://www.techwyse.com/twimages/loading.gif" alt="" />';
		runAjax('check_captcha','process_mail.php',thisform.verify_digit.value);
		return false;
	}//thisform ends here
}//function ends here


//function for validate contact us form

function contact_validate(thisform)
{
	with (thisform)
	{
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false)
		{			
			fname.focus();
			return false;
		}

		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}
		if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}	

		if(emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false)
		{			
			comments.focus();
			return false;
		}
      
		if(emptyvalidation(yourenter_code,"Woops! You forgot to enter the Verification Code")==false)
		{			
			yourenter_code.focus();
			return false;
		}
		else
		{
		if(yourenter_code.value == "23KMK")
		{
		
		return true;
		}
		else
		{
		alert("Please enter the correct Verification code");
		return false;
		}
		
		}
		thisform.submit();
		return false;

	}
}



///ends here
function contactus_validate(thisform)
{
	with (thisform)
	{
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false)
		{			
			fname.focus();
			return false;
		}
		if(emptyvalidation(phone,"Woops! You forgot to fill in your Phone Number")==false)
		{			
			phone.focus();
			return false;
		}
		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}
		if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}	


		if(emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false)
		{			
			comments.focus();
			return false;
		}
		document.getElementById("button_show_hide").innerHTML='<img  src="http://www.techwyse.com/twimages/loading_contact.gif" alt="" />';
		thisform.submit();
		return false;

	}
}

function hosting_validate(thisform)
{
	with (thisform)
	{
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false)
		{			
			fname.focus();
			return false;
		}
		
		if(emptyvalidation(phone,"Woops! You forgot to fill in your Phone Number")==false)
		{			
			phone.focus();
			return false;
		}

		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}

		if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}

		if(emptyvalidation(domain,"Woops! You forgot to fill in your Domain Name")==false)
		{			
			domain.focus();
			return false;
		}
		
		if(emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false)
		{			
			comments.focus();
			return false;
		}
		document.getElementById("button_show_hide").innerHTML='<img  src="twimages/loading.gif" alt="" />';
		thisform.submit();
		return false;
	}
}
function landing_validate(thisform)
{//function starts here
	with (thisform)
	{//thisform starts here
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false)
		{			
			fname.focus();
			return false;
		}

		if(emptyvalidation(phone,"Woops! You forgot to fill in your Phone Number")==false)
		{			
			phone.focus();
			return false;
		}
		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}

		if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}

		if(emptyvalidation(domain,"Woops! You forgot to fill in your Domain Name")==false)
		{			
			domain.focus();
			return false;
		}

		if(emptyvalidation(budget,"Woops! You forgot to fill in your Budget")==false)
		{			
			budget.focus();
			return false;
		}

		if(emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false)
		{			
			comments.focus();
			return false;
		}
        document.getElementById("button_show_hide").innerHTML='<img  src="http://www.techwyse.com/twimages/loading.gif" alt="" />';
		thisform.submit();
		return false;

		
	}//thisform ends here
}//function ends here

function healthcare_landing_validate(thisform)
{//function starts here
	with (thisform)
	{//thisform starts here
	
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false)
		{			
			fname.focus();
			return false;
		}

		if(emptyvalidation(phone,"Woops! You forgot to fill in your Phone Number")==false)
		{			
			phone.focus();
			return false;
		}
		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false)
		{			
			email.focus();
			return false;
		}

		if(validate_email(email,"Woops! You have entered an invalid Email Address")==false)
		{
			email.select();
			email.focus();
			return false;
		}

		if(emptyvalidation(comments,"Woops! You forgot to fill in your Comments")==false)
		{			
			comments.focus();
			return false;
		}
    
		thisform.submit();
		return false;

		
	}//thisform ends here
}//function ends here

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function checkMailId(email) 
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) 
   {
      return 0;
   }
}

function DomainVal(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');//list of domain extensions

var mai = nname;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	return 0;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	return 0;
		 	 }
		  }
		else	
		  {
		  	 return 0;
		  }
		}
	}
}
else
{
return 0;
}	
}

function phoneValidation(strString)
{
   var strValidChars = "0123456789-+ ";
   var strChar;
   var blnResult = true;
   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
			return 0;
         }
      }
}


function SubmitCheckForm(chkThis)
	{
	frmCheckform	= chkThis;
	// assigh the name of the checkbox;
	var chks = document.getElementsByName('services[]');

	var hasChecked = false;
	// Get the checkbox array length and iterate it to see if any of them is selected
	for (var i = 0; i < chks.length; i++)
	{
		if (chks[i].checked)
		{
		        hasChecked = true;
			break;
		}
	}
	// if ishasChecked is false then throw the error message
	if (!hasChecked)
	{
		/*alert("Please select at least one Service.");
		chks[0].focus();
		return false;*/
		return 0;
	}
		
}


function ppc_validation()
{
	if(trim(document.quick_contact_form.fname.value)==0)
	{
		alert("Please enter your name");
		document.quick_contact_form.fname.focus();
		return false;
	}
	if(trim(document.quick_contact_form.company.value)==0)
	{
		alert("Please enter your company name");
		document.quick_contact_form.company.focus();
		return false;
	}
	if(trim(document.quick_contact_form.email.value)==0)
	{
		alert("Please enter your email address");
		document.quick_contact_form.email.focus();
		return false;
	}
	
	result=checkMailId(document.quick_contact_form.email.value)
	
	if(result==0)
	{
		alert("Invalid email address");
		document.quick_contact_form.email.focus();
		return false;
	}
	
	if(trim(document.quick_contact_form.domain.value)==0)
	{
		alert("Please enter your website");
		document.quick_contact_form.domain.focus();
		return false;
	}
	
	result=DomainVal(document.quick_contact_form.domain.value)
	
	if(result==0)
	{
		alert("Invalid entry of website");
		document.quick_contact_form.domain.focus();
		return false;
	}
	if(trim(document.quick_contact_form.phone.value)==0)
	{
		alert("Please enter your phone number");
		document.quick_contact_form.phone.focus();
		return false;
	}
	
	result=phoneValidation(document.quick_contact_form.phone.value)
	
	if(result==0)
	{
		alert("Invalid phone number");
		document.quick_contact_form.phone.focus();
		return false;
	}
	if(trim(document.quick_contact_form.keyword.value)==0)
	{
		alert("Please enter keyword");
		document.quick_contact_form.keyword.focus();
		return false;
	}
	document.getElementById("button_show_hide").innerHTML='<img  src="http://www.techwyse.com/twimages/loading.gif" alt="" />';
	document.quick_contact_form.submit();
}

function req_info()
{
	if(trim(document.contactus_form.fname.value)==0)
	{
		alert("Please enter your name");
		document.contactus_form.fname.focus();
		return false;
	}
	if(trim(document.contactus_form.email.value)==0)
	{
		alert("Please enter your email address");
		document.contactus_form.email.focus();
		return false;
	}
	
	result=checkMailId(document.contactus_form.email.value)
	
	if(result==0)
	{
		alert("Invalid email address");
		document.contactus_form.email.focus();
		return false;
	}
	
	result=SubmitCheckForm(document.contactus_form)
	
	if(result==0)
	{
		alert("Select atleast one service");
		return false;
	}
	document.contactus_form.submit();
}

function captcha_refresh()
{
document.getElementById("button_div").src='button.php?'+Math.random();
return false;
}

<!--Ajax for checking the captcha code ends here -->

var xmlHttp
function runAjax(field,argurl,argVal)
{
//document.getElementById("check_captcha").innerHTML=" Loading...";
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url=argurl
url=url+"?verify_digit="+argVal
url=url+"&sid="+Math.random()
if(field=='check_captcha')
xmlHttp.onreadystatechange=check_captcha;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function check_captcha() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
			if(xmlHttp.responseText=="yes")
			{
				 document.getElementById("button_show_hide").innerHTML='<img  src="twimages/loading.gif" alt="" />';
				document.quick_contact_form.submit();
			}
			else
			{
				 document.getElementById("button_show_hide").innerHTML='<a href="#" onclick="return quick_contact_validate(document.quick_contact_form);"><img  src="twimages/submit.jpg" alt="" /></a>';
				captcha_refresh();
				document.quick_contact_form.verify_digit.value="Invalid Verification Code";
				document.quick_contact_form.verify_digit.focus();
				document.quick_contact_form.verify_digit.select();
				return false;
			}
	} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
	objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
	return objXMLHttp
}

<!--Ajax for checking the captcha code starts here -->
//Custom alert script starts here

/*



var ALERT_TITLE = "Alert!";



var ALERT_BUTTON_TEXT = "Ok";







if(document.getElementById) {



	window.alert = function(txt,field1) {



		createCustomAlert(txt,field1);



	}



}







function createCustomAlert(txt,field1) {



	d = document;







	if(d.getElementById("modalContainer")) return;







	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));



	mObj.id = "modalContainer";



	mObj.style.height = d.documentElement.scrollHeight + "px";



	



	alertObj = mObj.appendChild(d.createElement("div"));



	alertObj.id = "alertBox";



	if(d.all && !window.opera) alertObj.style.top = (document.documentElement.scrollTop+100) + "px";



	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";




	alertObj.style.visiblity="visible";







	h1 = alertObj.appendChild(d.createElement("h1"));



	h1.appendChild(d.createTextNode(ALERT_TITLE));







	msg = alertObj.appendChild(d.createElement("p"));



	msg.appendChild(d.createTextNode(txt));







	btn = alertObj.appendChild(d.createElement("a"));



	btn.id = "closeBtn";



	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));



	btn.href = "#";



	btn.focus();



	btn.onclick = function() { removeCustomAlert(); field1.focus();  return false; }







	alertObj.style.display = "block";



	



}







function removeCustomAlert() 

{



	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));



}

*/

//Custom alert script ends here
