
var scrollspeed=15;
if(typeof(Control) == 'undefined')
	Control = {};
Control.SliderMenu = Class.create();

Object.extend(Control.SliderMenu.prototype,{
	//configure path for left and right arrows
	goleftimage:"",
	gorightimage:"",
	//configure menu width (in px):
	menuwidth:550,
	//configure menu height (in px):
	menuheight:15,
	//Specify scroll buttons directions ("normal" or "reverse"):
	scrolldir:"normal",
	//configure scroll speed (1-10), where larger is faster
	//specify menu content
	menucontents:'',
	
  iedom:false,

  rightdircode:'onMouseover="moveleft()" onMouseout="clearTimeout(lefttime)"',
	leftdircode:'onMouseover="moveright()" onMouseout="clearTimeout(righttime)"',
	rval:0,
	element: false,
	initialize: function(str, w , h , limg,rimg, cursel){
		str = '<nobr>'+str+'</nobr>';
		this.iedom = document.all||document.getElementById;
		this.menucontents = str;
		this.menuwidth = w;
		this.menuheight = h;
		this.goleftimage = limg;
		this.gorightimage = rimg;
		this.rval = Math.floor(Math.random()*1000);
		this.rightdircode='onMouseover="Slidermoveleft('+this.rval+','+this.menuwidth+')" onMouseout="clearTimeout(lefttime)"';
		this.leftdircode='onMouseover="Slidermoveright('+this.rval+','+this.menuwidth+')" onMouseout="clearTimeout(righttime)"';
		document.write('<span id="slider_c_'+this.rval+'" style="visibility:hidden;position:absolute;top:-100px;left:-15000px"><nobr>'+this.menucontents+'</nobr></span>')

		if (this.iedom||document.layers){
			with (document){
				write('<table border="0" cellspacing="0" cellpadding="0">')
				write('<td valign="middle"><a class="slider-left" href="#" '+this.leftdircode+'><span style="display:none;">&laquo;</span></a> </td>')
				write('<td width="'+this.menuwidth+'px" valign="top">')
				if (this.iedom){
					write('<div style="position:relative;width:'+(this.menuwidth+3)+'px;height:'+this.menuheight+'px;overflow:hidden;background-color:#FFFFFF">')
					write('<div class="subblockmenu" id="slider_bar_'+this.rval+'" style="position:absolute;left:0;top:0;padding-top:3px;padding-left:3px; line-height:17px;">')
					write('</div></div>')
				}
				else if (document.layers){
					write('<ilayer width='+this.menuwidth+' height='+this.menuheight+' name="ns_scrollmenu">')
					write('<layer name="ns_scrollmenu2" left=0 top=0></layer></ilayer>')
				}
				write('</td>')
				write('<td valign="middle"> <a class="slider-right" href="#" '+this.rightdircode+'>')
				write('<span style="display:none;">&raquo;</span></a>')
				//write('<img class="slider-left" src="'+this.gorightimage+'"border=0></a>')
				write('</td></table>')
			}
		}
		$('slider_bar_'+this.rval).innerHTML=this.menucontents;
		if($(cursel)){
			var temp = 0;
			var val = 0;
			
			$('slider_bar_'+this.rval).absolutize();
			$('slider_c_'+this.rval).absolutize();
			$(cursel).absolutize();
			
			temp = $('slider_c_'+this.rval).getDimensions()['width'] - parseInt($(cursel).style.left);
			if(temp < this.menuwidth){
				val = $('slider_c_'+this.rval).getDimensions()['width'] - this.menuwidth;
				if(val<0){
					val=0;
				}
			}else if(parseInt($(cursel).style.left) < this.menuwidth){
				val = 0;
			}else{
				val = parseInt($(cursel).style.left);
			}
			$('slider_bar_'+this.rval).style.left=(parseInt($('slider_bar_'+this.rval).style.left)- val) +'px';
		}
	}
	
});

var lefttime,righttime;
iedom = document.all||document.getElementById;

function Slidermoveleft(id,wd){
		if (iedom&&parseInt($('slider_bar_'+id).style.left)>(wd-$('slider_c_'+id).getWidth())){
			$('slider_bar_'+id).style.left=parseInt($('slider_bar_'+id).style.left)-scrollspeed+"px"
		}
		else if (document.layers&&ns_scroll.left>(menuwidth-$('slider_c_'+id).getWidth()))
			ns_scroll.left-=scrollspeed
	lefttime=setTimeout("Slidermoveleft("+id+","+wd+")",50)
}

function Slidermoveright(id,wd){
	if (iedom&&parseInt($('slider_bar_'+id).style.left)<0)
		$('slider_bar_'+id).style.left=parseInt($('slider_bar_'+id).style.left)+scrollspeed+"px"
	else if (document.layers&&$('slider_bar_'+id).left<0)
		$('slider_bar_'+id).left+=scrollspeed
	righttime=setTimeout("Slidermoveright("+id+","+wd+")",50)
}
