//menu rollovers
$(function(){
	$('#menu a')
		.css( {backgroundPosition: "-20px 35px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-20px 110px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:100, complete:function(){
				$(this).css({backgroundPosition: "-20px 35px"})
			}})
		})
});

//make whole div clickable
/*$(document).ready(function() {
	updateLinks();
})*/

var type;
function loadPage($type, $prod, $med){
	
	type = $type;
	
	//deselect old menu
	$('#menu li').each(function() {
	      $(this).removeClass('selected');
	});
	
	//select new menu
	if($prod==-1){
		$('#menu_' + $type).addClass('selected');
	} else {
		$('#menu_' + $med).addClass('selected');
	}
		
	//hide content
	//$('#content').css("left", (W + 100) + "px");
	$('#content').hide();
	//$('#content').fadeOut(1);
	
	//getting the content
	if($prod==-1){
		$urlStr = 'content.php?t='+$type;
		$('#content').load($urlStr, showUpdatedContent); 
	} else {
		//media
		$urlStr = 'media.php?t='+$type+'&p='+$prod + '&m=' + $med;
		$('#media').load($urlStr, showUpdatedContent); 
	}
}

function showUpdatedContent() {
	
	//moving the colls
	//$("#content").animate({"left": xPosCol1 + "px"}, "slow");
	//$('#content').delay(550).fadeIn('slow');
	$('#content').fadeIn('slow', updateLinks);
}

function updateLinks() {
	
	//alert("updateLinks");	
	/*$("li:has(a)").click(function(){
		window.location = $("a:first",this).attr("href");
	});*/
	$(".button:has(a)").click(function(){
		window.location = $("a:first",this).attr("href");
		return false;
	});
}

function changeMedia($prod, $med, $medI) {   
  	//getting the content
	/*$('#media').fadeOut(1);*/
	//$("#content").css({ opacity: 0 });
	$("#media").fadeOut(1);
	
	//$('#content').load('media.php?t='+type+'&p='+$prod + '&m=' + $med + '&i=' + $medI, showUpdatedContent); 
	$("#media").load('media.php?t='+type+'&p='+$prod + '&m=' + $med + '&i=' + $medI, function() {
			
		//$('#media').fadeIn(200);
		$('#media').fadeIn('slow');
	});
}
