$(document).ready(function(){
//Saludos, y bienvenidos a las llamadas javascript.
	$('#s').autofill({
		value: 'Buscar en multimúsica',
		defaultTextColor: '#3f3f3f',
		activeTextColor: '#666'
	});
	
	$(".tabs").tabs(".panes > div");	
	
	$('.each').hoverIntent({
			sensitivity: 2,
			interval: 100,
			over: eachon,
			timeout: 300,
			out: eachoff
			});
		
	$('.destacados-each').hoverIntent({
			sensitivity: 2,
			interval: 100,
			over: destacamuestra,
			timeout: 300,
			out: destacaoculta
			});
			
	$('.each-content').hide();
		
	$(".slider-mask").scrollable({
			size: 3,
			items: '.slider-wrapper',
			next: '#botones-siguiente',
			prev: '#botones-anterior',
			loop: true,
			keyboard: true,
			speed: 600
		});
	
	$("#tcy-mask").scrollable({
			size: 12,
			items: '#tcy-wrapper',
			next: '#tcy-next',
			prev: '#tcy-prev',
			loop: false,
			keyboard: false,
			speed: 600
		});	
		
	$(".editorial-mask").scrollable({
			size: 1,
			items: '.editorial-wrapper',
			next: '#editorial-botones-siguiente',
			prev: '#editorial-botones-anterior',
			loop: true,
			interval: 4000,
			speed: 600 
		});
		
	$(".destacados-mask").scrollable({
			size: 1,
			items: '.destacados-wrapper',
			next: '#destacados-botones-siguiente',
			prev: '#destacados-botones-anterior',
			loop: true,
			speed: 600
		});
		
	$("#estuvisteahi-mask").scrollable({
			size: 1,
			items: '#estuvisteahi-wrapper',
			next: '#widget-botones-siguiente',
			prev: '#widget-botones-anterior',
			loop: true,
			speed: 600
		});
		
	$('#author').autofill({
			value: 'Tu nombre',
			defaultTextColor: '#bbb',
			activeTextColor: '#666'
		});
	
	$('#email').autofill({
			value: 'Tu e-mail',
			defaultTextColor: '#bbb',
			activeTextColor: '#666'
		});
	
	$('#comment').autofill({
			value: 'Lo que tengas que decir.',
			defaultTextColor: '#bbb',
			activeTextColor: '#666'
		});
	
	$('.destacados-loader-mask').scrollable({
			size: 1,
			items: '.destacados-loader-wrapper',
			next: '#destacados-botones-siguiente',
			prev: '#destacados-botones-anterior',
			loop: true,
			vertical: true,
			interval: 14000,
			speed: 1000
		});
	
/*	$('.wpcf7-form li').each(function(){
		var value = $(this).find('label').html();
		$(this).find('input[text],textarea').each(function(){
			$(this).autofill({
				value: value,
				defaultTextColor: '#999',
				activeTextColor: '#313131'
				});
			});
		});
		*/
		
	
	$('.persona').hoverIntent({
			sensitivity: 2,
			interval: 100,
			over: datomuestra,
			timeout: 300,
			out: datoculta
			});
	$('.persona .datos').each(function(){
		var alto = $(this).height();
		var alto = '-'+alto+'px';
		$(this).css("bottom",alto);
	});
	
/*	$('#formulario-registrar li').each(function(){
		var value = $(this).find('label').html();
		$(this).find('.input-text , .input-pass').each(function(){
			$(this).autofill({
				value: value,
				defaultTextColor: '#4d4d4d',
				activeTextColor: '#313131'
				});
			});
		}); */
	
/*	$('#num_celular').autofill({
		value: '8765 4321',
		defaultTextColor: '#4d4d4d',
		activeTextColor: '#313131'
		});
	
	$('#cod-celular').autofill({
		value: '9',		
		defaultTextColor: '#4d4d4d',
		activeTextColor: '#313131'
		});
*/
	
	$('#searchform .button').val('');
	
	$('.trayectoria-each h3').hoverIntent({
			sensitivity: 2,
			interval: 100,
			over: traymuestra,
			timeout: 300,
			out: trayoculta
			});

    $(".flickr_badge_image a").attr({ 
          target: "_blank"
          });
          
	$(".trayectoria-loaded-mask").scrollable({
			size: 1,
			items: '.trayectoria-wrapper',
/*			next: '#botones-siguiente',
			prev: '#botones-anterior', */
			loop: true,
			keyboard: false,
			speed: 600
		});

	 	 
	$(".trayectoria-loader-trigger").live("click", function(e){
			var Queeslaquehay = $(this).attr("rel");
			if( Queeslaquehay != '') {
				$.ajax({
					type : 'GET',
					url : 'http://www.multimusica.cl/wp-content/themes/multimusica/libraries/phpFlickr/getFlickr.php',
					dataType : 'html',
					data: {
					photoset : Queeslaquehay
				},
				success : function(data){
/*				$("#trayectoria .trayectoria-loader").fadeOut("fast", function(){
					Shadowbox.clearCache();
					$(this).empty();
					$(this).html(data);
					$(this).fadeIn("fast");														
					var F = $('.flickr-call');
					var G = $(this).find('.trayectoria-ttl02').html();
					Shadowbox.setup(F, {gallery: G,title: G});	
				}); */
				$("#trayectoria .trayectoria-loader").fadeOut("fast", function(){
					Shadowbox.clearCache();	
					$(this).prepend('<div class="trayectoria-target clearfix">'+data+'</div>');
					$(this).fadeIn("fast");
					$('.flickr-call .img').each(function(){
							$(this).hide();
							var src = $(this).attr('src');							
							$(this).parent().prepend('<div class="loading"></div>');
							$(this).load(function(){
								$(this).parent().find('.loading').remove();
								$(this).parent().css("background-image","url("+src+")");
								});
							});
					var F = $('.flickr-call');
					var G = $(this).find('.trayectoria-ttl02').html();
					Shadowbox.setup(F, {gallery: G,title: G});	
				});
					
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert('Hubo un error');
					}
				});
			};
			return false;
		});
	
	$('.btn-year-back').live('click', function(){
		$(this).parents().find('.trayectoria-loader').fadeOut('fast', function(){
			$(this).find('.trayectoria-target').empty();
			$(this).fadeIn('fast');
			});
		});
	
	$(".flickr-call").bind('load', function() { 
		$(this).hide();
		
	});

/*		Shadowbox.setup('#shadowlogo', {gallery: 'demogallery'});			*/	




/*
	$('.flickr-call').live('click', function(){
		var J = $(this);
		
		Shadowbox.open({
			content: J.attr('href'),
			title: J.attr('title'),
			player: 'img',
			options: {}
			});
			return false;
		}); 
*/

$("#tcy-wrapper div:first").addClass("active-year");
	
}); //document.ready


function eachon(){
			$(this).find(".each-content").each(function() {
			$(this).fadeIn("slow");})
			}
		  
function eachoff(){ 
			$(this).find(".each-content").each(function() {
			$(this).fadeOut("slow");})
			}

function destacamuestra(){
			$(this).find(".destacados-image").each(function() {
				var imageurl = $(this).html();
				$("#destacados .destacados-loader").fadeOut("fast", function(){
					$(this).empty();
					$(this).html(imageurl);
					$(this).fadeIn("fast");									
					});
				});
			}
		  
function destacaoculta(){
			$(this).find(".destacados-image").each(function() {
			$(this).fadeOut("slow");})
			}
			
function datomuestra(){
			$(this).find(".datos").each(function() {
				$(this).show();
					var position = $(this).position();
					var alto = $(this).height();
					var move = (position.top)-alto;
					$(this).animate({ 
			        top: '+'+move
			      }, 300 ); 
				});
			}

function datoculta(){ 
			$(this).find(".datos").each(function() {
				var position = $(this).position();
				var alto = $(this).parent().height();								
				$(this).animate({ 
		        top: '+'+alto
		      }, 600 );
		      alert(move);
			});
		}
	
function traymuestra(){
			$(this).parents().find(".active-year").removeClass("active-year");
			$(this).parent().addClass("active-year");
			$(this).parent().find(".trayectoria-hidden").each(function() {
				var trayinject = $(this).html();
/*				$("#trayectoria .trayectoria-loader-wrapper").animate({ 
					"top": "-=100px"
					}, 700, function(){
					$(this).insertAfter(trayinject);
			
					}); */
				$("#trayectoria .trayectoria-loader").fadeOut("fast", function(){
					$(this).empty();
					$(this).html(trayinject);
					$(this).fadeIn("fast");									
					});
				});
			}

function trayoculta(){ 
			$(this).find(".trayectoria-hidden").each(function() {
			$(this).fadeOut("slow");})
			}