$(document).ready(function() {
		$.ajaxSetup({
		  	async: false
		});
		$("#reg_mes").hide();		
});

function submitRequest()
{
	if(validate())
	{	
		submitQuatation();
	}
}

function submitWebinarData()
{
	
	if(validateWebinar())
	{	
		submitWebinar();
	} 
}


function submitConversionData()
{
	if(validate())
	{	
		submitQuatation();
	}
}

function submitWebinar()
{
		
	$(".button-submit").attr("disabled",true);
	$(".button-submit").val("Processing...");
	
	product = $("#product").val();
	if(typeof(product)=='undefined')
		product = "";
		
	no_of_unit = $("#unit").val();
	if(typeof(no_of_unit)=='undefined')
		no_of_unit = "";
	comment = $("#comment").val();
	if(typeof(comment)=='undefined')
		comment = "";
	business_name = $("#business_name").val();
	industry = $("#industry").val();
	if(typeof(industry)=='undefined')
		industry = "";
	name = $("#name").val();
	position=$("#position").val();
	phone = $("#phone").val();
	email = $("#email").val();
	street = $("#street").val();
	state = $("#state").val();
	city = $("#city").val();
	zip = $("#zip").val();

	first_name = $("#first_name").val();
	last_name = $("#last_name").val();
	title = $("#title").val();
	company = $("#company").val();

	information = $("#information_type").val();
	business_process = $("input:checkbox[id=business_process]:checked").val();
	if(typeof(business_process)=='undefined')
		business_process = "";
	business_desc = $("input:checkbox[id=business_desc]:checked").val();
	if(typeof(business_desc)=='undefined')
		business_desc = "";
	// check box value retrival //
	var chkBox = $("input:checkbox[id=location]:checked");
	chk_Box = Array();
	len = chkBox.length;
	for(i=0;i<len;i++)
	{
		chk_Box[i] = chkBox[i].value;
	}
	pos_location =chk_Box.join("~"); 
	//---------------------------------//
	var chkBox_fraud_exp = $("input:checkbox[id=fraud_exp]:checked");
	if(chkBox_fraud_exp.length)
	{
		chkBoxfraud_exp = Array();
		len = chkBox_fraud_exp.length;
		for(i=0;i<len;i++)
		{
			chkBoxfraud_exp[i] = chkBox_fraud_exp[i].value;
		}
		fraud_exp =chk_Box.join("~"); 
	}
	else
		fraud_exp = "";
		


$.post( sitePath +"/classes/ajax-request-responce.php", {"action_to_do":"webinar","product":product,"no_of_unit":no_of_unit, "comment":comment,"business_name":business_name,"industry":industry,"name":name,"phone":phone,"email":email,"state":state,"city":city,"street":street,"zip":zip,"pos":pos_location,"position":position,"information":information,"business_process":business_process,"business_desc":business_desc,"first_name":first_name,"last_name":last_name,"title":title,"company":company,"fraud_exp":fraud_exp}, function(data){
				//prompt("r",data);
		result = data.split("!");
		if(result[0] == "V") {
			if(result[1] =="true") {
				//$("#qot_mes").fadeIn(300);
				
				
				$("#demo").fadeOut(function(){$("#qot_mes").fadeIn(1000);});
				$("#title31-webinar").fadeOut(function(){$("#qot_mes").fadeIn(1000);});
			}else{
				$(".button-submit").attr("disabled",false);
				$(".button-submit").val("SUBMIT");
			}				
		}
		
	}); 
}

function submitQuatation()
{
	$(".button-submit").attr("disabled",true);
	$(".button-submit").val("Processing...");
	
	product = $("#product").val();
	if(typeof(product)=='undefined')
		product = "";
		
	no_of_unit = $("#unit").val();
	if(typeof(no_of_unit)=='undefined')
		no_of_unit = "";
	comment = $("#comment").val();
	if(typeof(comment)=='undefined')
		comment = "";
	business_name = $("#business_name").val();
	industry = $("#industry").val();
	if(typeof(industry)=='undefined')
		industry = "";
	name = $("#name").val();
	position=$("#position").val();
	phone = $("#phone").val();
	email = $("#email").val();
	street = $("#street").val();
	state = $("#state").val();
	city = $("#city").val();
	zip = $("#zip").val();

	first_name = $("#first_name").val();
	last_name = $("#last_name").val();
	title = $("#title").val();
	company = $("#company").val();

	information = $("#information_type").val();
	business_process = $("input:checkbox[id=business_process]:checked").val();
	if(typeof(business_process)=='undefined')
		business_process = "";
	business_desc = $("input:checkbox[id=business_desc]:checked").val();
	if(typeof(business_desc)=='undefined')
		business_desc = "";
	// check box value retrival //
	var chkBox = $("input:checkbox[id=location]:checked");
	chk_Box = Array();
	len = chkBox.length;
	for(i=0;i<len;i++)
	{
		chk_Box[i] = chkBox[i].value;
	}
	pos_location =chk_Box.join("~"); 
	//---------------------------------//
	var chkBox_fraud_exp = $("input:checkbox[id=fraud_exp]:checked");
	if(chkBox_fraud_exp.length)
	{
		chkBoxfraud_exp = Array();
		len = chkBox_fraud_exp.length;
		for(i=0;i<len;i++)
		{
			chkBoxfraud_exp[i] = chkBox_fraud_exp[i].value;
		}
		fraud_exp =chk_Box.join("~"); 
	}
	else
		fraud_exp = "";

	$.post( sitePath +"/classes/ajax-request-responce.php", {"action_to_do":"quatation","product":product,"no_of_unit":no_of_unit, "comment":comment,"business_name":business_name,"industry":industry,"name":name,"phone":phone,"email":email,"state":state,"city":city,"street":street,"zip":zip,"pos":pos_location,"position":position,"information":information,"business_process":business_process,"business_desc":business_desc,"first_name":first_name,"last_name":last_name,"title":title,"company":company,"fraud_exp":fraud_exp}, function(data){
				//prompt("r",data);
		result = data.split("!");
		if(result[0] == "V") {
			if(result[1] =="true") {
				//$("#qot_mes").fadeIn(300);
				
				$("#demo").fadeOut(function(){$("#qot_mes").fadeIn(1000);});
				$("#quatation").fadeOut(function(){$("#qot_mes").fadeIn(1000);});
			}else{
				$(".button-submit").attr("disabled",false);
				$(".button-submit").val("SUBMIT");
			}				
		}
		
	});
}

function validateWebinar()
{

		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;//[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}
		var alphaNumReg = /^[^a-zA-Z0-9_\.\-]$/;
		var stringReg = /^[^A-Za-z\s\.\' ]$/;
		var phoneReg = /^[^0-9\-\(\)\,\ \+-]+$/;
		var numReg = /^[^0-9]+$/;
		var selectReg = /^[^1-9]+$/;
		
		var email = $("#email").val();
		if(typeof(email)!='undefined')
		if(email == '') {
			$("#email").after('<span class="error">You forgot to enter the email address.</span>');
			hasError = true;
		} else if(!emailReg.test(email)) {
			$("#email").after('<span class="error">Enter a valid email address.</span>');
			hasError = true;
		}
		
		var zip = $("#zip").val();
		if(typeof(zip)!='undefined')
		if(zip == '') {
			$("#zip").after('<span class="error">You forgot to enter the Zip address.</span>');
			hasError = true;
		} else if(alphaNumReg.test(zip)) {
			$("#zip").after('<span class="error">Enter a valid Zip address. It should be alphanumeric.</span>');
			hasError = true;
		}
		
		if($("#information_type").val()=='TITLE31-WEBINAR')
		{
			var first_name = $("#first_name").val();
			if(typeof(first_name)!='undefined')
			if(first_name == '') {
				$("#first_name").after('<span class="error">You forgot to enter the First name.</span>');
				hasError = true;
			} 
			
		
			//----------------------------//
			var last_name = $("#last_name").val();
			if(typeof(last_name)!='undefined')
			if(last_name == '') {
				$("#last_name").after('<span class="error">You forgot to enter the Last name.</span>');
				hasError = true;
			} 
			//----------------------------------//
			var company = $("#company").val();
			if(typeof(company)!='undefined')
			if(company == '') {
				$("#company").after('<span class="error">You forgot to enter the Company name.</span>');
				hasError = true;
			} 

			var title = $("#title").val();
			if(typeof(title)!='undefined')
			if(title == '') {
				$("#title").after('<span class="error">You forgot to enter the Title.</span>');
				hasError = true;
			} 
			
			var primary_contact = $("#phone").val();
			if(primary_contact == '') {
				$("#phone").after('<span class="error">You forgot to enter phone no.</span>');
				hasError = true;
			} else if(phoneReg.test(primary_contact)) {
				$("#phone").after('<span class="error">Enter valid phone no.</span>');
				hasError = true;
			}
			var street = $("#street").val();
			if(typeof(street)!='undefined')
			if(street == '') {
				$("#street").after('<span class="error">You forgot to enter the Street name.</span>');
				hasError = true;
			}
		}	
			
		
	
		if(hasError)
		return false;
		else
		return true;
}

// For Validating Quatation form, Trial form, Vulnerability form.
function validate()
{

		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;//[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}
		var alphaNumReg = /^[^a-zA-Z0-9_\.\-]$/;
		var stringReg = /^[^A-Za-z\s\.\' ]$/;
		var phoneReg = /^[^0-9\-\(\)\,\ \+-]+$/;
		var numReg = /^[^0-9]+$/;
		var selectReg = /^[^1-9]+$/;
		//------------------------------------//
		var product = $("#product").val();
		if(typeof(product)!='undefined')
		if(product == '') {
			$("#product").after('<span class="error">You forgot to Select product.</span>');
			hasError = true;
		} 
		//------------------------------------//
		var no_of_unit = $("#unit").val();
		if(typeof(no_of_unit)!='undefined')
		if(no_of_unit == '') {
			$("#unit").after('<span class="error">You forgot to enter No. Of Unit Of product.</span>');
			hasError = true;
		} else if(numReg.test(no_of_unit)) {
			$("#unit").after('<span class="error">Unit can contain only number.</span>');
			hasError = true;
		}
		//------------------------------------//
		var industry = $("#industry").val();
		if(typeof(industry)!='undefined')
		if(industry == '') {
			$("#industry").after('<span class="error">You forgot to Select Industry.</span>');
			hasError = true;
		} 
		//------------------------------------//
		var business_name = $("#business_name").val();
		if(typeof(business_name)!='undefined')
		if(business_name == '') {
			$("#business_name").after('<span class="error">You forgot to enter First Name.</span>');
			hasError = true;
		} else if(alphaNumReg.test(business_name)) {
			$("#business_name").after('<span class="error">First Name can contain only alphanumeric value.</span>');
			hasError = true;
		}
		//-------------------------------//
		var name = $("#name").val();
		if(typeof(name)!='undefined')
		if(name == '') {
			$("#name").after('<span class="error">You forgot to enter Last Name.</span>');
			hasError = true;
		} else if(stringReg.test(name)) {
			$("#name").after('<span class="error">Last Name can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------//
		var title = $("#title").val();
		if(typeof(title)!='undefined')
		if(title == '') {
			$("#title").after('<span class="error">You forgot to enter the Website.</span>');
			hasError = true;
		} 
		
		//----------------------------------//
		var company = $("#company").val();
		if(typeof(company)!='undefined')
		if(company == '') {
			$("#company").after('<span class="error">You forgot to enter the Company name.</span>');
			hasError = true;
		}	
		//----------------------------------//
	/*	var company = $("#first_name").val();
		if(typeof(company)!='undefined')
		if(company == '') {
			$("#first_name").after('<span class="error">You forgot to enter the First name.</span>');
			hasError = true;
		}		
		//----------------------------------//
		var company = $("#last_name").val();
		if(typeof(company)!='undefined')
		if(company == '') {
			$("#last_name").after('<span class="error">You forgot to enter the Last name.</span>');
			hasError = true;
		}		*/
		//----------------------------------//
		var email = $("#email").val();
		if(typeof(email)!='undefined')
		if(email == '') {
			$("#email").after('<span class="error">You forgot to enter the email address.</span>');
			hasError = true;
		} else if(!emailReg.test(email)) {
			$("#email").after('<span class="error">Enter a valid email address.</span>');
			hasError = true;
		}
		//----------------------------------//
		var zip = $("#zip").val();
		if(typeof(zip)!='undefined')
		if(zip == '') {
			$("#zip").after('<span class="error">You forgot to enter the Zip address.</span>');
			hasError = true;
		} else if(alphaNumReg.test(zip)) {
			$("#zip").after('<span class="error">Enter a valid Zip address. It should be alphanumeric.</span>');
			hasError = true;
		}
		//----------------------------------//
		if($("#information_type").val()!='REQUEST COMPLIANCE' && $("#information_type").val()!='FRAUD PREVENTION')
		{
			var chkBox = $("input:checkbox[id=location]:checked");
			{
				chk_Box = Array();
				len = chkBox.length;
				for(i=0;i<len;i++)
				{
					chk_Box[i] = chkBox[i].value;
				}
				pos_location =chk_Box.join("~");
				var location = pos_location;
				if(location == '') {
					$("#loc").after('<span class="error">You forgot to choose the pOS Location.</span>');
					hasError = true;
				} 
			}
		}
		
	//----------------------------------//
		if($("#information_type").val()=='TITLE31-WEBINAR')
		{
			var first_name = $("#first_name").val();
			if(typeof(first_name)!='undefined')
			if(zip == '') {
				$("#first_name").after('<span class="error">You forgot to enter the First name.</span>');
				hasError = true;
			} 
			
		
			//----------------------------//
			var last_name = $("#last_name").val();
			if(typeof(last_name)!='undefined')
			if(last_name == '') {
				$("#last_name").after('<span class="error">You forgot to enter the Last name.</span>');
				hasError = true;
			} 
			//----------------------------------//
			/*var company = $("#company").val();
			if(typeof(company)!='undefined')
			if(company == '') {
				$("#company").after('<span class="error">You forgot to enter the Company name.</span>');
				hasError = true;
			} 

			var title = $("#title").val();
			if(typeof(title)!='undefined')
			if(title == '') {
				$("#title").after('<span class="error">You forgot to enter the Title.</span>');
				hasError = true;
			} */
			
			var primary_contact = $("#phone").val();
			if(primary_contact == '') {
				$("#phone").after('<span class="error">You forgot to enter phone no.</span>');
				hasError = true;
			} else if(phoneReg.test(primary_contact)) {
				$("#phone").after('<span class="error">Enter valid phone no.</span>');
				hasError = true;
			}
			var street = $("#street").val();
			if(typeof(street)!='undefined')
			if(street == '') {
				$("#street").after('<span class="error">You forgot to enter the Street name.</span>');
				hasError = true;
			}
		}	 
			
		

		//----------------------------------//
		if($("#information_type").val()=='FRAUD PREVENTION')
		{
			var first_name = $("#first_name").val();
			if(typeof(first_name)!='undefined')
			if(zip == '') {
				$("#first_name").after('<span class="error">You forgot to enter the First name.</span>');
				hasError = true;
			} 
			
		
			//----------------------------//
			var last_name = $("#last_name").val();
			if(typeof(last_name)!='undefined')
			if(last_name == '') {
				$("#last_name").after('<span class="error">You forgot to enter the Last name.</span>');
				hasError = true;
			} 
			//----------------------------------//
			/*var company = $("#company").val();
			if(typeof(company)!='undefined')
			if(company == '') {
				$("#company").after('<span class="error">You forgot to enter the Company name.</span>');
				hasError = true;
			} 

			var title = $("#title").val();
			if(typeof(title)!='undefined')
			if(title == '') {
				$("#title").after('<span class="error">You forgot to enter the Title.</span>');
				hasError = true;
			} */
			var primary_contact = $("#phone").val();
			if(primary_contact == '') {
				$("#phone").after('<span class="error">You forgot to enter phone no.</span>');
				hasError = true;
			} else if(phoneReg.test(primary_contact)) {
				$("#phone").after('<span class="error">Enter valid phone no.</span>');
				hasError = true;
			}
			
			var street = $("#street").val();
			if(typeof(street)!='undefined')
			if(street == '') {
				$("#street").after('<span class="error">You forgot to enter the Street name.</span>');
				hasError = true;
			}
		}
		//----------------------------------//
	
		if(hasError)
		return false;
		else
		return true;
}

// Validating registration form
function registerUser()
{
	var test = validateRegistration();
	if(test)
	{
		addNewUser();
	}
}
function validateRegistration()
{
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;//[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}
		var alphaNumReg = /^[^a-zA-Z0-9_\.\-]$/;
		var stringReg = /^[^A-Za-z\s\.\' ]$/;
		var phoneReg = /^[^0-9\-\(\)\,\ \+-]+$/;
		var numReg = /^[^0-9]+$/;
		var selectReg = /^[^1-9]+$/;
		var ageReg = /^[0-9][0-9]?$/;
		//-------------- validation start ----------------//
		var first_name = $("#reg_first_name").val();
		if(first_name == '') {
			$("#reg_first_name").after('<span class="error">You forgot to enter Your Name.</span>');
			hasError = true;
		} else if(stringReg.test(first_name)) {
			$("#reg_first_name").after('<span class="error">Name can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var last_name = $("#reg_last_name").val();
		if(last_name == '') {
			$("#reg_last_name").after('<span class="error">You forgot to enter Your Last Name.</span>');
			hasError = true;
		} else if(stringReg.test(last_name)) {
			$("#reg_last_name").after('<span class="error">Last Name can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var user_name = $("#reg_user_name").val();
		if(user_name == '') {
			$("#reg_user_name").after('<span class="error">You forgot to enter Your User Name.</span>');
			hasError = true;
		} else if(stringReg.test(user_name)) {
			$("#reg_user_name").after('<span class="error">User Name can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var user_password = $("#reg_user_password").val();
		if(user_password == '') {
			$("#reg_user_password").after('<span class="error">You forgot to enter password.</span>');
			hasError = true;
		} else if(stringReg.test(user_password)) {
			$("#reg_user_password").after('<span class="error">password can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var company = $("#reg_company").val();
		if(company == '') {
			$("#reg_company").after('<span class="error">You forgot to enter Company.</span>');
			hasError = true;
		} else if(stringReg.test(company)) {
			$("#reg_company").after('<span class="error">Company can contain only alphabet.</span>');
			hasError = true;
		}
		
		//----------------------------------------------------------------------------//
		var title = $("#reg_title").val();
		if(title == '') {
			$("#reg_title").after('<span class="error">You forgot to enter Title.</span>');
			hasError = true;
		} else if(stringReg.test(title)) {
			$("#reg_title").after('<span class="error">Title can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var street = $("#reg_street").val();
			if(street == '') {
				$("#reg_street").after('<span class="error">You forgot to enter the Street name.</span>');
				hasError = true;
			}
		//----------------------------------------------------------------------------//
		var zip = $("#reg_zip").val();
		if(zip == '') {
			$("#reg_zip").after('<span class="error">You forgot to enter the Zip address.</span>');
			hasError = true;
		} else if(alphaNumReg.test(zip)) {
			$("#reg_zip").after('<span class="error">Enter a valid Zip address. It should be alphanumeric.</span>');
			hasError = true;
		}
		//--------------------------------------------//
		
		//----------------------------------------------------------------------------//
		var email = $("#reg_email").val();
		if(email == '') {
			$("#reg_email").after('<span class="error">You forgot to enter the email address.</span>');
			hasError = true;
		} else if(!emailReg.test(email)) {
			$("#reg_email").after('<span class="error">Enter a valid email address.</span>');
			hasError = true;
		}
		
		//----------------------------------------------------------------------------//
		if(hasError)
		return false;
		else
		return true;
}
function addNewUser()
{
	$("#register").attr("disabled",true);
	$("#register").val("Processing..");
	
	var name = $("#reg_first_name").val();
	var last_name = $("#reg_last_name").val();
	user_name = $("#reg_user_name").val();
	user_password = $("#reg_user_password").val();
	var company = $("#reg_company").val();
	var title = $("#reg_title").val();
	var street = $("#reg_street").val();
	var zip = $("#reg_zip").val();
	mob_no = $("#reg_mob_no").val();
	email = $("#reg_email").val();
	city = $("#reg_city").val();
	state = $("#reg_state").val();
	country = $("#reg_country").val();
	$.post( sitePath +"/classes/ajax-request-responce.php", {"action_to_do":"register","name":name,"last_name":last_name,"user_name":user_name, "user_password":user_password,"company":company,"street":street,"title":title,"zip":zip,"email":email,"mob_no":mob_no,
		   "country":country,"state":state,"city":city }, function(data){
		//alert(data);
		result = data.split("!");
		if(result[0] == "V") {
			if(result[1] =="true") {
				$("#registration").fadeOut(function(){$("#reg_mes").fadeIn(1000);});
			}else{
				$("#register").attr("disabled",false);
				$("#register").val("SUBMIT");
			}				
		}
		
	});
}
function validateSignIn()
{
	$(".error").hide();
	var hasError = false;
	var user_name = $("#user_name").val();
	if(user_name == '') {
		$("#user_name").after('<span class="error">You forgot to enter User Name.</span>');
		hasError = true;
	} 
	//----------------------------------------------------------------------------//
	var password = $("#password").val();
	if(password == '') {
		$("#password").after('<span class="error">You forgot to enter password.</span>');
		hasError = true;
	}
	if(hasError)
	return false;
	else
	return true;
}
function validateLoginUser()
{
	var test = validateSignIn();
	if(test)
	{
		successLoggin();
	}
}
function successLoggin()
{
	$(".button-submit").attr("disabled",true);
	$(".button-submit").val("Processing..");
	
	var user_name = $("#user_name").val();
	var password = $("#password").val();
	$.post(sitePath+"/classes/ajax-request-responce.php",{"action_to_do":"login_user","user_name":user_name,"user_password":password},
	function(data){
			//prompt("R",data);
			result = data.split("!");
			if(result[0] =="V")
			{
				if(result[1] == 'valid')
				{
					location.href=sitePath+"/fraud-prevention-library.php";
				}
				else{
					$(".button-submit").attr("disabled",false);
					$(".button-submit").val("SUBMIT");
					$("#error").html("<center><span class=error> "+result[1]+" </span></center>");
				}
			}

	});
}
//------------------------------- Channel-partner-------------------------//
function addChannel()
{
	var test = validateChannel();
	if(test)
	{
		submitChannelDetail();
	}
}
function validateChannel()
{
	$(".error").hide();
	var hasError = false;
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;//[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}
	var alphaNumReg = /^[^a-zA-Z0-9_\.\-]$/;
	var stringReg = /^[^A-Za-z\s\.\' ]$/;
	var phoneReg = /^[^0-9\-\(\)\,\ \+-]+$/;
	var numReg = /^[^0-9]+$/;
	var selectReg = /^[^1-9]+$/;
	//-------------- validation start ----------------//
		var name = $("#name").val();
		if(name == '') {
			$("#name").after('<span class="error">You forgot to enter Your Name.</span>');
			hasError = true;
		} else if(stringReg.test(name)) {
			$("#name").after('<span class="error">Name can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var address = $("#address").val();
		if(address == '') {
			$("#address").after('<span class="error">You forgot to enter Mailing Address.</span>');
			hasError = true;
		} 
		//---------------------------------------------------------------------------//
		var city = $("#city").val();
		if(city == '') {
			$("#city").after('<span class="error">You forgot to enter City.</span>');
			hasError = true;
		} else if(alphaNumReg.test(city)) {
			$("#city").after('<span class="error">City can contain only alphanumeric characters.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var state = $("#state").val();
		if(state == '') {
			$("#state").after('<span class="error">You forgot to enter State.</span>');
			hasError = true;
		} else if(alphaNumReg.test(state)) {
			$("#state").after('<span class="error">State can contain only alphanumeric characters.</span>');
			hasError = true;
		}
		//--------------------------------------------//
		var zip = $("#zip").val();
		if(zip == '') {
			$("#zip").after('<span class="error">You forgot to enter the Zip address.</span>');
			hasError = true;
		} else if(alphaNumReg.test(zip)) {
			$("#zip").after('<span class="error">Enter a valid Zip address. It should be alphanumeric.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var country = $("#country").val();
		if(country == '') {
			$("#country").after('<span class="error">You forgot to enter the Country.</span>');
			hasError = true;
		} else if(alphaNumReg.test(country)) {
			$("#country").after('<span class="error">Country can contain only alphanumeric characters.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var primary_contact = $("#primary_contact").val();
		if(primary_contact == '') {
			$("#primary_contact").after('<span class="error">You forgot to enter primary Contact No.</span>');
			hasError = true;
		} else if(phoneReg.test(primary_contact)) {
			$("#primary_contact").after('<span class="error">Enter valid primary Contact no.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var title = $("#title").val();
		if(title == '') {
			$("#title").after('<span class="error">You forgot to enter Title.</span>');
			hasError = true;
		} else if(stringReg.test(title)) {
			$("#title").after('<span class="error">Title can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		
		//----------------------------------------------------------------------------//
		
		var email = $("#email").val();
		if(email == '') {
			$("#email").after('<span class="error">You forgot to enter the email address.</span>');
			hasError = true;
		} else if(!emailReg.test(email)) {
			$("#email").after('<span class="error">Enter a valid email address.</span>');
			hasError = true;
		}
	if(hasError)
	return false;
	else
	return true;
}
function submitChannelDetail()
{
	$(".button-submit").attr("disabled",true);
	$(".button-submit").val("Processing..");
	name = $("#name").val();
	address = $("#address").val();
	city = $("#city").val();
	state = $("#state").val();
	zip = $("#zip").val();
	country = $("#country").val();
	primary_contact = $("#primary_contact").val();
	title = $("#title").val();
	phone = $("#phone").val();
	fax = $("#fax").val();
	cell_phone = $("#cell_phone").val();
	email = $("#email").val();
	business_line = $("#business_line").val();
	years = $("#years").val();
	revenue = $("#revenue").val();
	sales = $("#sales").val();
	product = $("#product").val();
	customer = $("#customer").val();
	comment = $("#comment").val();
	$.post(sitePath + "/classes/ajax-request-responce.php", {"action_to_do":"channel","name":name,"address":address, "zip":zip,"email":email,"cell_phone":cell_phone,"primary_contact":primary_contact,"title":title,"country":country,"state":state,"city":city,"phone":phone,"fax":fax,"business_line":business_line,"years":years,"revenue":revenue,"sales":sales,"product":product,"customer":customer,"comment":comment}, function(data){
		//alert(data);
		result = data.split("!");
		if(result[0] == "V") {
			if(result[1] =="true") {
				$("#channel_partner").fadeOut(function(){$("#channel_mes").fadeIn(1000);});
			}else{
				$(".button-submit").attr("disabled",false);
				$(".button-submit").val("SUBMIT");
			}				
		}
		
	});
}
///--------------------- Channel partner Ends ------------------------------------------//
// -------------------------- Contact Starts ----------------------------------------//
function addContact()
{
	var test = validateContact();
	if(test)
	{
		submitContactDetail();
	}
}
function validateContact()
{
	$(".error").hide();
	var hasError = false;
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;//[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}
	var alphaNumReg = /^[^a-zA-Z0-9_\.\-]$/;
	var stringReg = /^[^A-Za-z\s\.\' ]$/;
	var phoneReg = /^[^0-9\-\(\)\,\ \+-]+$/;
	var numReg = /^[^0-9]+$/;
	var selectReg = /^[^1-9]+$/;
	//-------------- validation start ----------------//
		var name = $("#name").val();
		if(name == '') {
			$("#name").after('<span class="error">You forgot to enter Your Name.</span>');
			hasError = true;
		} else if(stringReg.test(name)) {
			$("#name").after('<span class="error">Name can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var company = $("#company").val();
		if(name == '') {
			$("#company").after('<span class="error">You forgot to enter Company.</span>');
			hasError = true;
		} else if(stringReg.test(company)) {
			$("#company").after('<span class="error">Company can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		var title = $("#title").val();
		if(title == '') {
			$("#title").after('<span class="error">You forgot to enter Title.</span>');
			hasError = true;
		} else if(stringReg.test(title)) {
			$("#title").after('<span class="error">Title can contain only alphabet.</span>');
			hasError = true;
		}
		//----------------------------------------------------------------------------//
		
		//----------------------------------------------------------------------------//
		
		var email = $("#email").val();
		if(email == '') {
			$("#email").after('<span class="error">You forgot to enter the email address.</span>');
			hasError = true;
		} else if(!emailReg.test(email)) {
			$("#email").after('<span class="error">Enter a valid email address.</span>');
			hasError = true;
		}
	if(hasError)
	return false;
	else
	return true;
}

function submitContactDetail()
{
	$(".button-submit").attr("disabled",true);
	$(".button-submit").val("Processing...");
	name = $("#name").val();
	company = $("#company").val();
	title = $("#title").val();
	phone = $("#phone").val();
	email = $("#email").val();
	comment = $("#comment").val();
	$.post(sitePath +"/classes/ajax-request-responce.php", {"action_to_do":"contact","name":name,"company":company,"title":title,"phone":phone,"email":email,"comment":comment}, function(data){
		//alert(data);		
		result = data.split("!");
		if(result[0] == "V") {
			if(result[1] =="true") {
				//$("#qot_mes").fadeIn(300);
				$("#contact").fadeOut(function(){$("#contact_mes").fadeIn(1000);});
			}else{
				$(".button-submit").attr("disabled",false);
				$(".button-submit").val("SUBMIT");
			}				
		}
		
	});
	
}
function forgotPassword()
{
	$("#login_form").fadeOut(function(){$("#forgot_pas").fadeIn(1000);});
}
function informPassword()
{
	var test = validatePassword();
	if(test)
	{
		submitPasswordDetail();
	}
}
function validatePassword()
{
	$(".error").hide();
	var hasError = false;
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;//[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}
	var user_id = $("#user_id").val();
	if(user_id == '') {
		$("#user_id").after('<span class="error">You forgot to enter User Name.</span>');
		hasError = true;
	} 
	//----------------------------------------------------------------------------//
	var pas_email = $("#pas_email").val();
		if(pas_email == '') {
			$("#pas_email").after('<span class="error">You forgot to enter the Email.</span>');
			hasError = true;
		} else if(!emailReg.test(pas_email)) {
			$("#pas_email").after('<span class="error">Enter a valid email address.</span>');
			hasError = true;
		}
	if(hasError)
	return false;
	else
	return true;
}
function submitPasswordDetail()
{
	
	var user_name = $("#user_id").val();
	var pas_email = $("#pas_email").val();
	$.post(sitePath +"/classes/ajax-request-responce.php",{"action_to_do":"set_password","user_id":user_name,"email":pas_email},function(data)
	{
		//prompt("R",data);
		result = data.split("!");
		if(result[0] =="V")
			{
				if(result[1] == 'valid')
				{
					$("#forgot_pas").fadeOut(function(){$("#password_mes").fadeIn(1000);});
				}
				else
				$("#error_pas").html("<center><span class=error>Either User name or email address is wrong!</span></center>");
			}
	});
	
}
function validateUser(value)
{	
	
	var user = value;
	$.post(sitePath +"/classes/ajax-request-responce.php",{"action_to_do":"chk_user","user_id":user},function(data)
	{
		//prompt("R",data);
		result = data.split("!");
		if(result[0] =="V")
			{
				if(result[1] == 'valid')
				{
					$(".error").hide();
				}
				else{
					$(".error").hide();
					$("#user_name").after('<span class="error">User Name already exist.</span>');
					$("#user_name").select();
				
				}
			}
	});
	
}
