// JScript 文件
$().ready(function(){getLink();});
var PropertyTable = null;
var listTable=null;
var type=null;
var tb = null;
var PropertyName = null;
var List = null;
var AddNew = null;
var li1 = null;
function g(id){return document.getElementById(id);}
function getId(){
          PropertyTable=g("PropertyTable");
          listTable=g("listTable");
          tb = g("tb");
          PropertyName=g("PropertyName");
          PropertyUrl = g("PropertyUrl");
          PropertDesc = g("PropertDesc");
          hID=g("hID");
          List = g("List");
          AddNew = g("AddNew");
          li1 = g("li1");
}
function Change(n)
{   
    getId();
    switch(n)
    {
      case 0:
         PropertyTable.style.display="none";
         listTable.style.display="";
         type=null;
         AddNew.className="";
         li1.className = "";
         List.className = "hover";
         li1.style.display = "none";
         break;
      case 1:
         PropertyTable.style.display="";
         listTable.style.display="none";
         AddNew.className="hover";
         li1.className = "";
         List.className = "";
         li1.style.display = "none";
         type=0;
         break;
      case 2:
        type=1;
        PropertyTable.style.display="";
        listTable.style.display="none";
        AddNew.className="";
         li1.className = "hover";
         List.className = "";
         li1.style.display = "";
        break;
    }
}
function getLink()
{
  getId();
  var response = admini_SiteManager.getLink().value;
  $("#tb").html(response);
}
function Save()
{
   var k = hID.value;
   var sname =PropertyName.value;
   var st = $("#select1").val();
   var surl=PropertyUrl.value;
   var sdesc = PropertDesc.value; 
   var response = null;
   if(type==0)
       response = admini_SiteManager.addNewSite(null,sname, surl, sdesc, st).value;
   else
      response = admini_SiteManager.addNewSite(k,sname, surl, sdesc, st).value;
      if(response==null)
      {
         alert("失败！");
      }else if(response=="1"){
        alert("成功！");
        getLink();
        Change(0);
      }
      else
        alert(response);
}

function Update(key,name,url,desc,t)
{
   Change(2);
   hID.value=key;
   PropertyName.value=name;
   $("#select1").val(t);
   PropertyUrl.value=url;
   PropertDesc.value=desc;
}

function del(key)
{
    if(!confirm("确定删除吗？"))
        return;
    var response = admini_SiteManager.del(key).value;
    if(response=="1")
    {
        alert("ok");
        getLink();
        Change(0);
    }else
     alert(response);
}

function Cancel(){Change(0);};