function addCookie1(objName,objValue,objHours){//添加cookie
var str = objName;
if(objHours > 0){//为0时不设定过期时间，浏览器关闭时cookie自动消失
var date = new Date();
var ms = objHours*3600*1000;
date.setTime(date.getTime() + ms);
if(getCookie(objName)!="")
   str += "=" +escape(objValue+"$"+getCookie(objName) )+"; expires=" + date.toGMTString()+";path=/;/ secure";
else
    str +="=" + escape(objValue) +"; expires=" + date.toGMTString()+";path=/; secure";
}
document.cookie = str;
}
function getCookie(objName){
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName) return unescape(temp[1]);
} 
}
function add_(cookie_name,cookie_value,cookie_expireHours){

if(cookie_name=="shangbiaoname")
{
    var arrStr = cookie_value.split("-");
    cookie_value=arrStr[0];
}

if(cookie_name=="shangbiaovalue"&&getCookie("cookie_name"))
{
var arrStrName =getCookie("shangbiaoname").split("$");
var arrStrValue =getCookie("shangbiaovalue").split("$"); 
for(var i = 0;i < arrStrValue.length;i ++)
{
    if(arrStrValue[i]==cookie_value)
	{
	    delDouble("shangbiaovalue",arrStrValue[i],cookie_expireHours);
		delDouble("shangbiaoname",arrStrName[i],cookie_expireHours);
	}
	    
}
}

//if(getCookie("shangbiaovalue").indexOf(cookie_value)!=-1)   
//{   
    addCookie1(cookie_name,cookie_value,cookie_expireHours);
//}
}

function delDouble(objName,objValue,objHours)
{
    var str = objName;
	var newStr=getCookie(objName);
    if(objHours > 0){//为0时不设定过期时间，浏览器关闭时cookie自动消失
    var date = new Date();
    var ms = objHours*3600*1000;
    date.setTime(date.getTime() + ms);
    if(getCookie(objName)!="")
	{
	    newStr=newStr.replace("$"+objValue,"");
		newStr=newStr.replace(objValue,"");
        str += "=" +newStr+"; expires=" + date.toGMTString();
		document.cookie = str;
	}
    }
}

function get_(cookie_name){
var cookie_value = getCookie(cookie_name);
document.write(cookie_value+"<br>");
}
function getTitle()
{
   return document.title;
}
function getURL()
{
    return window.document.location.href;
}
function getList(num)
{
    var str="";
try{
    var arrStrName =getCookie("shangbiaoname").split("$");
    var arrStrValue =getCookie("shangbiaovalue").split("$"); 
	var ii=num;
	if(num>arrStrName.length-1)
	    ii=arrStrName.length-1;
	for(var i = 0;i < ii;i ++)
	    str+="<a style='color:red' href="+arrStrValue[i]+" target=_blank>"+arrStrName[i]+"</a> ";
		
		}
catch(err){}
    return str;
}
function show()
{

	document.write("<table width=100% border=0 align=center cellpadding=0 cellspacing=1'<TR><TD width=75% height=25 bgcolor=#f0f0f0>&nbsp;&nbsp;您浏览过的商标有："+getList(16)+"<a href='#' onClick='showPop(getList(100))'>更多</a></TD></TR></TABLE>");
}
function myCookies()
{
	//alert(getCookie("shangbiaovalue"));
	//alert(getURL());
	
	if(getCookie("shangbiaovalue")!=null)
	{
	
	
	if(getCookie("shangbiaovalue").indexOf(getURL())!=-1)   
    {   
	 
	}
	else
	{
		toCookies();
	}
	
	}
	
	else
	{
		toCookies();
	}
}

function addcookie()
{
	add_('shangbiaoname',getTitle(),'360');
	add_('shangbiaovalue',getURL(),'360');
}
function showPop(str){
		  
            var msgw,msgh,bordercolor;
            msgw=500;//提示窗口的宽度
            msgh=400;//提示窗口的高度
            titleheight=25 //提示窗口标题高度
            bordercolor="#336699";//提示窗口的边框颜色
            titlecolor="#99CCFF";//提示窗口的标题颜色
           
            var sWidth,sHeight;
            sWidth=document.body.offsetWidth;
            sHeight=screen.height;

            var bgObj=document.createElement("div");
            bgObj.setAttribute('id','bgDiv');
            bgObj.style.position="absolute";
            bgObj.style.top="0";
            bgObj.style.background="#777";
            bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
            bgObj.style.opacity="0.6";
            bgObj.style.left="0";
            bgObj.style.width=sWidth + "px";
            bgObj.style.height=sHeight + "px";
            bgObj.style.zIndex = "10000";
            document.body.appendChild(bgObj);
           
            var msgObj=document.createElement("div")
            msgObj.setAttribute("id","msgDiv");
            msgObj.setAttribute("align","center");
            msgObj.style.background="white";
            msgObj.style.border="1px solid " + bordercolor;
            msgObj.style.position = "absolute";
            msgObj.style.left = "50%";
            msgObj.style.top = "50%";
            msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
            msgObj.style.marginLeft = "-225px" ;
            msgObj.style.marginTop = -135+document.documentElement.scrollTop+"px";
            msgObj.style.width = msgw + "px";
            msgObj.style.height =msgh + "px";
            msgObj.style.textAlign = "left";
            msgObj.style.lineHeight ="25px";
            msgObj.style.zIndex = "10001";
  
           var title=document.createElement("h4");
           title.setAttribute("id","msgTitle");
           //title.setAttribute("align","right");
           title.style.margin="0";
           title.style.padding="3px";
           title.style.background=bordercolor;
           title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
           title.style.opacity="0.75";
           title.style.border="1px solid " + bordercolor;
           title.style.height="18px";
           title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
           title.style.color="white";
           title.style.cursor="pointer";
           title.innerHTML="<span style='float:left;width:430px;line-height:18px;'>我浏览过的商标</span><span style='float:left;width:50px;text-align:right;line-height:18px;'>关闭</span>";
           title.onclick=function(){
                document.body.removeChild(bgObj);
                document.getElementById("msgDiv").removeChild(title);
                document.body.removeChild(msgObj);
                }
           document.body.appendChild(msgObj);
           document.getElementById("msgDiv").appendChild(title);
           var txt=document.createElement("p");
           txt.style.margin="1em 0"
           txt.setAttribute("id","msgTxt");
           txt.innerHTML=str;
           document.getElementById("msgDiv").appendChild(txt);
            }
