﻿// JScript 文件

//设置首页顶部时间
function SetTopDate()
{
    setInterval("jnkc.innerHTML='<font color=#ffffff>'+new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay())+'</font>';",1000);
}

// ============ OnMouseOver事件 ============
//公用 (All Form include HyperLink)
function AddOnFontMouseOver()
{
    var obj = window.event.srcElement;
    obj.style.color="#cc0000";
}

// ============ OnMouseOut事件 ============
// (All Form include HyperLink)
function AddOnFontMouseOut(strColor)
{
    var obj = window.event.srcElement;
    obj.style.color=strColor;
}

// ============ OnMouseOver事件 ============
//公用 (All Form include HyperLink)
function AddImgMouseOver()
{
    var obj = window.event.srcElement;
    obj.style.filter="alpha(opacity = 100)";
}

// ============ OnMouseOut事件 ============
// (All Form include HyperLink)
function AddImgMouseOut(strColor)
{
    var obj = window.event.srcElement;
    obj.style.filter="alpha(opacity = 80)";
}

//添加OnMouseOver事件
//公用
function AddOnMouseOver()
{
    var obj = window.event.srcElement;
    obj.style.textDecoration="underline";
}

//添加OnMouseOut事件
//公用 
function AddOnMouseOut()
{
    var obj = window.event.srcElement;
    obj.style.textDecoration="";
}

//添加OnMouseOver事件
//公用
function AddOnLinkMouseOver()
{
    var obj = window.event.srcElement;
    obj.style.color = "#ff0000"
    obj.style.textDecoration="underline";
}

//添加OnMouseOut事件
//公用 
function AddOnLinkMouseOut()
{
    var obj = window.event.srcElement;
    obj.style.color = "#003300";
    obj.style.textDecoration="none";
}

function SetFullScreen()
{
    self.moveTo(-4,-4);self.resizeTo(screen.availWidth+8,screen.availHeight+8);
}
function InitPage()
{
    SetFullScreen();
    
    var Aobj1 = window.document.getElementById("A1");
    Aobj1.onmouseover = function(){AddOnLinkMouseOver();}
    Aobj1.onmouseout = function(){AddOnLinkMouseOut();}
    
    var Aobj2 = window.document.getElementById("A2");
    Aobj2.onmouseover = function(){AddOnLinkMouseOver();}
    Aobj2.onmouseout = function(){AddOnLinkMouseOut();}
    
    var Aobj3 = window.document.getElementById("A3");
    Aobj3.onmouseover = function(){AddOnLinkMouseOver();}
    Aobj3.onmouseout = function(){AddOnLinkMouseOut();}
    
    var Aobj4 = window.document.getElementById("A4");
    Aobj4.onmouseover = function(){AddOnLinkMouseOver();}
    Aobj4.onmouseout = function(){AddOnLinkMouseOut();}
    
    var Aobj5 = window.document.getElementById("A5");
    Aobj5.onmouseover = function(){AddOnLinkMouseOver();}
    Aobj5.onmouseout = function(){AddOnLinkMouseOut();}
    
    //var Aobj6 = window.document.getElementById("A6");
    //Aobj6.onmouseover = function(){AddOnLinkMouseOver();}
    //Aobj6.onmouseout = function(){AddOnLinkMouseOut();}
    
    var Aobj7 = window.document.getElementById("A7");
    Aobj7.onmouseover = function(){AddOnLinkMouseOver();}
    Aobj7.onmouseout = function(){AddOnLinkMouseOut();}
    
    //var Aobj8 = window.document.getElementById("A8");
    //Aobj8.onmouseover = function(){AddOnLinkMouseOver();}
    //Aobj8.onmouseout = function(){AddOnLinkMouseOut();}
}


//设置横向滚动
function SetLineScroll()
{
    var demo = window.document.getElementById("demo");
    var demo1 = window.document.getElementById("demo1");
    var demo2 = window.document.getElementById("demo2");
    var speed=40 
    demo2.innerHTML=demo1.innerHTML 
    var MyMar=setInterval(Marquee,speed) 
    demo.onmouseover=function() 
    {
	    clearInterval(MyMar)
    } 
    demo.onmouseout=function() 
    {
	    MyMar=setInterval(Marquee,speed)
    } 
}

function Marquee()
{
    var demo = window.document.getElementById("demo");
    var demo1 = window.document.getElementById("demo1");
    var demo2 = window.document.getElementById("demo2"); 
	if(demo.scrollLeft>=demo1.scrollWidth)
	{ 
		demo.scrollLeft=0 
	}
	else
	{ 
		demo.scrollLeft++ 
	} 
}

//点击相应image进入授权专区
function EnterAuthorityArea()
{
    var obj = window.event.srcElement;
    var isLoginObj = window.document.getElementById("HIsLogin"); 
    var userCodeObj = window.document.getElementById("HLoginCode"); 
    
    if(isLoginObj.value != "yes")
    {
        alert("您要查看的页面需登录后方能查看!");
        return;
    }
    
    if(obj.id == "IMG1")
    {
        var sysManagerStr = userCodeObj.value;
        if(sysManagerStr != "00000000")
        {
            alert("请使用管理员身份登录!");
            return;
        }
        window.open("sys/index.aspx","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "IMG3")
    {
        window.open("Hidden/indexManager.aspx","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "IMG4")
    {
        window.open("AccidentReport/indexManager.aspx","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "IMG5")
    {
        window.open("SafeReport/indexManager.aspx","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "IMG6")
    {
        window.open("Analysis/indexManager.aspx","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "IMG7")
    {
        window.open("DayReport/indexManager.aspx","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "IMG8")
    {
        window.open("Appeal/indexManager.aspx","_blank","scroll=0,resizable=0,help=0,status=0");
    }
}


//点击相应基层单位进入授权专区
function EnterInferiorUnitArea()
{
    var obj = window.event.srcElement;
    var isLoginObj = window.document.getElementById("HIsLogin"); 
    var userCodeObj = window.document.getElementById("HLoginCode"); 
    
    if(isLoginObj.value != "yes")
    {
        alert("您要查看的页面需登录后方能查看!");
        return;
    }
    
    if(obj.id == "TDUnit1")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=01","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit2")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=02","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit3")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=03","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit4")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=04","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit5")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=05","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit6")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=06","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit7")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=07","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit8")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=08","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit9")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=09","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit10")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=10","_blank","scroll=0,resizable=0,help=0,status=0");
    }
    if(obj.id == "TDUnit11")
    {
        window.open("sys/InferiorUnit/index.aspx?unitCode=11","_blank","scroll=0,resizable=0,help=0,status=0");
    }
}

//登录
function MainLogin()
{
    var isLoginObj = window.document.getElementById("HIsLogin"); 
    var loginNameObj = window.document.getElementById("HLoginName"); 
    var fontLoginObj = window.document.getElementById("FontLogin");
    var displayLoginObj = window.document.getElementById("DisplayLogin");
    var changePasswordObj = window.document.getElementById("TD1");
    
    var returnValue = window.showModalDialog("login.aspx",window,"scrollbars=no;resizable=no;help=no;status=no;center=yes;dialogWidth=307px;dialogHeight=235px");
    if(returnValue == true)
    {
        isLoginObj.value = "yes";
        fontLoginObj.innerText = "注销登录";
        displayLoginObj.innerText = "当前用户："+loginNameObj.value;
        fontLoginObj.onclick = function(){ExitLogin();}
        changePasswordObj.style.display = "";
    }
}

//退出登录
function ExitLogin()
{
    var isLoginObj = window.document.getElementById("HIsLogin"); 
    var loginNameObj = window.document.getElementById("HLoginName"); 
    var fontLoginObj = window.document.getElementById("FontLogin");
    var displayLoginObj = window.document.getElementById("DisplayLogin");
    var changePasswordObj = window.document.getElementById("TD1");
    
    isLoginObj.value = "no";
    loginNameObj.value = "";
    displayLoginObj.innerText = "";
    fontLoginObj.innerText = "登录";
    fontLoginObj.onclick = function(){MainLogin();}
    changePasswordObj.style.display = "none";
}

//去掉字符串左右空格
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}

//设置Cookie
function SetCookie(name, value, expires) 
{ 
    document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/"; 
} 

//获取Cookie
function GetCookie(name) 
{ 
    if(name.Trim() == "")
        return "";
        
    var search; 
    // Returns the value of the named cookie. 
    search = name + "="; 
    offset = document.cookie.indexOf(search); 
    if (offset != -1)
    { 
        offset += search.length; 
        end = document.cookie.indexOf(";", offset); 
        if (end == -1) 
        {
            end = document.cookie.length; 
        }
        return unescape(document.cookie.substring(offset, end)); 
    } 
    else
    { 
        return ""; 
    }
}

//登录
function Login()
{
    nameObj = window.document.getElementById("Text1");
    passwordObj = window.document.getElementById("Password1");
    checkObj = window.document.getElementById("Checkbox1");   
    
    if(nameObj.value.Trim() == "")
    {
        alert("请输入登录用户名");
        nameObj.focus();
        return false;
    }
    if(passwordObj.value.Trim() == "")
    {
        alert("请输入登录密码");
        passwordObj.focus();
        return false;
    }
    if(checkObj.checked)
    {
        var pass =  escape(passwordObj.value.Trim());
        pass = Encrypt(pass);
        var expires = new Date();
        expires.setTime(expires.getTime() + 3 * 30 * 24 * 60 * 60 * 1000);
        SetCookie(nameObj.value.Trim(),pass,expires);
    }
    __doPostBack('Button1','');
}

//获取用户口令
function GetPassword()
{
    nameObj = window.document.getElementById("Text1");
    passwordObj = window.document.getElementById("Password1");
    var pass = GetCookie(nameObj.value.Trim());
    if(pass != "")
    {
       passwordObj.value= Decode(pass);
    }
}

//Encrypt
function Encrypt(str)
{
    var s ="";
    for(var i = 0; i<str.length; i++)
    {
        var myChar = str.substring(i,i+1);
        var asc10 = (myChar.charCodeAt(0));
        var asc16 = asc10.toString(16);
        if(asc16.length<2)
        {
            asc16 = "0"+asc16;
        }
        s += asc16;
    }
    return s;
}

//Decode
function Decode(str)
{
    var s ="";
    var tempStr = "";
    for(var i = 0; i<str.length; i++)
    {
        if(i%2 == 0)
        {
            tempStr = str.substring(i,i+1);
            continue;
        }
        else
        {
            tempStr += str.substring(i,i+1);
        }
        var asc10 = parseInt(tempStr, 16)
        s += String.fromCharCode(asc10);
    }
    return s;
}

//打开安全信息日报
function OpenReport()
{
     //alert("aa");
     var myWidth = "770px";
     var myHeight = "720px";
     if(window.screen.availHeight<700)
        myHeight = "580px";
     //alert("aa");
     window.showModalDialog("DayReport/index.aspx",null,"scrollbars=no;resizable=no;help=no;status=no;center=yes;dialogWidth="+myWidth+";dialogHeight="+myHeight);
}

//打开安全要闻
function OpenNews()
{
     var myWidth = "770px";
     var myHeight = "720px";
     if(window.screen.availHeight<700)
        myHeight = "580px";
     window.showModalDialog("news/index.aspx",null,"scrollbars=no;resizable=no;help=no;status=no;center=yes;dialogWidth="+myWidth+";dialogHeight="+myHeight);
}

//打开监察要闻
function OpenNewNews(newsId)
{
     //var myWidth = "770px";
     //var myHeight = "720px";
     //if(window.screen.availHeight<700)
        //myHeight = "580px";
     //window.showModalDialog("news/newIndex.aspx?id="+newsId,null,"scrollbars=no;resizable=no;help=no;status=no;center=yes;dialogWidth="+myWidth+";dialogHeight="+myHeight);
     window.open("news/newIndex.aspx?id="+newsId);
}

//打开领导讲话
function OpenLeaderTalk(newsId)
{
   window.open("leaderTalk/index.aspx?id="+newsId);
}

//打开安全日报
function OpenDayReport(newsId)
{
   window.open("DayReport/newIndex.aspx?id="+newsId);
}

//打开事故通报
function OpenTrain(newsId)
{
   window.open("Train/index.aspx?id="+newsId);
}

//打开专项监察
function OpenSupervise(newsId)
{
   window.open("Supervise/index.aspx?id="+newsId);
}

//打开警钟常鸣
function OpenAlert(newsId)
{
   window.open("Alert/index.aspx?id="+newsId);
}

//打开安全文化
function OpenCulture(newsId)
{
   window.open("Culture/index.aspx?id="+newsId);
}

//打开干部入井
function OpenGoMine(newsId)
{
   window.open("GoMine/index.aspx?id="+newsId);
}

//打开经验交流
function OpenExperience(newsId)
{
   window.open("Experience/index.aspx?id="+newsId);
}

//打开行业聚焦交流
function OpenSafeFocus(newsId)
{
   window.open("SafeFocus/index.aspx?id="+newsId);
}



function ExportFlash(title1,title2,title3,title4,title5,link1,link2,link3,link4,link5)
{
    var _width = 180
    var _height = 150
    var text_height = 20
    var flash_height = _height + text_height 

    var pic_arr = new Array(); 
    var link_arr = new Array(); 
    var text_arr = new Array(); 

    var i = 0;
    pic_arr[0] = "image/news/t01.jpg";
    pic_arr[1] = "image/news/t02.jpg";
    pic_arr[2] = "image/news/t03.jpg";
    pic_arr[3] = "image/news/t04.jpg";
    pic_arr[4] = "image/news/t05.jpg";

    link_arr[0] = "news/newNewsPicture.aspx?id="+link1;
    link_arr[1] = "news/newNewsPicture.aspx?id="+link2;
    link_arr[2] = "news/newNewsPicture.aspx?id="+link3;
    link_arr[3] = "news/newNewsPicture.aspx?id="+link4;
    link_arr[4] = "news/newNewsPicture.aspx?id="+link5;

    text_arr[0] = title1;
    text_arr[1] = title2;
    text_arr[2] = title3;
    text_arr[3] = title4;
    text_arr[4] = title5;

    var p = pic_arr.join("|");
    var l = link_arr.join("|");
    var t = text_arr.join("|");
    var f = "image/main.swf";

    document.write('<body id="MyBody" runat =server leftmargin="0" topmargin="0" scroll="no">');
    document.write('<object ID="focus_flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ _width +'" height="'+ flash_height +'">');
    document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+f+'"><param name="quality" value="high"><param name="bgcolor">');
    document.write('<param name="menu" value="false"><param name=wmode value="transparent">');
    document.write('<param name="FlashVars" value="pics='+p+'&links='+l+'&texts='+t+'&borderwidth='+_width+'&borderheight='+_height+'&textheight='+text_height+'">');
    document.write('<embed ID="focus_flash" src="'+f+'" wmode="opaque" FlashVars="pics='+p+'&links='+l+'&texts='+t+'&borderwidth='+_width+'&borderheight='+_height+'&textheight='+text_height+'" menu="false" quality="high" width="'+ _width +'" height="'+ flash_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
    document.write('</body>');
}

function SetFloaterPosition()
{    
    floater1Obj = window.document.getElementById("floater1");
    floaterObj = window.document.getElementById("floater");
    winWidth = document.body.offsetWidth;
    
    if(winWidth<780)
    {
        floater1Obj.style.display = "none";
        floaterObj.style.display = "none";
        return;
    }
    else
    {
        floater1Obj.style.display = "";
        floaterObj.style.display = "";
    }
    
    var left1 = (winWidth - 778 - floater1Obj.clientWidth * 2)/4;
    if(left1<0)
        left1 = left1 * 2 - 6;
    floater1Obj.style.left = left1-5;
    floaterObj.style.left = winWidth - floaterObj.clientWidth - left1 - 16;
}

self.onError = null;
currentX = currentY = 0;
whichIt = null;
lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
    
function SetFloater()
{    
    var floater1CloseObj = window.document.getElementById("floater1Close");
    var floaterCloseObj = window.document.getElementById("floaterClose");
    if(NS || IE) 
    {
        var action = window.setInterval("heartBeat('floater;floater1')", 20);
        floater1CloseObj.onclick = function(){clearInterval(action);HiddenFloater();}
        floaterCloseObj.onclick = function(){clearInterval(action);HiddenFloater();}
    }
}

function HiddenFloater()
{
    floater1Obj = window.document.getElementById("floater1");
    floaterObj = window.document.getElementById("floater");
    floater1Obj.style.display="none";
    floaterObj.style.display="none";
    document.body.onresize="";
}

function heartBeat(objectid) 
{
    IE = 1;
    NS = 0;
    if(IE) { diffY = document.body.scrollTop;}
    if(NS) { diffY = self.pageYOffset;}
    if(diffY != lastScrollY) 
    {
        percent = .1 * (diffY - lastScrollY);
        if(percent > 0)
            percent = Math.ceil(percent);
        else
            percent = Math.floor(percent);
        
        if(IE)
        {
            objectid = objectid.split(";");
            for (i = 0; i < objectid.length; i++)
                eval("document.all."+objectid[i]).style.pixelTop += percent;
        }
        
        if(NS) 
        {
            objectid = objectid.split(";");
            for (i = 0; i < objectid.length; i++)
                eval("document."+objectid[i]).top += percent;
        }
        lastScrollY = lastScrollY + percent;
    }
}

//给组合框颜色选择器填充背景色
function FillSelectColor()
{
    obj = window.document.getElementById("Select1");
    for(var i=0; i<obj.options.length;i++)
    {
        obj.options[i].style.backgroundColor = obj.options[i].value;
    }
}

// ============ OnKeypress事件 ============
// MainInfo 
function LoginConfirm()
{
    var userObj = window.document.getElementById("Text1");
    var passwordObj = window.document.getElementById("Password1");
    
    if(userObj.value.Trim() == "")
    {
        alert("请输入您的用户名后再登录");
        userObj.focus();
        return false;
    }
    
    if(passwordObj.value.Trim() == "")
    {
        alert("口令不能为空，请输入您的登录口令");
        passwordObj.focus();
        return false;
    }
    
    __doPostBack('Button1','');
}

// ============ OnKeypress事件 ============
// MainInfo 
function EnterConfirm()
{
    var obj = window.event.srcElement;
    var myKeyCode = window.event.keyCode;
    var loginButtonObj = window.document.getElementById("Button1");
    if(myKeyCode == 13 && obj.id != "Button1")
    {
        LoginConfirm();
    }
}

//设置项部导航条位置
function SetTopDivPosition()
{
    var divObj = window.document.getElementById("topDiv");
    var tdObj = window.document.getElementById("topTd");
    
    var x=0;
    var y=0;

    while(tdObj)
    {
        x += tdObj.offsetLeft;
        y += tdObj.offsetTop;
        tdObj=tdObj.offsetParent; 
    }
    divObj.style.position="absolute";
    divObj.style.left = x+171;
    divObj.style.top = y+112;
}

function goLinkUrl(strUrl)
{
    window.open(strUrl,"_blank");
}

// ============ 打开更改口令 ============
function OpenPassword()
{
    window.showModalDialog("sys/changePassword.aspx","","scrollbars=no;resizable=no;help=no;status=no;center=yes;dialogWidth=330px;dialogHeight=250px");
}
