//-------------------------------------------------------------
// 文件名称: product.js
// 描   述: 脚本语言
// 修改标识: Modify By 李传 2008-11-12
// 修改内容: 不显示配件商品 
//          function selectid(path)中fitobj[i].value.indexof("fitting")
//          改为fitobj[i].name.indexOf("fitting_9");
//-------------------------------------------------------------
var isloading = 0;
function selecttabpro(obj, index, areaname){
    var node = childs(obj.parentNode.childNodes);
    for(var i=0;i<node.length;i++){
		node[i].id = "";
		getobj(areaname + (i+1)).style.display = "none";	
	}
	obj.id = "proselect";
	getobj(areaname + index).style.display = "";
}

function selectid(path){
	var storage = $("storage").value;
    var proid = document.getElementById("proid").value;
	var outofstock = $("outofstock").value;
	
	if(storage <= 0){
		if(outofstock == "0"){
			if(confirm('库存不足，是否进行缺货登记')){
				window.location.href=path + 'productreg.aspx?id=' + proid;
			}
		}else{
			alert('库存不足!');	
		}
		return false;	
	}
	//自定义属性
    var selfpropobj = document.getElementsByName("selfproperty");
	var selfproperty = "";
	for(var i=0;i<selfpropobj.length;i++){
        if(i==0){
            selfproperty = selfpropobj[i].options[selfpropobj[i].selectedIndex].value;
        }else{
            selfproperty += "," + selfpropobj[i].options[selfpropobj[i].selectedIndex].value;
        }
    }
	
	if(isloading == 1){
		alert('价格读取中，请稍等!');	
		return false;
	}
	
	//商品属性
    var propobj = document.getElementsByName("property");
	var count = $("buynum").value;
	if (count == "0") 
		count = "1";
    var url = path + "cart.aspx?id=" + proid + "&act=buy&count=" + count + "&prop=";
    var propvalue = "";
    var propname = "";
    
    var fit = "";
    
    //获取选中商品ID  Mod By 钟登科 2008-11-24
    var fitobj = document.getElementsByTagName("input");
    for(var i = 0; i < fitobj.length; i++){
        if(fitobj[i].name.indexOf("fitting_") != -1)
        {
            if(fitobj[i].checked)
            {
                fit += "," + fitobj[i].value;
            }
        }
    }

    for(var i=0;i<propobj.length;i++){
        if(i==0){
            propvalue = propobj[i].value;
            propname = propobj[i].options[propobj[i].selectedIndex].text;
        }else{
            propvalue += "," + propobj[i].value;
            propname += "," + propobj[i].options[propobj[i].selectedIndex].text;
        }
    }
	var price = "0";
	if($("detailprice")){
		price = $("detailprice").innerHTML;
	}
	
    window.location.href = url + propvalue + "&propname=" + escape(propname) + "&selfprop=" + escape(selfproperty) + "&fit=" + fit + "&price=" + price;
	return false;
}
//AJAX获取价格
function GetPriceDetail(path, id){
	var pstr = ",";
	var propertys = document.getElementsByName("property");
	if(propertys){
		for(var i=0;i<propertys.length;i++){
			pstr += propertys[i].value + ",";
		}
	}
	//if(pstr != ","){
	isloading = 1;
	var url = path + "product.aspx?id="+ id +"&act=detailprice&pstr=" + pstr + "&d=" + Date();

	var myajax = new Ajax.Updater(    
		{success: 'detailprice'},     
		url,    
		{    
			asynchronous:true,    
			method: 'get',    
			evalscrīpts:true,
			onComplete : Canbuy
		}    
	);   
	//}
}

function Canbuy(){
	isloading = 0;
}