// JavaScript Document

// Menu Desplegable

function mainmenu(){

	$("#nav li").hover(function(){
		$(this).find('ul:first:hidden').css({display: "none"}).slideDown(400);
		},function(){
			$(this).find('ul:first').slideUp(400);
	});
}

// Slider

$(function() {
		$(".anyClass").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass2").jCarouselLite({
			btnNext: ".next2",
			btnPrev: ".prev2",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass3").jCarouselLite({
			btnNext: ".next3",
			btnPrev: ".prev3",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass4").jCarouselLite({
			btnNext: ".next4",
			btnPrev: ".prev4",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass5").jCarouselLite({
			btnNext: ".next5",
			btnPrev: ".prev5",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass6").jCarouselLite({
			btnNext: ".next6",
			btnPrev: ".prev6",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass7").jCarouselLite({
			btnNext: ".next7",
			btnPrev: ".prev7",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass8").jCarouselLite({
			btnNext: ".next8",
			btnPrev: ".prev8",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass9").jCarouselLite({
			btnNext: ".next9",
			btnPrev: ".prev9",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass10").jCarouselLite({
			btnNext: ".next10",
			btnPrev: ".prev10",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass11").jCarouselLite({
			btnNext: ".next11",
			btnPrev: ".prev11",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass12").jCarouselLite({
			btnNext: ".next12",
			btnPrev: ".prev12",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass13").jCarouselLite({
			btnNext: ".next13",
			btnPrev: ".prev13",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass14").jCarouselLite({
			btnNext: ".next14",
			btnPrev: ".prev14",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass15").jCarouselLite({
			btnNext: ".next15",
			btnPrev: ".prev15",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass16").jCarouselLite({
			btnNext: ".next16",
			btnPrev: ".prev16",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass17").jCarouselLite({
			btnNext: ".next17",
			btnPrev: ".prev17",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass18").jCarouselLite({
			btnNext: ".next18",
			btnPrev: ".prev18",
			visible: 1
		});
	});
	
	$(function() {
		$(".anyClass19").jCarouselLite({
			btnNext: ".next19",
			btnPrev: ".prev19",
			visible: 1
		});
	});

	$(function() {
		$(".anyClass20").jCarouselLite({
			btnNext: ".next20",
			btnPrev: ".prev20",
			visible: 1
		});
	});

	
	
// Popup

$(document).ready(function() {	
	mainmenu();
	$('.window').css("display","none");	
	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		$('html, body').scrollTop(0);
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
		$(id).css('visibility','visible');
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('.window').fadeOut(200);
		$('#mask').fadeOut();
		
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$('.window').fadeOut(200);
		$(this).fadeOut();
	});			
	
	
	
	
	/*   Novedades   */
	
	
	$('.acordion').click(function(e) {
		e.preventDefault();
		var desplega = $(this).attr("rel");
		$('.display').slideUp(800);
		$('#grilla').slideUp(800);
		if($('#'+desplega).is(':hidden')){
			$('#'+desplega).slideDown(800);
		}
		else {
			$('#'+desplega).slideUp(800);
			if($('#grilla').is(':visible'))
			$('#grilla').slideUp(800);
		}

	});
	
	$('.grilla').toggle(function() {
								 
	  $('#grilla').slideDown(800);
	  
	}, function() {
		
	  $('#grilla').slideUp(800);
	  
	});
	
	$('.grilla2').toggle(function() {
								 
	  $('#grilla2').slideDown(800);
	  
	}, function() {
		
	  $('#grilla2').slideUp(800);
	  
	});
	
	
	
	
});

