/*
 *this file is part of Nseer cloud ERP
 *Copyright (C)2000-2010 Nseer Technology Co.,Ltd/http://www.nseer.com
 */
try{
 document.onmousedown=function (e){n_D.initDrag(e);}
 document.onmouseup=function (e){n_D.dragimg(e);}
 document.body.onmousemove=function (e){n_D.mouseStyle(e);}
 function Nseer_DivViewChange(name){
    this.Version = "NSEER ERP V7.0-js1.0";
	this.name=name;
    this.onmousedown = document.onmousedown;
    this.onmousemove = document.onmousemove;
    this.onmouseup = document.onmouseup;
    this.onselectstart = document.onselectstart;
	this.dE=document.getElementById&&!document.all;
	this.mouse_tag=0;
	this.isdrag=false;
	this.oDragObj=null;
	this.nseerZindex=0;
	this.port_X=0;
	this.port_Y=0;
	this.port_X1=0;
	this.port_Y1=0;
	this.left1=0;
	this.top1=0;
	this.tag=0;
	this.min_tag=0;
	this.max_tag=0;
	this.data=new Array();
	this.v=0;
	this.db_max_return=0;
	this.def=0;
	this.nseerDef=0;
	this.scrollW=document.body.scrollWidth;
	this.changeSize=function(){};

	this.detachEvent=function(){
		document.onselectstart=this.onselectstart;
	}
	this.coverSelect=function(div){
		var n_iframe=document.createElement('iframe');
		n_iframe.src="javascript:false";
		n_iframe.style.cssText="position:absolute;visibility:inherit;top:0px;left:0px;width:100%;height:100%;z-index:-1;filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'";
		div.appendChild(n_iframe);
	}
	this.initDrag=function (e){
		e=e||window.event;
		this.mouse_tag=1;
		var oDragHandle = this.dE ? e.target : e.srcElement; 
		var topElement = "HTML"; 
		while (oDragHandle.tagName != topElement && oDragHandle.getAttribute("nseerDef") != "dragAble"&&oDragHandle.getAttribute("nseerDef") != "dragonly"&&oDragHandle.getAttribute("nseerDef") != "closeonly"){
			oDragHandle = this.dE ? oDragHandle.parentNode : oDragHandle.parentElement;
		} 
		if(oDragHandle.getAttribute("nseerDef")!=null&&oDragHandle.getAttribute("nseerDef")!='undefined'){
			if(oDragHandle.getAttribute("nseerDef")=="dragAble"){this.nseerDef=1;}
			if(oDragHandle.getAttribute("nseerDef")=="dragonly"){this.nseerDef=2;}
			if(oDragHandle.getAttribute("nseerDef")=="closeonly"){this.nseerDef=3;}
			if(this.nseerDef==1||this.nseerDef==2||this.nseerDef==3){
			this.isdrag = true;
			this.oDragObj = oDragHandle; 
			//*********************************************
			//this.oDragObj.style.zIndex=++this.nseerZindex;
			this.oDragObj.style.overflow='hidden';
			this.port_X1=e.clientX;
			this.port_Y1=e.clientY;
			var x12=parseInt(this.getStyle(this.oDragObj,"left","left"))+parseInt(this.getStyle(this.oDragObj,"width","width"));
			var y12=parseInt(this.getStyle(this.oDragObj,"top","top"))+parseInt(this.getStyle(this.oDragObj,"height","height"));
			this.left1=parseInt(this.getStyle(this.oDragObj,"left","left"));
			this.top1=parseInt(this.getStyle(this.oDragObj,"top","top"));
			this.loadDiv(this.oDragObj,0,e);
			//*****************************
			if(this.tag==0){
				document.onselectstart=this.onselectstart;
			}else{
				document.onselectstart = function() { return false;};
				if (oDragHandle.setCapture) {
					oDragHandle.setCapture();
				} else {
					e.preventDefault();
				}
			}
			eval('document.onmousemove=function (e){'+this.name+'.moveMouse(e);}');
			return false;
			}
		}
	}
	this.loadDiv=function (obj,t,e){
		e=e||window.event;
		var nseer_r=obj;
		var w = obj.offsetWidth;
		var h = obj.offsetHeight;
		var x = obj.offsetLeft;
		var y = obj.offsetTop;
		while(obj=obj.offsetParent){
			x += obj.offsetLeft;
			y += obj.offsetTop;
		}
		if(this.nseerDef==1){

		}else if(this.nseerDef==2){
			if(parseInt(e.clientY)>parseInt(y)&&parseInt(e.clientY)<parseInt(y)+20&&parseInt(e.clientX)<parseInt(x)+parseInt(w)-10&&parseInt(e.clientX)>parseInt(x)&&nseer_r.id!=''){
			if(t!=0){
				nseer_r.style.cursor='move';
			}else{
				this.tag=4;
			}
		}else{
			if(t!=0){
				nseer_r.style.cursor='default';
			}else{
				this.tag=0;
			}
		}
		}
	}
	this.moveMouse=function (e){
		if(this.isdrag==true&&this.max_tag==0){
			e=e||window.event;
			var x12=parseInt(this.getStyle(this.oDragObj,"left","left"))+parseInt(this.getStyle(this.oDragObj,"width","width"));
			var y12=parseInt(this.getStyle(this.oDragObj,"top","top"))+parseInt(this.getStyle(this.oDragObj,"height","height"));
			if(this.tag==0){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				this.left1=parseInt(this.getStyle(this.oDragObj,"left","left"));
				this.top1=parseInt(this.getStyle(this.oDragObj,"top","top"));
			}else  if(this.tag==1){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_X>0&&this.port_X>parseInt(this.left1)) this.oDragObj.style.width=this.port_X-parseInt(this.left1)+2;
			}else if(this.tag==8){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_X>0&&this.port_X<x12){
					this.oDragObj.style.left=this.port_X-2;
					this.oDragObj.style.width=x12-this.port_X+2;
				}
			}else if(this.tag==2){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_Y>0&&this.port_Y>parseInt(this.top1)) this.oDragObj.style.height=this.port_Y-parseInt(this.top1);
			}else if(this.tag==6){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_Y>0&&this.port_Y<y12){
					this.oDragObj.style.top=this.port_Y-2;
					this.oDragObj.style.height=y12-this.port_Y+2;
				}
			}else if(this.tag==3){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_X>0&&this.port_Y>0&&this.port_X>parseInt(this.left1)&&this.port_Y>parseInt(this.top1)){
					this.oDragObj.style.width=this.port_X-parseInt(this.left1);
					this.oDragObj.style.height=this.port_Y-parseInt(this.top1);
				}
			}else if(this.tag==5){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_X>0&&this.port_Y>0&&this.port_X>parseInt(this.left1)&&this.port_Y<y12){
					this.oDragObj.style.top=this.port_Y-2;
					this.oDragObj.style.width=this.port_X-parseInt(this.left1)+2;
					this.oDragObj.style.height=y12-this.port_Y+2;
				}
			}else if(this.tag==7){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_X>0&&this.port_Y>0&&this.port_X<x12&&this.port_Y<y12){
					this.oDragObj.style.top=this.port_Y-2;
					this.oDragObj.style.left=this.port_X-2;
					this.oDragObj.style.width=x12-this.port_X+2;
					this.oDragObj.style.height=y12-this.port_Y+2;
				}
			}else if(this.tag==9){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				if(this.port_X>0&&this.port_Y>0&&this.port_Y>parseInt(this.top1)&&this.port_X<x12){
					this.oDragObj.style.left=this.port_X-2;
					this.oDragObj.style.width=x12-this.port_X+2;
					this.oDragObj.style.height=this.port_Y-this.top1+2;
				}
			}else if(this.tag==4){
				this.port_X=e.clientX;
				this.port_Y=e.clientY;
				document.body.scrollTop=0;
				document.body.scrollLeft=0;
				this.oDragObj.style.left=(this.left1+this.port_X-this.port_X1)<0?"0px":this.left1+this.port_X-this.port_X1+"px";
				this.oDragObj.style.top=(this.top1+this.port_Y-this.port_Y1)<0?"0px":this.top1+this.port_Y-this.port_Y1+'px';
				if(parseInt(this.oDragObj.style.left)+parseInt(this.getStyle(this.oDragObj,"width","width"))>document.body.clientWidth){
					this.oDragObj.style.left=document.body.clientWidth-parseInt(this.getStyle(this.oDragObj,"width","width"));
				}
				if((document.body.clientHeight-parseInt(this.getStyle(this.oDragObj,"height","height")))<parseInt(this.getStyle(this.oDragObj,"top","top"))){
					this.oDragObj.style.top=document.body.clientHeight-parseInt(this.getStyle(this.oDragObj,"height","height"));
				}
			}
			return false;
		}
	} 
	this.getStyle=function (elem,IE,FF){
		return navigator.appName=="Microsoft Internet Explorer"?elem.currentStyle[IE]:document.defaultView.getComputedStyle(elem, "").getPropertyValue(FF);
	}
	this.dragimg=function (e){
		this.mouse_tag=0;
		if(this.oDragObj!=null){
			//this.oDragObj.style.zIndex=++this.nseerZindex;
			if (this.oDragObj.releaseCapture) {
				this.oDragObj.releaseCapture();
			}
			if(this.tag!=0&&this.tag!=4){
				this.changeSize();
			}
		}
		this.isdrag=false;
		this.detachEvent();
	}
	this.mouseStyle=function (e){
		e=e||window.event;
		if(this.mouse_tag==0){
			var x12;
			var y12;
			var port_X;
			var port_Y;
			var oDragHandle1 = this.dE?e.target : event.srcElement;
			var topElement = "HTML";
			while (oDragHandle1.tagName != topElement && oDragHandle1.getAttribute("nseerDef") != "dragAble"&&oDragHandle1.getAttribute("nseerDef") != "dragonly") {
				oDragHandle1 = this.dE?oDragHandle1.parentNode:oDragHandle1.parentElement;
			}
			if(oDragHandle1.getAttribute("nseerDef")!=null&&oDragHandle1.getAttribute("nseerDef")!='undefined'){
			if(oDragHandle1.getAttribute("nseerDef")=="dragAble"){this.nseerDef=1;}
			if(oDragHandle1.getAttribute("nseerDef")=="dragonly"){this.nseerDef=2;}
			if(this.nseerDef==1||this.nseerDef==2){
				eval('oDragHandle1.ondblclick=function(e){'+this.name+'.doubleClickDiv(e);}');
				x12=parseInt(this.getStyle(oDragHandle1,"left","left"))+parseInt(this.getStyle(oDragHandle1,"width","width"));
				y12=parseInt(this.getStyle(oDragHandle1,"top","top"))+parseInt(this.getStyle(oDragHandle1,"height","height"));
				port_X=e.clientX;
				port_Y=e.clientY;
				this.top1=parseInt(this.getStyle(oDragHandle1,"top","top"));
				this.left1=parseInt(this.getStyle(oDragHandle1,"left","left"));
			}
			}
			this.loadDiv(oDragHandle1,1,e);
		}
	}
	this.mmcMouseStyle=function(obj){
		obj.style.cursor='pointer';
	}
	this.closeDiv=function (closeType){
	    unloadCover(this.oDragObj.id);
	    this.nseerDef=0;
		if(closeType=='remove'){
			try{
			document.body.removeChild(document.getElementById(this.oDragObj.id));
			//if (window.ActiveXObject){document.body.removeChild(document.getElementById(this.oDragObj.id));}else{this.oDragObj.oparentNode.removeChild(document.getElementById(this.oDragObj.id));}
			}catch(e){}
		}
		else if(closeType=='hidden'){this.oDragObj.style.display='none';}
		else if(closeType=='reconfirm'){}
	}
	this.closeDivIndex=function (closeType,obj_id){
	    this.nseerDef=0;
		if(closeType=='remove'){
			try{
				document.getElementById('noticeDiv').style.display='none';
			}catch(e){}
		}
	}
	this.doubleClickDiv=function (e){
		
	}
	this.closeDivDelivery=function (closeType,obj_id){
	    this.nseerDef=0;
		if(closeType=='remove'){
			try{
				document.getElementById('other_addr').style.display='none';
				unloadCover('other_addr');
			}catch(e){}
		}
	}
	
	this.closeDivCart=function (closeType,obj_id){
	    this.nseerDef=0;
		if(closeType=='remove'){
			try{
				document.getElementById('additional').style.display='none';
				unloadCover('additional');
			}catch(e){}
		}
	}
	
 }
 var n_D=new Nseer_DivViewChange('n_D');
 }catch(e){}

