// JavaScript Document
var globalFunction ="";
$(document).ready(function(){
	getHomeContents();
})
function getHomeContents(){
	$.get("homeMiddle.php",function(data){
		$("#resultDiv").html(data);								
	})				   	
}
function validatePassAndCPass(){
	
	if($("#rpass").val().length < 6){
		alert("Password should be 6 charector long");
		$("#rpass").focus();
		return false;
	}
	if($("#cpass").val().length < 6){
		alert("Confirm password should be 6 charector long");
		$("#cpass").focus();
		return false;
	}
	if($("#rpass").val() != $("#cpass").val()){
		alert("Both password are different");
		$("#rpass").focus();
		return false;
	}
	var emailId = $("#emailId").val();
	var requesturl  	= "modules/homeRegistration/registrationFormAS.php";
	var action   		= "validation";
	var urlData 		= "action="+action+"&emailId="+emailId;
	ajaxS(requesturl, urlData, "GET");
	if(resultResponse == 1){
		alert("This record already present");
		$("#emailId").focus();
		return false;
	}
}

function checkSession(){
	if($("#username").val() == ''){
		alert("You have not entered username");
		$("#username").focus();
		return false;
	}
	if($("#lpass").val() == ''){
		alert("You have not entered password");
		$("#lpass").focus();
		return false;
	}
	var username = $("#username").val();
	var pass = $("#lpass").val();
	$.get('modules/login/loginFormAS.php?action=checkSession&username='+username+'&pass='+pass,function(data){
		if(data == "False"){
			alert("Invalide username and password");
			$("#username").focus();
			return false;
		}
		else{
			window.location = "master.php";
		}
	});
}

function getForgotForm(id){
	if(id == "loginTable"){
		$("#loginTable").hide();
		$("#forgotTable").show();
	}
	else{
		$("#loginTable").show();
		$("#forgotTable").hide();
	}
}

function getForgotPassword(){
	var username = $("#femailId").val();
	if(username == ""){
		alert("You have not entered email ID");
		$("#femailId").focus();
		return false;	
	}
	var requesturl  	= "modules/login/loginFormAS.php";
	var action   		= "getForgotPassword";
	var urlData 		= "action="+action+"&username="+username;
	ajaxS(requesturl, urlData, "GET");
	if(resultResponse != ""){
		$("#message").html(resultResponse);
		$("#femailId").focus();
		return false;
	}	
}

function processOver(result){
	if(result != ""){
		//alert(result);
		alert(result);
		document.reg.reset();
	}
	else{
		alert("There might be problem in system");
		//alert("There might be problem in system");
	}
}

function getSearchList(PageNo,PerPageRecord){
	globalFunction = "getSearchList";
	
	if($("#cmbfromage").val() == ""){
		alert("You have not selected age");
		$("#cmbfromage").focus
		return false;
	}
	if($("#cmbtoage").val() == ""){
		alert("You have not selected age");
		$("#cmbtoage").focus
		return false;
	}
	
	var getData = $("#qsearch").serialize();
	var requesturl  	= "modules/advancedSearch/advancedSearchAS.php";
	var action   		= "getSearchList";
	var urlData 		= "action="+action+"&"+getData+'&PerPageRecord='+PerPageRecord+'&PageNo='+PageNo;
	ajaxA(requesturl, urlData, "GET","setSearchList()","Y");
}

function setSearchList(){
	
	$("#resultDiv").html(resultResponse);
}
$(function() {
		$('#dateOfBirth').datepicker({
				dateFormat : 'dd-mm-yy',
				changeMonth: true,
				changeYear: true,
				yearRange:'-90:+0'
		});	
});

function getProfile(){
	globalFunction = "getHomeContents";
	if($("#searchTxt").val() == ""){
		alert("You have not entered profile id");
		$("#searchTxt").focus();
		return false;
	}
	var profileId = $("#searchTxt").val();
	wait();
	$.get('modules/previewProfile/profile.php?profileId='+profileId,function(data){
		$('#resultDiv').html(data);
		removeWait();
	})
}

