// Firstpage Javascript

// Team ÖSK snurran
var totalw = 0;
var totall = 0;

$(function(){
	$("#teamInnerwrapper > .teamPartner").each(function(){
		totalw = totalw + 200;
		totall++;
	});
	moveleft();
	//setTimeout("moveleft()", 5500);
});

function moveleft()
{
	$("#teamInnerwrapper").animate({ left: "-"+ totalw +"px" }, totall * 2500,"linear", function(){
		$(this).css("left", "350px");
		moveleft();
	});
	/*$("#teamWrapper > .teamPartner").each(function(){
		var $this = $(this);
		var l = $this.css("left");
		$this.animate({"left": "-=10px"}, 500);

	});*/
}

// Scrollabe blurbs
var $blurbs;

$(function(){
	$blurbs = $(".blurb_wrapper").scrollable({ size: 4, api: true, loop: true, clickable: false });
	$blurbs.onBeforeSeek(function(e){
		//if($blurbs.getIndex() >= 4)
			//return false;
	});
	
	$(".custom_innerwrapper > div > div > div").each(function(){
		var cname = $(this).attr("class").replace("_button","").split(" ")[0];
		var cookie = $.cookie(cname);
		if(cookie == '1')
		{
			$(this).css("background-image", "url(/images/18.4cad860812491721aed8000167/custom_button_bg_inactive.gif)");
			$("."+ cname).hide();
		}
	});

	$(".custom_innerwrapper > div > div > div").click(function(){
		var $this = $(this);
		var parent = $this.attr("class").replace("_button","").split(" ")[0];
		var $parent = $("."+ parent);

		if($parent.is(":visible"))
		{
			//$this.addClass("parentInactive");
			$this.css("background-image", "url(/images/18.4cad860812491721aed8000167/custom_button_bg_inactive.gif)");
			$parent.hide();
			$blurbs.reload();
			$.cookie(parent, '1', { expires: 365, path: '/' });
		}
		else
		{
			$this.css("background-image", "url(/images/18.a90725d1245c7cf0e38000500/custom_button_bg.gif)");
			$this.removeClass("parentInactive");
			$parent.show();
			$blurbs.reload();
			$.cookie(parent, '0', { expires: 365, path: '/' });
		}
	});

});


$svjq(function(){

$svjq(".custom_wrapper > .custom_innerwrapper").hide();

	$svjq(".custom_fold_btn > img").click(function(){
		if($svjq(".custom_innerwrapper").is(":visible"))
		{
			$svjq(".custom_innerwrapper").slideUp(1000);
		}
		else
		{
			$svjq(".custom_innerwrapper").slideDown(1000);
			$svjq.scrollTo(".blurb_innerwrapper", 1500);
		}
	});
});
