$(function(){
	$("#side_menu a").each(function(i) {
		var lh = encodeURI(decodeURI(location.href));
		var th = encodeURI(decodeURI(this.href));
		if(i>0 && lh.indexOf(th)>=0 || lh==th)
		$(this).addClass('active');
	});
}); 

/* scrollers from: http://www.pixelpusher.biz/examples/scroll/ + improvements */

var scrlSpeed=1;
scrlSpeed=(document.all)?scrlSpeed:Math.max(1,scrlSpeed-1); //decreasing speed for mozilla

function initScroll(container,object,dir) {
	if (document.getElementById(container) != null){
		var contObj=document.getElementById(container);
		var obj=document.getElementById(object);
		contObj.style.visibility = "visible";
		contObj.scrlSpeed = scrlSpeed;
		contObj.style.overflow='hidden';
/*		if(contObj.style.position!='absolute' && contObj.style.position!='fixed')
			contObj.style.position='relative';*/
		obj.style.position='absolute';
		obj.style.left='0';
		obj.style.top='0';
		if(dir=='r'||dir=='l') {
			obj.style.whiteSpace='nowrap';
			widthObject=obj.offsetWidth;
			widthContainer=contObj.offsetWidth;
			if(dir=='r')
				obj.style.left=parseInt(-widthObject)+"px";
			else
				obj.style.left=parseInt(widthContainer)+"px";
		} else {
			heightObject=obj.offsetHeight;
			heightContainer=contObj.offsetHeight;
			if(dir=='d')
				obj.style.top=parseInt(-heightObject)+"px";
			else
				obj.style.top=parseInt(heightContainer)+"px";
		}
		interval=setInterval("objScroll('"+ container +"','"+ object +"','"+ dir +"')",60);
		contObj.onmouseover = function(){
			contObj.scrlSpeed=0;
		}
		contObj.onmouseout = function(){
			contObj.scrlSpeed=scrlSpeed;
		}	
	}
}
function objScroll(container,object,dir){
	var contObj=document.getElementById(container);
	var obj=document.getElementById(object);
	if(dir=='r'||dir=='l') {
		widthObject=obj.offsetWidth;
		widthContainer=contObj.offsetWidth;
		if(dir=='r') {
			if (parseInt(obj.style.left)<widthContainer){
				obj.style.left=parseInt(obj.style.left)+contObj.scrlSpeed+"px";
			} else {
				obj.style.left=parseInt(-widthObject)+"px";
			}
		} else {
			if (parseInt(obj.style.left)>-widthObject){
				obj.style.left=parseInt(obj.style.left)-contObj.scrlSpeed+"px";
			} else {
				obj.style.left=parseInt(widthContainer)+"px";
			}
		}
	} else {
		heightObject=obj.offsetHeight;
		heightContainer = contObj.offsetHeight;
		if(dir=='d') {
			if (parseInt(obj.style.top)<heightContainer){
				obj.style.top=parseInt(obj.style.top)+contObj.scrlSpeed+"px";
			} else {
				obj.style.top=parseInt(-heightObject)+"px";
			}
		} else {
			if (parseInt(obj.style.top)>-heightObject){
				obj.style.top=parseInt(obj.style.top)-contObj.scrlSpeed+"px";
			} else {
				obj.style.top=parseInt(heightContainer)+"px";
			}
		}
	}
}

$(document).ready(function(){
	initScroll('flash_box_cont','flash_box_roller','u');
});
