/*=======================================*/
/* var moves=new movediv("move");		 */
/* var moves=new movediv("move",400,200);*/
/* moves.setbody("body");				 */
/* moves.settitle("aaaa");				 */
/* onclick=moves.show(event.clientX,	 */
/*						event.clientY,	 */
/*						event.screenX,	 */
/*						event.screenY);	 */
/* moves.show();						 */
/*=======================================*/
function movediv(N,widths,heights){
	if(typeof(N) =='undefined') return false;
	this.body=document.compatMode == "BackCompat" ? document.body : document.documentElement;
	this.DoID=0;
	this.N=N;
	if(typeof(widths) =='undefined') widths=502;
	//if(typeof(heights) =='undefined') heights=302;
	this.HTML='<style type="text/css">';
	this.HTML+='.'+this.N+'Main{border:1px solid #4e6f2d;color:#FFFFFF;background:#FFFFFF; padding:0px;}';
	this.HTML+='.'+this.N+'Title{height:28px;color:#FFFFFF;background:url(/images/dialog_ct.png) repeat-x; font-size:12px; text-align:left; padding-left:10px; font-weight:bold;}';
	this.HTML+='.'+this.N+'Center{padding:10px; font-size:12px; text-align:left;}';
	this.HTML+='.'+this.N+'aaa{background:url(/images/dialog_lt.png) no-repeat;}';
	this.HTML+='.'+this.N+'bbb{background:url(/images/dialog_rt.png) no-repeat right top; }';
	this.HTML+='.'+this.N+'ccc{background:url(/images/dialog_mrm.png) no-repeat; }';
	this.HTML+='.'+this.N+'Buttom{background:#FFFFFF; height:20px}';
	this.HTML+='</style>';
	this.HTML+="<div id='"+this.N+"' class='"+this.N+"Main' style='width:502px;left:50%;margin-left:-250px;top:80px;position:absolute;filter:alpha(opacity=100);opacity:1;-moz-opacity:1;overflow:visible;z-index:110;display:block;visibility:hidden;'><table border=0 width=100% height=auto cellspacing=0>";
	this.HTML+="<tr id='"+this.N+"Title' class='"+this.N+"Title'><td onmousedown='javascript:"+this.N+"s.mousedo(event);' onmousemove='javascript:"+this.N+"s.mousemove(event);' onmouseup='javascript:"+this.N+"s.mouseup();' width="+(widths-2)+" id='"+this.N+"_title' align=left style='padding-bottom:0px;padding-top:0px; padding-left:30px;color:#fff;line-height:16px;font-size:14px;'>login</td><td align=center style='cursor:pointer;color:#fff;background-position:top right;font-weight:bold;font-size:14px;' width='50' onclick=javascript:"+this.N+"s.hidden(); id='"+this.N+"closea' >¹Ø±Õ</td></tr>";
	//height:"+(heights+100)+"px;
	this.HTML+="<tr><td  colspan='2'><div id='"+this.N+"Center'  class='"+this.N+"Center' style='width:100%;text-align:center;'>&nbsp;</div></td></tr>";
	this.HTML+="<tr id='"+this.N+"Buttom' class='"+this.N+"Buttom' style='display:none;'><td onmousedown='javascript:"+this.N+"s.mousedo(event);' onmousemove='javascript:"+this.N+"s.mousemove(event);' onmouseup='javascript:"+this.N+"s.mouseup();'><marquee  scrolldelay='200'  width=100%><span id='"+this.N+"bar'>login</span></marquee></td><td style='cursor:p ointer;padding:1px; text-align:right; font-size:14px;' onclick=javascript:"+this.N+"s.hidden(); id='"+this.N+"closeb'>¹Ø±Õ</td></tr></table></div>";
	this.HTML+="<span id='"+this.N+"_buttom' style='height:"+(this.body.clientHeight+(this.body.scrollHeight>this.body.clientHeight ? this.body.scrollHeight-this.body.clientHeight : 0))+"px;width:"+this.body.clientWidth+"px;left:0;top:0;background-color:#000000;position:absolute;filter:alpha(opacity=65);opacity:0.65;-moz-opacity:0.65;overflow:hidden;z-index:100;display:block;visibility:hidden;'></span>";
	document.write(this.HTML);
	this.isInit=function(){
		try{
			if(document.getElementById(this.N)==null){
				var newTag=document.createElement("DIV");
				newTag.innerHTML=this.HTML;
				this.body.insertBefore(newTag);
			}
		} catch (e) { }
	}
	this.mouseup=function(){
		this.isInit();
		if(this.DoID==1){
			document.getElementById(this.N).style.cursor='default';
			this.DoID=0;
		}
	}
	this.divtop=0;
	this.divleft=0;
	this.mousedo=function(obj){
		this.isInit();
		var e= obj==null ? window.event : obj;
		this.DoID=1;
		//this.divleft=e.clientX-parseInt(document.getElementById(this.N).style.left);
		this.divtop=e.clientY-parseInt(document.getElementById(this.N).style.top);
	}
	this.mouse=new Object();
	this.mouse.x=0;
	this.mouse.y=0;
	this.mousemove=function(obj){ 
		this.isInit();
		var e= obj==null ? window.event : obj;
		this.mouse.x=e.x;
		this.mouse.y=e.y;
		if(this.DoID){
			document.getElementById(this.N).style.cursor='move';
			//document.getElementById(this.N).style.left=parseInt(parseInt(e.clientX)-parseInt(this.divleft))+"px";
			document.getElementById(this.N).style.top=parseInt(parseInt(e.clientY)-parseInt(this.divtop))+"px";
		}
	}
	this.IsChild=function(obj){
		var TObj=obj;
		try{
			while(TObj.nodeName!="BODY"){
				if(TObj.id==this.N)return true;
				TObj=TObj.parentNode;
			}
		} catch (e) { }
		return false;
	}
	this.show=function(clientX,clientY,screenX,screenY){
		this.isInit();
        if(typeof(screenX) =='undefined')screenX=10;
		if(typeof(screenY) =='undefined')screenY=100;
		if(typeof(clientX) =='undefined')clientX=100;
		if(typeof(clientY) =='undefined')clientY=10;
		var width=parseInt(document.getElementById(this.N).style.width);
		var height=parseInt(document.getElementById(this.N).style.height);
	    var x=screen.width/2-width/2,y=screen.height/2-height/2;
	    if(x>screenX)
			clientX=x-screenX+clientX+this.body.scrollLeft;
	    else
			clientX=clientX-(screenX-x)+this.body.scrollLeft;
	    if(y>screenY)
			clientY=y-screenY+clientY+this.body.scrollTop;
	    else
			clientY=clientY-(screenY-y)+this.body.scrollTop;
		document.documentElement.scrollLeft=0;
		document.documentElement.scrollTop=0;
		for(var i=0;i<document.getElementsByTagName('SELECT').length;i++){
			if(!this.IsChild(document.getElementsByTagName('SELECT')[i]))document.getElementsByTagName('SELECT')[i].style.visibility="hidden";
		}
	    //document.getElementById(this.N).style.left=(clientX-100)+"px";
	    //document.getElementById(this.N).style.top=(clientY-100)+"px";	
		document.getElementById(this.N).style.top=(100)+"px";	
		document.getElementById(this.N).style.visibility="visible";
		document.getElementById(this.N+'_buttom').style.width=this.body.clientWidth;
		document.getElementById(this.N+'_buttom').style.height=(this.body.clientHeight+(this.body.scrollHeight>this.body.clientHeight ? this.body.scrollHeight-this.body.clientHeight : 0));
		document.getElementById(this.N+'_buttom').style.visibility="visible";
	}
	this.hidden=function(){
		this.isInit();
		document.getElementById(this.N+'Center').innerHTML="";
		document.getElementById(this.N).style.visibility="hidden";
		document.getElementById(this.N+'_buttom').style.visibility="hidden";
		for(var i=0;i<document.getElementsByTagName('SELECT').length;i++){
			if(!this.IsChild(document.getElementsByTagName('SELECT')[i]))document.getElementsByTagName('SELECT')[i].style.visibility="visible";
		}
	}
	this.setBackground=function(background){
		this.isInit();
		document.getElementById(this.N+'_buttom').style.background=background;
	}
	this.setAlpha=function(alpha){
		this.isInit();
		document.getElementById(this.N+'_buttom').style.opacity=alpha/100;
		document.getElementById(this.N+'_buttom').style.filter="alpha(opacity="+parseInt(alpha)+")";
	}
	this.settitle=function(title){
		this.isInit();
		if(typeof(title) =='undefined') return false;
		document.getElementById(this.N+'_title').innerHTML=title;
	}
	this.setbody=function(body){
		this.isInit();
		if(typeof(body) =='undefined') return false;
		document.getElementById(this.N+'Center').innerHTML=body;
	}
	this.setbar=function(bar){
		this.isInit();
		if(typeof(bar) =='undefined') return false;
		document.getElementById(this.N+'bar').innerHTML=bar;
	}
	this.setclose=function(closea,closeb){
		this.isInit();
		if(typeof(closea) =='undefined') return false;
		if(typeof(closeb) =='undefined') closeb=closea;
		document.getElementById(this.N+'closea').innerHTML=closea;
		document.getElementById(this.N+'closeb').innerHTML=closeb;
	}
}
