// JScript 文件
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 getLink()
{
    var response = admini_ShuaManager.getLink().value;
    if(response!=null)
    {
       if(response=="0")
       {
          $("#tb").html("<tr><td colspan=5 style=\"text-align:center;\">没有数据</td></tr>");
       }else if(response.length>0)
       {
           var str="";
          for(i=0;i<response.length;i++)
          {
             
             str+="<tr><td>"+response[i][1]+"</td>";
             str+="<td>"+response[i][2]+"</td>";
             str+="<td>"+response[i][3]+"</td>";
             str+="<td>"+(response[i][4]==1?"是":"否")+"</td>";
             str+="<td><a href=\"javascript:Update("+response[i][0]+",'"+response[i][1]+"','"+response[i][2]+"','"+response[i][3]+"','"+response[i][4]+"')\">修改</a></td></tr>";
          }
          $("#tb").html(str);
       }else
          alert(response);
    }
    else
        alert("失败");
   
}
var _key=null;
function Update(key,sname,surl,sdesc,sByte)
{
     Change(2);
     $("#select1").val(sByte);
     $("#PropertyName").val(sname);
     $("#PropertyUrl").val(surl);
     $("#PropertDesc").val(sdesc);
     _key=key;
}
function Change(n)
{   
    getId();
    switch(n)
    {
      case 0:
         PropertyTable.style.display="none";
         listTable.style.display="";
         _key=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";
         _key=null;
         break;
      case 2:
        PropertyTable.style.display="";
        listTable.style.display="none";
        AddNew.className="";
         li1.className = "hover";
         List.className = "";
         li1.style.display = "";
        break;
    }
}
function Save()
{ 
   var key = _key;
   var sByte=$("#select1").val();
   var sname=  $("#PropertyName").val();
   var surl= $("#PropertyUrl").val();
   var sdesc=  $("#PropertDesc").val();
   var response=null;
     if(key!=null)
         response = admini_ShuaManager.addNewSite(key,sname,surl,sdesc,sByte);
     else
        response = admini_ShuaManager.addNewSite(null,sname,surl,sdesc,sByte);
     if(response.value=="1"){
        alert("ok");
        Change(0);
        getLink();
     }
     else
        alert("失败");
}
function Cancel(){Change(0);};