$(function() {
	
	
	// Use this example, or...
	//$('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
	// This, or...
	//$('#gallery a').lightBox(); // Select all links in object with gallery ID
	// This, or...
	$('a.lightboxx').lightBox(); // Select all links with lightbox class
	$('a.lightboxe').lightBox(); // Select all links with lightbox class
	$('a.lightboxg').lightBox(); // Select all links with lightbox class
	// This, or...
	//$('a').lightBox(); // Select all links in the page
	// ... The possibility are many. Use your creative or choose one in the examples above

	
	
	$('#slider_2').show('fast');
	$('#slider_3').show('fast');
	$('#slider_4').show('fast');
	function desparezcoPresentacion()
	{
		for(var i=1;i<10;i++)
		{
			$('#d'+i).hide();
		}
	}
	$('.kwicks').kwicks({
		max : 170,
		spacing : 20,
		sticky : true
		});
	$("#menu_inicio").click(function(){
		  $(".sliders").animate({"margin-left": "0px"}, "slow");
		  desparezcoPresentacion();
		  return false;
	});
	$("#menu_nosotros").click(function(){
		  $(".sliders").animate({"margin-left": "-960px"}, "slow");
		  desparezcoPresentacion();
		  return false;
	});

	$("#menu_galeria").click(function(){
		  $(".sliders").animate({"margin-left": "-1920px"}, "slow");
		  return false;
	});

	$("#menu_contacto").click(function(){
		  $(".sliders").animate({"margin-left": "-2880px"}, "slow");
		  desparezcoPresentacion();
		  return false;
	});
	
	//Custom settings
	var style_in = 'easeOutBounce';
	var style_out = 'jswing';
	var speed_in = 1000;
	var speed_out = 300;
	var anterior='';	
	//Calculation for corners
	var neg = Math.round($('.qitem').width() / 2) * (-1);	
	var pos = neg * (-1);	
	var out = pos * 2;

	$('.qitem').each(function (){
		url = $(this).find('a').attr('href');
		img = $(this).find('img').attr('src');
		alt = $(this).find('img').attr('img');
		$('img', this).remove();
		$(this).append('<div class="topLeft"><\/div><div class="topRight"><\/div><div class="bottomLeft"><\/div><div class="bottomRight"><\/div>');
		$(this).children('div').css('background-image','url('+ img + ')');
		$(this).find('div.topLeft').css({top:0, left:0, width:pos , height:pos});	
		$(this).find('div.topRight').css({top:0, left:pos, width:pos , height:pos});	
		$(this).find('div.bottomLeft').css({bottom:0, left:0, width:pos , height:pos});	
		$(this).find('div.bottomRight').css({bottom:0, left:pos, width:pos , height:pos});	
	}).hover(function () {
		$(this).find('div.topLeft').stop(false, true).animate({top:neg, left:neg}, {duration:speed_out, easing:style_out});	
		$(this).find('div.topRight').stop(false, true).animate({top:neg, left:out}, {duration:speed_out, easing:style_out});	
		$(this).find('div.bottomLeft').stop(false, true).animate({bottom:neg, left:neg}, {duration:speed_out, easing:style_out});	
		$(this).find('div.bottomRight').stop(false, true).animate({bottom:neg, left:out}, {duration:speed_out, easing:style_out});	
	},
	function () {
		$(this).find('div.topLeft').stop(false, true).animate({top:0, left:0}, {duration:speed_in, easing:style_in});	
		$(this).find('div.topRight').stop(false, true).animate({top:0, left:pos}, {duration:speed_in, easing:style_in});	
		$(this).find('div.bottomLeft').stop(false, true).animate({bottom:0, left:0}, {duration:speed_in, easing:style_in});	
		$(this).find('div.bottomRight').stop(false, true).animate({bottom:0, left:pos}, {duration:speed_in, easing:style_in});	
	}).click (function () {
		var num = (($(this).find('a').attr('id')).substring(1,10));
		num='#d'+num;
		var activo=false;
		//
		for(var i=1;i<10;i++)
		{
			$('#d'+i).hide();
		}
		$(num).fadeIn('slow', function() {});
		/*
		$(anterior).fadeOut('slow', function() {
			$(num).fadeIn('slow', function() {});
		});
		if(anterior==''){
			$(num).fadeIn('slow', function() {});
		}
		*/
		anterior=num;
		e.preventDefault();
			
	});
}
);

