﻿// JScript 文件
var STO = null;
$(document).ready(function()
{
    Create_MessageBox();
});

/* 获取当前时间 */
function getDate()
{
    var date = new Date();
    return date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate()+" "+date.getHours() +":"+ date.getMinutes() +":"+ date.getSeconds()
}

/* 获取滚动条和页面长宽值 */
function getRange() 
{
      var top     = document.documentElement.scrollTop;
      var left    = document.documentElement.scrollLeft;
      var height  = document.documentElement.clientHeight;
      var width   = document.documentElement.clientWidth;

      if (top==0 && left==0 && height==0 && width==0) {
        top     = document.body.scrollTop;
        left    = document.body.scrollLeft;
        height  = document.body.clientHeight;
        width   = document.body.clientWidth;
      }

      return  {top:top,left:left,height:height ,width:width} ;
}

/* 窗口随滚动条移动 */
function onbodyscroll()
{
    var div = $("#messagebox");
	var rang=getRange();
	div.css ({"top":rang.top+(rang.height-div.height())/2,"left":rang.left+(rang.width-div.width())/2});
}

/* 创造一个DIV窗口 */
function Create_MessageBox()
{
    $("<div id='messagebox'></div>").appendTo("body"); ;
    var div = $("#messagebox");
    //div.css({'position':'absolute','top':'50%','left':'50%','display':'none','z-Index':'10000'}); 
    div.css({'position':'absolute','display':'none','z-Index':'10000'});
   div.fadeTo("fast",0); 
}
/* 显示DIV窗口（1） */
function MessageBox(htmlStr,flag)
{
    $("select").hide();
    if(STO != null)
    {
        clearTimeout(STO);
    }
    var div = $("#messagebox"); 
    htmlStr = "<div class='win2'><div class='bg4 pLR'><h4 class='fll color5'>信息提示</h4><p class='flr closeButton' onclick='closeMessageBox2()'>关闭</p><div class='clearB'></div></div><div class='pad10'>"+htmlStr+"</div></div><div>";  
    div.html(htmlStr);
    var rang = getRange();
    div.css ({"top":rang.top+(rang.height-div.height())/2,"left":rang.left+(rang.width-div.width())/2});
    div.fadeTo("fast", 1.0).show();
   if(flag)
   { 
        STO = setTimeout("closeMessageBox()",3000);  
   } 
   window.onscroll=onbodyscroll;
}
/* 显示DIV窗口（2） */
function MessageBox2(title,htmlStr,flag)
{
    $("select").hide();
    if(STO != null)
    {
        clearTimeout(STO);
    }
    var div = $("#messagebox"); 
    htmlStr = "<div class='win2'><div class='bg4 pLR'><h4 class='fll color5 font14 b'>"+title+"</h4><p class='flr closeButton' onclick='closeMessageBox2()'>关闭</p><div class='clearB'></div></div><div class='pad10'>"+htmlStr+"</div></div><div>";  
    div.html(htmlStr);
    var rang = getRange();
    div.css ({"top":rang.top+(rang.height-div.height())/2,"left":rang.left+(rang.width-div.width())/2});
    div.fadeTo("fast", 1.0).show();
   if(flag)
   { 
        STO = setTimeout("closeMessageBox()",3000);  
   } 
   window.onscroll=onbodyscroll;
}
/* 关闭DIV窗口（慢慢的关闭） */
function closeMessageBox()
{
    var div = $("#messagebox");
    div.fadeTo("slow", 0,function()
    {
        $(this).hide();
        $("select").show();
    });
}
/* 关闭DIV窗口（快速关闭） */
function closeMessageBox2()
{
    var div = $("#messagebox");
    div.hide().fadeTo("fast",0);
   $("select").show(); 
} 
/* 登陆窗口 */
function login()
{
    var htmlStr = '<div class="input color1"><p class="textC b Dnone color2" id="login_error">不能为空！</p><p>用户名：<input type="text" name="u_name" id="u_name" /></p><p>密<span style="color:white;">一</span>码：<input type="password" name="u_pass" id="u_pass" /></p><p>验证码：<input style="width:80px;" size="4" maxlength="4" type="text" id="yzm_login" name="yzm_login" />&nbsp;<img class="yzm_img" src="'+webroot+'/yzm.aspx" align="absmiddle" />&nbsp;<a href="javascript:ChangeYZM();">换一张</a>（不区分大小写）</p><p class="textC"><input style="width:60px; height:25px;" type="button" onclick="toLogin();" value="登陆" /></p><div>';
    MessageBox2("登陆",htmlStr,false);
}
/* Ajax登陆 */
function toLogin()
{
    if($.trim($("#u_name").val()) == "" || $.trim($("#u_pass").val()) == "" || $.trim($("#yzm_login").val()) == "")
   {
        $("#login_error").html("错误：用户名，密码 都不能为空！").show();
        return;
   } 
    $("#login_error").html("<img class='imgM' src='"+webroot+"/images/ajax-loader.gif' />&nbsp;&nbsp;正在登陆...").show();
    $.post(webroot+"/Ajax/Login.ashx",{ sid:Math.random(),username:$("#u_name").val(),password:$("#u_pass").val(),yzm_login:$("#yzm_login").val() },function(result)
    {
        if(result == "yzmerror")
        {
            $("#login_error").html("验证码错误！");
            ChangeYZM();
            return;
        } 
        if(result == "noname")
        {
            $("#login_error").html("用户或密码错误！");
            ChangeYZM();
            return;
        }
        if(result =="yes")
        {
            MessageBox("<div class='textC'><p>登陆成功，欢迎光临！</p><p>3秒后将自动进入刷新...</p><div>",false);
            setTimeout("location.href='"+webroot+"/guestbook.aspx'",3000);
        }
        else
        {
            MessageBox("<p class='textC'>操作失败,请重新登陆！</p>",false);
            ChangeYZM();
        }
    });
}

/* 变换菜单 */
function changeMenu()
{
    $("#head_menu img").hover(function()
    { 
        var src_img = $(this).attr("src");
        src_img = src_img.replace("1.gif","2.gif");
        $(this).attr("src",src_img);
    },function()
    {
        var src_img = $(this).attr("src");
        src_img = src_img.replace("2.gif","1.gif");
        $(this).attr("src",src_img); 
    });
}
/* 刷新验证码 */
function ChangeYZM()
{
    $(".yzm_img").attr("src",webroot+"/yzm.aspx?"+Math.random());
}
function createFlash(src, width, height)
{
    src = src.replace(" ", ""); 
    var TEMP_IMAGE = '<img src="$src$" height="$height$" width="$width$" border="0" />'; 
    var TEMP_FLASH = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' 
    + ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" ' 
    + ' height="$height$" width="$width$"> ' 
    + '<param name="movie" value="$src$" /> ' 
    + '<param name="quality" value="high" /> ' 
    + '<param name="wmode" value="opaque" /> ' 
    + '<EMBED src="$src$" quality="high" WIDTH="$width$" HEIGHT="$height$" ' 
    + ' wmode="opaque" TYPE="application/x-shockwave-flash" ' 
    + ' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED> ' 
    + '</object>'; 
    return (/\.swf$/gi.test(src) == true ? TEMP_FLASH : TEMP_IMAGE) 
    .replace(/\$src\$/gi, src)
    .replace(/\$width\$/gi, width)
    .replace(/\$height\$/gi, height)
}

function WMV(src,height,width)
{
    var str = '<OBJECT ID="MediaPlayer" WIDTH="'+width+'" HEIGHT="'+height+'" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject">'
                +'<PARAM NAME="FileName" VALUE="'+src+'"> '
                +'<PARAM name="ShowControls" VALUE="true"> '
                +'<param name="ShowStatusBar" value="false"> '
                +'<PARAM name="ShowDisplay" VALUE="false"> '
                +'<PARAM name="autostart" VALUE="true"> '
                +'<EMBED TYPE="application/x-mplayer2" SRC="'+src+'" NAME="MediaPlayer" WIDTH="'+width+'" HEIGHT="'+height+'" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="true"> </EMBED> '
                +'</OBJECT>';
    document.write(str); 
}

function Real(src,height,width)
{
        document.writeln("<object name='mplay' id='mplay' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='"+width+"' height='"+height+"'  id='amourReal'>");
        document.writeln("  <param name='src' value='"+src+"'>");
        document.writeln("  <param name='autostart' value='false'>");
        document.writeln("  <param name='controls' value='imagewindow'>");
        document.writeln("  <param name='console' value='clip1'>");
        document.writeln("  <embed src='"+src+"' width='"+width+"' height='"+height+"' type='audio/x-pn-realaudio-plugin' autostart='true' controls='imagewindow' console='video'>");
        document.writeln("  </embed>");
        document.writeln("</object>");
        document.writeln("<br />");
        document.writeln("<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='"+width+"' height='50' id='amourReal'>");
        document.writeln("  <param name='src' value='"+src+"'>");
        document.writeln("  <param name='autostart' value='false'>");
        document.writeln("  <param name='controls' value='all'>");
        document.writeln("  <param name='console' value='clip1'>");
        document.writeln("  <embed type='audio/x-pn-realaudio-plugin' src='"+src+"' width='"+width+"' height='50' autostart='true' controls='all' console='video'>");
        document.writeln("  </embed>");
        document.writeln("</object>");
        document.close();
}
function Flash(src,height,width)
{
        document.write("<object name='flashplay' id='flashplay' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+width+"' height='"+height+"'>");
        document.write("<param name='movie' value='"+src+"'>");
        document.write("<param name='quality' value='high'>");
        document.write("<embed src='"+src+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed>");
        document.write("</object>");
        document.close();
}
function Flash1(src,height,width)
{
        document.write("<object name='flashplay' id='flashplay' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+width+"' height='"+height+"'>");
        document.write("<param name='movie' value='"+src+"'>");
        document.write("<param name='quality' value='high'>");
        document.write("<param name='wmode' value='transparent'>");
        document.write("<embed src='"+src+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed>");
        document.write("</object>");
        document.close();
}
function FLV(src,height,width)
{
    var str='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'">'
    +'<param name="movie" value="http://www.cnzz.cc/Flv/Flvplayer.swf" />'
    +'<param name="quality" value="high" />'
    +'<param name="allowFullScreen" value="true" />'
    +'<param name="FlashVars" value="vcastr_file='+src+'&LogoText=www.cnzz.cc&BufferTime=3" />'
    +'<embed src="http://www.cnzz.cc/Flv/Flvplayer.swf" allowfullscreen="true" flashvars="vcastr_file='+src+'&LogoText=www.cnzz.cc" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>'
    +'</object>';
    document.write(str); 
}

function FLV_()
{
   
     var str='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="320" height="240">'
             +'<param name="movie" value="http://www.cnzz.cc/Flv/Flvplayer.swf" />'
             +'<param name="quality" value="high" />'
             +'<param name="allowFullScreen" value="true" />'
             +'<param name="FlashVars" value="vcastr_file=http://www.xingzhicn.com/akchina1/file/xwfbh.flv&LogoText=www.cnzz.cc&BufferTime=3" />'
             +'<embed src="http://www.cnzz.cc/Flv/Flvplayer.swf" allowfullscreen="true" flashvars="vcastr_file=http://www.xingzhicn.com/akchina1/file/xwfbh.flv&LogoText=www.cnzz.cc" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="320" height="240"></embed>'
             +'</object>';
    document.write(str);          
}

function ClickImg()
{
    if(document.getElementById("imgShow") != null)
   {
        $("#imgShow img").click(function()
        {
            window.open($(this).attr("src"));
        })
   } 
}


function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. 
{ 
    var arVersion = navigator.appVersion.split("MSIE") 
    var version = parseFloat(arVersion[1]) 
    if ((version >= 5.5) && (document.body.filters)) 
    { 
       for(var j=0; j<document.images.length; j++) 
       { 
          var img = document.images[j] 
          var imgName = img.src.toUpperCase() 
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
          { 
             var imgID = (img.id) ? "id='" + img.id + "' " : "" 
             var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
             var imgStyle = "display:inline-block;" + img.style.cssText 
             if (img.align == "left") imgStyle = "float:left;" + imgStyle 
             if (img.align == "right") imgStyle = "float:right;" + imgStyle 
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
             var strNewHTML = "<span " + imgID + imgClass + imgTitle 
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
             img.outerHTML = strNewHTML 
             j = j-1 
          } 
       } 
    }     
} 
//window.attachEvent("onload", correctPNG); 


