// JavaScript Document

function menyMouseOver(div) {
	document.getElementById(div).style.backgroundImage = "url('/grafikk/pil.png')"; 
	document.getElementById(div).style.backgroundPosition = "center right"; 
	
}

function menyMouseOut(div) {
	document.getElementById(div).style.backgroundImage = ""; 
}

function galleryImg(aid, bid, current) {
	var h = $('#ImgContainer').height();
	var top = (h/2);
	$('#ImgContainer').html('<div style="height: '+h+'px;";><div style="padding-top: '+top+'px;"><img src="/grafikk/load.gif" /></div></div>');
	//$('#ImgContainer'+PostID).show();
	$.post("/ajax/galleryNextImg.php", { aid: aid, bid: bid, current: current }, function(data) {
		//alert(data);
		var response = data.split("---");
		//alert(response);
		//$('#XL_'+PostID).width(response[0]);
		//$('#ImgContainer').height(response[1]);
		$('#ImgContainer').html(response[2]);;
		$('#BildeContainer').html(response[3]);
		$('#NextContainer').html(response[4]);
		//$('#ImgContainer').html(data);
		$.scrollTo('#Gallery', 800, {margin: true});
	});
}

$(document).ready(function() {
   /*$('#s3slider').s3Slider({
      timeOut: 3000
   });
	 */
});

$(function(){
	/*Get features working*/
	feature = {
		interval: false
	}

	feature.interval = setInterval(function(){nextFeature()},4000);

	$('.featurecount_int > li').click(function(){
		i = $(this).index('.featurecount_int > li');
		$(this).siblings().removeClass('selected').end().addClass('selected');
		$('#featured').animate({left:-675*i},'slow');
		
		clearTimeout(feature.interval);
		feature.interval = setInterval(function(){nextFeature()},4000);
	})
	$('#featured').mouseover(function(){
		clearTimeout(feature.interval);
	}).mouseout(function(){
		feature.interval = setInterval(function(){nextFeature()},4000);
	}).find('li').click(function(){
		window.location = $(this).attr('permalink');
	});
	
});

function nextFeature(){
	i = $('.featurecount_int .selected').index('.featurecount_int > li');
	n = i >= 4 ? 0 : i+1;
	
	$('#featured').animate({left:-675*n},'slow');
	
	$('.featurecount_int > li').removeClass('selected').eq(n).addClass('selected');
}

