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 = "offerId";
  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 + ";path=/;" + "domain="+domainName;

         cookieValue = cookieName+ "=" + value+" " ;
	document.cookie = cookieValue;
   // alert( document.cookie );
  }

  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);
	//alert(value + " " + value.indexOf(arg));
	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);
	     //alert( strArray[count] );
	     count++;
	     var len = temp.length;
	     temp =  temp.substring(position+1,len);

	   }
	   strArray[count] = temp;
	   //alert(strArray[count]);
	   return strArray;
  }
  
  function clickcompareBox(id,box) {
    if(box.checked){
      if(getOfferIdCount()>=5){
        alert('您已经选择了5个产品，候选产品不能超过5个');
        box.checked=false;
      }else{
        addOfferId(id);
        var countId = box.id.substring("compareBox".length,box.id.length);
        var trTag = document.getElementById("compareColor"+countId);
        trTag.bgColor=bgColor;
      }
    } else {
      delOfferId(id);
      var countId = box.id.substring("compareBox".length,box.id.length);
      var trTag = document.getElementById("compareColor"+countId);
      if(countId%2!= 0){
        trTag.bgColor="ffffff";
      }else{
	    trTag.bgColor="F6F6F6";
        
      }
    }
  }
  
  function cleanCookie() {
    if(confirm("您确认执行清空操作吗？")){
      var value = "null";
      cookieValue= cookieName + "=" + value + " " ;
      document.cookie = cookieValue;
      for(var s=0;s<=40;s++){
        var elem = document.getElementById("compareBox"+s);
        if(elem != null && elem.checked){
          elem.checked = false;
          elem = document.getElementById("compareColor"+s);
          if(s%2 != 0){
            elem.bgColor="ffffff";

          }else{            
			elem.bgColor="F6F6F6";
          }
        }
      }
	}
  }
  
    ;
  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(ptype) 
{
	var	folder='';
	if(ptype=='' || ptype=='undefined' ){
		alert(ptype);
		folder='../'+ptype+'/';
	}

	value =getCookie(cookieName);
	if(value!=null){
		 if (value.length>0 ){
				 window.open (folder+"contrast.asp?info_Id=" +value);
		  }else{
			  alert("请先选择要比较的产品");  
		  
		 } 	    
	}else{
		 alert("请先选择要比较的产品");  
		   
	} 
	return;
}