	/****************************************************************/
	/*****   CREATED BY	 : Dileep Kumar  			 			*****/
	/*****   CREATION DATE  : 24 March 2009		 			    *****/
	/*****											 			*****/
	/*****    MODIFIED  BY   : 					     			*****/
	/*****    MODIFIED ON	 : 							 		*****/
	/*****											 			*****/
	/*****   CODE BRIEFING : contain the JS functions to 		*****/
	/*****					validate the contact us form		*****/
	/*****   COMPANY		: Chetu India Pvt Ltd.	 			*****/
	/*****											 			*****/
	/****************************************************************/
/*
* Company: Chetu Inc;
* Created By: Dileep Kumar;
* Created On: 25 March 2009;
* Description: function is used to create the AJAX request;
*/
function create_request(){
	var request = null;
	try{
		// Try with other browsers
		request = new XMLHttpRequest();
	}catch(e){
		// Try with other microsoft browsers
		try{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	if(request == null){
		alert("Sorry! your browser does not support AJAX.");
		return false;
	}
	return request;
}
/*
* Company: Chetu Inc;
* Created By: Dileep Kumar;
* Created On: 24 March 2009;
* Description: function is used validate the email ID;
*/
function is_email(email){
	if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
		return false;
	return true;
}
/*
* Company: Chetu Inc;
* Created By: Dileep Kumar;
* Created On: 24 March 2009;
* Description: function is used validate the Number;
*/
function is_validPhone(number){
	if(!number.match(/^[\.0-9-]+$/))
		return false;
	return true;
}
/*
* Company: Chetu Inc.;
* Added By: Dileep Kumar;
* Added Date: 25 March 2009;
* Description: function used to send the appointment mail.
*/

function sendMailToFriend(){
	var param = new String();
	// Get values from form
	var txtname		= document.frmMailToFriend.name;
	var txtemail	= document.frmMailToFriend.email;
	var friendname	= document.frmMailToFriend.friendname;
	var friendemail	= document.frmMailToFriend.friendemail;
	var sendMail	= document.frmMailToFriend.sendMail;
	// Validate Form;
	if(validateFrmMailToFriend()){
		document.frmMailToFriend.sendemail.disabled = true;
		// create the parametes to post;
		param += "name="+txtname.value+"&email="+txtemail.value+"&friendname="+friendname.value+"&friendemail="+friendemail.value+"&sendMail="+sendMail.value;
		// Create the AJAX request;
		var request = create_request();
		request.open("POST", "mailtofriend.php", true);
		request.onreadystatechange = function(){
													// get the element to display the success/failure message;
													var displayMessage = document.getElementById("displayMessage");
													displayMessage.style.display = "block";
													if(request.readyState == 4){
														// Display the Success/Failure message here;
														displayMessage.innerHTML = request.responseText;
														// Make the fileds blank;
														document.frmMailToFriend.reset();
														document.frmMailToFriend.sendemail.disabled = false;
													}else{
														// Display the status here;
														displayMessage.innerHTML = "Sending Email, please wait....";
													}
												}
		// Set the headers for the POST method using AJAX;
		request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		request.setRequestHeader("Content-length", param.length);
		request.setRequestHeader("Connection", "close");
		// Send the request here;
		request.send(param);
	}
}
/*
* Company: Chetu Inc.;
* Added By: Dileep Kumar;
* Added On: 24 March 2009;
* Description: Function is used to validate the "Mail to Friend" form;
*/
function validateFrmMailToFriend(){
	// Get the form input elements here;
	var name = document.frmMailToFriend.name;
	var email = document.frmMailToFriend.email;
	var friendname	= document.frmMailToFriend.friendname;
	var friendemail	= document.frmMailToFriend.friendemail;
	// Validate the name here;
	if(name.value == ''){
		alert("Please enter your name!");
		name.focus();
		return false;
	}
	// Validate email here;
	if(!is_email(email.value)){
		alert("Please enter valid email!");
		email.focus();
		return false;
	}
	
	// Validate friend name here;
	if(friendname.value == ''){
		alert("Please enter Friend's name!");
		friendname.focus();
		return false;
	}
	
	// Validate friends email address;
	if(!is_email(friendemail.value)){
		alert("Please enter valid Friend's Email !");
		friendemail.focus();
		return false;
	}
	
	return true;
}

