// JavaScript Document
function echeck(str) 
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email id");
		   document.form1.EmailId.focus();
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid email id");
		   document.form1.EmailId.focus();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid email id");
			document.form1.EmailId.focus();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid email id");
			document.form1.EmailId.focus();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid email id");
			document.form1.EmailId.focus();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid email id");
			document.form1.EmailId.focus();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid email id");
			document.form1.EmailId.focus();
		    return false
		 }
 		 return true					
}

function ccheck(str) 
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid Chat Id");
		   document.form1.ChatId.focus();
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid Chat Id");
		   document.form1.ChatId.focus();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid Chat Id");
			document.form1.ChatId.focus();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid Chat Id");
			document.form1.ChatId.focus();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid Chat Id");
			document.form1.ChatId.focus();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid Chat Id");
			document.form1.ChatId.focus();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid Chat Id");
			document.form1.ChatId.focus();
		    return false
		 }
 		 return true					
}


function reloadCaptcha()
{
	now = new Date();
	var capObj = document.getElementById('image');
	if (capObj) 
	{
   		capObj.src = capObj.src + (capObj.src.indexOf('?') > -1 ? '&' : '?') + Math.ceil(Math.random()*(now.getTime()));
	}
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function RequestValidate()
{
	if(trim(document.form1.Name.value,"") == "")
	{
		alert("Please enter the Name");
		document.form1.Name.focus();
		return false;
	}	
	else if(trim(document.form1.Company.value,"") == "")
	{
		alert("Please enter the Company");
		document.form1.Company.focus();
		return false;
	}
	else if(echeck(document.form1.EmailId.value)== false)
	{						
		return false;
	}
	if(trim(document.form1.ChatId.value,"") == "")
	{
		alert("Please enter the ChatId");
		document.form1.ChatId.focus();
		return false;
	}
	/*else if(ccheck(document.form1.ChatId.value)== false)
	{						
		return false;
	}	*/
	else if(trim(document.form1.ContactNo.value,"") == "")
	{
		alert("Please enter the Contact No");
		document.form1.ContactNo.focus();
		return false;
	}
	else if(trim(document.form1.Location.value,"") == "")
	{
		alert("Please enter the Location");
		document.form1.Location.focus();
		return false;
	}
	else if(trim(document.form1.TimeZone.value,"") == "")
	{
		alert("Please enter the TimeZone");
		document.form1.TimeZone.focus();
		return false;
	}
	else if(document.form1.Date.value == "")
	{
		alert("Please enter the Date");
		document.form1.Date.focus();
		return false;
	}
	else if(document.form1.Hour.value == "")
	{
		alert("Please enter the Hour");
		document.form1.Hour.focus();
		return false;
	}
	else if(document.form1.Minute.value == "")
	{
		alert("Please enter the Minute");
		document.form1.Minute.focus();
		return false;
	}

	else
	{
		return true;
	}
}



function isNumberKey(evt)
{
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57))

		return false;

	 return true;

}
