var GB_ANIMATION = true;

$(function(){
		   
// Top link que aparece cuando el scroll baja 
jQuery.fn.topLink = function(settings) {
	settings = jQuery.extend({
		min: 1,
		fadeSpeed: 200
	}, settings);
	return this.each(function() {
		//listen for scroll
		var el = $(this);
		el.hide(); //in case the user forgot
		$(window).scroll(function() {
			if($(window).scrollTop() >= settings.min)
			{
				el.fadeIn(settings.fadeSpeed);
			}
			else
			{
				el.fadeOut(settings.fadeSpeed);
			}
		});
	});
};
	
//usage w/ smoothscroll
$(document).ready(function() {
	//set the link
	$('#top-link').topLink({
			min: 400,
			fadeSpeed: 500
		});
		//smoothscroll
		$('#top-link').click(function(e) {
			e.preventDefault();
			$.scrollTo(0,300);

	});
});  
		   
// Links con scroll suave
  $.scrollTo.defaults.axis = 'y';//scroll horizontally
  $.scrollTo.defaults.duration = 200;//the speed

/*$('.arriba').click(function(){
     $.scrollTo( '0' );
});
*/
	
// Links externos en vent nueva
$("a[href^='http']").attr({ target: "_blank" });

// FOTOS HEAD
	$('#fotos').cycle({ 
		fx:      'fade', 
		random:   1,
		next:	 '#fotos',
		speed:    1000,
		timeout:  2000 
	});

// MENU botones bg anim
		// set opacity to nill on page load
		$("ul#botones span").css("opacity","0");
		// on mouse over
		$("ul#botones span").hover(function () {
			// animate opacity to full
			$(this).stop().animate({
				opacity: 1
			}, 'slow');
		},
		// on mouse out
		function () {
			// animate opacity to nill
			$(this).stop().animate({
				opacity: 0
			}, 'slow');
		});
	

// AJAX:
//$('.botSeguridad').bind('click',	function() {
//	$('.divSeguridad').load('lipsum.html', '');
//});

// Auto Suggest
/*
$("#buscar").jSuggest({
	url: "suggestion.html",
	type: "GET",
	data: "searchQuery",
	autoChange: true
});
*/

// MAS datos personales
	$(".mas").click(function(){
		$(this).parents("li").animate({ height: 120 }, "slow");
	});

// Form Field Value Swap
    swapValues = [];
    $(".swap").each(function(i){
        swapValues[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });	


// Foto mas vista - Nombre de Album y Usr
$('.masvista').hover(function() { //mouse in  
        $("#span-fotos").animate({ bottom: '0px' }, 200);
		$("#span-videos").animate({ top: '0px' }, 200);
    }, function() { //mouse out  
        $("#span-fotos").animate({ bottom: '-28px' }, 600);  
		$("#span-videos").animate({ top: '-28px' }, 600); 
});  
//

// Bienvenido Usuario
	$('.bot-tu').hover(function(){
		$('#menu-subir').fadeOut(500);
		$('#menu-tu').fadeIn(1000);
	});
	$('.bot-subir').hover(function(){
	   $('#menu-tu').fadeOut(500);
		$('#menu-subir').fadeIn(1000);
	});
//

// proteger direcciones de Mail
// <a href="#C#webintenta#NOSPAM#gmail#P#com" class="dir_mail">Mi Correo</a>
$('.dir_mail').each(function(){
	$('.dir_mail').attr('href','mailto:' + $('.dir_mail').attr('href').replace('#NOSPAM#','@').replace('#C#','').replace('#P#','.'));
});
//

//	
});