// JavaScript Document



//Variables locales

var dire_now;



//flags varios

var cargando = false;



var current_li_vid;



var curr_vid;





function init_home() {

	$().ready(function($){

		swfobject.embedSWF(pelicula, "flash_01", "600", "340", "9.0.0", "wp-content/themes/mundial/swfobject/expressInstall.swf", flashvars, params, attributes);

		swfobject.embedSWF(pelicula2, "flash_02", "960", "356", "9.0.0", "wp-content/themes/mundial/swfobject/expressInstall.swf", flashvars2, params2, attributes2);



		//current_li_vid = $('#ul_videos_links li.links_videos_div').first();

		current_li_vid = $("#ul_videos_links a[href!=#proximamente]").last().parent();

		//current_li_vid = $('#ul_videos_links li.links_videos_div').filter(function() { return $(this).find('a').attr("rel").indexOf('#proximamente') == -1; }).first();

		

		//Reemplazamos los href

		$('#ul_videos_links li.links_videos_div').map(function(){

			//Evento click principal

			$(this).click(function(){

				$(this).unbind('mouseenter mouseleave');

				if($(this).find('a').attr("rel").indexOf("#proximamente") == -1){

					current_li_vid = $(this);

					$('#ul_videos_links li.links_videos_div').map(function(){

						if($(this).find('a').attr("rel").indexOf("#proximamente") == -1){

							$(this).css("background-color","transparent");

							$(this).css("border-color","transparent");

						}

					})

					$(this).css("background-color","#fccb2b");

					$(this).css("border-color","#fccb2b");

					

					curr_vid = $(this).find('a').attr("rel");

					play_vid(curr_vid);

				}

			})

			

			$(this).find('a').attr("rel",$(this).find('a').attr("href"));

			$(this).find('a').attr("href","javascript:void(0);");

			

			if($(this).find('a').attr("rel").indexOf("#proximamente") == -1){

				$(this).css("cursor","pointer");

				$(this).css("background-color","transparent");

				$(this).css("border-color","transparent");

			}else{

				$(this).css("background-color","#ccc");

				$(this).css("border-color","#ccc");

			}

		})

		

		// Default Video

		current_li_vid.css("background-color","#fccb2b");

		current_li_vid.css("border-color","#fccb2b");

		$('#cont_links').jScrollPane({showArrows:true, scrollbarWidth:22, scrollbarMargin:5,arrowSize:20,dragMinHeight:48,dragMinHeight:48});$('#cont_links')[0].scrollTo(1000);

	})

}



function load_init_video(){

	if( $(document).getUrlParam("video_id") != null){

		
		var id = $(document).getUrlParam("video_id");
		curr_vid = $('#ul_videos_links li.links_videos_div').filter(function() { return $(this).find('a').attr("rel").indexOf('#proximamente') == -1; }).eq(id).find('a').attr("rel");
		
		current_li_vid = $('#ul_videos_links li.links_videos_div').filter(function() { return $(this).find('a').attr("rel").indexOf('#proximamente') == -1; }).eq(id);
		
		if(current_li_vid.find('a').attr("rel").indexOf("#proximamente") == -1){

			$('#ul_videos_links li.links_videos_div').map(function(){

				if($(this).find('a').attr("rel").indexOf("#proximamente") == -1){

					$(this).css("background-color","transparent");

					$(this).css("border-color","transparent");

				}

			})
		}

		current_li_vid.css("background-color","#fccb2b");

		current_li_vid.css("border-color","#fccb2b");
		
		play_vid();

	}else{

		//curr_vid = $('#ul_videos_links li.links_videos_div').first().find('a').attr("rel");

		//curr_vid = $('#ul_videos_links li.links_videos_div').filter(function() { return $(this).find('a').attr("rel").indexOf('#proximamente') == -1; }).first().find('a').attr("rel");

		curr_vid = $('#ul_videos_links li.links_videos_div').filter(function() { return $(this).find('a').attr("rel").indexOf('#proximamente') == -1; }).last().find('a').attr("rel");

		play_vid();

	}

}



function play_vid(){

	document.getElementById('video_player').callAS3Play(curr_vid);

}



function video_cargado(){

	cargando = false;

}



function video_instanciado (){

	load_init_video();

}



function exe_video(url){

	current_li_vid = $("#ul_videos_links a[rel='"+url+"']")

	$('#ul_videos_links li.links_videos_div').map(function(){

		if($(this).find('a').attr("rel").indexOf("#proximamente") == -1){

			$(this).css("background-color","transparent");

			$(this).css("border-color","transparent");

		}

	})

	current_li_vid.parent().css("background-color","#fccb2b");

	current_li_vid.parent().css("border-color","#fccb2b");



	curr_vid = url;

	play_vid(curr_vid);

}

init_home();
 
