﻿////采购清单
function gid(id)
  {return document.getElementById?document.getElementById(id):null;}
function gname(name)
  {return document.getElementsByTagName?document.getElementsByTagName(name):new Array()}
  function ScreenConvert() {
      var browser = new Browser();
      var objScreen = gid("ScreenOver");
      if (!objScreen)
          var objScreen = document.createElement("div");
      var oS = objScreen.style;
      objScreen.id = "ScreenOver";
      oS.display = "block";
      oS.top = oS.left = oS.margin = oS.padding = "0px";
      if (document.body.clientHeight)
      { var wh = document.body.clientHeight + "px"; }
      else if (window.innerHeight)
      { var wh = window.innerHeight + "px"; }
      else {
          var wh = "100%";
      }
      var W = parseInt(window.screen.width) - parseInt(20);
      oS.width = W + "px";
      //alert(oS.width);
      var h = window.screen.availHeight;
      if (h < document.body.scrollHeight) {
          h = document.body.scrollHeight;
      }
      oS.height = h + "px";
      oS.position = "absolute";
      oS.zIndex = "8";
      if ((!browser.isSF) && (!browser.isOP)) {
          oS.background = "#FFFFFF";
      }
      else {
          oS.background = "#FFFFFF";
      }
      oS.filter = "alpha(opacity=50)";
      oS.opacity = 40 / 100;
      oS.MozOpacity = 40 / 100;
      document.body.appendChild(objScreen);
      var allselect = gname("select");
      for (var i = 0; i < allselect.length; i++)
          allselect[i].style.visibility = "hidden";
  }
  
function Browser()
{
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.isOP = false;
this.isSF = false;
ua = navigator.userAgent.toLowerCase();
s = "opera";
if ((i = ua.indexOf(s)) >= 0)
{this.isOP = true;return;}
s = "msie";
if ((i = ua.indexOf(s)) >= 0)
 {this.isIE = true;return;}
 s = "netscape6/";
 if ((i = ua.indexOf(s)) >= 0) 
 {this.isNS = true;return;}
 s = "gecko";if ((i = ua.indexOf(s)) >= 0) 
 {this.isNS = true;return;}
 s = "safari";
 if ((i = ua.indexOf(s)) >= 0)
  {this.isSF = true;return;}
  }
  
function Show(Num)
{
        if(Num=="0")
        {
         return ;
        }
        else
        {
        
        var v=Num.split('@');
        var s=v[1].split('$');
      
        //document.getElementById("buycarcouts").innerHTML = v[0];
        //document.getElementById("buycartotal").innerHTML = TT;
           //遮罩
        ScreenConvert();
        
    	str = new StringBuilder();
        str.Append("<div class='dn_top_txt' style=\"margin-top:8px;padding-left:5px;\">欢迎光临国际工程机械网</div>");

        str.Append("<table width='90%' height='113' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td width='40%' align='right'>共有种 <b style=\"color:red\">" + v[0] + "</b> 商品</td>");
        str.Append("<td width='60%' align='center'> 总金额：<b style=\"color:red\">￥"+s[1]+"</b></td></tr>");
        str.Append("<tr><td align='right'>最新加入商品：</td><td align='left' style=\"color:#394F88\">"+s[0]+"</td></tr>");
        str.Append("<tr><td colspan='2'><table width='90%' border='0' align='center' cellpadding='0' cellspacing='0'>");
        str.Append("<tr> <td width='43%' align='center'><input type='button' name='Submit' value='进入采购清单' onclick='location.href=\"/mart/orderList.aspx\"' /></td><td width='57%' align='center'><input type='button' name='Submit2' value='继续添加商品' onclick=\"DialogHide()\" /></td></tr></table>");
        str.Append(" </td></tr></table></div>"); 
        DialogShow(str,300,140,300,140);
        }
	
	
	/*
	if (update == null) update = true;
	update = (update)?1:0;
	if (ActionType != null && ReferID != null && WishType != null)
	{
		var PostData = "?id=3";
		PostRequest("http://localhost/test2.html", PostData);
	}
	*/
}
//隐藏层
function DialogHide(){ScreenClean();var objDialog = gid("DialogMove");if (objDialog) objDialog.style.display = "none";}
//清除遮罩
function ScreenClean(){var objScreen = gid("ScreenOver");if (objScreen) objScreen.style.display = "none";var allselect = gname("select");for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "visible";}

function DialogShow(showdata,ow,oh,w,h)
{
var objDialog = gid("DialogMove");
if (!objDialog) objDialog = document.createElement("div");
t_DiglogW = ow;
t_DiglogH = oh;
DialogLoc();
objDialog.id = "DialogMove";
var oS = objDialog.style;
oS.display = "block";
oS.top = t_DiglogY + "px";
oS.left = t_DiglogX + "px";
oS.margin = "0px";
oS.padding = "0px";
oS.width = w + "px";
oS.height = h + "px";
oS.position = "absolute";
oS.zIndex = "15";
oS.background = "#FFF";
oS.border = "solid #cccccc 1px";
objDialog.innerHTML = showdata;
document.body.appendChild(objDialog);
}

function DialogLoc()
{
var dde = document.documentElement;
if (window.innerWidth)
{
var ww = window.innerWidth;
var wh = window.innerHeight;
var bgX = window.pageXOffset;
var bgY = window.pageYOffset;
}
else
{
var ww = dde.offsetWidth;
var wh = dde.offsetHeight;
var bgX = dde.scrollLeft;
var bgY = dde.scrollTop;
}
t_DiglogX = (bgX + ((ww - t_DiglogW)/2));
t_DiglogY = (bgY + ((wh - t_DiglogH)/2));
}
//字符串连接
function StringBuilder(str)
{
    this.tmp = new Array();        
}
StringBuilder.prototype.Append= function(value)
{
    this.tmp.push(value);
    return this;
}
StringBuilder.prototype.Clear = function()
{
    tmp.length=1;
}
StringBuilder.prototype.toString = function()
{
    return this.tmp.join('');
}


///*漂浮框 结束 */

/*添加采购 开始*/
function AddOrder(AccessoryId,num,type)
{
  var str=Order.AddAccessory(AccessoryId,num,type).value;
  //alert(str);
  
  Show(str);
}
/*  结束*/
function WriteCount(Num)
{
  if(Num=="0")
  {
    document.getElementById("cgqd").style.display="none";
   // document.getElementById("ProductCount").innerHTML=Num;
  }
  else
  {
    document.getElementById("cgqd").style.display="";
    var v=Num.split('@');
    document.getElementById("MartCount").innerHTML=v[0];
    var s=v[1].split('$');
    document.getElementById("martlists").innerHTML="<div class='list'>"+s[0].substr(0,12)+"</div>";
  }
}

//添加到常用配件库
function AddPJK(ProductId,type)
{
  var v=Order.CheckCaigouLogin().value
  //alert(v);
  if(v==0)
  {
    location.href="http://mart.inmachine.com/mart/stock/cgs_login.aspx?url="+location.href;
    return;
  }
  Order.AddSC(ProductId,type)
  alert("添加到配件库成功！");
}


//window.setInterval("heartBeat()",1);

//AddOrder(0,0,0);