var cookie={ 

Get:function(n){ 
    var re=new RegExp(n+'=([^;]*);?','gi'); 
    var r=re.exec(document.cookie)||[]; 
    return (r.length>1?r[1]:null) 
},
    Get1:function(n){ 
    var re=new RegExp(n+'=([^;]*);?','gi'); 
    var r=re.exec(document.cookie)||[]; 
    return unescape(r.length>1?r[1]:null) 
},

Set:function(n,v,e,p,d,s){ 
    var t=new Date; 
    if(e){ 
t.setTime(t.getTime() + (e*3.6e6));
     }
    document.cookie=n+'='+v+'; '+(!e?'':'; expires='+t.toUTCString())+(!p?'':'; path='+p)+(!d?'':'; domain='+d)+(!s?'':'; secure') // Set cookie
},
    Set1:function(n,v,e,p,d,s){ 
    var t=new Date; 
    if(e){ 
t.setTime(t.getTime() + (e*8.64e7));
      
     }
    document.cookie=n+'='+escape(v)+'; '+(!e?'':'; expires='+t.toUTCString())+(!p?'':'; path='+p)+(!d?'':'; domain='+d)+(!s?'':'; secure') // Set cookie
},
Del:function(n,p,d){ 
    var t=cookie.Get(n); 
    document.cookie=n+'='+(!p?'':'; path='+p)+(!d?'':'; domain='+d)+'; expires=Thu, 01-Jan-70 00:00:01 GMT'; 
    return t 
}
};

var ViewHistory = {
    intoCar: function(proid, proname, imgurl, ppp) {
        if (proid != "" && proname != "") {
            var HistoryList = cookie.Get("historyList"); 

            if (HistoryList != null && HistoryList != "" && HistoryList != "null") {
                var arr = HistoryList.split("&");
                if (ViewHistory.hasOne(proid)) {
                    var str = proid + "=" + proid + "|" + escape(proname) + "|" + escape(imgurl) + "|" + escape(ppp);
                    if (arr.length >= 5) { arr.pop(); }
                    arr.unshift(str);
                    HistoryList = arr.join("&");
                    cookie.Set("historyList", HistoryList, 2, "/");
                }
            }
            else {
                var str = proid + "=" + proid + "|" + escape(proname) + "|" + escape(imgurl) + "|" + escape(ppp);
                cookie.Set("historyList", str, 2, "/"); 
            }
        }
    }, 
    hasOne: function(pid) {
        HistoryList = cookie.Get("historyList"); 
        var flag = true;

        if (HistoryList.lastIndexOf("&") != -1) {
            var arr = HistoryList.split("&");
            for (i = 0; i < arr.length; i++) {
                if (arr[i].substr(0, arr[i].indexOf("=")) == pid) {
                    flag = false;
                }
            }
        }
        else if (HistoryList != "null" && HistoryList != "") {
            if (HistoryList.substr(0, HistoryList.indexOf("=")) == pid)
                flag = false;
        }
        return flag;
    }
};
