/*
	abrirHorario()							| Muestra el horario.
	cerrarHorario()							| Cierra el horario.
	buscarPalabrasClave()					| Busca palabras clave en el campo de búsqueda y actua acorde a lo esperado.
	cadenaContieneValores(cadena, valores)	| Devuelve 0 si la cadena no contiene valores
*/
 
 
 //------------------------------------------------------------------------------------------------------------
 //	abrirHorario()							| Muestra el horario.
 function abrirHorario()
 {	
	$("#botonesarreglo").animate({top:"335px"},500,"easeOutBounce");
	$("#botonabrirhorario").toggle();
	$("#botoncerrarhorario").toggle();
	$("#horario").stop().animate({height:"130px"},500,"easeOutBounce", function() 
	{
		$("#contenidohorario").fadeIn();
		$("#horariocentral").fadeIn(200,function()
		{	$("#horariotiendas").fadeIn(200,function()
			{	$("#horariocentral h1").fadeIn(200,function()
				{	$("#horariocentral table").fadeIn(200,function()
					{	$("#horariotiendas h1").fadeIn(200,function()
						{ 	$("#horariotiendas table").fadeIn(200,function() 
							{	$("#contenidohorario img").fadeIn(200);
							});
						});
					});
				});
			});
		});
	});
};

 //------------------------------------------------------------------------------------------------------------
//	cerrarHorario()							| Cierra el horario.
function cerrarHorario()
{
	$("#contenidohorario img").fadeOut(100);
	$("#horariotiendas table").fadeOut(100,function()
	{	$("#horariotiendas h1").fadeOut(100,function()
		{	$("#horariocentral table").fadeOut(100,function()
			{	$("#horariocentral h1").fadeOut(100,function()
				{	$("#horariotiendas").fadeOut(100,function() 
					{ 	$("#horariocentral").fadeOut(100,function() 
						{	
							$("#contenidohorario").hide(0,
							function() 
							{	$("#horario").stop().animate({height:"0px"},400,"linear");
								$("#botonabrirhorario").toggle();
								$("#botoncerrarhorario").toggle();
								$("#botonesarreglo").animate({top:"205px"},400,"linear");
							});
						});
					});
				});
			});
		});
	});
}


 //------------------------------------------------------------------------------------------------------------
//	buscarPalabrasClave()					| Busca palabras clave en el campo de búsqueda y actua acorde a lo esperado.
function buscarPalabrasClave()
{
	var sstop = false;
	if (cadenaContieneValores($("input[name='texto_busqueda']").val().toUpperCase(), ["HORARI", "SCHEDULE", "ZEITPLAN","HORARIO","HORARIO DE APERTURA","HORARI D'APERTURA", "HORAS", "CALENDARIO"]))
	{
		if (!sstop)
		{
			abrirHorario();
			sstop = true;
		}
		$('body').animate({scrollTop : 0},'slow');
		$('html').animate({scrollTop : 0},'slow');
		return false;
	}
	else
	{
		showhide('loading');
		return true;
	}
}


 //------------------------------------------------------------------------------------------------------------
//	cadenaContieneValores(cadena, valores)	| Devuelve 0 si la cadena no contiene valores
function cadenaContieneValores(cadena, valores)
{
	for (i = 0; i < valores.length; i++)
	{
		if (cadena == valores[i])
		{
			return true;
		}
	}
	return false;
}


 // Show Hide del registro loading
     
	
        function showhide(layer_ref) 
        {  
		if($("#"+layer_ref).is(":visible")) {		
			$("#" + layer_ref).hide(500);
		}
		else {
			$("#" + layer_ref).show(200);
		}
	
	 } 
	
       
     function testPassword(idComprueva, idTarget)
	{
			var passwd=document.getElementById(idComprueva).value
			var intScore   = 0
			var strVerdict = "weak"
			var strLog     = ""
			
			if (passwd.length<5)  {intScore = (intScore+3)		}
			else if (passwd.length>5 && passwd.length<8) 	{intScore = (intScore+6)	}
			else if (passwd.length>8 && passwd.length<16)	{intScore = (intScore+12)	}
			else if (passwd.length>9) {	intScore = (intScore+18)}
			if (passwd.match(/[a-z]/))	{intScore = (intScore+1)	}			
			if (passwd.match(/[A-Z]/))	{intScore = (intScore+8)}			
			if (passwd.match(/\d+/))	{	intScore = (intScore+5)	}			
			if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)) 	{	intScore = (intScore+9)		}
			if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))	{	intScore = (intScore+9)		}										
			if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))	{	intScore = (intScore+9)			}			
			if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))		{	intScore = (intScore+4)		}
			if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) 	{	intScore = (intScore+5)			}										
			if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))			{	intScore = (intScore+5)			}
			if(intScore < 16)			{			                        strVerdict = "Fortaleza: <span class='fortaleza_1'>Muy débil</span>"			}
			else if (intScore > 15 && intScore < 25)			{			   strVerdict = "Fortaleza: <span class='fortaleza_2'>Débil</span>"			}
			else if (intScore > 24 && intScore < 35)			{			   strVerdict = "Fortaleza: <span class='fortaleza_3'>Mediocre</span>"			}
			else if (intScore > 34 && intScore < 45)			{			   strVerdict = "Fortaleza: <span class='fortaleza_4'>Fuerte</span>"			}
			else	{                                                   strVerdict = "Fortaleza: <span class='fortaleza_5'>Muy fuerte</span>"		}
			var objetoSPAN = document.getElementById(idTarget);
			objetoSPAN.innerHTML = strVerdict
			//document.getElementById("fortalezaPass").value=strVerdict
			//return strVerdict
}


//------------------------------------------------------------
// A EJECUTAR CUANDO LA PAGINA ESTE CARGADA:

$(document).ready(function()
{
	// Abrir y cerrar el panel superior de horario 
	$("#botonabrirhorario").click(function(){abrirHorario()});	
	$("#botoncerrarhorario").click(function(){cerrarHorario()});
	
	$('img.captify').captify({
		// all of these options are... optional
		// ---
		// speed of the mouseover effect
		speedOver: 'fast',
		// speed of the mouseout effect
		speedOut: 'normal',
		// how long to delay the hiding of the caption after mouseout (ms)
		hideDelay: 500,	
		// 'fade', 'slide', 'always-on'
		animation: 'slide',		
		// text/html to be placed at the beginning of every caption
		prefix: '',		
		// opacity of the caption on mouse over
		opacity: '0.7',					
		// the name of the CSS class to apply to the caption box
		className: 'caption-bottom',	
		// position of the caption (top or bottom)
		position: 'bottom',
		// caption span % of the image
		spanWidth: '100%'
	});
	
}














);


