/**
*
* egLink Class
*/

function egLink(id, title, posX, posY, width, height, action, icon, container) {
	 this.objName = 'link_'+id;
	 this.id = id;

	 this.x = posX;
	 this.y = posY;
	 this.width = 0;
	 this.height = 0;
	
	 this.getHeight = egWindow_getHeight;
	 this.getWidth  = egWindow_getWidth;

	 this.show = egWindow_show;
	 this.hide = egWindow_hide;
	 this.moveTo = egWindow_moveTo;
	 this.displayAt = egWindow_displayAt;

	 this.setClassName = egLink_setClassName;

	 this.setActive = egLink_setActive;
	 this.setInactive = egLink_setInactive;

	 this.approxWidth = ((title.length)*6) + 22;
	 
   if (!container) {
      container = 'easy-GUI_mainLayer';
   }
	 divRoot = document.getElementById(container);

	 divRoot.innerHTML += '<div id="'+this.id+'" class="egLink" onmouseover="javascript:' + this.objName + '.setActive();" onmouseout="javascript:' + this.objName + '.setInactive();" onclick="javascript:cancelBubble(arguments[0]);' + action + ';"><div class="egLinkIcon" style="background: url(' + icon + ') no-repeat;"></div><div class="egLinkText">'+title+'</div></div>';

	 div = document.getElementById(this.id);
	 if(width == 0) {
	   div.style.width  = this.approxWidth + 'px';
	 }
	 else {
	   div.style.width  = width+'px';
	 }

	 div.style.left = posX+'px';
	 div.style.top  = posY+'px';
}

function egLink_setClassName(){
	var div = document.getElementById(this.id);
  var className = 'egLink';

  if(this.active) {
    className = 'egLink' + 'Hover';
  }
  div.className = className;
}

function egLink_setActive(){
	if(!this.active) {
    this.active = 1;
    this.setClassName();
	}
}

function egLink_setInactive(){
	if(this.active) {
    this.active = 0;
    this.setClassName();
	}
}
