$(document).ready(function(){
	
	mainmenu();
	
	//Slide Home
	$('#slideHome').cycle({ 
		fx: 'fade',
		timeout: 5000
	});
	
	$('#eTrotterBanner').cycle({ 
		fx: 'fade',
		timeout: 4000
	});
	
	
	//Productos
	
	
	//Representantes
	$('select[name="representantes"]').change(function() {
		
		var r = $(this).val();
		var distancia = $('#'+r).offset().top;
		//console.log(r);
		//console.log(distancia);
		$('.representante').animate({backgroundColor:'white'}, 500, function(){
			
			//$('#'+r).next().animate({backgroundColor:'#FFFF99'}, 250);
			$('#'+r).animate({backgroundColor:'#FFFF99'}, 250);
			
		});
		
		$('html,body').animate({scrollTop: distancia-240}, 2000, "swing");
		
		return false;
	});
	
	
	//Contacto
	$(".mapa").click(function (event) { 
							   
		//preveengo el link
		event.preventDefault();
		
	  	var titulo = $(this).attr("title");
		var mapaCual = $(this).attr("id");
		
		if( mapaCual == 'mapaQuilmes' ){
			mapa = '<iframe width="550" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.ar/maps?hl=es&amp;q=Marcelo T. de Alvear 2762&amp;ie=UTF8&amp;z=15&amp;output=embed"></iframe>';
		}else{
			mapa = '<iframe width="550" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.ar/maps?hl=es&amp;q=Gral. Iriarte 372, Crucesita, Buenos Aires&amp;ie=UTF8&amp;z=15&amp;output=embed"></iframe>';
		}
		
      	new Boxy(mapa, {title: titulo, closeText: "Cerrar", draggable: false, modal: true});
		
    });
	
});

function mainmenu(){
	// Oculto los submenus
	$("#nav li ul").css("display","none");
	// Defino que submenus deben estar visibles cuando se pasa el mouse por encima
	$("#nav li").hover(function(){
		$(this).children("a").animate({ backgroundColor: "#C4E1FF", height: "22px" }, 250);
    	$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).fadeIn(400);
    },function(){
        $(this).find('ul:first').fadeOut(400);
		$(this).children("a").animate({ backgroundColor: "#FFF", height: "13px" }, 400);
    });
}
