﻿// JScript 文件
//分类导航初始状态
function classBanInit()
{
    var pos_arr=["32px","117px","204px"];
    var oid=$("s2s_ToolT_h_classBan_id").value;
    if(oid!=-1)
    {
        $("a_class_ban_"+oid).className="on_";
        $("div_class_ban_ss").style.left=pos_arr[oid];
        $("div_class_ban_ss").style.display="block";
    }
}
addLoadEvent(classBanInit);

function numericCheck(obj)
{
    var nr1=obj.value;
    var flg=0;
    var str="";
    var spc="";
    for (var i=0;i<nr1.length;i++)
    {
        cmp="0123456789";
        tst=nr1.substring(i,i+1)
        if (cmp.indexOf(tst)<0)
        {
            flg++;
            str+=" "+tst;
            spc+=tst;
        }
    }
    if (flg!=0)
    {
        if (spc.indexOf(" ")>-1)
        {
            str+=" 空格";
        }
        //alert("这里只接受数字，发现"+flg+"个不可接受的字符:"+str);
        alert("这里只接受数字输入！");
        return false;
    }
    return true;
}

function nowListenPlug()
{
    if($("h_plug_uid").value==0 || !numericCheck($("txt_plug_width")))
        return false;
    if ($("txt_plug_width").value<200 || $("txt_plug_width").value>570)
    {
        alert("输入的数字已超过 200 - 570 之间的范围！");
        return false;
    }
        
    $("span_plug_width").innerHTML=$("txt_plug_width").value;
    $("txt_plug_code").value="<script src=\"http://www.see2say.com/channel/plug/last_playing/Default.aspx?userId="+$("h_plug_uid").value+"&width="+$("txt_plug_width").value+"\" language=\"javascript\" type=\"text/javascript\"></script>";
    
    var url="/channel/plug/last_playing/Default.aspx?userId="+$("h_plug_uid").value+"&width="+$("txt_plug_width").value+"&type=1";
    var oRequest = getXMLHttp();
	oRequest.onreadystatechange=function(){
        if(oRequest.readyState == 4)
        {
            $("div_plug_script").innerHTML=oRequest.responseText;
        }
	}	
	oRequest.open("GET",url,true);
	oRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
	oRequest.send(null);
}
function nowListenPlugSwf()
{
    if($("h_plug_uid").value==0 || !numericCheck($("txt_plug_swf_width")) || !numericCheck($("txt_plug_swf_height")))
        return false;
    if ($("txt_plug_swf_width").value<200 || $("txt_plug_swf_width").value>570)
    {
        alert("输入的宽度已超过 200 - 570 之间的范围！");
        return false;
    }
    if ($("txt_plug_swf_height").value<175 || $("txt_plug_swf_height").value>360)
    {
        alert("输入的高度已超过 175 - 350 之间的范围！");
        return false;
    }
        
    $("span_plug_swf_width").innerHTML=$("txt_plug_swf_width").value;
    $("span_plug_swf_height").innerHTML=$("txt_plug_swf_height").value;
    $("txt_plug_swf_code1").value=$("div_plug_swf").innerHTML="<embed src=\"http://www.see2say.com/channel/plug/last_playing/See2SayRecentMusic.swf?userId="+$("h_plug_uid").value+"\" wmode=\"transparent\" quality=\"high\" width=\""+$("txt_plug_swf_width").value+"\" height=\""+$("txt_plug_swf_height").value+"\" name=\"see2say_plug\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
    $("txt_plug_swf_code2").value="http://www.see2say.com/channel/plug/last_playing/See2SayRecentMusic.swf?userId="+$("h_plug_uid").value;
}
/* 
* 描述：跨浏览器的设置 innerHTML 方法 
*        允许插入的 HTML 代码中包含 script 和 style  
* 参数： 
*     el: 合法的 DOM 树中的节点 
*     htmlCode: 合法的 HTML 代码 
* 经测试的浏览器：ie5+, firefox1.5+, opera8.5+ 
*/ 
function html_script(el, htmlCode)
{
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0)
    {
         htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
         htmlCode = htmlCode.replace(/<script([^>]*)>/gi,'<script$1 defer>'); 
         el.innerHTML = htmlCode;
         el.removeChild(el.firstChild);
     }
     else
     {
        var el_next = el.nextSibling;
        var el_parent = el.parentNode;
        el_parent.removeChild(el); 
        el.innerHTML = htmlCode;
        if (el_next)
        {
             el_parent.insertBefore(el, el_next) 
         }
         else
         {
             el_parent.appendChild(el);
         }
     }
}