$(document).ready(function(){
	//Cufon
	Cufon.replace('h2');
	Cufon.replace('h3');
	
	//Premios
	
	$('.premio img').animate({"opacity":0.5},1000);
	$(function(){
		$('.premio img').hover(function(){
			$(this).stop().animate({"opacity":1},1000);
		}, function(){
			$(this).stop().animate({"opacity":0.5}, 500);	
		});
	});
	
	//Client Access
	$('.clientLogin').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	//Idiomas
	$('.idioma').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});	
	//Main Nav
	$('.nav a, .navDirectors_sel a, .navScouting a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	$('.nav a, .navDirectors a, .navScouting a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	//Footer - Country, Nav, Rakhas
	$('.country a, .footerNav a, .rakhas a').hover(function() {
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#31312F' }, {queue: false, duration: 300});
	});
	
	$('.tagBlog ul li a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	$('.cronBlog UL.hierarchy LI .mes_hierarchy LI UL.post li a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	$('.pag_bar .btn_ant a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	$('.pag_bar .btn_sgt a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	$('.postSiguiente span a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	$('.postAnterior span a').hover(function() {
		$(this).animate({ color: '#999999' }, {queue: false, duration: 300});
	}, function(){
		$(this).animate({ color: '#5F5F5F' }, {queue: false, duration: 300});
	});
	
	//ScrollFb
	$(function(){
		$('.holderFb').jScrollPane();
	});	
	
	//Grid Cilck
	$("#gridVideos div").click(function()
	{
		//$(".loader").show();
		
		var ajax_load = "loading..."; 
		var project= $(this).attr("id"); 
		
		/*ajax*/
		//loadajaxsend("video",project)
		
	});
	
	
	
	//Close Cilck 
	$(".close").click(function()
	{
		$.address.value(''); 
		$("#gridDetail").animate({opacity: 0.15}, {duration: 500, queue: false});
		$("#player").html("");
		$(".loader").show("fast");
		$("#grid").animate({easing: "swing" }, 600, function(){
			$("html, body").animate({scrollTop:0, easing: "swing"}, 600);
			$("#gridDirector").animate({ left: 0, easing: "swing" }, 600);
			$(".close").fadeTo(800, 1.0, function(){
				$("#player").html("");
				$("#detail").html("Loading...");
				$('#score').html("");
	   		});
			var objDiv = document.getElementById("gridVideos");
			alto = objDiv.scrollHeight;

			$(".videoTitle").fadeTo(800, 0.0);
			$("#myplaylist").fadeTo(800, 0.0);
			
			/*
			$(".navDirectors").fadeTo(500, 1);
			$(".navDirectors").hover(function(){
				$(this).animate({opacity: 1}, {duration: 500, queue: false});
			});*/
			 
			$("#gridVideos").animate({opacity: 0.15}, {duration: 1, queue: false});
			setTimeout('$("#gridVideos").animate({opacity: 1}, {duration: 500, queue: false});',600);
			setTimeout('$("#gridDetail").hide()',700)
			$(".loader").hide("fast");
			
		});
		
		
	});
	
	
	
}); //ready

//Player
	function loadAjax(evt)
	{
		$("#player").html("<img src='"+SERVER_NAME+"images/ajax-loader.gif' class='loaderVid' />");
	};

function loadajaxsend(content_show,id)
 {
	$(".loader").show("fast");
	utl_send_aj = "action="+content_show+"&id="+id;
	loadaJax = true;
	type_met = "POST";
	if(loadaJax)
	{
		cur_url_porc = "action.php";
		
		$.ajax(
			{
				type: type_met,
				cache:false,
				url: SERVER_NAME+"ajax/"+cur_url_porc,
				data: utl_send_aj,
				beforeSend: function()
				{					
					//$(".loader").show("fast");
					switch(content_show)
					{
						case "page":
							$("#gridVideos").animate({opacity: 0.15}, {duration: 500, queue: false});
							break;
						case "video":
							$("#gridVideos").animate({opacity: 0.15}, {duration: 500, queue: false});
							$("#gridDetail").animate({opacity: 0.15}, {duration: 500, queue: false});
							//$("#gridDetail").show();
							break;
						case "pagedet":
							$("#myplaylist").animate({opacity: 0.15}, {duration: 500, queue: false});
							break;
						case "listphoto":
							$("#gridFotos").animate({opacity: 0.15}, {duration: 500, queue: false});
							break;
						default:
							$(".loader").show("fast");
					}
					
				}, //show loading just when link is clicked
				complete: function()
				{ 
					//$("#loading").hide("fast");
					
				}, //stop showing loading when the process is complete ///slow,fast
				success: function(html)
					{ //so, if data is retrieved, store it in html
						
						switch(content_show)
						{
							case "listphoto":
								$("#gridFotos").html(html);
								$(".loader").hide("fast");
								$("#gridFotos").animate({opacity: 1}, {duration: 500, queue: false});
								$("a[rel='popup']").colorbox({transition:"none", width:"75%", height:"75%"});
								break;
							case "pagedet":
								$("#myplaylist").html(html);
								$(".loader").hide("fast");
								$("#myplaylist").animate({opacity: 1}, {duration: 500, queue: false});
								break;
							case "page":
								$("#gridVideos").html(html);
								$(".loader").hide("fast");
								$("#gridVideos").animate({opacity: 1}, {duration: 500, queue: false});
								break;
							case "video":
								var jsonre = eval("(" + html + ")"); 
								
								$("#videoTitle").html(jsonre.title);
								$("#myplaylist").html(jsonre.html);
								//$("#share_attshiajax").html(jsonre.share_attshiajax);
								$("#ishare").attr("src",jsonre.ishare)
								
								$("#inDiv_premios_detalle").html(jsonre.html_det_lis_premios);
								$.address.title(jsonre.title_limp+" | Cine70 Films");
								
								$('.detDirPremios li img').animate({"opacity":0.5},1000);
								$(function(){
									$('.detDirPremios li img').hover(function(){
										$(this).stop().animate({"opacity":1},1000);
									}, function(){
										$(this).stop().animate({"opacity":0.5}, 500);	
									});
								});
								
								if(jsonre.videotype == "mp4")
								{
									setVideoMp4Emb(jsonre.video,"player","0",'');
								}else
								{
									setVideoMovEmb(jsonre.video,"player","0",'');
								}
								
								
								
								$(".loader").hide("fast");
								$("html, body").animate({scrollTop:0, easing: "swing"}, 600);
								$("#gridDirector").animate({ left: -816, easing: "swing" }, 600, 
										function(){
											$("#grid").animate({ easing: "swing" }, 600);
										}
									);
								
								var ajax_load = "loading..."; 
								
								//$(".close").fadeTo(2500, 1.0, loadAjax);
								$(".close").fadeTo(2500, 1.0);
								$(".videoTitle").fadeTo(2500, 1.0);
								$("#myplaylist").fadeTo(500, 1.0);
								
								
								$(".navDirectors_sel").fadeTo(500, 0.3);
								$(".navDirectors_sel").hover(function()
								{
									$(this).animate({opacity: 1}, {duration: 500, queue: false});
									}, function(){
									$(this).animate({opacity: 0.3}, {duration: 500, queue: false});
								}); 
								
								$("#gridDetail").show();
								$("#gridDetail").animate({opacity: 1}, {duration: 500, queue: false});
								
								
								break;
								
							default:
								$("#"+content_show).html(html);
								$(".loader").hide("fast");
						}
						
					},
				timeout: 60000,
				error: function(e, txtstatus)
				{
					//alert('A ocurrido un error: '+txtstatus);
					$(".loader").hide("fast");
				}
	
		}); //close $.ajax(
	}
 }
 
function setVideoMovEmb(url,inDivid,scro,addtiel)
{
	
	if(scro == "1")
	{
		$.scrollTo( '#videoTitle', 800 );
	}
	if(addtiel != "")
	{
		
		a_tie = explode("|",addtiel);
		html_t = '<h2>'+a_tie[0]+' - <span class="slideClient">'+a_tie[1]+'</span></h2><span class="slideDirector">'+a_tie[2]+'</span>';
		$("#videoTitle").html(html_t);
	}
	setTimeout("loadAjax()",500)
	setTimeout('$("#'+inDivid+'").html(printvideomov("'+url+'",640,495,"true"));',3000); 
	Cufon.refresh();
	
	
}

function setVideoMp4Emb(url,inDivid,scro,addtiel)
{
	
	if(scro == "1")
	{
		$.scrollTo( '#videoTitle', 800 );
	}
	if(addtiel != "")
	{
		
		a_tie = explode("|",addtiel);
		html_t = '<h2>'+a_tie[0]+' - <span class="slideClient">'+a_tie[1]+'</span></h2><span class="slideDirector">'+a_tie[2]+'</span>';
		$("#videoTitle").html(html_t);
	}
	setTimeout("loadAjax()",500)
	setTimeout('$("#'+inDivid+'").html(printvideomov_onflash("'+url+'",640,495,"true"));',3000); 
	Cufon.refresh();
	
	
}


function chkInt(str){

	var exp = /^[\+\-]{0,1}[0-9]+$/;

	if (str.search(exp) == -1) return false;
	return true;
}

function loadURLAd(url)
{
	$.address.value(url); 
	return false;
}


