function setActive (obj) {
	obj.className = 'menu-on';
	return;
}

function unsetActive (obj) {
	obj.className = 'menu';
	return;
}

function setActivee (obj) {
	obj.parentNode.className = 'menu-on';
	return;
}

function unsetActivee (obj) {
	obj.parentNode.className = 'menu';
	return;
}

var maxScroll = 0;
var scrollValue = 0;
var scrollWidth2 = 0;
var falseWidth = 0;
var scrollStep = 250;
var scrollSteps=new Array();

/*$(document).ready(function(){
  // $("#content-slider").slider({
    // animate: true,
    // change: handleSliderChange,
    // slide: handleSliderSlide
  // });
  
//  $("#slider").easySlider();
  
//  jQuery('#mycarousel').jcarousel();
  
  
  initScroll();
});*/

function initScroll() {
  window.maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  countDivWidth2();
  
  if(window.scrollWidth2 == falseWidth) { // ugly fix... to force wait till images are loaded
	countDivWidth2();
	//setTimeout("initScroll()", 500);
	return;
  } else {
    $("#content-holder").width(window.scrollWidth2);
  }
  
  
  
  //alert(window.scrollWidth2);
  //alert(''+$("#content-scroll").attr("scrollWidth"));
  //alert(''+$("#content-scroll").width());
}

/*function handleSliderChange(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
}*/

function stepLeft(){
	var arLen=scrollSteps.length;
	for ( var i=0; i<arLen; ++i ){
		//alert('1:'+parseInt(scrollSteps[i],10)+' 2:'+parseInt(window.scrollValue,10));
	    if(parseInt(scrollSteps[i],10) >= parseInt(window.scrollValue,10)) {
			if(parseInt(i,10)==parseInt(0,10)) {
				window.scrollValue = 0;
			} else {
				window.scrollValue = scrollSteps[i*1-1];
			}
			break;
		}
	}
	$("#content-scroll").attr({scrollLeft: window.scrollValue});
}

function stepRight(){
	var arLen=scrollSteps.length;
	for ( var i=0; i<arLen; ++i ){
		//alert('1:'+parseInt(scrollSteps[i],10)+' 2:'+parseInt(window.scrollValue,10));
	    if(parseInt(scrollSteps[i],10) >= parseInt(window.scrollValue,10)) {
			if(parseInt(i,10)==parseInt(arLen,10)) {
				window.scrollValue = scrollSteps[arLen];
			} else {
				window.scrollValue = scrollSteps[i*1+1];
			}
			break;
		}
	}
	if(window.scrollValue > $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width()) {
		window.scrollValue = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
	}
	$("#content-scroll").attr({scrollLeft: window.scrollValue});
}

function scrollLeft(){
	window.scrollValue = window.scrollValue - window.scrollStep;
	if(window.scrollValue < 0) {
		window.scrollValue = 0;
	}
	$("#content-scroll").attr({scrollLeft: window.scrollValue});
	//alert('l '+window.maxScroll+' '+window.scrollValue);
}

function scrollRight(){
	window.scrollValue = window.scrollValue + window.scrollStep;
	if(window.scrollValue > $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width()) {
		window.scrollValue = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
	}
	$("#content-scroll").attr({scrollLeft: window.scrollValue});
	//alert('r '+window.maxScroll+' '+window.scrollValue);
}

function countDivWidth2() {
	var imgs=document.getElementsByTagName('img');
	
	window.scrollWidth2 = 0;
	window.falseWidth = 0;
	
	for(var i = 0; i < imgs.length; i++){
		//alert('1:'+imgs[i].parentNode.id+' 2:'+imgs[i].parentNode.parentNode.id +' 3:'+imgs[i].parentNode.parentNode.parentNode.id);
		if(imgs[i].parentNode.parentNode.parentNode.id=="content-holder"){
			scrollSteps.push(window.scrollWidth2);
			window.scrollWidth2=parseInt(window.scrollWidth2)+parseInt(imgs[i].clientWidth)+10;
			window.falseWidth = parseInt(window.falseWidth)+10;
			
			//window.scrollWidth=parseInt(window.scrollWidth)+162;
		}
	}
	window.scrollWidth2=parseInt(window.scrollWidth2)+parseInt('3'); // need 3 for IE6
	window.falseWidth = parseInt(window.falseWidth)+parseInt('3');
	//window.alert(window.scrollWidth);
}
