﻿//添加到收藏夹方法

function addSaveBook(){
  window.external.addFavorite("http:\//www.88jiameng.com","88加盟网——餐饮品牌连锁加盟第一门户");
}
function addBookmark(title,url) {
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}

//添加一个cookie
function addCookie(name,value,expireHours){
  var cookieString = name + "=" + escape(value);
  if(expireHours>0){
    var date=new Date();    
    date.setTime(date.getTime()+expireHours*3600*1000); // 转换为毫秒

    cookieString = cookieString + ";expires=" + date.toGMTString() + ";path=/;domain=.88jiameng.com";
  }
  document.cookie=cookieString;
}

//获取一个cookie
function getCookie(name){
  var strCookie=document.cookie;
  var arrCookie=strCookie.split(";"); // 将多cookie切割为多个名/值对
  for(var i=0;i<arrCookie.length;i++){ // 遍历cookie数组，处理每个cookie对

    var arr=arrCookie[i].split("="); // 找到名称为userId的cookie，并返回它的值

    if(arr[0].replace(" ","")==name) return arr[1];
  }
  return "";
}

//删除一个cookie
function deleteCookie(name){
  var date=new Date();
  date.setTime(date.getTime()-10000); // 删除一个cookie，就是将其过期时间设定为一个过去的时间
  document.cookie = name + "=v;expires=" + date.toGMTString() + ";path=/;domain=.88jiameng.com";
}
function goction(){
        if(document.all.ppmc.value =="请输入要搜的项目关键字")
         {
	       document.all.ppmc.value='';
	       }
        }
////打开新页面时增加cookie计数器

//function load_SB(){
//  if(getCookie("CFW_SaveBooks") != "") return;
//  if(getCookie("DesktopCounts") == ""){
//    addCookie("DesktopCounts",1,720);
//  }
//  else{
//    var currentCount = parseInt(getCookie("DesktopCounts")) + 1;
//    deleteCookie("DesktopCounts");
//    addCookie("DesktopCounts",currentCount,720);
//  }
//}

//if((navigator.userAgent.indexOf('MSIE')>=0)&&(navigator.userAgent.indexOf('Opera')<0)){
//  //关闭页面时减少cookie计数器

//  window.onbeforeunload = function(){
//    if(getCookie("CFW_SaveBooks") != "") return;//已经收藏，退出操作

//    var x = document.documentElement.clientWidth==0?document.body.clientWidth:document.documentElement.clientWidth;
//    var y = document.documentElement.clientHeight==0?document.body.clientHeight:document.documentElement.clientHeight;
//    var currentCount = parseInt(getCookie("DesktopCounts")) - 1;//使下一次的加载时，数值恢复逻辑上的正常
//    deleteCookie("DesktopCounts");
//    addCookie("DesktopCounts",currentCount,720);
//    if(event.clientX>x&&event.clientY<0||event.clientY>y||event.altKey){//关闭
//      if(currentCount <= 0){
//        if(confirm("添加88加盟网到收藏夹？")) addSaveBook();
//        deleteCookie("CFW_SaveBooks");
//        addCookie("CFW_SaveBooks","true",720);//一个月后过期

//      }
//    }
//  }
//  load_SB();
//}
