﻿

//视频播放器，支持 .avi,.wmv
function ShoveWebControl_VideoPlay(filename, width, height)
{
    if(filename != "")
    {
        document.write("<object id='NSPlay' width=" + width + " height=" + height + " classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject' align='center' hspace='5'>");
        document.write("<param name='PlayCount' value=0>");
        document.write("<param name='AutoRewind' value='1'>");
        document.write("<param NAME='Balance' VALUE='0'> ");
        document.write("<param name='FileName' value='" + filename + "'>");
        document.write("<param name='ShowControls' value='1'>");
        document.write("<param name='ShowPositionControls' value='0'>");
        document.write("<param name='ShowDisplay' value='0'>");
        document.write("<param name='ShowStatusBar' value='1'>");
        document.write("<param name='volume' value='100%'> ");
        document.write("<param name='ShowAudioControls' value='1'>");
        document.write("<param name='ShowTracker' value='1'>");
        document.write("<param name='ShowDisplay' value='0'>");
        document.write("<param name='ShowStatusBar' value='0'>");
        document.write("<param name='ShowGotoBar' value='0'>");
        document.write("<param name='ShowCaptioning' value='0'>");
        document.write("<param name='AutoStart' value=1>");
        document.write("<param name='Volume' value='-2500'>");
        document.write("<param name='AnimationAtStart' value='0'>");
        document.write("<param name='TransparentAtStart' value='0'>");
        document.write("<param name='AllowChangeDisplaySize' value='0'>");
        document.write("<param name='AllowScan' value='0'>");
        document.write("<param name='EnableContextMenu' value='0'>");
        document.write("<param name='DisplayBackColor' value='0'>");
        document.write("<param name='ClickToPlay' value='0'>");
        document.write("</object>");
    }
}

function ShoveWebControl_FlashPlay(Src, Width, Height,isTransparent)
{
    document.write('<OBJECT codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0"\n');
    document.write('height="' + Height + '" width="' + Width + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>\n');
    document.write('<PARAM NAME="_cx" VALUE="16536">\n');
    document.write('<PARAM NAME="_cy" VALUE="1852">\n');
    document.write('<PARAM NAME="FlashVars" VALUE="">\n');
    document.write('<PARAM NAME="Movie" VALUE="' + Src + '">\n');
    document.write('<PARAM NAME="Src" VALUE="' + Src + '">\n');
    if(isTransparent == 1)
    {
        document.write('<PARAM NAME="WMode" VALUE="transparent">\n');
    }
    else
    {
        document.write('<PARAM NAME="WMode" VALUE="Opaque">\n');
    }
    document.write('<PARAM NAME="Play" VALUE="-1">\n');
    document.write('<PARAM NAME="Loop" VALUE="-1">\n');
    document.write('<PARAM NAME="Quality" VALUE="High">\n');
    document.write('<PARAM NAME="SAlign" VALUE="">\n');
    document.write('<PARAM NAME="Menu" VALUE="-1">\n');
    document.write('<PARAM NAME="Base" VALUE="">\n');
    document.write('<PARAM NAME="AllowScriptAccess" VALUE="">\n');
    document.write('<PARAM NAME="Scale" VALUE="ShowAll">\n');
    document.write('<PARAM NAME="DeviceFont" VALUE="0">\n');
    document.write('<PARAM NAME="EmbedMovie" VALUE="0">\n');
    document.write('<PARAM NAME="BGColor" VALUE="">\n');
    document.write('<PARAM NAME="SWRemote" VALUE="">\n');
    document.write('<PARAM NAME="MovieData" VALUE="">\n');
    document.write('<PARAM NAME="SeamlessTabbing" VALUE="1">\n');
    document.write('<PARAM NAME="Profile" VALUE="0">\n');
    document.write('<PARAM NAME="ProfileAddress" VALUE="">\n');
    document.write('<PARAM NAME="ProfilePort" VALUE="0">\n');
    document.write('<PARAM NAME="AllowNetworking" VALUE="all">\n');
    if (isTransparent == 1)
    {
        document.write('<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + Src + '" width="' + Width + '" height="' + Height + '" type="application/x-shockwave-flash" quality="high" wmode="transparent"></embed>\n');
    }
    else
    {
        document.write('<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + Src + '" width="' + Width + '" height="' + Height + '" type="application/x-shockwave-flash" quality="high"></embed>\n');
    }
    document.write('</OBJECT>\n');
}

function ShoveEIMS3_BindCitys(sender,city,cityFirstText,language)
{
   var dt = ShoveEIMS3.Web.UI.WebControls.ShoveWebControl_ProvinceAndCity.GetCitys(sender.value,language).value;
   
   var Citys = document.getElementById(city);

    Citys.options.length = 0;
    Citys.options.add(new Option(cityFirstText, "-1"));

    if (dt != null && dt.Rows.length > 0) 
    {
        for (var i = 0; i < dt.Rows.length; i++) 
        {
            Citys.options.add(new Option(dt.Rows[i]["Name"].toString(), dt.Rows[i]["Id"].toString()));
        }
    }
}

function ShoveEIMS3_SelectCity(sender,cityId)
{
    document.getElementById(cityId) = sender.value;
}


/***********************************用户名验证********************/


function ShoveEIMS3_CheckUserNameOnFocus(tb,css,focusId,errorId,existsId,trueId)
{
    tb.className = css;
    
    if(document.getElementById(focusId) != null)
    {
        document.getElementById(focusId).style.display = "inline";
    }
    if(document.getElementById(errorId) != null)
    {
        document.getElementById(errorId).style.display = "none";
    }
    if(document.getElementById(existsId) != null)
    {
       document.getElementById(existsId).style.display = "none";
    }
    if(document.getElementById(trueId))
    {
        document.getElementById(trueId).style.display = "none";
    }
}

function ShoveEIMS3_CheckUserNameOnBlur(tb,css,focusId,errorId,existsId,trueId)
{
    var value = tb.value;
    var patrn = /^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/;   
    
    var focus = document.getElementById(focusId);
    var error = document.getElementById(errorId);
    var exists = document.getElementById(existsId);
    var trues = document.getElementById(trueId);
    
    if (!patrn.exec(value.replace(" ","") == ""))
    {
        if(error != null)
        {
            error.style.display = "inline";
        }
        if(focus != null)
        {
            focus.style.display = "none";
        }
        if(exists != null)
        {
            exists.style.display = "none";
        }
        if(trues != null)
        {
            trues.style.display = "none";
        }
        tb.className = css;
    }
    
    var result = ShoveEIMS3.Web.UI.WebControls.ShoveWebControl_UserName.ShoveEIMS3_CheckUserNameExists(value).value;
    if(result)
    {
        if(error != null)
        {
            error.style.display = "none";
        }
        if(focus != null)
        {
            focus.style.display = "none";
        }
        if(exists != null)
        {
            exists.style.display = "inline";
        }
        if(trues != null)
        {
            trues.style.display = "none";
        }
        tb.className = css;
    }
    else
    {
        if(error != null)
        {
            error.style.display = "none";
        }
        if(focus != null)
        {
            focus.style.display = "none";
        }
        if(exists != null)
        {
            exists.style.display = "none";
        }
        if(trues != null)
        {
            trues.style.display = "inline";
        }
    }
} 

/************************************************************/

//密码和确认密码校验
function ShoveEIMS3_CheckResigterNewPassOnFocus(tb,css,focusId,errorId)
{
    tb.className = css;
    
    if(document.getElementById(focusId) != null)
    {
        document.getElementById(focusId).style.display = "inline";
    }
    if(document.getElementById(errorId) != null)
    {
        document.getElementById(errorId).style.display = "none";
    }
}

function ShoveEIMS3_CheckResigterNewPassOnBlur(tb,focuscss,errorcss,focusId,errorId,trueId)
{
    tb.className = focuscss;
    
    //如果验证通过
    if(/^(\w){6,20}$/.test(tb.value))
    {
        if(document.getElementById(trueId) != null)
        {
            document.getElementById(trueId).style.display = "inline";
        }
        if(document.getElementById(focusId) != null)
        {
            document.getElementById(focusId).style.display = "none";
        }
        if(document.getElementById(errorId) != null)
        {
            document.getElementById(errorId).style.display = "none";
        }
    }
    else
    {
        if(document.getElementById(trueId) != null)
        {
            document.getElementById(trueId).style.display = "none";
        }
        if(document.getElementById(focusId) != null)
        {
            document.getElementById(focusId).style.display = "none";
        }
        if(document.getElementById(errorId) != null)
        {
            document.getElementById(errorId).style.display = "inline";
        }
        
        document.getElementById(errorId).className = errorcss;
    }
}

//检测密码强度
function ShoveEIMS3_CheckResigterPassStrong(value,defaultcss,checkcss,td1,td2,td3)
{
    if(value.length > 10 && /[a-z]/.test(value) && /[0-9]/.test(value))
    {
        document.getElementById(td2).className = checkcss;
        document.getElementById(td1).className = defaultcss;
        document.getElementById(td3).className = defaultcss;
    }
    else if(value.length > 10 && /[a-z]/.test(value) && /[A-Z]/.test(value) && /[0-9]/.test(value))
    {
        document.getElementById(td3).className = checkcss;
        document.getElementById(td1).className = defaultcss;
        document.getElementById(td2).className = defaultcss;
    }
    else
    {
        document.getElementById(td1).className = checkcss;
        document.getElementById(td3).className = defaultcss;
        document.getElementById(td2).className = defaultcss;
    }
}

function ShoveEIMS3_CheckResigterConfirmPassOnFocus(tb,css,focusId,errorId,diffId)
{
    tb.className = css;
    
    if(document.getElementById(focusId) != null)
    {
        document.getElementById(focusId).style.display = "inline";
    }
    if(document.getElementById(errorId) != null)
    {
        document.getElementById(errorId).style.display = "none";
    }
    if(document.getElementById(diffId) != null)
    {
        document.getElementById(diffId).style.display = "none";
    }
}

function ShoveEIMS3_CheckResigterConfirmPassOnBlur(tb,newId,defaultcss,errorcss,focusId,errorId,diffId,trueId)
{
    if(document.getElementById(newId).value != tb.value)
    {
        if(document.getElementById(focusId) != null)
        {
            document.getElementById(focusId).style.display = "none";
        }
        if(document.getElementById(errorId) != null)
        {
            document.getElementById(errorId).style.display = "none";
        }
        if(document.getElementById(diffId) != null)
        {
            document.getElementById(diffId).style.display = "inline";
        }
        if(document.getElementById(trueId) != null)
        {
            document.getElementById(trueId).style.display = "none";
        }
        
        document.getElementById(diffId).className = errorcss;
        return false;
    }
    if(! /^(\w){6,20}$/.test(tb.value))
    {
        if(document.getElementById(focusId) != null)
        {
            document.getElementById(focusId).style.display = "none";
        }
        if(document.getElementById(errorId) != null)
        {
            document.getElementById(errorId).style.display = "inline";
        }
        if(document.getElementById(diffId) != null)
        {
            document.getElementById(diffId).style.display = "none";
        }
        if(document.getElementById(trueId) != null)
        {
            document.getElementById(trueId).style.display = "none";
        }
        
        document.getElementById(errorId).className = errorcss;
        return false;
    }
    
        if(document.getElementById(focusId) != null)
        {
            document.getElementById(focusId).style.display = "none";
        }
        if(document.getElementById(errorId) != null)
        {
            document.getElementById(errorId).style.display = "none";
        }
        if(document.getElementById(diffId) != null)
        {
            document.getElementById(diffId).style.display = "none";
        }
        if(document.getElementById(trueId) != null)
        {
            document.getElementById(trueId).style.display = "inline";
        }
        tb.className = defaultcss;
}

//购物车
function ShoveEIMS3_Cart_ChangeAmount(id,tb,type)
{
    ShoveEIMS3.Web.UI.WebControls.ShoveWebControl_Cart.ChangeAmount(id,tb.value,type);
}

function ShoveEIMS3_Cart_DeleteProduct(id)
{
    ShoveEIMS3.Web.UI.WebControls.ShoveWebControl_Cart.DeleteProduct(id);
    document.getElementById("CartTr"+id.toString()).style.display = "none";
}

//搜索事件
function ShoveEIMS3_Transf(page,key,one,two,three,four)
{
    var tb = document.getElementById(key);
    if(tb.value.replace(" ","") == "")
    {
        alert("请输入关键字!");
        return;
    }
    var ddl = document.getElementById(four);
    if(ddl != null && ddl.value != "0")
    {
        window.location.href(page+"?key="+encodeURI(tb.value.replace(" ",""))+"&TypeId="+ddl.value);
       return;
    }
    ddl = document.getElementById(three);
    if(ddl != null && ddl.value != "0")
    {
       window.location.href(page+"?key="+encodeURI(tb.value.replace(" ",""))+"&TypeId="+ddl.value);
       return;
    }
    ddl = document.getElementById(two);
    if(ddl != null && ddl.value != "0")
    {
       window.location.href(page+"?key="+encodeURI(tb.value.replace(" ",""))+"&TypeId="+ddl.value);
        return;
    }
    ddl = document.getElementById(one);
    if(ddl != null && ddl.value != "0")
    {
        window.location.href(page+"?key="+encodeURI(tb.value.replace(" ",""))+"&TypeId="+ddl.value);
         return;
    }
 
    window.location.href(page+"?key="+encodeURI(tb.value.replace(" ","")));
    return;
}


//导航菜单事件
function ShoveEIMS3_Search(sender,nextID,nextText)
{
   var dt = ShoveEIMS3.Web.UI.WebControls.ShoveWebControl_Search.GetOneLevel(sender.value).value;
   var Level = document.getElementById(nextID);
   Level.options.length = 0;
   Level.options.add(new Option(nextText, "-1"));
   if (dt != null && dt.Rows.length > 0) 
   {
      for (var i = 0; i < dt.Rows.length; i++) 
     {
       Level.options.add(new Option(dt.Rows[i]["Name"].toString(), dt.Rows[i]["Id"].toString()));
     }
   }
}






