﻿//function $(str){
//	    return document.getElementById(str);
//}

var _boxwidth=450;
var scrollTopPos,scrollLeftPos;
scrollTopPos=0;
scrollLeftPos=0;

var isie = navigator.appVersion.toLowerCase().indexOf('msie') >= 0;

function _(str){
	return document.getElementsByTagName(str);
}
function AL(WH)
{
	var cv = 0;
	if (self.innerWidth)
	{
		cv = eval("self.inner" + WH);
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		cv = eval("document.documentElement.client" + WH);
	}
	else if (document.body)
	{
		cv = eval("document.body.client" + WH);
	}
	else
	{
		cv = 0;
	}
	return cv;
}

//隐藏所有的select
function hideAllSelect()
{
     var obj;
     obj=_("SELECT");
     var i;
     for(i=0;i<obj.length;i++)
        obj[i].style.visibility="hidden";
}
//显示所有的select
function showAllSelect()
{
     var obj;
     obj=_("SELECT");
     var i;
     for(i=0;i<obj.length;i++)
        obj[i].style.visibility="visible";
}

window.onscroll=function()
{
    retscroll();
    msginit();
}
window.onresize=function()
{
    retscroll();
    msginit();
}

function retscroll()
{
    if (typeof window.pageYOffset != 'undefined') {
       scrollTopPos = window.pageYOffset;
       scrollLeftPos = window.pageXOffset;
       
    }
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
       scrollTopPos = document.documentElement.scrollTop;
       scrollLeftPos = document.documentElement.scrollLeft;
    }
    else if (typeof document.body != 'undefined') {
       scrollTopPos = document.body.scrollTop;
       scrollLeftPos = document.body.scrollLeft;
    }
    else
    {
        scrollTopPos=0;
        scrollLeftPos=0;
    }
}

function msginit()
{
    if($("msg_div_main")!= 'undefined')
    {
        $("msg_div_main").style.left = (AL("Width") - _boxwidth) / 2 + scrollLeftPos;
	    $("msg_div_main").style.top  = (AL("Height") - 110) / 2 +  scrollTopPos;
	    
	   if(isie)
	    {
	        $("msg_div_all").style.width=(_("body")[0].clientWidth>document.documentElement.scrollWidth)?_("body")[0].clientWidth:document.documentElement.scrollWidth;
			$("msg_div_all").style.height=(AL("Height")>document.documentElement.scrollHeight)?AL("Height"):document.documentElement.scrollHeight;
        }
        else
        {
	        $("msg_div_all").style.width=(_("body")[0].clientWidth>document.body.scrollWidth)?_("body")[0].clientWidth:document.body.scrollWidth;
	        $("msg_div_all").style.height=(_("body")[0].clientHeight>document.body.scrollHeight)?_("body")[0].clientHeight:document.body.scrollHeight;
        }
	   
    }
}

function msg(boxtitle,boxtype,boxwidth,msg,url){
	//scroll(0,0);
	
	hideAllSelect();
	$("msg_div_main").style.width = boxwidth;
	_boxwidth=boxwidth;
	$("msg_div_main").style.left = (AL("Width") - boxwidth) / 2 + scrollLeftPos;
	$("msg_div_main").style.top  = (AL("Height") - 110) / 2 +  scrollTopPos;
	
	var msg_div_main_but_tmp = "<br /><br />"
				+ "<button class='msg_div_main_but' id='msg_div_main_but' "
				+ "onclick=\"msg_close_tmp_biyuan();" + url + "\">确 定</button>";
	switch(boxtype * 1){
		case 1:
			$("msg_div_main_content").innerHTML = msg + msg_div_main_but_tmp;
			//$("msg_div_main_but").focus();
		break;
		case 2:
			$("msg_div_main_content").innerHTML =  msg + msg_div_main_but_tmp
							 + "&nbsp;&nbsp;<button class='msg_div_main_but' "
							 + "onclick='msg_close_tmp_biyuan();'>取 消</button>";
			//$("msg_div_main_but").focus();
		break;
		case 3:
			$("msg_div_main_content").innerHTML =  msg;
		break;
		defualt:
			$("msg_div_main_content").innerHTML =  msg;
		break;
	}
	if(isie)
	{
	    $("msg_div_all").style.width=(_("body")[0].clientWidth>document.documentElement.scrollWidth)?_("body")[0].clientWidth:document.documentElement.scrollWidth;
	    $("msg_div_all").style.height=(AL("Height")>document.documentElement.scrollHeight)?AL("Height"):document.documentElement.scrollHeight;

    }
    else
    {
	    $("msg_div_all").style.width=(_("body")[0].clientWidth>document.body.scrollWidth)?_("body")[0].clientWidth:document.body.scrollWidth;
	    $("msg_div_all").style.height=(_("body")[0].clientHeight>document.body.scrollHeight)?_("body")[0].clientHeight:document.body.scrollHeight;
    }	

	$("msg_div_main_title").innerHTML =  boxtitle;
	$("msg_div_all").style.zIndex  = 9990;
	$("msg_div_main").style.zIndex = 9999;
	
	$("msg_div_all").style.display = "";
	$("msg_div_main").style.display = "";
	$("msg_div_all").oncontextmenu = function(){
		return false;
	}
	$("msg_div_main").oncontextmenu = function(){
		return false;
	}
}
function msg_close_tmp_biyuan(){
	$('msg_div_all').style.display='none';
	$('msg_div_main').style.display='none';
	showAllSelect();
}

//加入对话框移动代码 兼容IE,Opera,Firefox
function fDragging(obj, e, limit){ 
        if(!e) e=window.event; 
        var x=parseInt(obj.style.left); 
        var y=parseInt(obj.style.top); 
         
        var x_=e.clientX-x; 
        var y_=e.clientY-y; 
         
        if(document.addEventListener){ 
            document.addEventListener('mousemove', inFmove, true); 
            document.addEventListener('mouseup', inFup, true); 
        } else if(document.attachEvent){ 
            document.attachEvent('onmousemove', inFmove); 
            document.attachEvent('onmouseup', inFup); 
        } 
         
        inFstop(e);     
        inFabort(e);
         
        function inFmove(e){ 
            var evt; 
            if(!e)e=window.event; 
             
            if(limit){ 
                var op=obj.parentNode; 
                var opX=parseInt(op.style.left); 
                var opY=parseInt(op.style.top); 
                 
                if((e.clientX-x_)<0) return false; 
                else if((e.clientX-x_+obj.offsetWidth+opX)>(opX+op.offsetWidth)) return false; 
                 
                if(e.clientY-y_<0) return false; 
                else if((e.clientY-y_+obj.offsetHeight+opY)>(opY+op.offsetHeight)) return false; 
                //status=e.clientY-y_; 
            } 
             
            obj.style.left=e.clientX-x_+'px'; 
            obj.style.top=e.clientY-y_+'px'; 
             
            inFstop(e); 
        } // shawl.qiu script 
        function inFup(e){ 
            var evt; 
            if(!e)e=window.event; 
             
            if(document.removeEventListener){ 
                document.removeEventListener('mousemove', inFmove, true); 
                document.removeEventListener('mouseup', inFup, true); 
            } else if(document.detachEvent){ 
                document.detachEvent('onmousemove', inFmove); 
                document.detachEvent('onmouseup', inFup); 
            } 
             
            inFstop(e); 
        } // shawl.qiu script 
  
        function inFstop(e){ 
            if(e.stopPropagation) return e.stopPropagation(); 
            else return e.cancelBubble=true;             
        } // shawl.qiu script 
        function inFabort(e){ 
            if(e.preventDefault) return e.preventDefault(); 
            else return e.returnValue=false; 
        } // shawl.qiu script 
}


document.writeln("<style type='text/css'>"
	+ "#msg_div_all {width:100%;height:100%;position:absolute;filter:Alpha(opacity=70);-moz-opacity:0.7;background:#112537;}"
	+ "#msg_div_main {position:absolute;}"
	+ "#msg_div_main_title {font-size:12px;color:#0e59a7;font-family:verdana;padding-top:7px;}"
	+ "#msg_div_main_content {font-size:12px;color:#000;padding-left:8px;}"
	+ ".msg_div_main_but {background:url(/img_msg/buttonbg.gif);width:65px;heigt:20px;border:none;padding-top:3px;font-size:12px;cursor:pointer;}"
	+ "</style>"
	+ "<div id='msg_div_all' style='display:none;'></div>"
	+ "<div id='msg_div_main' style='display:none;cursor:move;' onmousedown=\"fDragging(this, event, false);\">"
	+ "<table width='100%' height='29' border='0' cellspacing='0' cellpadding='0'>"
	+ "<tr >"
	+ "<td width='5'><img src='/img_msg/bg_01.gif' width='36' height='34' alt='' /></td><td background='/img_msg/bg_02.gif' width='3'></td>"
	+ "<td background='/img_msg/bg_02.gif' msg_canmove='true' msg_forid='msg_div_main' id='msg_div_main_title'></td>"
	+ "<td background='/img_msg/bg_02.gif' align='right'>"
	+ "<img src='/img_msg/bg_05.gif' width='32' height='34' alt='关闭' style='cursor:pointer;' "
	+ "onMouseover=\"this.src='/img_msg/bg_13.gif'\" "
	+ "onMouseout=\"this.src='/img_msg/bg_05.gif'\" onclick=\'msg_close_tmp_biyuan();\' "
	+ "onMousedown=\"this.src='/img_msg/bg_18.gif'\" /></td>"
	+ "<td width='5'><img src='/img_msg/bg_06.gif' width='5' height='34' alt='' /></td>"
	+ "</tr>"
	+ "</table>"
	+ "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
	+ "<tr>"
	+ "<td width='5' background='/img_msg/bg_07.gif'></td>"
	+ "<td bgcolor='#F7F7F7' align='center'><br /><span id='msg_div_main_content'></span><br /><br /></td>"
	+ "<td width='5' background='/img_msg/bg_08.gif'></td>"
	+ "</tr>"
	+ "<tr>"
	+ "<td width='5' height='5'><img src='/img_msg/bg_09.gif' width='5' height='5' alt='' /></td>"
	+ "<td background='/img_msg/bg_11.gif'></td>"
	+ "<td width='5' height='5'><img src='/img_msg/bg_10.gif' width='5' height='5' /></td>"
	+ "</tr>"
	+ "</table>"
	+ "</div>");