//All pages functions
	function set_language(language_id){
		document.forms['lang_select'].language.value = language_id; 
		document.forms['lang_select'].submit();
	}

	function doLogout(){
		document.forms['user_form'].act.value = 'user_logout';
		document.forms['user_form'].submit();
	}

//Category page functions
	function addToCart(prod_id){
		document.forms['prod_form'].req.value = "add";
		document.forms['prod_form'].prod_id.value = prod_id;
		el = document.getElementById('qty_'+prod_id);
		
		document.forms['prod_form'].qty.value = el.value;
		document.forms['prod_form'].submit();
	}


//Shopping Cart page functions
	function delFromCart(prod_id){
		document.forms['prod_list'].req.value = "del";
		document.forms['prod_list'].prod_id.value = prod_id;
		document.forms['prod_list'].submit();
	}

	function updateCart(){
		document.forms['prod_list'].req.value = "update";
		document.forms['prod_list'].submit();
	}
    function applyCoupon(){
    	if(document.forms['prod_list'].code.value != ''){
			document.forms['prod_list'].req.value = "apply_coupon";
			document.forms['prod_list'].submit();
		}
	}
	function unapplyCoupon(){
    
			document.forms['prod_list'].req.value = "unapply_coupon";
			document.forms['prod_list'].submit();
	
	}
//Checkout page functions
	function doSignup(){
		document.checkout_form.req.value = 'do_signup';
		document.checkout_form.submit();
	}

	function shippingAddressChaged(option){
		el = document.getElementById('shipping_info');
		if (option == 'same') {
//			alert(el.style.display);
			el.style.display = 'none';
		} else {
			el.style.display = 'block';
		}
	}
	
	function shippingAmountChanged(ship_value){
		document.checkout_form.shipping_method.value;
	}
	
	function paymentMethodChaged(option){
		el1 = document.getElementById('cc_option');
		el2 = document.getElementById('check_option');
  
		if (option == 'CHECK') {
//			alert(el.style.display);
			el1.style.display = 'none';
			el2.style.display = 'block'; 
			 
		} else 
			if(option!='MONEY' && option !='CASH'){
				el1.style.display = 'block';
				el2.style.display = 'none'; 
			
			}
			else{
				el1.style.display = 'none';
				el2.style.display = 'none'; 
				
			}
				
	}


// Show support site in new window
	function showsupportsite(url)	{
		window.open(url,'name','height=450,width=540,left=20,top=20,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no,minimizable=no,modal=yes');

	}

var xmlHttp = getXmlHttpRequestObject();

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Can't browse this site");
	}
}

function AjaxRequest(path){
	
	xmlHttp.open("POST", path , true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttp.onreadystatechange = returnResult;
	xmlHttp.send('');

}


function returnResult(){
	if (xmlHttp.readyState==4 ){
      		n1 = xmlHttp.responseText.indexOf('<complete>')+10;
          n2= xmlHttp.responseText.indexOf('</complete>');
          
		  res=xmlHttp.responseText.substr(n1,n2-n1);
		  eval(res);
	}
}