
function addtobasket(id,listcode,product_type,isValid){  
		var pro_num = 1;
		var pro_size = "-";
		var pro_color = "-";
		var formBuy = document.forms['LEBI_FORMBUY_'+listcode];
		if (formBuy)
		{
			var pro_num = formBuy.elements['pro_num_'+listcode+'_'+id].value;
			var pro_size = formBuy.elements['pro_size_'+listcode+'_'+id].value;
			if (pro_size == "")
			{
				var pro_size = document.getElementById("pro_size_"+listcode+"_"+id+"").options[document.getElementById("pro_size_"+listcode+"_"+id+"").selectedIndex].value;  
			}
			var pro_color = formBuy.elements['pro_color_'+listcode+'_'+id].value;
			if (pro_color == null || pro_color == "")
			{
				var pro_color = document.getElementById("pro_color_"+listcode+"_"+id+"").options[document.getElementById("pro_color_"+listcode+"_"+id+"").selectedIndex].value;  
			}
		}
		var url="Admin_order_cart.asp?action=buy&id="+id+"&pro_num="+pro_num+"&pro_size="+escape(pro_size)+"&pro_color="+escape(pro_color)+"&product_type="+product_type;
		xmlHttp.open("GET", url, true);
        xmlHttp.send(null);  
		xmlHttp1.open("GET", "Ajax_cart.asp?showtype=0&t="+Math.random(), true);
		xmlHttp1.onreadystatechange = upcart;
        xmlHttp1.send(null);  
		fixedtooltip(formBuy.elements['button_'+listcode+'_'+id+''], "<b>恭喜：配件添加成功！</b><br><br><a href='Swant_order.asp'>结帐</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='#'  onclick=\"this.parentNode.style.display=\'none\';return false;\">继续订购</a>", null, null)
}
function upcart() {
  if (xmlHttp1.readyState < 4) {
	carttotalprice.innerHTML="Loading..";
	carttotalnum.innerHTML="Loading..";
  }
  if (xmlHttp1.readyState == 4) {
    var response = xmlHttp1.responseText.split("|");
	carttotalprice.innerHTML=response[0];
	carttotalnum.innerHTML=response[1];
  }
}

var _jsc = {};
_jsc.pos = (function(){
	var t = {};
	t.getX = function (obj){
        var curleft = 0;
        if (obj.offsetParent)
        {
          while (obj.offsetParent){
             curleft += obj.offsetLeft;
             obj = obj.offsetParent;
          }
          curleft += obj.offsetLeft;
        }
        else if (obj.x) {
          curleft += obj.x;
        }
        return curleft;
    };
    t.getY = function (obj){
    var curtop = 0;
        if (obj.offsetParent){
          while (obj.offsetParent){
             curtop += obj.offsetTop;
             obj = obj.offsetParent;
          }
          curtop += obj.offsetTop;
        }
        else if (obj.y)
          curtop += obj.y;
        return curtop;
    };
	return t;
})();

function market_tooltip(c){
	var _tooltips = document.getElementsByTagName('div');
	for (var i=0;i<_tooltips.length;i++) {
		if (_tooltips[i].getAttribute('tooltip') == 'market') _tooltips[i].parentNode.removeChild(_tooltips[i]);
	}
	var _tooltip = document.createElement('div');
	_tooltip.innerHTML = '<div id="fixedtipdiv">'+c+'</div>';
	_tooltip.className = 'mm_tips_market mm_tips_market_right';
	_tooltip.setAttribute('tooltip', 'market');
	//_tooltip.style.width='200px';
	_tooltip.style.zIndex = '9999';
	_tooltip.style.display = 'none';
	return document.body.appendChild(_tooltip);
}

// 气泡控制
var simple_fixedtooltip_timer;
function fixedtooltip(o, _tooltip_body,offsetT,offsetL){
	clearTimeout(simple_fixedtooltip_timer);
	var tooltip = market_tooltip(_tooltip_body);
	tooltip.style.top = offsetT ? (_jsc.pos.getY(o) + offsetT) + 'px' : (_jsc.pos.getY(o) - 80) + 'px';
	tooltip.style.left = offsetL ? (_jsc.pos.getX(o) + offsetL) + 'px' : (_jsc.pos.getX(o) - 80) + 'px';
	tooltip.style.display = 'block';
	tooltip.id = 'market_tooltip';
	tooltip.onmouseover = function() {
		clearTimeout(simple_fixedtooltip_timer);
	}
	simple_fixedtooltip_timer = setTimeout(function(){
		document.getElementById('market_tooltip').style.display = 'none';
	}, 6000);
}


function checkMaxInput(checkcase) 
{
	if (checkcase.other.value.length > maxLen) 
	checkcase.other.value = checkcase.other.value.substring(0, maxLen);
	else checkcase.remLen.value = maxLen - checkcase.other.value.length;
}
function from_checkMaxInput(checkcase) 
{
	if (checkcase.from_other.value.length > maxLen) 
	checkcase.from_other.value = checkcase.from_other.value.substring(0, maxLen);
	else checkcase.from_remLen.value = maxLen - checkcase.from_other.value.length;
}
var item_one='start';
var item_two='start';
function turnit(ss,bb) {
  if (ss.style.display=="none") {
    if(item_one!='start') item_one.style.display="none";
    if(item_one!='start') item_two.src="";
    ss.style.display="";
    item_one=ss;
    item_two=bb;
    bb.src="";
  }
  else {
    ss.style.display="none"; 
    bb.src="";
  }
}

