﻿// JScript 文件

var d=document;
var messageBox={
    interval:null,
    an_times:0,
    id:"",
    ws:null,
    rate1:-1,
    rate2:-1,
    selectEle:null,
    setWS:function(ws){
        messageBox.ws=ws;
    },showpopup:function(id,msgw,msgh){ //msgw,msgh为显示的DIV的宽和高
            messageBox.selectEle=d.getElementsByTagName("select");
            if(messageBox.selectEle!=null){
                for(var i=0;i<messageBox.selectEle.length;i++){
                    //messageBox.selectEle[i].style.display="none";
                    messageBox.selectEle[i].setAttribute("disabled","disabled");
                }
            }
            var ele=d.getElementById(id);
            ele.style.fontSize="26px";

	        var msgw,msgh,bordercolor;
	        
	        //msgw=395;//提示窗口的宽度
	        //msgh=260;//提示窗口的高度
	        //bordercolor="#336699";//提示窗口的边框颜色
	        //titlecolor="#99CCFF";//提示窗口的标题颜色
	        
            var sWidth,sHeight;
	        sWidth=getWinWidth();//document.body.offsetWidth;
	        if(sWidth<document.body.offsetWidth) {sWidth=document.body.offsetWidth;}
	        sHeight=getWinHeight();//document.body.offsetHeight;
	        if(sHeight<document.body.offsetHeight) {sHeight=document.body.offsetHeight;}

	        var bgObj=document.createElement("div");
	        bgObj.setAttribute('id','bgDiv');
	        bgObj.style.position="absolute";
	        bgObj.style.top="0";
	        //bgObj.style.background="#fff";
	        //bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=0,finishOpacity=0";
	        bgObj.style.opacity="0";
	        bgObj.style.left="0";
	        bgObj.style.width=sWidth + "px";
	        bgObj.style.height=sHeight + "px";
	        bgObj.style.zIndex=8999;
	        document.body.appendChild(bgObj);
	        
            var msgObj=document.getElementById(id);
            msgObj.style.zIndex=9000;
            msgObj.style.display="";
            var scrollPos; 
            if (typeof window.pageYOffset != 'undefined')    //针对Netscape 浏览器
            { 
               scrollPos = window.pageYOffset; 
            } 
            else if (typeof document.compatMode != 'undefined' &&   document.compatMode != 'BackCompat')
            { 
               scrollPos = document.documentElement.scrollTop; 
            } 
            else if (typeof document.body != 'undefined') 
            { 
               scrollPos = document.body.scrollTop; 
            } 
            if((document.documentElement.scrollTop + (getWinHeight()-msgh)/2)>0)
    	        msgObj.style.top=(scrollPos + (getWinHeight()-msgh)/2) + "px";
    	    else
    	        msgObj.style.top="10px";
	        msgObj.style.left=(getWinWidth()-msgw)/2 + "px";

    },closepopup:function(id,bcomment){
        if(messageBox.selectEle!=null){
            for(var i=0;i<messageBox.selectEle.length;i++){
                //messageBox.selectEle[i].style.display="";
                messageBox.selectEle[i].removeAttribute("disabled");
            }
        }
        var bgObj=d.getElementById("bgDiv");
        document.body.removeChild(bgObj);
        d.getElementById(id).style.display="none";
        
        if(bcomment){
            messageBox.Animation("comments");
        }else{
            messageBox.Animation("help");
        }
    },Animation:function(id){
        var ele=d.getElementById(id);
        messageBox.id=id;
        //messageBox.interval=setInterval(messageBox.Animation_start,100);
    },Animation_start:function(){
            var ele=d.getElementById(messageBox.id);
            ele.style.visibility=ele.style.visibility=="hidden"?"visible":"hidden";
            messageBox.an_times++;
            if(messageBox.an_times>=8){
                messageBox.an_times=0;
                clearInterval(messageBox.interval);
            }
    },click_rate:function(brate1,index){
        if(brate1){
            var lastimg=d.getElementById("rate1_"+messageBox.rate1);
            var curimg=d.getElementById("rate1_"+index);
            lastimg.src=lastimg.src.replace(/green/i,"gray");
            curimg.src=curimg.src.replace(/gray/i,"green");
            messageBox.rate1=index;
        }else{
            var lastimg=d.getElementById("rate2_"+messageBox.rate2);
            var curimg=d.getElementById("rate2_"+index);
            lastimg.src=lastimg.src.replace(/green/i,"gray");
            curimg.src=curimg.src.replace(/gray/i,"green");
            messageBox.rate2=index;
        }
    }
};
    function getWinWidth(){
        try{
			var w;
			if(typeof (window.innerWidth)=="number"){w=window.innerWidth;}
			else{
				if(d.documentElement&&(d.documentElement.clientWidth||d.documentElement.clientHeight)){w=d.documentElement.clientWidth;}
				else{
					if(d.body&&(d.body.clientWidth||d.body.clientHeight)){w=d.body.clientWidth;}
				}
			}
			if(typeof(w)=="number"){
			    if(!(window.ActiveXObject ? true : false)){
			        w-=20;
			    }
			}
			return w;
        }catch(error){
            alert(error.message);
        }
    };
    function getWinHeight(){
        try{
			var h;
			if(typeof (window.innerHeight)=="number"){h=window.innerHeight;}
			else{
				if(d.documentElement&&(d.documentElement.clientWidth||d.documentElement.clientHeight)){h=d.documentElement.clientHeight;}
				else{
					if(d.body&&(d.body.clientWidth||d.body.clientHeight)){h=d.body.clientHeight;}
				}
			}
			return h;
        }catch(error){
            alert(error.message);
        }
    };

