// JavaScript Document

function attachEventListener(target, eventType, functionRef, capture) {
    if (typeof target.addEventListener != "undefined") {
        target.addEventListener(eventType, functionRef, capture);
    } else if (typeof target.attachEvent != "undefined") {
        target.attachEvent("on" + eventType, functionRef);
    } else {
        return false;
    }
    return true;
}

function getElementsByClass(searchClass, node, tag) {
	var classElements = new Array();
	if (node == null) node = document;
	if (tag == null) tag = "*";
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if (pattern.test(els[i].className)) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function target_blank() {
	if (!document.getElementsByTagName) return;
	var i;
	var enlaces = document.getElementsByTagName("a");
	var cuantos = enlaces.length;
	for (i = 0; i < cuantos; i++) {
		if (enlaces[i].getAttribute("href") && enlaces[i].getAttribute("rel") == "external") enlaces[i].target = "_blank";
	}
}


<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->

function reset_form() {
	if (!document.getElementsByTagName) return;
	var i, cuantos;
	var los_inputs = document.getElementsByTagName("input");
	var los_textareas = document.getElementsByTagName("textarea");
	cuantos = los_inputs.length;
	for (i = 0; i < cuantos; i++) {
		if (los_inputs[i].getAttribute("type").toLowerCase() == "text" || los_inputs[i].getAttribute("type").toLowerCase() == "password") {
			los_inputs[i].onfocus = function() {
				if ((this.value.charCodeAt(0) == 32 || this.value.charCodeAt(0) == 160) && this.value.length == 1) this.value = "";
			};
		}
	}
	cuantos = los_textareas.length;
	for (i = 0; i < cuantos; i++) {
		los_textareas[i].onfocus = function() {
			if (this.value.charCodeAt(0) == 32 || this.value.charCodeAt(0) == 160 && this.value.length == 1) this.value = "";
		};
	}
}


function desplegar(){
	var obj = document.getElementById('desplegable');
	document.getElementById('docu').blur();
	if (obj) {
		
		if (obj.style.display == 'block') {
			obj.style.display = 'none';
		} else {
			obj.style.display = 'block';
		}
	}
	
	}
	function desplegar2(){
	var obj = document.getElementById('desplegable2');
	document.getElementById('docu').blur();
	if (obj) {
		
		if (obj.style.display == 'block') {
			obj.style.display = 'none';
		} else {
			obj.style.display = 'block';
		}
	}
	
	}
	
	/*   ESPEC?FICOS DEL SITIO WEB   */
$(document).ready(function(){
	var miMenu = new ADImenu($("ul.ADImenu"));
	miMenu.display();
	
	/*
	$("ul.ADImenu li a").focus(function(event){
		$(this).parent().children("ul").css({"position": "relative", "left": "0"});
	});
	*/
});
	
	
	
	
	
	// http://www.no-margin-for-errors.com/projects/prettyPhoto/
$(document).ready(function(){
	$(".gallery a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 0, /* padding for each side of the picture */
		opacity: 0.65, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
	});
});

attachEventListener(window, "load", target_blank, false);
attachEventListener(window, "load", reset_form, false);
attachEventListener(window, "load", mmn, false);
