HOY_Tabmenu = Class.create();
HOY_Tabmenu.prototype = {
	initialize : function(){
		this.idList = new Array();
		this.oldImagePaths = new Array();
		this.newImagePaths = new Array();
		this.styles = new Array();
		this.preId = '';
	},
	AddEvent : function(obj, eventName, functionNotify)
	{
		if(obj.attachEvent){
			obj.attachEvent('on'+eventName,functionNotify);
		}else if(obj.addEventListener){
			obj.addEventListener(eventName, functionNotify, true);
		}else{
			obj['on'+eventName] = functionNotify;
		}
	},
	
	 /**
	   * ÀÌº¥Æ® Ã¼Å©
	   * Firefox¿Í IE°£ È£È¯À» À§ÇÔ
	   */
	fucusOn : function(evt){
		//eventÃ¼Å© 
		//Firefox¿Í IE°£ È£È¯À» À§ÇÔ
		if (!evt) { //IEÀÏ °æ¿ì
			evt = window.event;
		}
		if (!evt.target){
			evt.target = evt.srcElement;			
		}
		
		//event ¹ß»ý ³ëµå °¡Á®¿È		
		var el = evt.target;
		if(el.nodeName == 'IMG') {
			el = el.parentNode;
		}
		this.changeArea(el.id);		
	},
	
	//tab ¸Þ´º º¯È¯
	changeArea : function(objId) {
		//alert(objId +' == '+this.preId +' : '+(objId == this.preId));
		if(objId == this.preId) return;
		
		for(var i= 0; i < this.idList.length; i++)
		{
			var id = this.idList[i];
			//ÄÁÅÙÃ÷ div °¡Á®¿È
			var viewArea = $(id+'_page');
			var path;
			//ÇØ´ç idÀÇ ÀÌ¹ÌÁö ¹× 
			if(id ==objId){
				path = this.oldImagePaths[id];
				viewArea.style.display = '';
			}
			else{
				path = this.newImagePaths[id];
				viewArea.style.display = 'none';
			}
			
			var style = this.styles[id];
			if(style == null) style = '';
			//¸Þ´º ÀÌ¹ÌÁö º¯È¯
			$(id).innerHTML = '<IMG src="'+path+'" align="top" style="'+style+'"/>';
		}
		this.preId = objId;
	},
	
	addItem : function (id, oldImagePath, newImagePath, eventType, styles) {
		this.idList.push(id);
		this.oldImagePaths[id] = oldImagePath;
		this.newImagePaths[id] = newImagePath;
		this.styles[id] = styles;
		
		var div = document.getElementById(id);

		if(eventType == null){
			this.AddEvent(div, 'click', this.fucusOn.bindAsEventListener(this));
		}else {
			this.AddEvent(div, eventType, this.fucusOn.bindAsEventListener(this));
		}
	}
};

