/**************************************************************************************************
*           *       @       Created By              :       Vinod Kumar Keshri                    *
*           *       @       Modified By             :                           				  *
*           *       @       Date Of Creation        :       11-05-2010                            *
*           *       @       Date Of Modification    :                    					      *
*           *       @       Project Name            :       etrade travel agent                   *
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate travel agent, Start 
**************************************************************************************************/
function validateAgent(){
	var state_id 	= document.form.state_id.value;
	var city_id 	= document.form.city_id.value;
	var category_id = document.form.category_id.value;
	var agent 		= document.form.agent.value;
	var description = document.form.description.value;
	var address 	= document.form.address.value;
	var mobile 		= document.form.mobile.value;
	var phone 		= document.form.phone.value;
	var fax 		= document.form.fax.value;
	var url 		= document.form.url.value;
	if(state_id==''){
		document.getElementById('agentDiv').innerHTML = "State is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.state_id.focus();
		return false;
	}
	if(city_id==''){
		document.getElementById('agentDiv').innerHTML = "City is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.city_id.focus();
		return false;
	}
	if(category_id==''){
		document.getElementById('agentDiv').innerHTML = "Category is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.category_id.focus();
		return false;
	}
	if(agent==''){
		document.getElementById('agentDiv').innerHTML = "Travel agent is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.agent.focus();
		return false;
	}
	if(description==''){
		document.getElementById('agentDiv').innerHTML = "Description is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.description.focus();
		return false;
	}
	if(address==''){
		document.getElementById('agentDiv').innerHTML = "Address is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.address.focus();
		return false;
	}
	if(mobile==''){
		document.getElementById('agentDiv').innerHTML = "Mobile number is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.mobile.focus();
		return false;
	}
	if(phone==''){
		document.getElementById('agentDiv').innerHTML = "Phone number is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.phone.focus();
		return false;
	}
	if(fax==''){
		document.getElementById('agentDiv').innerHTML = "Fax number is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.fax.focus();
		return false;
	}
	if(url==''){
		document.getElementById('agentDiv').innerHTML = "Url is mandatry.";
		document.getElementById('agentDiv').style.display="block";
		document.form.url.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate travel agent, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to change admin password , Start 
**************************************************************************************************/
function changePasswordValidate(){
	var oldPassword = document.form.oldPassword.value;
	var newPassword = document.form.newPassword.value;
	var rePassword 	= document.form.rePassword.value;
	if(oldPassword==''){
		document.getElementById('changePasswordDiv').innerHTML = "Enter old password.";
		document.getElementById('changePasswordDiv').style.display="block";
		document.form.oldPassword.focus();
		return false;
	}
	if(newPassword==''){
		document.getElementById('changePasswordDiv').innerHTML = 'Enter new password.';
		document.getElementById('changePasswordDiv').style.display = 'block';
		document.form.newPassword.focus();
		return false;
	}
	if(rePassword==''){
		document.getElementById('changePasswordDiv').innerHTML = 'Enter Re-password.';
		document.getElementById('changePasswordDiv').style.display = 'block';
		document.form.rePassword.focus();
		return false;
	}
	if(newPassword!=rePassword){
		document.getElementById('changePasswordDiv').innerHTML = 'New password and Re-password did not match.';
		document.getElementById('changePasswordDiv').style.display = 'block';
		document.form.newPassword.focus();
		document.form.newPassword.value='';
		document.form.rePassword.value='';
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to change admin password , End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate admin profile, Start 
**************************************************************************************************/
function validateAdminProfile(){
	var emailExp= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var admin 	= document.form.admin.value;
	var email	= document.form.email.value;
	if(admin==''){
		document.getElementById('adminProfileDiv').innerHTML = "User name is mandatry.";
		document.getElementById('adminProfileDiv').style.display="block";
		document.form.admin.focus();
		return false;
	}
	if(email==''){
		document.getElementById('adminProfileDiv').innerHTML = "Email is mandatry.";
		document.getElementById('adminProfileDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('adminProfileDiv').innerHTML = "Enter valid email.";
		document.getElementById('adminProfileDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate admin profile, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate category, Start 
**************************************************************************************************/
function validateCategory(){
	var id		 = document.form.id.value;
	var category = document.form.category.value;
	if(id==''){
		document.getElementById('categoryDiv').innerHTML = "Category code is mandatry.";
		document.getElementById('categoryDiv').style.display="block";
		document.form.id.focus();
		return false;
	}
	if(category==''){
		document.getElementById('categoryDiv').innerHTML = "Category is mandatry.";
		document.getElementById('categoryDiv').style.display="block";
		document.form.category.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate category, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate city, Start 
**************************************************************************************************/
function validateCity(){
	var state_id = document.form.state_id.value;
	var id		 = document.form.id.value;
	var city 	 = document.form.city.value;
	if(state_id==''){
		document.getElementById('cityDiv').innerHTML = "State is mandatry.";
		document.getElementById('cityDiv').style.display="block";
		document.form.state_id.focus();
		return false;
	}
	if(id==''){
		document.getElementById('cityDiv').innerHTML = "City code is mandatry.";
		document.getElementById('cityDiv').style.display="block";
		document.form.id.focus();
		return false;
	}
	if(city==''){
		document.getElementById('cityDiv').innerHTML = "City is mandatry.";
		document.getElementById('cityDiv').style.display="block";
		document.form.city.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate city, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate admin login, Start 
**************************************************************************************************/
function validateAdminLogin(){
	var admin 		= document.form.admin.value;
	var password 	= document.form.password.value;	
	if(admin==''){
		document.getElementById('adminLoginDiv').innerHTML = "Enter User Name.";
		document.getElementById('adminLoginDiv').style.display="block";
		document.form.admin.focus();
		return false;
	}
	if(password==''){
		document.getElementById('adminLoginDiv').innerHTML = "Enter password.";
		document.getElementById('adminLoginDiv').style.display="block";
		document.form.password.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate admin login, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate attraction, Start 
**************************************************************************************************/
function validateAttraction(){
	var state_id	= document.form.state_id.value;
	var city_id 	= document.form.city_id.value;
	var id 			= document.form.id.value;	
	var attraction 	= document.form.attraction.value;	
	if(state_id==''){
		document.getElementById('attractionDiv').innerHTML = "State is mandatry.";
		document.getElementById('attractionDiv').style.display="block";
		document.form.state_id.focus();
		return false;
	}
	if(city_id==''){
		document.getElementById('attractionDiv').innerHTML = "City is mandatry.";
		document.getElementById('attractionDiv').style.display="block";
		document.form.city_id.focus();
		return false;
	}
	if(id==''){
		document.getElementById('attractionDiv').innerHTML = "Attraction code is mandatry.";
		document.getElementById('attractionDiv').style.display="block";
		document.form.id.focus();
		return false;
	}
	if(attraction==''){
		document.getElementById('attractionDiv').innerHTML = "Attraction is mandatry.";
		document.getElementById('attractionDiv').style.display="block";
		document.form.attraction.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate attraction, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate nearby, Start 
**************************************************************************************************/
function validateNearby(){
	var state_id= document.form.state_id.value;
	var city_id = document.form.city_id.value;
	var nearby	= document.form.nearby.value;	
	if(state_id==''){
		document.getElementById('nearbyDiv').innerHTML = "State is mandatry.";
		document.getElementById('nearbyDiv').style.display="block";
		document.form.state_id.focus();
		return false;
	}
	if(city_id==''){
		document.getElementById('nearbyDiv').innerHTML = "City is mandatry.";
		document.getElementById('nearbyDiv').style.display="block";
		document.form.city_id.focus();
		return false;
	}
	if(nearby==''){
		document.getElementById('nearbyDiv').innerHTML = "Near by is mandatry.";
		document.getElementById('nearbyDiv').style.display="block";
		document.form.nearby.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate nearby, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate query form, Start 
**************************************************************************************************/
function validateQueryForm(){
	var emailExp= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var date 		= document.queryform.date.value;
	var duration 	= document.queryform.duration.value;
	var people 		= document.queryform.people.value;
	var budget 		= document.queryform.budget.value;
	var category 	= document.queryform.category.value;
	var plan 		= document.queryform.plan.value;
	var name 		= document.queryform.name.value;
	var email 		= document.queryform.email.value;
	var phone 		= document.queryform.phone.value;
	var mobile 		= document.queryform.mobile.value;
	var country 	= document.queryform.country.value;
	var city 		= document.queryform.city.value;
	if(date==''){
		document.getElementById('queryDiv').innerHTML = "Arrival date is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.date.focus();
		return false;
	}
	if(duration==''){
		document.getElementById('queryDiv').innerHTML = "Duration is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.duration.focus();
		return false;
	}
	if(people==''){
		document.getElementById('queryDiv').innerHTML = "No. of people is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.people.focus();
		return false;
	}
	if(budget==''){
		document.getElementById('queryDiv').innerHTML = "Budget is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.budget.focus();
		return false;
	}
	if(category==''){
		document.getElementById('queryDiv').innerHTML = "Tour category is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.category.focus();
		return false;
	}
	if(plan==''){
		document.getElementById('queryDiv').innerHTML = "Requirements is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.plan.focus();
		return false;
	}
	if(name==''){
		document.getElementById('queryDiv').innerHTML = "Name is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.name.focus();
		return false;
	}
	if(email==''){
		document.getElementById('queryDiv').innerHTML = "Email Id is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('queryDiv').innerHTML = "Enter valid email.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.email.focus();
		return false;
	}
	if(phone==''){
		document.getElementById('queryDiv').innerHTML = "Phone number is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.phone.focus();
		return false;
	}
	if(isNaN(phone)){
		document.getElementById('queryDiv').innerHTML = "Phone number should be numeric.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.phone.focus();
		return false;
	}
	if(mobile==''){
		document.getElementById('queryDiv').innerHTML = "Mobile number is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.mobile.focus();
		return false;
	}
	if(isNaN(mobile)){
		document.getElementById('queryDiv').innerHTML = "Mobile number should be numeric.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.mobile.focus();
		return false;
	}
	if(country==''){
		document.getElementById('queryDiv').innerHTML = "Country is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.country.focus();
		return false;
	}
	if(city==''){
		document.getElementById('queryDiv').innerHTML = "City is mandatry.";
		document.getElementById('queryDiv').style.display="block";
		document.queryform.city.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate query form, End 
**************************************************************************************************/
