var dragonzl = new Object();

dragonzl.xWin = function(page, container, name, title, type){
	this.dbId = null;
	this.page = page;
	this.container = container;
	this.name = name;
	this.title = title;
	this.type = type;
	this.position = "relative";
	this.isTitleShow = 1;
	this.titleBgColor = "#C0DCF2";
	this.titleFontColor = "#000000";
	this.borderWidth = 1;
	this.borderColor = "#4b7c9f";
	this.borderType = "solid";
	this.bgColor = "#ffffff";
	this.css = "";
	this.winLeft = 0;
	this.winTop = 0;
	this.width = 0;
	this.height = 80;
	this.background = "";
	this.titleBackground = "";
	this.contentId = null;
	this.imageWidth = 0;
	this.imageHeight = 0;
	this.method = "";
	this.html = "";
	this.isParam = 0;
	this.contentType = 0;
	this.categoryBgColor = "#ffffff";
	this.categoryFontColor = "#000000";
	this.categoryPoint = "point0.gif";
	this.isPage = 1;
	this.isAddTime = 0;
	this.line = 1;
	this.url = "";
	this.navStyle = 0;
	this.navDirect = 0;
	this.links = "";
	this.isMarquee = 0;
	this.marqueeDirect = "up";
	this.subtitle = 0;	
}

dragonzl.xWin.prototype={
	Build4Edit : function(){
		var tempName = this.name;
		var tempContainer = this.container;
		var mContainer = document.getElementById(this.container);
		if(mContainer.innerHTML == "&nbsp;"){
			mContainer.innerHTML = "";
		}
		var win = document.createElement("div");
		win.id = "xWin_" + this.name;
		
		win.className = "xWindow";
		
		/*win.onmousedown = function(e){
			setFocus("xWin_" + tempName);
		}*/
				
		mContainer.appendChild(win);
		
		var headerBar = document.createElement("div");
		headerBar.className = "xHeaderBar";
		headerBar.id = "xHeader_" + this.name;
		
		var titleSpan=document.createElement("span");
		titleSpan.id="xTitle_"+this.name;
		titleSpan.className = "xTitle";
		
		titleSpan.innerHTML=this.title;
	
		var ctrlSpan=document.createElement("span");
		ctrlSpan.id="xCtrl_"+this.name;
		ctrlSpan.className = "xCtrl";
		
		ctrlSpan.style.width="60px";
		ctrlSpan.style.height="20px";
		ctrlSpan.onmousedown=function(e){return false;}
		ctrlSpan.onmouseup=function(e){return false;}
		ctrlSpan.onmousemove=function(e){return false;}		
		//ctrlSpan.innerHTML = "<img style='CURSOR:hand;' src='TemplateDesigner/images/bt_config.gif' width=20 height=20 onclick='configWin()' alt='ÅäÖÃ'/><img style='CURSOR:hand;' src='TemplateDesigner/images/bt_delete.gif' width=20 height=20 onclick='deleteWin('" + this.container + "','" + this.name + "')' alt='É¾³ý'/>";
		
		var btbinder=document.createElement("IMG");
		btbinder.id="xBtBinder_"+this.name;
		btbinder.src="TemplateDesigner/images/bt_binder.gif";
		btbinder.alt = "ÄÚÈÝ°ó¶¨";
		btbinder.className = "btbinder";		
		btbinder.onclick=function(){startContentBind(tempName);}
		
		var btconfig=document.createElement("IMG");
		btconfig.id="xBtConfig_"+this.name;
		btconfig.src="TemplateDesigner/images/bt_config.gif";
		btconfig.alt = "´°ÌåÅäÖÃ";
		btconfig.className = "btconfig";		
		btconfig.onclick=function(){configWin(tempName);}
		
		var btdelete=document.createElement("IMG");
		btdelete.id="xBtDelete_"+this.name;
		btdelete.src="TemplateDesigner/images/bt_delete.gif";
		btdelete.alt = "´°ÌåÉ¾³ý";
		btdelete.className = "btdelete";
		
		btdelete.onclick=function(){deleteWin(tempContainer, tempName);}		
		
		var bodyDiv = document.createElement("div");
		bodyDiv.id = "xBody_" + this.name;
		bodyDiv.className = "xBody";		
		
		var stateBar=document.createElement("DIV");
		stateBar.id="xStateBar_"+this.name;
		stateBar.className = "xStateBar";
		
		var btresize=document.createElement("span");
		btresize.id="xBtResize_"+this.name;
		btresize.className = "btresize";
		btresize.onmousedown=function(e){startResize(tempName, e);}
		ctrlSpan.appendChild(btbinder);
		ctrlSpan.appendChild(btconfig);
		ctrlSpan.appendChild(btdelete);
		stateBar.appendChild(btresize);
		headerBar.appendChild(titleSpan);
		headerBar.appendChild(ctrlSpan);
		win.appendChild(headerBar);
		win.appendChild(bodyDiv);
		win.appendChild(stateBar);
		titleSpan.style.cssText="width:"+(win.offsetWidth-60-2)+"px;";
		ctrlSpan.style.cssText="left:"+(win.offsetWidth-1-60)+";top:"+0+";";
	},
	
	Build4Show : function(){
		var mContainer = document.getElementById(this.container);
		if(mContainer.innerHTML == "&nbsp;"){
			mContainer.innerHTML = "";
		}
		var win = document.createElement("div");
		win.id = "xWin_" + this.name;		
		win.className = "xWindow";		
		mContainer.appendChild(win);
		var headerBar = document.createElement("div");
		headerBar.className = "xHeaderBar";
		headerBar.id = "xHeader_" + this.name;
		win.appendChild(headerBar);
		headerBar.innerHTML = this.title;
		var bodyDiv = document.createElement("div");
		bodyDiv.id = "xBody_" + this.name;
		bodyDiv.className = "xBody";		
		win.appendChild(bodyDiv);
	},
	
	setStyle : function(position, isTitleShow, titleBgColor, titleFontColor, borderWidth, borderColor, borderType, bgColor, css, winLeft, winTop, width, height){
		this.position = position;
		this.isTitleShow = isTitleShow;
		this.titleBgColor = titleBgColor;
		this.titleFontColor = titleFontColor;
		this.borderWidth = borderWidth;
		this.borderColor = borderColor;
		this.borderType = borderType;
		this.bgColor = bgColor;
		this.css = css;
		this.winLeft = winLeft;
		this.winTop = winTop;
		this.width = width;
		this.height = height;
	},
	
	setPosition : function(position){
		this.position = position;
	},
	
	setIsTitleShow : function(isTitleShow){
		this.isTitleShow = isTitleShow;
	},
	
	setTitleBgColor : function(titleBgColor){
		this.titleBgColor = titleBgColor;
	},
	
	setTitleFontColor : function(titleFontColor){
		this.titleFontColor = titleFontColor;
	},
	
	setBorderWidth : function(borderWidth){
		this.borderWidth = borderWidth;
	},
	
	setBorderColor : function(borderColor){
		this.borderColor = borderColor;
	},
	
	setBorderType : function(borderType){
		this.borderType = borderType;
	},
	
	setBgColor : function(bgColor){
		this.bgColor = bgColor;
	},
	
	setCss : function(css){
		this.css = css;
	},
	
	setWinLeft : function(winLeft){
		this.winLeft = winLeft;
	},
	
	setWinTop : function(winTop){
		this.winTop = winTop;
	},
	
	setWidth : function(width){
		this.width = width;
	},
	
	setHeight : function(height){
		this.height = height;
	},
	
	setBackground : function(background){
		this.background = background;
	},
	
	setTitleBackground : function(titleBackground){
		this.titleBackground = titleBackground;
	},
	
	setDbId : function(dbId){
		this.dbId = dbId;
	},
	
	contentBindPanal : function(){
		if(this.type == 0){
			selWin("xBody_" + this.name);
		}else if(this.type == 1){
			imageBind(this.name);
		}else if(this.type == 2){
			htmlBind(this.name);
		}else if(this.type == 3){
			contentBind(this.name);
		}else if(this.type == 4){
			categoryBind(this.name);
		}else if(this.type == 5){
			navigatorBind(this.name);
		}else{
			return;
		}
	},
	
	saveBindedData: function(){
		if(this.type == 1){
			saveBindedImage(this.dbId, this.name, this.contentId, this.imageWidth, this.imageHeight, this.method);
		}else if(this.type == 2){
			saveBindedHTML(this.dbId, this.name, this.html, this.method);
		}else if(this.type == 3){
			saveBindedContent(this.dbId, this.name, this.contentId, this.isParam, this.contentType, this.url, this.method);
		}else if(this.type == 4){
			saveBindedCategory(this.dbId, this.name, this.contentId, this.isParam, this.contentType, this.url, this.isPage, this.line, this.categoryPoint, this.categoryBgColor, this.categoryFontColor, this.isAddTime, this.isMarquee, this.marqueeDirect, this.subtitle, this.method);
		}else if(this.type == 5){
			saveBindedNavigator(this.dbId, this.name, this.navStyle, this.navDirect, this.links, this.method);
		}
	}	
	
}
