// JavaScript Document
function nTabs(thisObj,Num){
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length; i++)
	{
		if (i == Num)
		{
			thisObj.className = "active"; 
    		document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
			tabList[i].className = "normal"; 
			document.getElementById(tabObj+"_Content"+i).style.display = "none";
		}
	} 
}
  cookieName = "compare_id";
  domainName = "http://show.bioon.com";
  prefix = "";
  bgColor = "FEEEE0";
  
  function addOfferId(arg) {
  	arg  = arg + prefix;
  	
    if(hasOfferId(arg)) {
        return;
    }
    if(arg == "") {
        return;
    }
	value = getCookie(cookieName);
	if(value == null || value == "null" ) {
		value = arg ;
	} else {
	   value=value+","+ arg;
    }

	 cookieValue = cookieName+ "=" + value+" " ;
	document.cookie = cookieValue;
  }

  function delOfferId(arg) {
    arg = arg + prefix;

    if(!hasOfferId(arg)) {
       alert("要删除的产品选择不存在");
       return;
    }

	value = getCookie(cookieName);
	var offerIds = stringToArray(value);
	var len = offerIds.length;
	var result = "";
	var counter = 0;
	for(var s=0;s<len;s++) {
	  if(offerIds[s] != arg) {
	  	    if(counter == 0) {
  	     	  result = offerIds[s];
	  	    } else {
  	     	  result = result + "," + offerIds[s];
	  	    }
	  	    counter++;
	  }
	}
	cookieValue = cookieName + "=" + result + " ";
	document.cookie = cookieValue;
  }
  
  
  function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var s=0;
    while(s<clen) {
    	var j=s+alen;
    	if(document.cookie.substring(s,j)==arg)
    		return www_helpor_net(j);
    	s=document.cookie.indexOf(" ",s)+1;if(s==0)
    		break;
    }
    return null;
  }

  function www_helpor_net(offset) {
	  var endstr=document.cookie.indexOf(";",offset);
	  if(endstr==-1)
	  endstr=document.cookie.length;
	  return unescape(document.cookie.substring(offset,endstr));
  }

  function hasOfferId(arg) {
  	var value = getCookie(cookieName);
	if(value == null || value == "null" || value.indexOf(arg) == -1 ) {
	    return false;
	} else {
	  	return true;
	}
  }


  function getOfferIdCount() {

	value = getCookie(cookieName);
	
	if(value == null || value == 'null') {
	  return 0;
	}
	
  	var count = 1;
    while(value.indexOf(",") != -1) {
       var position = value.indexOf(",");
       var len = value.length;
       value =  value.substring(position+1,len);
       count++;
    }
    return count;
  }
  
  function stringToArray(str) {
	   var temp = str;
       var strArray = new Array();
       var count = 0;
	   while(temp.indexOf(",") != -1) {

	     var position = temp.indexOf(",");
	     
	     strArray[count] = temp.substring(0,position);
	     count++;
	     var len = temp.length;
	     temp =  temp.substring(position+1,len);

	   }
	   strArray[count] = temp;
	   return strArray;
  }
  
  function clickcompareBox(id,box) {
    if(box.checked){
      if(getOfferIdCount()>=5)
	  {
        alert('您已经选择了5个产品，候选产品不能超过5个\n\n小提示：如果您在别的页面也勾选过产品，它们也将参与比较或询价。您可以点“清空选择”，再重新勾选.');
        box.checked=false;
      }
	  else
	  {
        addOfferId(id);
        var countId = box.id.substring("compareBox".length,box.id.length);
        var trTag = document.getElementById("compareColor"+countId);
      }
    }
	else
	{
      delOfferId(id);
      var countId = box.id.substring("compareBox".length,box.id.length);
      var trTag = document.getElementById("compareColor"+countId);
    }
  }
  
  function cleanCookie() {
    if(confirm("您确认执行清空操作吗？"))
	{
      var value = "null";
      cookieValue= cookieName + "=" + value + " " ;
      document.cookie = cookieValue;
	}
	var fsbox=document.compareform.id;
	for(i=0;i<fsbox.length;i++)
	{
		fsbox[i].checked=false;
	}
  }
  
    ;
  for(var s = 1;s < 41;s++)
  {
    var cpbox = document.getElementById("compareBox"+s);
    var cpcolor = document.getElementById("compareColor"+s);
    if(cpbox!= null){
      if(hasOfferId(cpbox.name))
	  {
          cpbox.checked = true;
          if(cpcolor != null)
		  {
            cpcolor.bgColor= bgColor;
          }
      }
	  else
	  {
          cpbox.checked = false;
      }
    }
  }
function CompThis() 
{   
   value =getCookie(cookieName);
    
   if(value!=null)
   {
         if (value.length>0 )
		{
			window.open ("compare.asp?ids=" +value);
		}
		else
		{
			alert("请先选择要比较的产品");  
		} 	    
   }
   else
   {
         alert("请先选择要比较的产品");  
   } 
    return;
}


function batchinquiry()
{
   value =getCookie(cookieName);
   if(value!=null)
   {
         if (value.length>0 )
		{
		   var urlfrom=window.location.href;
			window.open ("inquiry.asp?id=" +value+'&amp;urlfrom='+urlfrom);
		}
		else
		{
			alert("请先选择要询价的产品");  
		} 	    
   }
   else
   {
         alert("请先选择要询价的产品");  
   } 
    return;
}


/* */
