
var url = 'http://www.chateagratis.es/';

function creaAjax(){
var objetoAjax=false;
if (window.XMLHttpRequest) { objetoAjax = new XMLHttpRequest(); }
else if (window.ActiveXObject) { objetoAjax= new ActiveXObject("Microsoft.XMLHTTP"); }
return objetoAjax;
}




function cambiarCheck() {
ClosingVar = false;
}

function iniciarChat() {
//document.getElementById('contedorWebchat').className = 'maximizado';
document.getElementById('webchat').className = 'maximizado';
ClosingVar = true;
var ajax = creaAjax();
var contenedor = document.getElementById('webchat');
var cadenaFormulario = '';
var sepCampos='';
ajax.open("POST", url + 'chat/index.php', true);
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
for (var i=0; i <= document.entrada.elements.length-1;i++) {
cadenaFormulario += sepCampos+document.entrada.elements[i].name+'='+encodeURI(document.entrada.elements[i].value);
sepCampos="&";
}

var h = 0; // height
var w = 0; // width
if( typeof( window.innerHeight ) == 'number' ) {
//no es IE
h = window.innerHeight;
w = window.innerWidth;
} else if( document.body && document.body.clientHeight ) {
//IE 4 o superior
h = document.body.clientHeight;
w = document.body.clientWidth;
}
cadenaFormulario = '&alto=' + h + '&ancho=' + w; 


ajax.onreadystatechange = function() {
if (ajax.readyState==1) { contenedor.innerHTML = "Cargando."; }
if (ajax.readyState==2) { contenedor.innerHTML = "Cargando.."; }
if (ajax.readyState==3) { contenedor.innerHTML = "Cargando..."; }
if (ajax.readyState==4) {contenedor.innerHTML = ajax.responseText;}
}
ajax.send(cadenaFormulario);
}

function iniciarScripts() {
var h = 0; // height
var w = 0; // width
if( typeof( window.innerHeight ) == 'number' ) {
//no es IE
h = window.innerHeight;
w = window.innerWidth;
} else if( document.body && document.body.clientHeight ) {
//IE 4 o superior
h = document.body.clientHeight - 250;
w = document.body.clientWidth;
}

var btnom = document.getElementById("nombre");
if(btnom != null) btnom.focus();

var ifra = document.getElementById('iframeWebchat');
if(ifra != null) {
ifra.width = w - 0.23 * w - 40;
ifra.height = h - 150;
}
}

function pulsar(e) {
  tecla = (document.all) ? e.keyCode :e.which;
  if(tecla == 13) iniciarChat();
  if(tecla == 8) { 
  document.location.href='http://www.chateagratis.es';
  }
  return (tecla!=13 || tecla!= 8);
} 


function agregarFavoritos(url, texto) {
	if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
		window.external.AddFavorite(url, texto);
	} else {
		window.sidebar.addPanel(texto, url, '');   
	}
}

function Recordar() {
if (navigator.appName == "Netscape"){
document.write('<a class="enlaceG" href="#" onclick="agregarFavoritos(\'http://www.chateagratis.es\', \'Chat gratis ChateaGratis.es\');" ><img src="/img/inicio_min.jpg" alt="Chateagratis Página de Inicio" border="0" />Agréganos a tus Favoritos</a><br />');
}
else if (navigator.appName.indexOf("Explorer") != -1) {
	document.write('<a class="enlaceG" href="#" onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.chateagratis.es\');"><img src="/img/inicio_min.jpg" alt="página inicio chateagratis" border="0" />Haz este chat tu página de Inicio</a><br />');
		document.write('<a class="enlaceG" href="#" onclick="window.external.AddFavorite(\'http://www.chateagratis.es\',\'Chat de Chateagratis.es\');"><img src="/img/favoritos_min.jpg" alt="Agregar a Favoritos" border="0" />Agréganos a tus Favoritos</a><br />');
} 
} 
