 
function Update_Cart(product_id){	
    //alert(product_id);
	$('#response'+product_id).html('<img src="images/loading.gif"');
	$.post("files/ajax.php?a=addCart", {
		product_id: product_id,
		product_qty: "1"
	}, function(response){
		//alert(response);
		$('#response'+product_id).html(unescape(response));
		
		window.location.href='shopping_cart.php';
	});
	return false;
}

 
//ADD THE PRODUCT FROM product_details.php PAGE
function Add_To_Cart(product_id,product_qty){
	 
	if(product_qty == "" || product_qty<=0)
	{
		$('#response_error').css('display','block');
		$('#response_error').html('Please enter quantity');
		return false;
	}
	$('#response'+product_id).html('<img src="images/loading.gif"');
	$('#response'+product_qty).html('<img src="images/loading.gif"');
	$.post("files/ajax.php?a=addCart", {
		product_id: product_id,
		product_qty: product_qty
	}, function(response){
		$('#response'+product_id).html(unescape(response));
		$('#response'+product_qty).html(unescape(response));
		if(response!="")
		{
			$('#response_error').css('display','block');
			$('#response_error').html(unescape(response));
			return false;
			} else {
		window.location.href='shopping_cart.php';
		}
	});
	return false;
}

function copy_value(){
	//alert($('#chkBox').attr("checked"));	
	if($('#chkBox').attr("checked")==true){
		$('#shipping_name').val($('#billing_name').val());
		$('#shipping_city').val($('#billing_city').val());
		$('#shipping_address').val($('#billing_address').val());
		$('#shipping_state').val($('#billing_state').val());
		$('#shipping_postcode').val($('#billing_postcode').val());
		$('#shipping_state').val($('#billing_state').val());
		$('#shipping_country').val($('#billing_country').val());
	}
	else {
		$('#shipping_name').val("");
		$('#shipping_city').val("");
		$('#shipping_address').val("");
		$('#shipping_state').val("");
		$('#shipping_postcode').val("");
		$('#shipping_state').val("");
		$('#shipping_country').val("");	
	}
}
function same_value(){
	//alert($('#chkBox').attr("checked"));	
	if($('#chkBox').attr("checked")==true){
		$('#billing_address').val($('#company_address').val());
		$('#billing_city').val($('#company_city').val());
		$('#billing_state').val($('#company_state').val());
		$('#billing_postcode').val($('#company_zip').val());
	}
	else {
		$('#billing_address').val("");
		$('#billing_city').val("");
		$('#billing_state').val("");
		$('#billing_postcode').val("");
		
	}
}


function same_val(){
	//alert($('#chkBox').attr("checked"));	
	if($('#chkBox').attr("checked")==true){
 		$('#shipping_company').val($('#billing_company').val());
		$('#shipping_name').val($('#user_fname').val());
		$('#shipping_phone').val($('#billing_phone').val());
		$('#shipping_address').val($('#billing_address').val());
		$('#shipping_email').val($('#user_email').val());
		$('#shipping_city').val($('#billing_city').val());
		$('#shipping_state').val($('#billing_state').val());
		$('#shipping_zipcode').val($('#billing_zipcode').val()); 
		$('#shipping_zipcode').val($('#billing_zipcode').val()); 
		$('#shipping_country').val($('#billing_country').val());
 	}  
	else {
		$('#shipping_company').val("");
		$('#shipping_name').val("");
		$('#shipping_phone').val("");
		$('#shipping_address').val("");
		$('#shipping_email').val("");
 		$('#shipping_city').val("");
		$('#shipping_state').val("");
		$('#shipping_zipcode').val("");
		$('#shipping_country').val("");
	  	 }
}
 
 
//***********************Email Exist in databse or not*****************************************
function email_check(email_id){	
	var span_id="emailChk";
	$('#'+span_id).html('<img src="images/ajax-loader.gif" />');
	$.get("files/ajax.php?a=email_check", {
		email_id: email_id
	}, function(response){
		//alert(unescape(response));
		if(unescape(response)=="0"){
				$('#'+span_id).html("<font color='#ff0000'><b>Email Id already exist.</b></font>");
				if(span_id!="")$('#user_email').val("");
				$('#user_email').val("");
		}
		else {
				$('#'+span_id).html("");
		}
		//window.location.href='user_management.php';
	});
	return false;
}
//***********************Email Exist in databse or not*****************************************
function forgot_password(email_id){	
	var span_id="response";
	$('#'+span_id).html('<img src="images/ajax-loader.gif" />');
	$.post("login.php?a=forgot", {
		email_id: email_id,
		action: "ajax"
	}, function(response){
		$('#'+span_id).html(unescape(response));
		if(unescape(response).search("success")>0){
			$('#form_input').hide();
			$('#form_message').show();
			//window.location.href='user_management.php';
		}
	});
	return false;
}


function special_alert(){	
   // alert('amresh');
     var val=$('#alert_email').val();
	 if(val==""){
		 //alert('blanck');
		$('#alert_email').addClass("ajax_error");
		return false;
	}
		if(checkEmail(val)==false)
     	{
      		$('#alert_email').addClass("ajax_error");
      		return false; 
    	}
 			$('#res').html('<img src="images/loading.gif"');
			$.post("files/ajax.php?a=special_alert", {
			alert_email: val 
			}, function(response){
 			if(response==1)
			{
				alert("Email All Ready Present");
			}
			else
			{
				$('#res').html('Saved');
			}
		 
  });
	return false;
}

function checkEmail(myForm)
{
   if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm)){
   return (true)
  }
    $('#alert_email').addClass("ajax_error");
    return (false)
}


