// JavaScript Document
// javascript functions by robersant.com

$(document).ready(function(){
						   
	// Logo function
	$("#robersant").hover(
		  function () {
				$("#robersant img").replaceWith('<img src="inc/robersanth.png" alt="robersant :diseņo audiovisual y otras cosas" width="425" height="85" border="0" />');
		  },
		  function () {
				$("#robersant img").replaceWith('<img src="inc/robersant.png" alt="robersant :diseņo audiovisual y otras cosas" width="425" height="85" border="0" />');
		  }
	);
	
	// Set and get index
	var i = 1;
	var t = $("#set img").length
	//var t = 4;
	var w = 0;
	
	// Next function
	$("#next").click(function(event){
		if(i==t) { 
			i = 1; 
			w = 0;
		} else { 
			w = w+$("#"+i).attr('width')+4;
			i++;
		}		
		$("#set").animate({marginLeft: '-'+w+'px'},'slow');	
	});
	 
	// Prev function
	$("#prev").click(function(event){
		if(i!=1) {
			i = i-1;
			w = w-$("#"+i).attr('width')-4;
			$("#set").animate({marginLeft: '-'+w+'px'},'slow');
		}
	});
	
	//Menu function
	$("#menu a").click(function(event){
		$("#submenu").hide();
			var sm = $(this).attr('rel');
			$("#submenu").html($("#"+sm).html());
		$("#submenu").slideDown('fast');
		
		$("#menu a").removeClass("selected");
		$(this).addClass("selected");
	});
	
});

