
// comienza el código jQuery JS
$(document).ready(function(){
 
	// declaro ecuacion x defecto
	jQuery.easing.def = 'easeOutBounce';
  
 // ------------------------------------ 
 //EVENTOS PESTANAS 
 
 $("#link_pest_01").click(function(event){
   move_perrito(0);
 });
 $("#link_pest_02").click(function(event){
   move_perrito(1);
 });
 $("#link_pest_03").click(function(event){
   move_perrito(2);
 });
 $("#link_pest_04").click(function(event){
   move_perrito(3);
   //pre_img_youtube();
 });
 $("#link_pest_05").click(function(event){
   move_perrito(4);
 });
 
 $('#cabecera').crossSlide({
	  sleep: 15,
	  fade: 2
	}, [
	  { src: 'imgs/top_02.jpg' },
	  { src: 'imgs/top_03.jpg' },
	  { src: 'imgs/top_05.jpg' },
	  { src: 'imgs/top_06.jpg' },
	  { src: 'imgs/top_07.jpg' },
	  { src: 'imgs/top_08.jpg' },
	  { src: 'imgs/top_04.jpg' },
	  { src: 'imgs/top_09.jpg' },
	  { src: 'imgs/top_10.jpg' }
	]);
 
 // ------------------------------------
 // mantenimiento menu INDEX
 // ------------------------------------

		var navegador = navigator.appName
		
		if (navegador == "Microsoft Internet Explorer")
			var w_pest = new Array(72,282,460,710,900);
		else
			//var w_pest = new Array(222,432,610,850,1050);
			var w_pest = new Array(72,282,460,710,900);
	
	function move_perrito(n){
		var pos_pest = w_pest[n];
		$('#perrito').animate({
			"marginLeft": pos_pest+"px"
		}, 1500, function(){
			$('#back_ground_0'+(n+1)).slideDown(800);
		});
		//view_tit(n);
	}
	
	var bot_sel = new Array();
		
	function news_tab(n){
		$('#back_ground_0'+n).slideDown(800);
	}
	
	 function clean_bots(n){
	 	for(var i = 1; i < 6; i++){
	 		if(n==i) i++;
			$('#link_pest_0'+i).stop().animate({backgroundPosition:"(0px 7px)"}, {duration:800, complete:function(){
				$('#link_pest_0'+i).css({backgroundPosition: "0px 7px"})
			}})
	 	}
	 }
	 
	function del_background(n){
		var pre_n = bot_sel[bot_sel.length-2];
		pre_n = pre_n.substring(pre_n.length-1,pre_n.length);
		$('#back_ground_0'+pre_n).slideUp(500);
	}
	
	$(function(){
		$('#a a')
			.css( {backgroundPosition: "0px 7px"} )
			.mouseover(function(){
				$(this).stop().animate({backgroundPosition:"(0px 146px)"}, {duration:1100})
			})
			.mouseout(function(){
				if(bot_sel[bot_sel.length-1] != $(this).attr('id')){
					$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:1000, complete:function(){
						$(this).css({backgroundPosition: "0px 7px"})
					}})
				}
			})
			.click(function(){
				$(this).stop().animate({backgroundPosition:"(0px 146px)"}, {duration:1000})
				bot_sel.push($(this).attr('id'));
				var n = $(this).attr('id');
				n = n.substring(n.length-1,n.length);
				clean_bots(n);
				if(bot_sel.length>1){
					id_array = bot_sel[bot_sel.length-1];
					if($(this).attr('id') != bot_sel[bot_sel.length-2]){
						del_background(n);
					}
				}
			})
			
	});
	
	var urles = new Array();
	//[TITULO (BANDA - TITULO),TIPO TEMA, SALA (CIUDAD), EDITOR]
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=UDfv9kM7TaA&vq=medium","MSBK - HOOCHIE","VIDEO CLIP","CLIP SINGLE HOOCHIE","NORTHERN LIGHTS"];
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=apVi6bbGOJc&vq=medium","MSBK - WHO DO YOU LOVE?","WHO DO YOU LOVE?","RITMO Y COMPAS (MADRID)","MELODIC FEST"];
	
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=_RhszUMhABA&vq=medium","MSBK - LIVIN' NOW","VIDEO CLIP","SALA HEINEKEN (MADRID)","ROCKBOXTV"];
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=BuqHe7kEhOA&vq=medium","MSBK - GOOD TIMES","ACOUSTIC LIVE","ROCKBOXTV (MADRID)","ROCKBOXTV"];
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=1YAI7k_3F4M&vq=medium","MSBK - SLIP AWAY","ACOUSTIC LIVE","ROCKBOXTV (MADRID)","ROCKBOXTV"];
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=gaZSX0vNx5U&vq=medium","MSBK - BIG BANG","LIVE VIDEO","RITMO Y COMPAS (MADRID)","SOME FAN"];
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=cpG_KZLK5HI&vq=medium","MSBK - SLIP AWAY","ACOUSTIC LIVE","SALA HEINEKEN (MADRID)","ROCKBOXTV"];
	urles[urles.length] = ["http://www.youtube.com/watch_popup?v=LV1i1PZpCrE&vq=medium","MI HERMANO JESÚS GARCÍA","HOMENAJE A. VEGA","SGAE FUNERAL ANTONIO VEGA","SGAE"];
	
	function pre_img_youtube(){
		/* LIGHTBOX VERSION
		for(var i = 0; i < urles.length; i++){
			var urle = '';
			urle = $.jYoutube(urles[i][0],'small');
			$('#tubes').append($('<div class="pre_tube"><a href="'+urles[i][0]+'" rel="prettyPhoto" title="'+urles[i][1]+' | '+urles[i][3]+'"><img src="'+urle+'"/></a></br><strong style="" class="song_title">'+urles[i][1]+'</strong></br><strong>'+urles[i][2]+'</strong></br><strong>'+urles[i][3]+'</strong></br><strong>'+urles[i][4]+'</strong></div>'));
		}*/
		
		/* VERSION POP-UP*/
		var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=450, height=350, top=0, left=0";
		for(var i = 0; i < urles.length; i++){
			var urle = '';
			urle = $.jYoutube(urles[i][0],'small');
			$('#tubes').append($('<div class="pre_tube" rel="'+urles[i][0]+'"><a href="#" id="open_'+i+'"><img src="'+urle+'"/></a></br><strong style="" class="song_title">'+urles[i][1]+'</strong></br><strong>'+urles[i][2]+'</strong></br><strong>'+urles[i][3]+'</strong></br><strong>'+urles[i][4]+'</strong></div>'));
			
			$(".pre_tube:eq("+i+")").click(function(event){
				window.open($(this).attr("rel"),"",opciones);
			});
			
			$(".pre_tube").mouseover(function(event){
				$(this).css({'background':'#330000','cursor':'hand'});
			});
			$(".pre_tube").mouseout(function(event){
				$(this).css('background-color','#0e0e0e');
			});
		}
	}
 // ------------------------------------ 
 //EVENTOS discos INFO
 
 var ficha_selec = new Array("0");
 
 function marcador_disco(n){
 	ficha_selec.push(n);
 	
 	for(var i=0; i < 5; i++){
  	$('#info_disco_0'+(i+1)).slideUp(200);
  	$('.ficha_disco:eq('+i+')').css('background-color','#0e0e0e');
  	$('.disco:eq('+i+')').css('borderRight','0px');
 	}
  $('#info_disco_0'+(n+1)).slideDown(800);
  $('.disco:eq('+n+')').css('borderRight','4px solid #FF0000');
  $('.ficha_disco:eq('+n+')').css('background-color','#440000');
 }
 
	function ficha_out_mouse(n){
		if(n!=ficha_selec[ficha_selec.length-1]){
			$('.ficha_disco:eq('+n+')').css('background','#0e0e0e');
		}else{
			$('.ficha_disco:eq('+n+')').css('background','#440000');
		}
	}
 
 $(".ficha_disco:eq(0)").click(function(event){
	marcador_disco(0);
 });
 $(".ficha_disco:eq(1)").click(function(event){
	marcador_disco(1);
 });
 $(".ficha_disco:eq(2)").click(function(event){
	marcador_disco(2);
 });
 $(".ficha_disco:eq(3)").click(function(event){
	marcador_disco(3);
 });
 
 $(".ficha_disco").mouseover(function(event){
   $(this).css({'background':'#660000','cursor':'hand'});
 });

 $(".ficha_disco:eq(0)").mouseout(function(event){
 	ficha_out_mouse(0);
 });
 $(".ficha_disco:eq(1)").mouseout(function(event){
 	ficha_out_mouse(1);
 });
 $(".ficha_disco:eq(2)").mouseout(function(event){
 	ficha_out_mouse(2);
 });
 $(".ficha_disco:eq(3)").mouseout(function(event){
 	ficha_out_mouse(3);
 });

 
 // ------------------------------------	
 // control links "ver >"
 
 $('.entrar:eq(0)').click(function(event){
 	falso_click('4');
 });
 $('.entrar:eq(1)').click(function(event){
 	falso_click('5');
 });
 
 function falso_click(n){
		move_perrito(n-1);
		$('#link_pest_0'+n).stop().animate({backgroundPosition:"(0px 150px)"}, {duration:1000})
		bot_sel.push("link_pest_0"+n);
		clean_bots(n);
		del_background('1');
 }
	
	//init menu
	pre_img_youtube();
	bot_sel.push("link_pest_01");
	clean_bots('1');
	marcador_disco(0);
	$('#link_pest_01').stop().animate({backgroundPosition:"(0px 150px)"}, {duration:1000})
	$("a[rel^='prettyPhoto']").prettyPhoto();
	$('#back_ground_01').slideDown(800);
	
	
 // ------------------------------------	
 	
 	/*
 		gestion aparicion logo DAGAROD
 	
 		$('#logo').css({'top': '50px', 'left': '162px'});
	 	
	 	gestion titulos menu parte baja
	 	
		var v_tit = new Array('news','bio','disco','media','contacto');
		var curr_tit = new Array();
		
		function view_tit(n){
			var view_pest = v_tit[n];	
			if(curr_tit.length>0){
				$('#titulo_'+curr_tit[curr_tit.length-1]).hide("slow", function () {
		      $('#titulo_'+view_pest).show("slow"); 
		    });
			}else{
				$('#titulo_'+view_pest).show("slow");
			}
			curr_tit.push(view_pest);
		}
 	*/
 	
});
