Scrollbox=function(scrollbox){
	this.scrollbox=scrollbox;
	this.ul=STD.getElementByTagName("ul",this.scrollbox);

	this.ul_copy=this.ul.cloneNode(true);
	this.ul_copy.style.position="static";
	this.ul_copy.className="float-horizontal-list menu";

	this.list=STD.getElementsByTagName("li",this.ul);

	this.vertical=true;

	if(STD.inString(this.scrollbox.className,"horizontal")==true){
		this.vertical=false;

		for(var i=0;i<this.list.length;i++){
			this.set_pos(this.list[i],this.list[i].clientWidth*i);
		}
	}

	this.start_pos=this.get_start(this.ul);
	this.current_element=0;

	var button;

	button=STD.createElement("div");
	button.onclick=STD.delegate(this,this.next);
	button.className="scroll-arrow scroll-next";
	this.scrollbox.appendChild(button);

	button=STD.createElement("div");
	button.onclick=STD.delegate(this,this.prev);
	button.className="scroll-arrow scroll-prev";
	this.scrollbox.appendChild(button);

	var all_link;

	all_link=STD.createElement("a","view all");
	all_link.href="#view-all";
	all_link.onclick=STD.delegate(this,this.view_all);
	all_link.className="scroll-all";
	this.scrollbox.appendChild(all_link);
};

//static
Scrollbox.load=function(){
	var scrollboxes=STD.getElementsByClassName("scrollbox");
	
	for(var i=0;i<scrollboxes.length;i++){
		new Scrollbox(scrollboxes[i]);
	}
};


//methods
Scrollbox.prototype.get_start=function(element){
	if(this.vertical==true){
		return element.offsetTop;
	}else{
		return element.offsetLeft;
	}
}
Scrollbox.prototype.set_pos=function(element,pos){
	var new_pos=pos+"px";

	if(this.vertical==true){
		element.style.top=new_pos;
	}else{
		element.style.left=new_pos;
	}
}
Scrollbox.prototype.next=function(){
	if(this.current_element<this.list.length-1){
		++this.current_element;

		this.update();
	}
};
Scrollbox.prototype.prev=function(){
	if(this.current_element>0){
		--this.current_element;

		this.update();
	}
};
Scrollbox.prototype.update=function(){
	var new_pos=this.start_pos-this.get_start(this.list[this.current_element]);
	this.set_pos(this.ul,new_pos);
};
Scrollbox.prototype.view_all=function(){
	var data=STD.createElement("div");
	data.id="scrollbox-view-all";
	data.className="cover-data";

	var close=STD.createElement("div","close");
	close.className="close";
	close.onclick=STD.delegate(this,this.close);

	data.appendChild(close);

	var inner_div=STD.createElement("div");
	inner_div.className="inner";	
	inner_div.appendChild(this.ul_copy);

	var cl=STD.createElement("div");
	cl.className="clear";
	inner_div.appendChild(cl);

	data.appendChild(inner_div);

	document.body.appendChild(data);
	data.style.display="block";

	return false;
};
Scrollbox.prototype.close=function(){
	var data=STD.getElementById("scrollbox-view-all");
	data.parentNode.removeChild(data);
};