/**************************************************************

	2011 Eenda Works
	scripts.js

**************************************************************/


	/*
	Actualizar la web
	en el tiempo definido */
	function redirSearch(web, num){ 
		setTimeout("window.location = '"+web+"'", num);
	} function set_time_redir(web){redirSearch(web, 2000);}
	
	
	
	
	/*
	Añadido de maxlength
	a los áreas de texto */
	window.onload = function(){
		var selects = document.getElementsByTagName("textarea");
		for (var i = 0; i < selects.length; i++) { 
			if(selects[i].getAttribute("maxlength") > 0){
				selects[i].onkeydown = function(){
				if (this.value.length > this.getAttribute("maxlength")) 
					this.value = this.value.substring(0, this.getAttribute("maxlength"));
				}
				selects[i].onblur = function(){
					if (this.value.length > this.getAttribute("maxlength")) 
					this.value = this.value.substring(0, this.getAttribute("maxlength"));
				}
			}
		}
	}
	
	
	
	
	/*
	Selección de clases */
	function getElementsByClassName(clsName) {
		var i, matches=new Array();
		var els=document.getElementsByTagName('*');
	
		for(i=0; i<els.length; i++) {
			if(els.item(i).className==clsName) {
				matches.push(els.item(i));
			}
		}
		return matches;
	}
	
	
	
	
	/*
	Volver a la
	pagina referida */
	function volver(){
		var origen = document.referrer; 
		window.location.href=origen;
	}
	
	
	
	
	/* 
	Función codificación de códigos html con JS */
	function html_entity_decode(string, quote_style){
		var histogram = {}, symbol = '', tmp_str = '', entity = '';
		tmp_str = string.toString();
		
		if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
			return false;
		}
	
		delete(histogram['&']);
		histogram['&'] = '&amp;';
	
		for (symbol in histogram) {
			entity = histogram[symbol];
			tmp_str = tmp_str.split(entity).join(symbol);
		}
		
		return tmp_str;
	}
	
	
	
	
	/*
	AntiSpam script */
	function mail(e){
		document.location = 'mailto:'+e+'@'+'magrit.es';
	}










	/*
	Efectos y 
	compilaciones con Jquery */
	$(document).ready(function(){
		
		/*
		Inicio el Jquery Lightbox
		para el zoom de las imágenes */
		$("a[rel^='zoom']").prettyPhoto({
			show_title: false,
			theme: 'dark_square',
			social_tools: '',
			deeplinking: false,
			default_width: 560,
			wmode: 'opaque'
		});
		
		/*
		Efecto menú secundario */
		$("#menu_secundario").animate({width:'toggle'}, 500, function(){
			$(this).css("background-color", "#ffffff");
		});

		
	});
