﻿function setCurNavLink(){    
    var lis = document.getElementById("masthead_act").getElementsByTagName("li");      
    var localUrl = window.location.href.toLowerCase();     
    for(var i=0;i<lis.length;i++){
        var links = lis[i].getElementsByTagName("a");
        for(var j=0;j<links.length;j++){
            if(localUrl==links[j].href.toLowerCase()){
                lis[i].className = "cur";
            }
            else{
                lis[i].className = "";
            }            
        }        
    }    
}
function setCurNavLink2(liID){    
    if(liID=="") 
    {
        setCurNavLink();
        return;
    }
    var lis = document.getElementById("masthead_act").getElementsByTagName("li"); 
    for(var i=0;i<lis.length;i++){
        var links = lis[i].getElementsByTagName("a");
        for(var j=0;j<links.length;j++){           
           lis[i].className = "";
        }        
    }
    document.getElementById(liID).className = "cur";
}

var fodTime = 0;
var eventMode = "onclick";//onmouseover

function G(o){ return (typeof o == "object")?o:document.getElementById(o);}

function getNames(obj,name,tij){var plist = G(obj).getElementsByTagName(tij);var rlist = new Array();for(i=0;i<plist.length;i++){if(plist
[i].getAttribute("name") == name){rlist[rlist.length] = plist[i];}}return rlist;}

function cplay(){var o,n,t,na,c1,c2;o = G(arguments[0]);num=arguments[1];t=arguments[2];n=arguments[3];c1=arguments[4];c2=arguments[5];var 
f=getNames(o,n,t);for(i=0;i<f.length;i++){	if(i == num){f[i].className = c1;}else{f[i].className = c2;}}}


function fod(){var o1,o2,t1,t2,n1,n2,c1,c2,c3,c4,num;o1=G(arguments[0]);o2=G(arguments[1]);num=arguments[2];t1=arguments[3];n1=arguments
[4];t2=arguments[5];n2=arguments[6];c1=arguments[7];c2=arguments[8];c3=arguments[9];c4=arguments[10];cplay(o1,num,t1,n1,c1,c2);cplay
(o2,num,t2,n2,c3,c4);}

function _fod(o1,o2,t0,t1,n1,t2,n2,c1,c2,c3,c4)
{return function(){fod(o1,o2,t0,t1,n1,t2,n2,c1,c2,c3,c4)}}
//formatArea(o1,t1,n1,t2,n2[,c1,c2,c3,c4]) 
//o2 = o1 + "Info"
//t: tag; n: name
//c: tag className
//ClassStyle:s/dis/undis
function formatArea() 
{var o1=G(arguments[0]);var o2=G(arguments[0]+"Info");var t1=arguments[1];var n1=arguments[2];var t2=arguments[3];var n2=arguments[4];var 
c1,c2,c3,c4;if(arguments.length>5){c1=arguments[5];c2=arguments[6];c3=arguments[7];c4=arguments[8];}else{c1="s";c2="";c3="dis";c4="undis"}
var f=getNames(o1,n1,t1);		for(i=0;i<f.length;i++){f[i].value = i;f[i].onfocus = function(){ this.blur();};if(!!
eventMode&&eventMode=="onclick"){f[i].onclick = function(){clearTimeout(fodTime);fodTime=0;fodTime = setTimeout(_fod
(o1,o2,this.value,t1,n1,t2,n2,c1,c2,c3,c4),100);	};}else{f[i].onmouseover = function(){clearTimeout(fodTime);fodTime=0;fodTime = 
setTimeout(_fod(o1,o2,this.value,t1,n1,t2,n2,c1,c2,c3,c4),100);	};f[i].onmouseout=function(){clearTimeout(fodTime);fodTime=0;}}}
}



    bgColor = "FEEEE0";
    var memberIds = "";
    
  for(var i = 1;i < 31 ;i++){
	var cpbox = document.getElementById("compareBox"+i);
	var cpcolor = document.getElementById("compareColor"+i);
	if(cpbox!= null){
	  if(memberIds.indexOf(cpbox.name) != -1){
		  cpbox.checked = true;
		  if(cpcolor != null){
			cpcolor.style.background= bgColor;
		  }
	  }else{
		  cpbox.checked = false;
	  }
	}
  }
    
  function clickcompareBoxBuyTool(memberId,box) {
		if(box.checked){
	  if(getMemberIdCountBuyTool()>=20){
		alert('您已经选择了20条供应信息，候选供应信息不能超过20个');
		box.checked=false;
	  }else{
		memberIds += memberId + ",";
		var countId = box.id.substring("compareBox".length,box.id.length);
	
		var trTag = document.getElementById("compareColor"+countId);
		trTag.style.background=bgColor;
		
	  }
	} else {
	  delMemberIdBuyTool(memberId);
	  var countId = box.id.substring("compareBox".length,box.id.length);
	  var trTag = document.getElementById("compareColor"+countId);
		trTag.style.background="ffffff";
	  
	}
  }
  
  function getMemberIdCountBuyTool(){
    var count = 0;
    value = memberIds;
    while(value.indexOf(",") != -1) {
      var position = value.indexOf(",");
      var len = value.length;
      value =  value.substring(position+1,len);
      count++;
	}
	return count;	
  }
  
  function delMemberIdBuyTool(id){
    
    var position = memberIds.indexOf(id);
  	if(position == -1){
  	  alert("待删除的id不存在");
  	  return ;
  	}
  	var result = memberIds.substring(0,position);
  	var temp = memberIds.substring(position,memberIds.length);
  	position = temp.indexOf(",");
  	result += temp.substring((position+1),temp.length);
  	memberIds = "";
  	memberIds = result;
  }
  
  function selectAll(boxObj){
    ;
	  memberIds = "";
	  	  	  if(boxObj.checked){
    for(var i = 0;i < 31 ;i++){
    	  var cpbox = document.getElementById("compareBox"+i);
    	  var cpcolor = document.getElementById("compareColor"+i);
		    	  if(cpbox!= null && !cpbox.disabled){
        	memberIds += cpbox.name + ",";
    	    cpbox.checked = true;
    	    if(cpcolor != null){
    			      cpcolor.style.background= bgColor;
    	    }
    	  }
    }
  }
    else{
      for(var i = 1;i < 31 ;i++){
    	var cpbox = document.getElementById("compareBox"+i);
    	var cpcolor = document.getElementById("compareColor"+i);
    	if(cpbox!= null && !cpbox.disabled){
    	  cpbox.checked = false;
    	  if(cpcolor != null){
    			  cpcolor.style.background= "ffffff";
    		  }
    	  }
      }
    }
      }
      
      function actCheckbox(){
    var count = 0;
    var ids = "";
    var obj = document.batchForm.elements;
    for(var i = 0;i < obj.length;i++){
      if(obj[i].name == "cmpId"){
        if(obj[i].checked){
          count++;
          if(ids == ""){
            ids = obj[i].value;
          }else{
            ids = ids + ","+obj[i].value;
          }
        }
      }
    }
    if(count < 1){
      alert("请至少选择1条公司信息进行留言!");
      return false;
    }else if(count > 5){
      alert("您已经选择了"+count+"条公司信息,候选公司信息不能超过5条");
      return false;
    }
    var url = "http://redirect.china.alibaba.com/gateway/10024"+"?company_ids="+ids+"&tracelog=companylist_feedbacks";
    FD.common.goTo(url,"_blank");
  }
  
function cleanChecked(){ 
  if(confirm("您确认执行清空操作吗？"))
  {
    var obj = document.getElementsByName("cmpId");
    for(var i = 0;i < obj.length;i++)
    {
      //清空复选框
      if(obj[i].checked)
      {
        obj[i].checked = false;
      }
      //清除选中的背景色
      var countId = obj[i].id.substring("compareBox".length,obj[i].id.length);
      var elem = document.getElementById("compareColor"+countId);
      if(elem)
      {
        if(obj[i].getAttribute("special")) 
        {
          elem.className="offer_nol";
        }else 
        {
          elem.className="offer";
        }
      }
    }
  }
  }
  
  function Price()
    {
        var A = document.getElementById("accouts").innerHTML;
        var D;
        D = A*0.95;
        D = D.toFixed(2);
        document.getElementById("discount").innerHTML = D;
        A = A*1;
        A = A.toFixed(2);
        document.getElementById("accouts").innerHTML = A;
        
    }
    
    //popup window
    function popupWindow(URL,width,height,left,top)
    {
      if (typeof(width)=="undefined"||typeof(height)=="undefined"||width==""||height=="")
      {
  	    width="500"
	    height="300"
      }  
      if (typeof(left)=="undefined"||typeof(top)=="undefined"||left==""||top=="")
      {
  	    left=screen.width/5
	    top=screen.height/9
      }
      var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
      var msgWindow = window.open(URL,"", styleStr); 

    }
    
    //popup window
    function popupWindow2(URL,width,height,left,top)
    {
      if (typeof(width)=="undefined"||typeof(height)=="undefined"||width==""||height=="")
      {
  	    width="500"
	    height="300"
      }  
      if (typeof(left)=="undefined"||typeof(top)=="undefined"||left==""||top=="")
      {
  	    left=screen.width/5
	    top=screen.height/9
      }
      var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=925,height=600,left='+left+',top='+top+',screenX='+left+',screenY='+top;
      var msgWindow = window.open(URL,"", styleStr); 

    }