﻿$.ajaxSetup({
  url: "/Service.ashx",
  global: false,
  cache:true,
  type: "POST"
});
var loadingImg = "loading<img src=/images/loading.gif />";
function SetCookie(sName, sValue) 
{ 
 document.cookie = sName + "=" + escape(sValue) + "; "; 
} 
function GetCookie(sName) 
{ 
 var aCookie = document.cookie.split("; "); 
 for (var i=0; i < aCookie.length; i++) 
 { 
   
  var aCrumb = aCookie[i].split("="); 
  if (sName == aCrumb[0])  
  return unescape(aCrumb[1]); 
 } 
  
} 
function DelCookie(sName) 
{ 
document.cookie = sName + "=Delete; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
var Cookie = {Set:SetCookie,Get:GetCookie,Del:DelCookie}
function AddTool(ID) {
    if (Cookie.Get("myTools") != undefined)
        Cookie.Set("myTools", Cookie.Get("myTools") + "," + ID);
    else
        Cookie.Set("myTools", ID);
    alert("添加成功!");
    return false;
}
var DelTool = function(ID) {
    var result = window.confirm("确定要移除此工具吗? ");
    if (result) {
        var v = Cookie.Get("myTools");
        var col;
        if (v != "") {
            col = v.split(',');
        }
        else {
            col = [];
        }
        var index = -1;
        for (var i = 0; i < col.length; i++) {
            if (col[i] == ID.toString()) {
                index = i;
                break;
            }
        }
        if (index != -1) {
            col.splice(index, 1);
            Cookie.Set("myTools", col.toString());
            alert("移除成功");
            document.location = document.location;
        }
        else {
            alert("我的工具中没有这个工具");
        }
    }
    return false;
}


