jQuery(document).ready(function($) {
	
	$('#enq_form').submit(function(e) {

		login();
		e.preventDefault();
		
	});

       $('#infoForm').submit(function(e) {

		update_info();
		e.preventDefault();
		
	});
	
	
});

function login()
{
	
	//var Enx_base_url = 'http://localhost/clixoo/';
	hideshow('loading',1);
	error(0);
	$.ajax({
		type: "POST",
		url: "/includes/send_enq.php",
		data: $('#enq_form').serialize(),
		dataType: "json",
		success: function(msg){
			
			if(parseInt(msg.status)==1)
			{
				error(1,msg.txt);
				$('#enq_form').each(function(){
					this.reset();
					});
			}
			else if(parseInt(msg.status)==0)
			{
				error(1,msg.txt);
					

			}
			hideshow('loading',0);
		}
	});
}

function update_info()
{
	
	//var Enx_base_url = 'http://localhost/clixoo/';
	hideshow('loading',1);
	error(0);
	$.ajax({
		type: "POST",
		url: "/includes/update_info.php",
		data: $('#infoForm').serialize(),
		dataType: "json",
		success: function(msg){
			
			if(parseInt(msg.status)==1)
			{
				error(1,msg.txt);
				$('#infoForm').each(function(){
					this.reset();
					});
			}
			else if(parseInt(msg.status)==0)
			{
				error(1,msg.txt);
					

			}
			hideshow('loading',0);
		}
	});
}


function hideshow(el,act)
{
	if(act) $('#'+el).css('display','block');
	else $('#'+el).css('display','none');
}

function error(act,txt)
{
	hideshow('error',act);
	if(txt) $('#error').html(txt);
}
