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 target_blank() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	var i, enlace;
	for (i = 0; i < anchors.length; i++) {
		if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") anchors[i].target = "_blank";
	}
}

function reset_form() {
	if (!document.getElementsByTagName) {
		return;
	}

	var los_inputs = document.getElementsByTagName("input");
	var los_textareas = document.getElementsByTagName("textarea");
	var i;
	for (i = 0; i < los_inputs.length; 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 = "";
			};
		}
	}	
	for (i = 0; i < los_textareas.length; i++) {
		los_textareas[i].onfocus = function() {
			if (this.value.charCodeAt(0) == 32 || this.value.charCodeAt(0) == 160 && this.value.length == 1) this.value = "";
		};
	}
}






function abrir_lista_documentos() {
	$("a.abrir_lista_documentos").click(function() {
		$.extend($.blockUI.defaults.displayBoxCSS);
		$.extend($.blockUI.defaults.overlayCSS,     { backgroundColor: '#ffffff', opacity: '0.7', cursor: 'default', padding: '0' });
		$.extend($.blockUI.defaults.pageMessageCSS, { width:'900px', height: '600px', margin:'0 0 0 -450px', padding:'0', top:'7%', left:'50%', textAlign: 'left', color:'#000000', backgroundColor:'#ff0000', border:'1px solid #000000', cursor: 'default' });
		$.get($(this).attr("href") + "?" + new Date().getTime(), { },
		function(data) {
			$.blockUI(data);
 		});
 		return false;
	});
}




$(document).ready(function(){
			$("a[rel^='prettyPhoto']").prettyPhoto({
				animationSpeed: 'normal', /* fast/slow/normal */
				padding: 40, /* padding for each side of the picture */
				opacity: 0.35, /* 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_square', /* light_rounded / dark_rounded / light_square / dark_square */
				callback: function(){}
			});
		});



attachEventListener(window, "load", target_blank, false);
attachEventListener(window, "load", reset_form, false);





/* ELEMENTOS QUE SE CARGAN AL INICIO DE TODAS LAS PÁGINAS */
$(document).ready(function() {
	// Varios
	abrir_lista_documentos();
});

