var bg = "";

$(document).ready(function(){
//	$("#boxabstracthp .abs:first-child").fadeIn(7000);
	$("#boxarrowhp").fadeOut(7000);
	$("#menu li a").click(function() {
		//$("#menu li").css("width","auto");	
//		var c = $(this).parent().innerWidth();
//		$(this).parent().css("width", c +"px");
		$("#menu li a").removeClass("selected");
		$(this).addClass("selected");
								   
		 $("#menu > li > div").hide();    
		 $(this).parent().find("div").show();	
	});
	
	$("#contboxabstracthp #abstractopen").click(function() {
		$("#abstract").slideToggle("fast");	
	});	
	
	$("#news #newsopen").click(function() {
		$("#elnews").slideToggle("fast");	
	});	
	$("#news #newsclose").click(function() {
		$("#boxnewshp").hide();
	});	
	
	$('#bg').cycle({ 
		fx:     'fade', 
		speed:  '8000', 
		timeout: 0, 
		next:   '#nextBtn', 
		prev:   '#prevBtn',
		before:   function() { 
			var idbox = "#abs_"+$(this).attr("rel");
			$("#abstract .abs").hide();
			$(idbox).fadeIn();			
		}
	});
	
	$('#bgint').cycle({ 
		fx:     'fade', 
		speed:  '8000', 
		timeout: 0, 
		next:   '#nextBtn', 
		prev:   '#prevBtn' 
	});
	
	$("#prevBtn").click(function() {
		$("#boxarrowhp").hide();
	});
	$("#nextBtn").click(function() {
		$("#boxarrowhp").hide();

	});
	$("#arrowx").click(function() {
		$("#boxarrowhp").hide();
	});
	
	$(document).keydown(function(e) {
		switch(e.keyCode) { 
			case 37:
				$('#prevBtn').click();
				$("#boxarrowhp").hide();	
			break;
			case 39:
				$('#nextBtn').click();
				$("#boxarrowhp").hide();
			break;
		}
	});	
	
		
	$("#elprod li").mouseover(function() {
		bg = $(this).find(".testo").css("background");
		$(this).find(".testo").css("background", "none");
		$(this).find("h2").css("background", "url(/images/prod_on.jpg) bottom left repeat-y");
		$(this).find("p span").css("visibility","visible");
	});
	$("#elprod li").mouseout(function() {
		$(this).find("h2").css("background", "none");
		$(this).find("p span").css("visibility","hidden");
		$(this).find(".testo").css("background", bg);
	});
	
	$("#icon li img").mouseover(function() { 
		var src = $(this).attr("src").match(/[^\.]+/) + "_on.png";
		$(this).attr("src", src);
	}).mouseout(function() {
		var src = $(this).attr("src").replace("_on", "");
		$(this).attr("src", src);
	});

	$(".inside").mouseover(function() {
		//$(this).parent().find(".tooltip").fadeIn();	
		$(".tooltip").show();
	}).mouseout(function() {
		$(".tooltip").hide();
		//$(this).parent().find(".tooltip").fadeOut();	
	});
	
	$("#nav #listadesigner").click(function() {
		$("#eldesigner").slideToggle("fast");	
	});
	
	
	var prev = 1;
	$(".w_next").click(function() {
		var n = 1;
		var n1 = 1;
		var c = 860;
		n = $(this).attr('id');
		$(".w_next").removeClass("selected");
		$(this).addClass("selected");
		n1 = n-prev;	
		c = "-="+n1*c;
		prev = n;
		$("#wallpapers_wrapper").animate({
				marginLeft: c
		},500);
	
	});
	

});

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
