//**************** Digit Function**********************
// This Function Allows Only Digits (0-9) in Textbox.
//******************************************************

function digit(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
	{
		return false;
	}
	return true;
}

//******************* Instruction For Implementation ********************
//write this in your textbox tag : onkeypress="return digit(event)"
//***********************************************************************

//**************** Digit Function End **********************


//**************** Digit Function 1**********************
// This Function Allows Only Digits (0-9) and . in Textbox.
//******************************************************


function digit1(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && charCode != 46 && (charCode < 48 || charCode > 57))
	{
		return false;
	}
	return true;
}

//******************* Instruction For Implementation ********************
//write this in your textbox tag : onkeypress="return digit1(event)"
//***********************************************************************

//**************** Digit Function 1 End **********************




//**************** Alpha Function**********************
// This Function Allows Only Alphabets (A-Z and a-z and blank space) in Textbox.
//******************************************************

function alpha(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode!=32 && (charCode < 65 || charCode > 90)&&(charCode < 97 || charCode > 122))
	{
		return false;
	}
	return true;
}

//******************* Instruction For Implementation ********************
//write this in your textbox tag : onkeypress="return alpha(event)"
//***********************************************************************

//**************** Alpha Function End **********************


//**************** Alphanumeric Function**********************
// This Function Allows Only Alphabets (A-Z and a-z and blank space) and Digits (0-9) in Textbox.
//******************************************************

function alphanumeric(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if ( charCode!=32 &&(charCode < 48 || charCode > 57) && (charCode < 65 || charCode > 90 ) && (charCode < 97 || charCode > 122))
	{
		return false;
	}
	return true;
}


//******************* Instruction For Implementation ********************
//write this in your textbox tag : onkeypress="return alphanumeric(event)"
//***********************************************************************

//**************** Alphanumeric Function End **********************


//**************** Email Function**********************
// This Function Valifdates Email address in textbox
//******************************************************
function email_check(obj)
{
	if(obj.value!="")
	{
		var email,AtPos,StopPos,Message
		email = obj.value
		AtPos = email.indexOf("@")
		StopPos = email.lastIndexOf(".")
		Message = ""		
		if (AtPos == -1 || StopPos == -1) 
		{
			Message = "Not a valid email address"
		}
		if (StopPos < AtPos) 
		{
			Message = "Not a valid email address"
		}
		if (StopPos - AtPos == 1) 
		{
			Message = "Not a valid email address"
		}
		if (Message!="")
		{
			alert(Message);
			obj.focus();
			return(false);
		}
	}
}


//******************* Instruction For Implementation ********************
//write this in your textbox tag : onBlur="return email(this)"
//***********************************************************************

//**************** Email Function End **********************


//**************** New Window **********************
// This Function Opens newwindow
//******************************************************

var win = null;
function NewWindow(mypage,myname,w,h,scroll)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=0,status=0'
	win = window.open(mypage,myname,settings)
}

//******************* Instruction For Implementation ********************
//write this :javascript:NewWindow('page link','page title',800,600,1)
//***********************************************************************

//**************** New window Function End **********************

//**************** Check pincode **********************
// This Function Checks pincode
//******************************************************

//function pin(obj)
//{
//	if (obj.value.length<6 && obj.value.length!=0)
//	{
//		alert("Please Enter 6 Digit Number.");
//		obj.focus();
//		return (false);
//	}
//}

//******************* Instruction For Implementation ********************
//write this : onBlur="javascript:pin(this);"
//***********************************************************************

//**************** check pincode Function End **********************

//**************** website addresscheck **********************
// This Function validate website address
//******************************************************
function webcheck(obj)
{
	if(obj.value!="")
	{
		var email,AtPos,StopPos,Message
		email = obj.value
		AtPos = email.indexOf("www")
		StopPos = email.lastIndexOf(".")
		Message = ""
		if (AtPos == -1 || StopPos == -1 || http == -1) 
		{
			Message = "Not a valid Website address"
		}
		
		if (StopPos < AtPos) 
		{
			Message = "Not a valid Website address"
		}
		if (StopPos - AtPos == 1) 
		{
			Message = "Not a valid Website address"
		}
		if (Message!="")
		{
			alert(Message);
			obj.focus();
			return(false);
		}
	}
}

function echeck(incomingString)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g) == -1)
	{
		return false;
	}
	else
		return true;	
}
//******************* Instruction For Implementation ********************
//write this :javascript:onBlur="return webcheck(this)"
//set value="http://" of your textbox
//***********************************************************************
//**************** webcheck Function End **********************



//**************** uppercase ***************************
// This Function converts all characters to uppercase
//******************************************************

function uppercase(obj)
{
	obj.value=obj.value.toUpperCase();
}
//******************* Instruction For Implementation ********************
//write this :javascript:onKeyup="uppercase(this);"
//***********************************************************************



//**************** Maxlength in textarea ***************************
// This Function sets maxlength of text area
//******************************************************
function maxlength(obj,obj1)
{
	if(obj.value.length>obj1)
	{
		obj.value=obj.value.substring(0, obj1);	
	}
}
//******************* Instruction For Implementation ********************
//write this :javascript:onKeypress="maxlength(this,5);"
//***********************************************************************

var xmlhttp

function call_me_send(p,pp,ppp)
{
if (p=="" || pp=="" || ppp=="")
{
	if (p=="")
	{
		alert("Enter your name.")
		document.call_me_form.p_name.focus();
	}
	else if (pp=="")
	{
		alert("Enter country code.")
		document.call_me_form.p_phone1.focus();
	}
	else if (ppp=="")
	{
		alert("Enter your contact No.")
		document.call_me_form.p_phone2.focus();
	}
}
else
	{
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		var url="call_me.asp";
		url=url+"?p="+p;
		url=url+"&pp="+pp;
		url=url+"&ppp="+ppp;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChanged;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("call_me").innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}