// JavaScript Document
function precarga() {
	imagenes = document.images;
    cargadas = true;
		for (var i = 0; i < imagenes.length; i ++)
			cargadas = cargadas & imagenes[i].complete;
		if (!cargadas)
			setTimeout("precarga()", 100);
}

precarga();

// Funciones para habilitar y deshabilitar la pÃ¡gina al invitar a un usuario al chat
function getTamPagina() 
{
	/*
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
	*/
	 
	var w = 0;
	var h = 0;
	//IE
	if(!window.innerWidth){
	  //strict mode
	  if(!(document.documentElement.clientWidth == 0)){
		 w = document.documentElement.clientWidth;
		 h = document.documentElement.clientHeight;
	  }
	  //quirks mode
	  else{
		 w = document.body.clientWidth;
		 h = document.body.clientHeight;
	  }
	}
	//w3c
	else{
	  w = window.innerWidth;
	  h = window.innerHeight;
	}
	return [w,h];
}
	
function deshabilitarPagina()
{
	var arrayTamPagina = getTamPagina();
	//alert(arrayTamPagina[0] + 'px | ' + arrayTamPagina[1] + 'px');
	
	var capa = document.getElementById('trans');
	capa.style.width = arrayTamPagina[0] + 'px';
	capa.style.height = arrayTamPagina[1] + 'px';
	capa.style.visibility = 'visible';
}

function habilitarPagina()
{
	var capa = document.getElementById('trans');
	capa.style.width ='50%';
	capa.style.height = '50%';
	capa.style.visibility = 'hidden';
}

// Deshabilitar botÃ³n derecho
//document.oncontextmenu = function(){return false}

/*****************************************************************************
Pop-up ajustada a foto. Script creado por Tunait!
Si quieres usar este script en tu sitio eres libre de hacerlo con la condiciÃƒÂ³n de que permanezcan intactas estas lÃƒÂ­neas, osea, los crÃƒÂ©ditos.
No autorizo a publicar y ofrecer el cÃƒÂ³digo en sitios de script sin previa autorizaciÃƒÂ³n
Si quieres publicarlo, por favor, contacta conmigo.
http://javascript.tunait.com/
tunait@yahoo.com 

Ejemplo de llamada: -- onClick="afoto('fotos/tibidabo.jpg','Catedral del Tibidabo');return false" --
******************************************************************************/

var titulopordefecto = "Imagen"; //Si no se especifica un tÃƒÂ­tulo al llamar a la funciÃƒÂ³n colocarÃƒÂ¡ el que se especifique aquÃƒÂ­
var ventana;
var cont=0;

function afoto(cual,titulo)
{
if(cont==1){ventana.close();ventana=null}
if(titulo==null){titulo=titulopordefecto}
ventana=window.open('','ventana','resizable=yes,scrollbars=no')

ventana.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><img src="' + cual + '" onLoad="opener.redimensionar(this.width, this.height)"></body></html>');

ventana.document.close();
cont++;
}

function redimensionar(ancho, alto)
{
	if (navigator.appName.indexOf("Microsoft") != -1) 
	{
		ventana.resizeTo(ancho+12,alto+30);
		
		ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
	}
	else
	{
		ventana.innerWidth = ancho;  
		ventana.innerHeight = alto;  
		
		ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
	}
}

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

function validar_gcon()
{
	alert(errores[2][0]);
}
