﻿//和服务器交互
function exectuteCode() {

    var title = $("#txt_title").val();
    var sort = $("#txt_sort").val();
    var selectvalue = $("#DropDownListSelectMenu").val();
    var pValue = "";
    if ($("#btnAddMain").val() == "添加菜单") {
        pValue = "add";
    }
    else {
        pValue = "edit";
    }
    
    
    $.get("SDT_Handler.ashx", { Action: "get", type: pValue, parsentID: selectvalue, name: title, top: sort }, function(data, textStatus) {
        //返回的 data 可以是 xmlDoc, jsonObj, html, text, 等等.
        this; // 在这里this指向的是Ajax请求的选项配置信息，请参考下图
        //alert(data);              
        //alert(textStatus);//请求状态：success，error等等。
        // 当然这里捕捉不到error，因为error的时候根本不会运行该回调函数
        //alert(this);
        $("#txt_title").val('');
        $("#txt_sort").val('');
        msg(data);

    });

}



function exectuteCode1(n,id) {
       

    var title = $("#txt_title1").val();
    var sort = $("#txt_sort1").val();
    var selectvalue = n;
    var pValue = "add";
   
    
    $.get("SDT_Handler.ashx", { Action: "get", type: pValue, parsentID: selectvalue, name: title, top: sort ,zid:id}, function PM_Role(data, textStatus) {
        //返回的 data 可以是 xmlDoc, jsonObj, html, text, 等等.
        this; // 在这里this指向的是Ajax请求的选项配置信息，请参考下图
        //alert(data);              
        //salert(textStatus);//请求状态：success，error等等。
        // 当然这里捕捉不到error，因为error的时候根本不会运行该回调函数
        //alert(this);
        $("#txt_title1").val('');
        $("#txt_sort1").val('');
       ///msg(data);
      /// location.reload();
      ///$("#ad_menu").html(data);
      $("#tjkxc"+id).append(data);
     
    });

}


function exectuteCode2(n,id) {

    var title = $("#txt_title2").val();
    var sort = $("#pp").val();
    var selectvalue = n;
    var pValue = "edit";
  
    
    $.get("/admin/SDT_Handler.ashx", { Action: "get", type: pValue, parsentID: sort, name: title, top: sort,zid:id}, function(data, textStatus) {
        //返回的 data 可以是 xmlDoc, jsonObj, html, text, 等等.
        this; // 在这里this指向的是Ajax请求的选项配置信息，请参考下图
        ///alert(sort);              
        //alert(textStatus);//请求状态：success，error等等。
        // 当然这里捕捉不到error，因为error的时候根本不会运行该回调函数
        //alert(this);
       /// $("#txt_title2").val('');
        ///$("#txt_sort2").val('');
       ///msg(data);
       ///$("#ad_menu").html(data);
       /// $("#a"+ id ).html(data);
        ///location.reload();
    });

}


function exectuteDelFL1(paid,pnum) {   

    $.get("SDT_Handler.ashx", { Action: "get", type: "FLDelL",aid: paid, num: pnum }, function(data, textStatus) {
      
      
            /// var div = document.getElementById(paid);//通过ID得指定的div
            ///div.style.display = "none"; //隐藏而不删除
            ///div.parentNode.removeChild(div); //删除
            $("#tjkx"+ paid).remove();

            ///$("#v_" + paid).remove();
            ///location.reload();
    });
}




//弹出提示框
function msg(n) {
    if (n == 1) {
        alert("操作成功！");
    }
    else if (n == 2) {
        alert("只能填数字且不能为空！");
    }
    else {
        alert("添加失败");
    }
    return;
}
//只能填数字
function regExpress(szStr) {
    var reg = new RegExp("^[0-9]*$");

    if (reg.exec(szStr) == '' || reg.exec(szStr) == null) {
        msg(2);
    }
    return;
}

//弹出提示框
function msg1(n) {
    if (n == 1) {
        alert("操作成功！");
    }
    else if (n == 2) {
        alert("不能为空！");
    }
    else {
        alert("添加失败");
    }
    return;
}
//只能填数字
function regExpress1(szStr) {
    var reg = new RegExp("^[0-9]*$");

    if (reg.exec(szStr) == '' || reg.exec(szStr) == null) {
        msg(2);
    }
    return;
}
//////////////////////////////////////////////////////////////////////////

var szhtml = "名称： <input type='text' name='txt_title'  id='txt_title' /><br />";
szhtml += " 选择： <select name='select' id='select_menu' style='width:155px;'></select><br />";
szhtml += "排序： <input type='text' name='txt_sort'  id='txt_sort' onblur='regExpress(this.value)' />";
szhtml += "<input id='btnAddMain' type='button' value='添加主菜单' onclick='exectuteCode();' />";

var szopencon = "<table width='500' border='0' cellspacing='2' cellpadding='2'>  <tr>    <td width='10%' height='25'>&nbsp;</td>    <td>编号：</td>  </tr>  <tr>    <td height='25'>&nbsp;</td>";
    szopencon+="<td>欢迎您对此件物品留言。您的支持是我们最大的动力！</td>  </tr>  <tr>    <td height='25'>&nbsp;</td>    <td>如要购买我们将尽快处理并与您沟通。</td>  </tr>";
    szopencon+="<tr><td height='25'><div align='right'>内容</div></td> <td height='25'><div align='right'>内容</div></td>   <td><textarea name='textfield' rows='6' id='txtContentLeftWord' style='width:90%;'>";
    szopencon+="</textarea></td> </tr>  <tr>    <td height='25'>&nbsp;</td>    <td>&nbsp;</td>  </tr>  <tr>    <td height='25'>&nbsp;</td>";
    szopencon += " <td><input type='image' name='imageField' src='Images/tijiao.jpg' /> <input type='image' name='imageField2' src='Images/reset.jpg' /></td>  </tr></table>";

//////////////////////////////////////////////////////////////////////////
function add_menu() {
    var t = new Dialog(szhtml);
    $("#select_menu").append("<option value='0'>请选择</option>");
    getSelectValue("0");
    t.show();
}

function add_leftWord() {
    var t = new Dialog(szopencon);   
    alert('sssssss');
    t.show();
}
//弹出留言窗体
function openWin(k, szLink) {
    if (k == "") {
        alert("您还没有登录，不能留言！");
        return;
    }
    else {
        showModalDialog(szLink, null, "dialogHeight:330px;   dialogWidth:510px;   dialogTop:   350px;   edge:   Raised;   center:   Yes;   help:   no;   resizable:   no;   status:   no;");
    }
    
    
}

function exectutePicCode(paid,pnum) {   

    $.get("SDT_Handler.ashx", { Action: "get", type: "PicDel",aid: paid, num: pnum }, function(data, textStatus) {
      
            alert('删除成功');
            location.reload();
    });
}

function exectutePicCodeP(paid,pnum) {   

    $.get("SDT_Handler.ashx", { Action: "get", type: "PicDelP",aid: paid, num: pnum }, function(data, textStatus) {
      
            alert('删除成功');
            location.reload();
    });
}


function exectutePicCodeX(paid,pnum) {   

    $.get("SDT_Handler.ashx", { Action: "get", type: "PicDelX",aid: paid, num: pnum }, function(data, textStatus) {
      
            alert('删除成功');
            location.reload();
    });
}

function exectutePicCodeL(paid,pnum) {   

    $.get("SDT_Handler.ashx", { Action: "get", type: "PicDelL",aid: paid, num: pnum }, function(data, textStatus) {
      
            alert('删除成功');
            location.reload();

    });
}

function exectuteDelFL(paid,pnum) {   

    $.get("SDT_Handler.ashx", { Action: "get", type: "FLDelL",aid: paid, num: pnum }, function(data, textStatus) {
      
            alert('删除成功');
            $("#v_" + paid).remove();
    });
}

function getSelectValue(sid) {

    $.get("SDT_Handler.ashx", { Action: "get", type: "select", szID: sid }, function(data, textStatus) {


        for (var i = 0; i < data.split(",").length; i++) {
            var szArr = data.split(",")[i];
            var szTV = szArr.split("|");
            $("#select_menu").append('<option value=' + szTV[1] + '>' + szTV[0] + '</option>');
            //getSelectValue(szTV[1]);
        }

    });
}

//弹出窗体

function openMenu(n) {
    var getlql = showModalDialog("A_editManager.aspx?type="+n, null, "dialogHeight:200px;   dialogWidth:360px;   dialogTop:   350px;   edge:   Raised;   center:   Yes;   help:   no;   resizable:   no;   status:   no;");
    if (getlql != null && getlql != "") {
        //var txt2 = 'pfile2';
        //document.getElementById(txt2).value = getlql;

    }
}

//弹出上传窗体
function openUploadWinPic(aid,num) {

    showModalDialog("uploadepic.aspx?id=" + aid + "&num=" + num, null, "dialogHeight:200px;   dialogWidth:360px;   dialogTop:   350px;   edge:   Raised;   center:   Yes;   help:   no;   resizable:   no;   status:   no;");

}
//弹出上传窗体
function openUploadWin() {
    var s = $("#txt_number").val();   
    showModalDialog("A_uploadPage.aspx?type=" +s, null, "dialogHeight:200px;   dialogWidth:360px;   dialogTop:   350px;   edge:   Raised;   center:   Yes;   help:   no;   resizable:   no;   status:   no;");
    
}
//修改菜单

function EditinputValue() {
    var sid = $("#DropDownListSelectMenu").val();
    $.get("SDT_Handler.ashx", { Action: "get", type: "selectTxt", szID: sid }, function(data, textStatus) {

        $("#txt_title").val(data);

    });

}
//显示菜单设置页面
function disMenu(n) {
    $("#li_" + n).click(function() {
        if ($("#li_" + n).attr("txt") == "0") {
            $("#li_" + n).attr("txt", "1");
            $("#div_" + n).show();
        }
        else {
            $("#li_" + n).attr("txt", "0");
            $("#div_" + n).hide();
        }

    });
}
//静态相应服务端事件

function pCall() {
  __doPostBack('Linkbntupload','');
}


//关闭
function closeWin() {
    window.opener = null; 
    window.close(this);
 }

 function menuSwitch(id) {
     var a=new Array("0","1","3","2","110","4","6")
     for (var i = 1; i < 7; i++) {
         if (id == a[i]) {
           
             $("#span" + i).removeClass("div_master_header_right_one_span").addClass("div_master_header_right_one_span_switch");
          
            
         }
         else {
             $("#span" + i).removeClass("div_master_header_right_one_span_switch").addClass("div_master_header_right_one_span");
         }
     }

 }

//地址页面切换
 function addressSwitch(id) {
     if (id == 1) {
         $("#address2").css('color','#000000');
         $("#address1").css('color','#EA5504');
         $("#address_text").show();
         $("#address_map").hide();
     }
     if (id == 2) {
         $("#address1").css('color','#000000');
         $("#address2").css('color','#EA5504');
         $("#address_text").hide();
         $("#address_map").show();
     }
 }

 //---------------
 function changeLeftShow(id) {
     switch (id) {
         case 1:
             $("#SDT_index").show();
             $("#SDT_contact").hide();            
             break;
         case 6:
             $("#SDT_index").hide();
             $("#SDT_contact").show();
             break;
         default:            
         
             break;
    }
    
 }

 ///---------------

 function leftSwitch(id) {
     $("#div_second_repeater_" + id).show();
     $("#li_" + id).css('color','#EA5504');
     //$("#li_" + id).addClass("div_left_content_menu_top_type_ul_li");
     //$("#li_" + id).css("background","url(../Images/9.jpg)");
 }
 function leftSecondSwitch(id) {
     $("#li_one_" + id).css('color','#EA5504');
 }

 function myaccount(k) {
     
     if (k != "" || k != null) {
         $("#div_myaccount").show();
         switch(k) {
         case "1":
            $("#div_favoriten").addClass("div_change_background");
            
         	break;
        case "0":
            $("#div_order").addClass("div_change_background");
         	break;
         default:
         }
        
        
     }

     if ($("#div_myaccount").attr("txt") == "0") {
         $("#div_myaccount").attr("txt", "1");
         $("#div_myaccount").hide();
     }
     else {
         $("#div_myaccount").attr("txt", "0");
         $("#div_myaccount").show();
     }     
 }
 
 
