<%@ Page Language="VB" AutoEventWireup="false" Inherits="b2bNet.Admin_PageTags_Add" ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="GENERATOR" content="Microsoft FrontPage 4.0" />
<meta name="ProgId" content="FrontPage.Editor.Document" />
<title>添加自定义标签</title>
<link href="inc/admin_style.css" rel="stylesheet" type="text/css" />
<link href="inc/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="inc/xml_http_lib.js"></script>
<script type="text/javascript">
function openwin(page, ctrl, style)
{
    if (page.indexOf("?") > 0)
        page = page + "&id=" + ctrl.id + "&val=" + ctrl.value;
    else
        page = page + "?id=" + ctrl.id + "&val=" + ctrl.value;
    window.open(page, "", style);
}

function checkInput(inputCtrl)
{
    if (inputCtrl.id.substr(0, 2) == "s_")
    {
       if ("\",()';{}%$^&[]".indexOf(String.fromCharCode(event.keyCode)) >= 0) event.returnValue = false;
    }
    else if (inputCtrl.id.substr(0, 2) == "i_")
    {
        if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;
    }
}
function setTagScript()
{
    if (document.all.txtTagName.value == "") return;
    var tag = document.all.txtTagName.value + "(";
    
    var j=0;
    var pAll = document.all.div_parameters.all;
    for(i=0;i<pAll.length; i++)
    {
        var val = "";
        if (pAll[i].tagName.toUpperCase() == "INPUT")
        {
            if (pAll[i].type == "button")
            {
                continue;
            }
            else if (pAll[i].type == "checkbox")
            {
                val = pAll[i].checked;
            }
            else 
            {
                val = pAll[i].value;
            }
        }
        else if (pAll[i].tagName.toUpperCase() == "SELECT")
            val = pAll[i].value;
        else
            continue;
            
        if (j>0) tag += ","
        if (pAll[i].id && pAll[i].id.substr(0, 2) == "s_") val = '"' + val + '"';
        tag += val;
        j++;
    }
    
    tag += ")"
    var htmlTag = encodeURIComponent(tag.replace(/\"/g, ""));
    document.all.txtTag.value = htmlTag;
    document.all.txtJavaScript.value = '<script type="Text\/JavaScript" src="<%=AppConst.SiteUrl%>\/TagJS.aspx?t=' + htmlTag + '"><\/script>';
    document.all.txtHtmlScript.value = '[SF,' + tag.replace(/\"/g, "") + ']';
    document.all.txtScript.value = "<" + "%=" + tag + "%" + ">";
}
function getTagHtml()
{
    xmlHttp.open("GET", "/TagJS.aspx?p=y&t=" + document.all.txtTag.value + "&r=" + Math.random(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.getElementById("div_Preview").innerHTML = xmlHttp.responseText;
            document.getElementById("btnSelfPreview").disabled = false;
        }
    }
}
</script>
</head>
<body onload="setTagScript();">
    <table style="width:100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td>
     <table style="height:22; width:100%" border="0" cellpadding="0" cellspacing="1">
      <tr class="topbg">
        <td style="height:22" align="center" class="topbg"><strong><%=channelName%>自定义标签</strong></td>
      </tr>
    </table>
    <table style="width:100%"  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td style="height:27; width:30" align="center"><img src="<%=AppConst.SiteUrl%>/<%=AppConst.Skinpath%>/gojump01.gif" width="16" height="16" /></td>
        <td><a href="?channel=info">商业机会标签</a> | <a href="?channel=products">产品展厅标签</a> | <a href="?channel=shopping">订购中心标签</a> | <a href="?channel=company">企业大全标签</a> | <a href="?channel=classad">分类信息标签</a></td>
      </tr>
    </table>
	<table style="width:100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><div align="center"><strong><%=channelName%>自定义函数标签</strong></div></td>
      </tr>
    </table>
    <form name="ListTNews" method="post" runat="server">
      <table style="width:776px"  border="1" cellpadding="5" cellspacing="0" align="center" bgcolor="#ffffcc" bordercolor="#ffcc33">
        <tr>
            <td style="text-align: right; width:150px" bgcolor="#ccffcc">
                <strong><span style="color: #ff0000">* 选择标签函数：</span></strong></td>
            <td bgcolor="#ccffcc" style="width:320px">
                <asp:DropDownList ID="txtTagName" runat="server" Width="300px" AutoPostBack="True">
                </asp:DropDownList></td>
            <td bgcolor="#ccffcc" id="div_methodDescribe" runat="server" style="width:330px"></td>
       </tr>
       <tr height="4"></tr>
       <tr><td colspan="3" id="div_parameters" name="div_parameters" runat="server"></td></tr>
        <tr height="4"></tr>
         <tr><td style="text-align:right; background-color:#ffff99" valign="top">
             模版页面标签：</td><td  style="width: 320px" bgcolor="#ffff99">
                <input type="hidden" id="txtTag"/>
                <textarea id="txtHtmlScript" style="width: 300px" onmouseenter="this.select(0,this.value.length);" rows="2" readonly="readonly"></textarea></td>
                <td bgcolor="#ffff99" valign="top">
                <input type="button" value="复制" style="width:61px" onclick='javascript: var textRange=txtHtmlScript.createTextRange(); textRange.execCommand("Copy")'>
             </td>
         </tr>
         <tr height="4"></tr>
         <tr><td style="text-align:right; width:150px; background-color:#ffff99" valign="top">
            Aspx页面调用：</td><td  style="width: 320px" bgcolor="#ffff99">
                <textarea id="txtScript" style="width: 300px" rows="2" onmouseenter="this.select(0,this.value.length);" readonly="readonly"></textarea></td>
                <td bgcolor="#ffff99" valign="top">
                <input type="button" value="复制" style="width:61px" onclick='javascript: var textRange=txtScript.createTextRange(); textRange.execCommand("Copy")'>
                <input type="button" value="本页预览" style="width:61px" id="btnSelfPreview" onclick='this.disabled=true;getTagHtml();'/></td>
         </tr>
         <tr height="4"></tr>
         <tr><td style="text-align:right; background-color:#ffff99" valign="top">
             JavaScript调用：</td><td  style="width: 320px" bgcolor="#ffff99">
                <textarea id="txtJavaScript" style="width: 300px" onmouseenter="this.select(0,this.value.length);" rows="5" readonly="readonly"></textarea></td>
                <td bgcolor="#ffff99" valign="top">
                <input type="button" value="复制" style="width:61px" onclick='javascript: var textRange=txtJavaScript.createTextRange(); textRange.execCommand("Copy")'>
                <input type="button" value="新页预览" style="width:61px" onclick='window.open("/TagJS.aspx?p=y&t=" + txtTag.value, "_blank");'/></td>
         </tr>
         <tr height="4"></tr>
         <tr><td colspan="3"><div id="div_Preview"></div></td></tr>
       </table>
      </form>
    </td>
  </tr>
  <tr height="20"></tr>
</table>
</body>
</html>