/**
 * smenu
 *
 * @package smenu
 * @version 1.0.0.20070504
 * @copyright Creative Pulse Ltd 2007
 * @link http://www.creativepulse.eu/goto/smenu
 *
 * Smenu (acronym for Slide Menu) is a menu with animation
 * effects that smoothly slides the menu options left and right
 */

function Smenu()
{
	this.width_open = 0;
	this.ref_count = 0;
	this.sel_menu = '';
	this.slide = false;
	this.locked = false;
	this.timer_id = 0;
	this.data_count = 0;
	this.data_width = 0;
	this.data = { };
	
	// Configuration Start /////////////////////////////////////////////////

	// Height of menu options
	this.height = 50;

	// Width of menu options when they are in normal state
	this.width_norm = 172;

	// Width of menu options when they are shrinked
	this.width_min = 130;

	// Animation interval in milli-seconds - Default: 20
	this.interval = 20;

	// Animation speed in percentage (Min: 0, Max: 100) - Default: 20
	this.speed_perc = 30;

	// Data
	// Example: this.data.smenu1 = { content: 'Option 1', bgcolor: '#00f', bgimg: '', width: 0, link: '', title: '' }
	// `smenu1` defines the element id of the menu option.
	// `content` sets the inner HTML content of the item. It must have HTML format.
	// `bgcolor` sets the background color. An empty value disables it.
	// `bgimg` sets the background image. An empty value disables it.
	// `width` sets the item width in pixels. Set it to 0 if you want the menu option to expand/shrink, or to a specific with in pixels if you want it to be static.
	// `link` defines the target URL. Works only when width is 0.
	// `title` defines the target URL title. Works only when width is 0.
	// You can copy and paste the example line as many times necessary to match the options of your menu

	// Configuration End ///////////////////////////////////////////////////
}
	
Smenu.prototype.onmouseover=function(aa){this.ref_count++;this.sel_menu=aa.id;for(var k in this.data){if(!this.data[k].width){this.data[k].trg_width=k==aa.id?this.width_open:this.width_min;}}
this.slide=true;}
Smenu.prototype.onmouseout=function(ba){this.ref_count--;if(this.ref_count==0){for(var k in this.data){if(!this.data[k].width){this.data[k].trg_width=this.width_norm;}}
this.slide=true;}}
Smenu.prototype.ontimer=function(){if(this.slide&&!this.locked){this.locked=true;this.slide=false;var ca=0;for(var k in this.data){if(this.data[k].width){ca+=this.data[k].width;}
else{var da=document.getElementById(k);var ea=parseInt(da.style.width);if(ea==this.data[k].trg_width){ca+=ea;}
else{var fa=this.data[k].trg_width>=ea?1:-1;diff=Math.floor(fa*(this.data[k].trg_width-ea)*this.speed_perc/100);if(diff==0){diff=1;}
var ga=ea+fa*diff;ca+=ga;da.style.width=ga+'px';this.slide=true;}}}
if(this.sel_menu!=''&&ca!=this.data_width){var da=document.getElementById(this.sel_menu);da.style.width=(parseInt(da.style.width)+this.data_width-ca)+'px';}
if(!this.slide&&this.ref_count==0){this.sel_menu='';}
this.locked=false;}}
Smenu.prototype.h_onload=function(ha,ia){var ja=document.getElementById(ha);if(ia){var ka=document.createElement('table');ka.setAttribute('cellspacing',0);ka.setAttribute('cellpadding',0);ja.appendChild(ka);var la=document.createElement('tbody');ka.appendChild(la);var tr=document.createElement('tr');la.appendChild(tr);ja=tr;}
else{var ma=ja.firstChild;while(ma){ja.removeChild(ma);ma=ja.firstChild;}}
this.data_width=0;this.width_open=0;for(var k in this.data){var na=document.createElement('td');ja.appendChild(na);na.innerHTML=this.data[k].content;na.setAttribute('id',k);na.style.height=this.height+'px';if(this.data[k].bgcolor){na.style.backgroundColor=this.data[k].bgcolor;}
if(this.data[k].bgimg){na.style.backgroundImage='url('+this.data[k].bgimg+')';na.style.backgroundRepeat='no-repeat';}
if(this.data[k].width){na.style.width=this.data[k].width+'px';this.data_width+=this.data[k].width;this.width_open+=this.data[k].width;}
else{this.data_count++;this.data[k].trg_width=this.width_norm;na.style.width=this.width_norm+'px';na.onmouseover=function(){smenu.onmouseover(this);}
na.onmouseout=function(){smenu.onmouseout(this);}
this.data_width+=this.width_norm;this.width_open+=this.width_min;if(this.data[k].link){if(this.data[k].title!=''){na.setAttribute('title',this.data[k].title);}
na.setAttribute('link',this.data[k].link);na.onclick=function(){document.location=this.getAttribute('link');}
na.style.cursor='pointer';}}}
this.width_open=this.data_width-this.width_open+this.width_min;}
var smenu=new Smenu();
