﻿ var isIndex = true;
 var bookmarkname=document.title;
 var dynamichost=document.location.host;
 var countimg=document.createElement('img');
 document.onclick=clickOut;

function SetCookie (name, value) { 
       var exp = new Date(); 
       exp.setTime (exp.getTime()+86400*365); 
       document.cookie = name + "=" + value + "; expires=" + exp.toGMTString()+"; path=/"; 
}

function getCookieVal (offset) { 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) endstr = document.cookie.length; 
    return unescape(document.cookie.substring(offset, endstr)); 
 } 
function DelCookie(name)
{
    SetCookie(name, '');
    return;
}

function GetCookie(name) {
         var arg = name + "="; 
         var alen = arg.length; 
         var clen = document.cookie.length; 
         var i = 0; 
         while (i < clen) { 
             var j = i + alen; 
             if (document.cookie.substring(i, j) == arg) return getCookieVal (j); 
             i = document.cookie.indexOf(" ", i) + 1; 
             if (i == 0) break; 
         } 
	     return null; 
 } 

function history_show()
{   
try
{
 var history=GetCookie("history");
 history=unescape(history);
 var content='';
 if(history!="null"&&history.indexOf("&")==-1)
 {
 history_arg=history.split("_honghesoft_");
 i=0;
 linknum=0;
 len= history_arg.length;
 for(i=0;i<len;i++)
 { 
 	var wlink=history_arg[i].split("+");
    if(history_arg[i]!="null" && content.indexOf(wlink[0])==-1 && linknum<44){
       content+="<li><a href=\""+wlink[1]+"\" target=\"_blank\"  title=\""+wlink[0]+"\">"+wlink[0]+"</a></li>";
       linknum+=1;
    }    
}    
 //document.getElementById("history").innerHTML=content; 

}else{
 	document.getElementById("history").innerHTML="</ul><div style='margin-top:35px;text-align=center'>您目前还没有浏览记录。</div><ul>";

}
}
catch(e){}
}

function clickOut(evt)
{
    evt=evt?evt:window.event;
    var srcElem=(evt.target)?evt.target:evt.srcElement;
    if (('A' == srcElem.tagName.toUpperCase()) && ('' != srcElem.id) && (!isNaN(srcElem.id)))
    {
         var  wlink=srcElem.innerHTML+"+"+srcElem.href +"_honghesoft_"; 
         wlink+=GetCookie("history");
         wlink=escape(wlink);
         SetCookie("history",wlink); 
         history_show();
    
        var url = "/apps/clickout.php?sId=" + srcElem.id + "&t=" + (new Date()).getTime();
        
        try 
        {
            if (!isIndex)
            {
                url = '../' + url;
            }
        }
        catch (e)
        {
            url = '../' + url;
        }
        
        countimg.src= url;
    }
}