//显示clasp信息
function product_clasp_list(design){
	delete xmlhttp ;
	var xmlhttp;
	if (xmlhttp==null || typeof(xmlhttp)!="object"){
		try{
			xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
		}catch(e){
			try{
				xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
			}catch(e){
				try{
					xmlhttp= new XMLHttpRequest();
				}catch(e){}
			}
		}
	}
	xmlhttp.onreadystatechange=function(){
		var i=0;
		if (4==xmlhttp.readyState){
			if (200==xmlhttp.status){
				var return_value=xmlhttp.responseText;
				if (return_value != null & return_value != ""){
					document.getElementById("div_content_clasp").innerHTML = unescape(escape(return_value));
				}
			}
		delete xmlhttp ; 
		xmlhttp=null;
		CollectGarbage;
		}
	}
	xmlhttp.open("post", "/ajax_product_clasp_list.php", true);
	xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded;text/xml;charset=utf-8");
	xmlhttp.send("act=list&design="+design);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
//显示默认FREE的clasp
function default_select_clasp(design){
	delete xmlhttp ;
	var xmlhttp;
	if (xmlhttp==null || typeof(xmlhttp)!="object"){
		try{
			xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
		}catch(e){
			try{
				xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
			}catch(e){
				try{
					xmlhttp= new XMLHttpRequest();
				}catch(e){}
			}
		}
	}
	xmlhttp.onreadystatechange=function(){
		var i=0;
		if (4==xmlhttp.readyState){
			if (200==xmlhttp.status){
				var return_value=xmlhttp.responseText;
				if (return_value != null & return_value != ""){
					var data_arr=return_value.split("|||");
					var str_obj	 = data_arr[0];
					var price	 = data_arr[1];
					 select_clasp(document.getElementById(str_obj), price);
				}
			}
		delete xmlhttp ; 
		xmlhttp=null;
		CollectGarbage;
		}
	}
	xmlhttp.open("post", "/ajax_product_clasp_list.php", true);
	xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded;text/xml;charset=utf-8");
	xmlhttp.send("act=free&design="+design);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
//选择clasp时处理事件
//str_obj为clasp内容的对象，price为clasp的价格
function select_clasp(str_obj, price){
	//将选中的clasp内容显示在右边区域
	document.getElementById("choice_content").innerHTML=unescape(escape(str_obj.innerHTML));
	//提出产品的价格
	var product_price = document.frm_cart.price.value;
	product_price = cTrim(product_price.split("-")[0],0);
	if ( ! isNumber(product_price) ) product_price = 0;
	var total_price,total_eur_price;
	total_price = parseFloat(product_price) + parseFloat(cTrim(price,0)); //产品价格总和 = 产品价格 + clasp价格
	total_eur_price = parseFloat(total_price) * 0.72;//欧元价格
	total_price = total_price.toFixed(2);
	document.getElementById("total_price_txt").innerHTML = "US$"+total_price;
	document.frm_cart.total_price.value = total_price;
	document.getElementById("total_eur_price_txt").innerHTML = "( EUR " + total_eur_price.toFixed(2) + " )";//显示欧元价格
}

////////////////////////////////////////////////////////////////////////////////////////////////////
//判断是否为数字
function isNumber(oNum) { 
	if(!oNum) return false; 
	var strP=/^\d+(\.\d+)?$/; 
	if(!strP.test(oNum)) return false; 
	try{ 
		if(parseFloat(oNum)!=oNum) return false; 
	} catch(ex) { 
		return false; 
	} 
	return true; 
}
//JS去掉前后空格函数
function cTrim(sInputString,iType){
	var sTmpStr = ' ';
	var i = -1;
	if(iType == 0 || iType == 1)
	{
		while(sTmpStr == ' '){
			++i;
			sTmpStr = sInputString.substr(i,1);
		}
		sInputString = sInputString.substring(i);
	}
	
	if(iType == 0 || iType == 2)
	{
		sTmpStr = ' ';
		i = sInputString.length;
		while(sTmpStr == ' '){
		--i;
		sTmpStr = sInputString.substr(i,1);
		}
		sInputString = sInputString.substring(0,i+1);
	}
	return sInputString;
}
