/*********************************************************
ÆÄÀÏ¸í : $_SERVER[DOCUMENT_ROOT]/classes/GH_Tag_Style.js
ÃÖÃÊ °³¹ßÀÚ : ¿ì»óÀ±
ÃÖÃÊ °³¹ßÀÏ : 2008.01.14
ÃÖÁ¾ ¼öÁ¤ÀÚ : ¿ì»óÀ±
ÃÖÁ¾ ¼öÁ¤ÀÏ : 2007.01.14
»ó¼¼ ¼³¸í : ÅÂ±×¿¡ ½ºÅ¸ÀÏ ÁÖ´Â ½ºÅ©¸³Æ®
**********************************************************/

//ÅÂ±× ½ºÅ¸ÀÏ ÁÖ±â - Edit. 2008.1.14, sywoo
/*************************************************************
ÀÔ·ÂµÇ´Â ½ºÅ¸ÀÏ °ªÀº ¹Ýµå½Ã ´ÜÀ§±îÁö ½á¾ßÇÔ.
border : Å×µÎ¸® ½ºÅ¸ÀÏ - border-width | border-style | border-color(ex : "1px solid #000")
*************************************************************/
tagStyle = function(objName, tagId, width, height, top, left, bgcolor, border, txtSize, txtType, txtColor, iconPath){
	//ÅÂ±× ½ºÅ¸ÀÏ °ª
	this.objName = objName;
	this.tagId = tagId;
	this.width = width;
	this.height = height;
	this.top = top;
	this.left = left;
	this.bgcolor = bgcolor;
	this.border = border;
	this.txtSize = txtSize;
	this.font = txtSize+"px "+txtType;
	this.txtColor = txtColor
	this.iconPath = iconPath;
	this.viewtype = this.objName+"_on";
	
	//¼¿·ºÆ® ¹Ú½º »ý¼º ½ºÅ©¸³Æ®
	tagStyle.prototype.selectBox = function(){
		var select_Div = document.getElementById(this.objName);
		var select_Id = document.getElementById(this.tagId);
		var select_ItemNum = select_Id.options.length;
		var viewItemsDiv = new Array();
		var viewItemsTxt = new Array();
		
		select_Id.style.display = "none";
		
		//¼¿·ºÆ® ¹Ú½º »ý¼º
		var newSelect = select_Div.appendChild(document.createElement("Div"));
		newSelect.style.width = this.width+"px";
		newSelect.style.height = this.height+"px";
		newSelect.style.top = this.top+"px";
		newSelect.style.left = this.left+"px";
		newSelect.style.background = bgcolor;
		newSelect.style.border = border;
		newSelect.style.cursor = "pointer";
		newSelect.style.zindex = "999";
		
		//¼¿·ºÆ® ¹Ú½º ÄÜÅÙÃ÷ »ý¼º
		var newSelectTxt = newSelect.appendChild(document.createElement("Div"));
		newSelectTxt.style.margin = "0px";
		newSelectTxt.style.padding = "0px";
		newSelectTxt.style.width = (this.width - 4 - this.height)+"px";
		newSelectTxt.style.height = this.txtSize+"px";
		newSelectTxt.style.font = this.font;
		newSelectTxt.style.color = this.txtColor;
		newSelectTxt.style.overflow = "hidden";
		newSelectTxt.style.float = "left";
		newSelectTxt.style.position = "absolute";
		var marginpx = (this.height - txtSize) / 2;
		newSelectTxt.style.marginTop = marginpx + "px";
		newSelectTxt.style.marginLeft = (marginpx + 3) + "px";
		newSelectTxt.style.zindex = "999";
		
		newSelectItem = document.createTextNode(select_Id.options[select_Id.selectedIndex].text);		
		newSelectTxt.appendChild(newSelectItem);
		
		//¼¿·ºÆ® ¹Ú½º È­»ìÇ¥ »ý¼º
		var newSelectIcon = newSelect.appendChild(document.createElement("img"));
		newSelectIcon.style.height = (this.height - 2) + "px";
		newSelectIcon.style.width = (this.height - 2) + "px";
		newSelectIcon.style.border = "0px";
		newSelectIcon.style.margin = "1px";
		newSelectIcon.style.position = "absolute";
		newSelectIcon.style.left = (this.width - 2) - (this.height - 2) + "px";
		newSelectIcon.src = iconPath;
		newSelectIcon.style.cursor = "pointer";
		newSelectIcon.style.zindex = "999";
		
		//¼¿·ºÆ® ¹Ú½º ¾ÆÀÌÅÛ »ý¼º
		var viewItemsBox = select_Div.appendChild(document.createElement("Div"));
		viewItemsBox.style.width = this.width+"px";
		viewItemsBox.style.height = ((select_Id.options.length - 1) * (this.txtSize + (this.txtSize * 0.5) + 2))+"px";
		viewItemsBox.style.border = this.border;
		viewItemsBox.style.background = this.bgcolor;
		viewItemsBox.style.marginTop = "-1px";
		viewItemsBox.style.zindex = "999";
		viewItemsBox.id = tagId+"viewItems";
		for(i=1;i<select_ItemNum;i++){
			viewItemsDiv[i] = viewItemsBox.appendChild(document.createElement("Div"));
			viewItemsDiv[i].style.width = ((this.width) - ((((this.txtSize + (this.txtSize * 0.4)) - this.txtSize) / 2)+3))+"px";
			viewItemsDiv[i].style.height = (this.txtSize + (this.txtSize * 0.3))+"px";
			viewItemsDiv[i].style.marginTop = "0px";
			viewItemsDiv[i].style.paddingTop = (((this.txtSize + (this.txtSize * 0.4)) - this.txtSize) / 2)+(((this.txtSize + (this.txtSize * 0.4)) - this.txtSize) / 2)+"px";
			viewItemsDiv[i].style.paddingLeft = ((((this.txtSize + (this.txtSize * 0.4)) - this.txtSize) / 2)+3)+"px";
			viewItemsDiv[i].style.overflow = "hidden";
			viewItemsDiv[i].style.color = this.txtColor;
			viewItemsDiv[i].style.font = this.font;
			viewItemsDiv[i].style.cursor = "pointer";
			viewItemsDiv[i].style.zindex = "999";
			viewItemsDiv[i].id = tagId+"_"+i;
			viewItemsTxt[i] = document.createTextNode(select_Id.options[i].text);
			viewItemsDiv[i].appendChild(viewItemsTxt[i]);
			
			//¼¿·ºÆ® ¹Ú½º ¾ÆÀÌÅÛ¿¡ ¸¶¿ì½º ¿À¹ö
			viewItemsDiv[i].onmouseover = function(){
				this.style.color = "#FFFFFF";
				this.style.background = "#0A246A";
			}
			
			//¼¿·ºÆ® ¹Ú½º ¾ÆÀÌÅÛ¿¡ ¸¶¿ì½º ¾Æ¿ô
			viewItemsDiv[i].onmouseout = function(){
				//alert(newSelectTxt.style.color);
				this.style.color = newSelectTxt.style.color;
				this.style.background = newSelectTxt.style.background;
			}
			
			//¼¿·ºÆ® ¹Ú½º ¾ÆÀÌÅÛ Å¬¸¯
			viewItemsDiv[i].onclick = function(){
				//alert(this.id);
				var selectedId = this.id;
				var selectedNo_Array = selectedId.split("_");
				var selectedNo = selectedNo_Array[1];
				select_Id.options[parseInt(selectedNo)].selected = true;
				viewItemsBox.style.display = "";
				//tagStyle.viewtype = objName+"_on";
				newSelectTxt.innerHTML = select_Id.options[parseInt(selectedNo)].text;
				select_Id.onchange();
			}
		}
		viewItemsBox.style.display = "none";
		
		//È­»ìÇ¥ Å¬¸¯ ÀÌº¥Æ® ¹ß»ý
		select_Div.onclick = function(){
			//alert(viewItemsBox.style.display);
			if(viewItemsBox.style.display == "none"){
				viewItemsBox.style.display = "";
				//tagStyle.viewtype = objName+"_off";
			}else{
				viewItemsBox.style.display = "none";
				//tagStyle.viewtype = objName+"_on";
			}
		}
	}
}
