function viewIMG(imagen, dato) {
	img = "/redim/" + dato + "/" + imagen + "/";
	foto = new Image();
	foto.src = (img);
	
	if (foto.width != 0 && foto.height != 0) {
		ancho = foto.width + 20;
		alto = foto.height + 20;
		cadena = "width=" + ancho + ", height=" + alto;
		ventana = window.open(img, "", cadena);
	}
}

function agregar() { 
	var url = "http://www.horrornroll.com/";
	var title = "Horror 'n' Roll Webzine!";

	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	}
	else if (document.all) { 
		window.external.AddFavorite(url, title); 
	}
	else if (window.opera && window.print) { 
		return true; 
	} 
}

function selectIMG(img) {
	document.getElementById('big').innerHTML = "<img src=\"" + img + "\" alt=\"vista ampliada\"/>";
}

function viewHidde(capa) {
	result = false;
	capa = document.getElementById(capa);

	if (capa) {
		if (capa.style.visibility == "hidden") {
			capa.style.visibility = "visible";
			result = true;
		}
		else {
			capa.style.visibility = "hidden";
			result = false;
		}
		
		return result;
	}
}

function checkall(check, formu) {
	if (check.checked == true) {
		for (i = 0; i < document.forms[formu].elements.length; i++) {
			if (document.forms[formu].elements[i].type == "checkbox") {
				document.forms[formu].elements[i].checked = true;
			}
		}
	}
	else {
		for (i = 0; i < document.forms[formu].elements.length; i++) {
			if (document.forms[formu].elements[i].type == "checkbox") {
				document.forms[formu].elements[i].checked = false;
			}
		}
	}
}

function confirma() {
	return confirm("Realmente deseas realizar la operacion indicada?");
}

function bbcode(tipo, contenedor) {
	switch(tipo) {
		case "b":
		case "i":
		case "u":
			txt = prompt('Introduce el mensaje:','mensaje');
		break;
		
		case "img":
			txt = prompt('Introduce la url de la imagen:','http://');
		break;
		
		case "url":
			txt = prompt('Introduce la url del enlace:','http://');
		break;
		
		case "email":
			txt = prompt('Introduce la direccion email:','usuario@dominio.com');
		break;
		
		case "quote":
			txt = prompt('Introduce el texto a citar:','cita');
		break;
	}
	
	code = "[" + tipo + "]" + txt + "[/" + tipo + "]";
	
	objct = document.getElementById(contenedor);
	objct.value += code;
	objct.focus();
}

function create() { 
	var xmlhttp = false; 
	
	try { 
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch (error1) { 
		try { 
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch (error2) {
			xmlhttp = false;
		}
	}
	
	if ((!xmlhttp) && (typeof XMLHttpRequest != 'undefined')) {
		xmlhttp = new XMLHttpRequest();
	} 

	return xmlhttp; 
}

function carga(tipo, id) {
	capa = document.getElementById(id);
	capa.innerHTML = "<p class=\"verdi\">&nbsp;Cargando los datos solicitados...</b>";
	
	var ajax = create();
	ajax.open("GET", "/datos/" + tipo + "/", true);
	
	ajax.onreadystatechange = function() {
		if (ajax.readyState == 4) {
			capa.innerHTML = ajax.responseText;
		}
	}
	
	ajax.send(null);
	cambiaEstilo(tipo);
}

function cambiaEstilo(tipo) {
	var elementos = getElementsByClassName(document, "li", "sel");
	
	for (x = 0; x< elementos.length; x++) {
		elementos[x].className = null;
	}
	
	var cambia = document.getElementById(tipo);
	cambia.className = "sel";
}
 
function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
	
    for (var i = 0; i < arrElements.length; i++) {
        oElement = arrElements[i];
		
        if (oRegExp.test(oElement.className)) {
            arrReturnElements.push(oElement);
        }   
    }
	
    return (arrReturnElements)
}

function noticiasLayer(ano) {
	nLayer = document.getElementById("nano" + ano);
	cabezera = document.getElementById("nCabezeraAno" + ano);
	
	if (viewHidde("nano" + ano) == true) {
		nLayer.style.height = "auto";
		cabezera.innerHTML = "▼ Noticias del " + ano;
	}
	else {
		nLayer.style.height = "0px";
		cabezera.innerHTML = "► Noticias del " + ano;
	}
}