function check_price(quantity,price){
	var limit = quantity.length;

	var tmpqnt = '';
	var i = 0;
	for(i = 0; i < limit; i++){
		tmpqnt = tmpqnt+'9';
	}
	tmpqnt = price * tmpqnt; 
	tmpqnt = parseInt(tmpqnt);
	if(tmpqnt.toString().length <= 10){
		return true;
	}
	return false;
}	

// The follow variables are all the HTTP Request for the next AJAX functions.
var httpUpdateProduct = getHTTPObject();
var httpBoxCartContent = getHTTPObject();
var httpCartContent = getHTTPObject();
var product_quantity = -1;

/**
 * updateCart
 * This function is used to update the cart content throw AJAX
 * When the page is loaded in AJAX then is called the function updateProductProcessChange()
 *
 * @param country (int) the country id [default=undefined]
 * @param zone (int) the zone id [default=undefined]
 * @param method (string) the shipping method [default=undefined]
 * @author <a href="mailto:alberto@maxpho.com">Alberto Fontana</a>
 */
function updateCart(country, zone, method) { 
	url = linkUpdateCartContent;
	if( country!=undefined ){
		var parameters = "shipping_country="+country;
		url = concatLink2Parameter(url, parameters);
	}
	if( zone!=undefined ){
		var parameters = "shipping_zone="+zone;
		url = concatLink2Parameter(url, parameters);
	}
	if( method!=undefined ){
		var parameters = "shipping_method="+method;
		url = concatLink2Parameter(url, parameters);
	}
	var parameters = "rnd="+Math.random();
	url = concatLink2Parameter(url, parameters);

	getObject("wait").innerHTML = '<img src="images/wait_medium.gif" border="0">';
	loadXMLDoc(url, 'updateCartProcessChange()', httpCartContent);
}

/**
 * updateCartProcessChange
 * This function is used to update the shopping cart
 * and is called from the function updateCart()
 *
 * @author <a href="mailto:alberto@maxpho.com">Alberto Fontana</a>
 */
function updateCartProcessChange(){
	getObject("cart_content").innerHTML=httpCartContent.responseText;
	if(linkUpdateCartBox!=""){
		boxCartContent();	
	}
}

/**
 * updateProducts
 * Is an ajax function used to capture the real insertion of the number of product that we want
 * buy, the function use setTimeout and clearTimeout to manage the time problem in insertion of quantity
 *
 * @param product the name of id that contain the quantity of product that the customers want buy
 * @param value the quantity of product that customers want buy
 *
 * @author Alessandro Venturelli
 */
function updateProducts(product, value, delay) {
	if(delay != 'no_delay'){
		if(product_quantity != -1){
			clearTimeout(product_quantity);
		}
		product_quantity = setTimeout("runUpdateProducts('"+product+"','"+value+"')",500);
	}else{
		runUpdateProducts(product,value);
	}
}

/**
 * runUpdateProducts
 * This ajax function update the products quantity
 * and it use updateProductProcessChange for update all the values of the shopping cart
 *
 * @param product the name of id that contain the current value of the product in shopping cart
 * @param value the value that represent the current quantity of a product in shopping cart 
 * @author <a href="mailto:alberto@maxpho.com">Alberto Fontana</a>
 */
function runUpdateProducts(product, value){
	getObject("wait").innerHTML = '<img src="images/wait_medium.gif" border="0">';

	httpUpdateProduct = new getHTTPObject(); 
	var postValue = product+"="+value;

	var parameters = "action=cart_update&rnd="+Math.random();
	url = concatLink2Parameter(linkUpdateCartList, parameters);

	loadXMLDocPost(url,null ,"updateCart()", httpUpdateProduct, postValue);
}

/*
 * boxCartContent
 * This AJAX function empty the box cart content
 * and it use emptyCartProcessChange for update the box shopping cart
 * @author <a href="mailto:alberto@maxpho.com">Alberto Fontana</a>
 */
function boxCartContent() { 
	var parameters = "rnd="+Math.random();
	url = concatLink2Parameter(linkUpdateCartBox, parameters);
	loadXMLDoc(url, "boxCartContentProcessChange()", httpBoxCartContent);
}

/*
 * boxCartContent
 * This function is used to update the shopping cart box
 * and is called from the function boxCartContent()
 * @author <a href="mailto:alberto@maxpho.com">Alberto Fontana</a>
 */
function boxCartContentProcessChange() { 
	getObject("box_cart").innerHTML=httpBoxCartContent.responseText;
}

