//= Constants Initialization ===================================================
var slide_offset=4;
var slide_timeout=10;
var menuWidth=140;
var menuVisibleHeight=20;
var menuHeaderHeight=10;
var menuHeaderImage='/cnf/graphics/header.gif';
var menuFooterHeight=28;
var menuFooterImage='/cnf/graphics/footer.gif';
var menuElementHeight=20;
var menuElementImage='/cnf/graphics/element.gif';
var menuFooterStyle='.cMenuFooter {font-family:Verdana; color:#000000; font-size:10px; text-decoration:none; overflow:hidden; text-align:center; vertical-align:bottom; padding-bottom:4px;}\n';
var menuElementTDStyle='.cMenuElementTD {overflow:hidden; text-align:center; vertical-align:middle;}\n';
var menuElementStyle='.cMenuElement {font-family:Verdana; color:#212828; font-size:10px; text-decoration:none;}\nA.cMenuElement:hover {font-family:Verdana; color:#FF2828; font-size:10px; text-decoration:none;}\n';
var noneImage='/cnf/graphics/none.gif';

function preLoadImgs(){
  for(i=0;i<arguments.length;i++){
    this[i]=new Image()
    this[i].src=arguments[i]
  }
  return this
}

var aElements = new Array();

function tElement(x,y,h,w,c) {
		 this.x=x;
		 this.y=y;
		 this.height=h;
		 this.Width=w;
		 this.color=c;
		 this.sliding=0;
		 this.issliding=false;
		 this.timeoutID=0;
}

//= Initialization Functions ===================================================
function set_element(t_name,t_offsetX,t_offsetY,t_width,t_height,t_color) {
		 var tempElement;
		 tempElement = new tElement(t_offsetX,t_offsetY,t_height,t_width,t_color);
		 aElements[t_name] = tempElement;
}

function setDummy(t_Width,t_height,t_offset,t_bg) {
		 document.write('<div style="position:absolute; top:0; left:'+t_offset+'; z-index:4;"><table cellpadding="0" cellspacing="0" width="'+t_Width+'" height="'+t_height+'"><td height="'+t_height+'" background="'+t_bg+'"><img src="'+noneImage+'"></td></table></div>');
		 }

function create_element(t_name,t_header,t_header_height,t_header_img,t_footer_height,t_footer_img) {
		 document.write('<div id="'+t_name+'" style="position:absolute; top:'+aElements[t_name].y+'; left:'+aElements[t_name].x+'; background:'+aElements[t_name].color+'; z-index:5;" onMouseOver="JavaScript:set_slide(\''+t_name+'\',\'down\');" onMouseOut="JavaScript:set_slide(\''+t_name+'\',\'up\');">');
		 document.write('<table cellpadding="0" cellspacing="0" width="'+aElements[t_name].Width+'" height="'+aElements[t_name].height+'"><tr><td height="'+t_header_height+'" background="'+t_header_img+'"><img src="'+noneImage+'"></td></tr>');
		 document.write('<tr><td><div id="'+t_name+'_container"></div></td></tr>');
		 document.write('<tr><td height="'+t_footer_height+'" background="'+t_footer_img+'" class="cMenuFooter">'+t_header+'</td></tr></table>');
		 document.write('</div>');
}

function setMenuElement(t_id,t_header,t_offset) {
		 var temp_offsetY;
		 var temp_height;
		 temp_height=menuHeaderHeight+menuFooterHeight;
		 temp_offsetY=menuVisibleHeight-temp_height;
		 set_element(t_id,t_offset,temp_offsetY,menuWidth,temp_height,'#000000');
		 create_element(t_id,t_header,menuHeaderHeight,menuHeaderImage,menuFooterHeight,menuFooterImage);
}

function setInnerElement(t_id,t_header,t_href) {
		 aElements[t_id].y-=menuElementHeight;
		 document.getElementById(t_id).style.top=aElements[t_id].y;
		 aElements[t_id].height+=menuElementHeight;
		 document.getElementById(t_id+'_container').innerHTML+='<table cellpadding="0" cellspacing="0" width="'+menuWidth+'" height="'+menuElementHeight+'"><td width="100%" height="100%" background="'+menuElementImage+'" class="cMenuElementTD"><a href="'+t_href+'" class="cMenuElement">'+t_header+'</td></table>';
}

function defineStyles() {
		 document.write('<style>'+menuFooterStyle+menuElementTDStyle+menuElementStyle+'</style>');
}

//= Slide Initialization =======================================================
function set_slide(objname,direction) {
switch (direction) {
	   case 'up' :
	   		aElements[objname].sliding=1;
			if (!aElements[objname].issliding) {
			aElements[objname].timeoutID = setInterval('do_slide("'+objname+'")',slide_timeout);
			aElements[objname].issliding=true;
			}
			break;
	   case 'down' :
	   		aElements[objname].sliding=-1;
			if (!aElements[objname].issliding) {
			aElements[objname].timeoutID = setInterval('do_slide("'+objname+'")',slide_timeout);
			aElements[objname].issliding=true;
			}
			break;
	   default :
	   		aElements[objname].sliding=0;
			aElements[objname].issliding=false;
			clearInterval(aElements[objname].timeoutID);
	   }

}

//= Slide Routine ==============================================================
function do_slide(objname) {
var temp_y;
temp_y=parseInt(document.getElementById(objname).style.top);

if (aElements[objname].sliding==1) {
   temp_y=parseInt(document.getElementById(objname).style.top);
   if (temp_y>aElements[objname].y) {
   	  temp_y-=slide_offset;
	  if (temp_y<aElements[objname].y) {
	  	 temp_y=aElements[objname].y;
		 }
	  temp_y+='px';
	  document.getElementById(objname).style.top=temp_y;
	  }
   else {
   	  aElements[objname].sliding=0;
	  aElements[objname].issliding=false;
	  clearInterval(aElements[objname].timeoutID);
	  }
   }

if (aElements[objname].sliding==-1) {
   temp_y=parseInt(document.getElementById(objname).style.top);
   if (temp_y<0) {
   	  temp_y+=slide_offset;
	  if (temp_y>0) {
	  	 temp_y=0;
		 }
	  temp_y+='px';
	  document.getElementById(objname).style.top=temp_y;
	  }
   else {
   	  aElements[objname].sliding=0;
	  aElements[objname].issliding=false;
	  clearInterval(aElements[objname].timeoutID);
	  }
   }

if (aElements[objname].sliding==0) {
   aElements[objname].issliding=false;
   clearInterval(aElements[objname].timeoutID);
   }
}

