<!--
// 
// Last Edit - 2010-11oct-31sun
// JavaScript by Oscar Cardoso http://www.vryand.com/
// Copyright 2010-2020
// This code is made freely available but please keep this notice.
// I accept no liability for any errors in my coding but please
// let me know of any errors you find. My address is on my home page.
//
var gAs_Rw = 300;
var gAs_Rh = 250;
//
var gAs_Sw = 250;
var gAs_Sh = 250;
//
var gAs_Bw = 468;
var gAs_Bh =  60;
//
var gAs_Lw = 728;
var gAs_Lh =  90;
//
var Aw = 1276; 
var Ah = 796;
//
var MeH = 600; //Minimum H
var MeW = 800; //Minimum W
//
var MeHr = 150;
var MeWr = 100;
MeH = MeH -MeHr;
MeW = MeW -MeWr;

function Dim(id) {
	var e = document.getElementById(id);
	var a = "";
		//a += "W: "+ e.width +"\tH: "+ e.height +"\n";
		//a += "W: "+ e.Width +"\tH: "+ e.Height +"\n";
		//a += "W: "+ e.availWidth +"\tH: "+ e.availHeight +"\n";

		a += "W: "+ e.clientWidth +"\tH: "+ e.clientHeight +"\n";	//IE7, IE6, IE5, FF2, Sa3?, Op9, Fl1, Gt3?
		a += "W: "+ e.offsetWidth +"\tH: "+ e.offsetHeight +"\n";	//IE7, IE6, IE5, FF2, Sa3?, Op9, Fl1, Gt3?
	//alert(a);
}

var t;
var s = Math.round(5*60*1000); //Every 5 minutes
var main = "chat/core/";
function Analizar(){

	var Lcode = '';
	var Bcode = '';
	var Rcode = '';
	var Scode = '';

	//
	var a = "";
	//
	var ColW = 0;
	var RowH = 0;
	//
	var e = document.getElementById('area');
	var eH = e.clientHeight - 1;
	var eW = e.clientWidth - 1;
	//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- //
	//1st Hor priority - Width
	var nS = 0;
	var nR = 0;
	//
	//
if(eH > MeH){
  //if(eW > MeW){
	if(eH < gAs_Rh){ //500
		nS = 0; 
		nR = 0; //No W
	}else{
		nR = Math.round(eH/gAs_Rh);
		eHr= eH-(nR*gAs_Rh);
		nS = Math.round(eHr/gAs_Sh);
	}
	//	a += "S: "+ nS +"\tR: "+ nR +"\n";
	//alert(a);
	if(nR>0){
		ColW = gAs_Rw; //300;
	}else
	if(nS>0){
		ColW = gAs_Sw; //250;
	}
  //}
}
	//alert(ColW);
	var Wr = eW; // - ColW; //Restante
	//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- //
	//2nd Ver priority - Height
	var nB = 0;
	var nL = 0;
	//
	//
//if(eH > MeH){
  if(eW > MeW){
	if(Wr < gAs_Lw){ //468
		nB = Math.round(Wr/gAs_Bw);
		nL = 0; //No H
	}else{
		nL = Math.round(Wr/gAs_Lw);
		eWr= Wr-(nL*gAs_Lw);
		nB = Math.round(eWr/gAs_Bw);
	}
	//	a += "B: "+ nB +"\tL: "+ nL +"\n";
	//alert(a);

	if(nL>0){
		RowH = gAs_Lh;
	}else
	if(nB>0){
		RowH = gAs_Bh;
	}
  }
//}
	//alert(RowH);
	var Hr = eH - RowH; //Restante
	//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- //
	//Render DIVS Dims
	//DinamicDiv(id,      W,      H,        X,      Y, D)
	DinamicDiv('ver',  ColW-0,   eH-0,    0-1,    0+0, ColW);
	DinamicDiv('hor',    Wr-0, RowH-0, ColW+0,    0+0, RowH);
	DinamicDiv('work',   Wr-ColW,   Hr-0, ColW+0, RowH+0, true);
	//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- //
	//Fill Ver
	var Vc = "";
	for(v = 0; v < nR; v++){
		//Vc += CreateDiv(300-0,250-0,'border: 1px dashed #FFFF00;','Rectangle[=]');
		//Vc += CreateDiv(300-0,250-0,'border: 1px dashed #FFFF00;',Rcode);
		var d = new Date();
		var f = v + 1;
		if(f>2){
			f = 0;
		}
		Vc += CreateIFrame('','GoogleAdSense/R'+ f +'.htm?Q='+d.toUTCString()+v,' width="'+ gAs_Rw +'" height="'+ gAs_Rh +'" scrolling="no" ','');
	}
	for(v = 0; v < nS; v++){
		//Vc += CreateDiv(250-0,250-0,'border: 1px dashed #FFFF00;','Squere[]');
		//Vc += CreateDiv(250-0,250-0,'border: 1px dashed #FFFF00;',Scode);
		var d = new Date();
		var f = v + 1;
		if(f>2){
			f = 0;
		}
		Vc += CreateIFrame('','GoogleAdSense/S'+ f +'.htm?Q='+d.toUTCString()+v,' width="'+ gAs_Sw +'" height="'+ gAs_Sh +'" scrolling="no" ','');
	}
	//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- //
	//Fill Hor
	var Hc = "";
	for(h = 0; h < nL; h++){
		//Hc += CreateDiv(728-0,90-0,'border: 1px dashed #FFFF00;float:left;','Leader[_]');
		//Hc += CreateDiv(728-0,90-0,'border: 1px dashed #FFFF00;float:left;',Lcode);
		var d = new Date();
		var f = h + 1;
		if(f>2){
			f = 0;
		}
		Hc += CreateIFrame('','GoogleAdSense/L'+ f +'.htm?Q='+d.toUTCString()+h,' width="'+ gAs_Lw +'" height="'+ gAs_Lh +'" scrolling="no" align="center" ','float:left;');
	}
	for(h = 0; h < nB; h++){
		//Hc += CreateDiv(468-0,60-0,'border: 1px dashed #FFFF00;float:left;','Banner[-]');
		//Hc += CreateDiv(468-0,60-0,'border: 1px dashed #FFFF00;float:left;',Bcode);
		var d = new Date();
		var f = h + 1;
		if(f>2){
			f = 0;
		}
	  //Hc += CreateIFrame('','GoogleAdSense/B'+ f +'.htm?Q='+d.toUTCString()+h,' width="'+ gAs_Bw +'" height="'+ gAs_Bh +'" scrolling="no" align="center" ','');
		Hc += CreateIFrame('','GoogleAdSense/B'+ f +'.htm?Q='+d.toUTCString()+h,' width="'+ gAs_Bw +'" height="'+ gAs_Bh +'" scrolling="no" align="center" ','float:left;');
	}
	Hc += '<DIV style="clear:both;"></DIV>';
	//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- //
	//Render Ver & Hor Dims
	OverWriteContent('ver',Vc);
	OverWriteContent('hor',Hc);
	//OverWriteContent('work','AREA DE TRABAJO');
	//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- //
	//Render WorkArea
	Wr -= ColW;
	if(!mainExiste){
		//alert("NO Existe");
		var M = "";
		var R = Math.round(Hr);
		if(main != null){
/*
			//---- ---- ---- ---- ---- //
			//Add Radio
			D = '/radio.htm';
			Rh = 27;
			R = Math.round(R-Rh);
			M = M+ CreateIFrame('mainIFrameRm',D   ,' width="'+ Wr +'" height="'+ Math.round(Rh) +'" scrolling="no" '   ,'');
			//---- ---- ---- ---- ---- //
			//Add Search Bar
			B = 'http://www.chatsmx.com/buscar.htm';
			Bh = 26;
			R = Math.round(R-Bh);
			M = M+ CreateIFrame('mainIFrameBm',B   ,' width="'+ Wr +'" height="'+ Math.round(Bh) +'" scrolling="no" '   ,'');
*/
			//---- ---- ---- ---- ---- //
			//Add Chat
			M = M+ CreateIFrame('mainIFrame',  main,' width="'+ Wr +'" height="'+ Math.round(R) +'" ','');
			//alert(Hr);
			if(R == NaN){
				M = M+CreateIFrame('mainIFrame',main,' width="'+ Wr +'" height="'+ Math.round(R) +'" ','');
			}
		}else{
			M = CreateIFrame('mainIFrame',"about:blank",' width="'+ Wr +'" height="'+ R +'" ','');
		}
		OverWriteContent('work',M);
		mainExiste = true;
	}else{
		//alert("Existe");
		AjustarMain(Wr,Hr);
	}
	//
	clearTimeout(t);
	t = setTimeout("Analizar()",s);
}

var mainExiste = false;
function AjustarMain(W,H) {
	var i = document.getElementById('mainIFrame');
		i.width  = W;
		i.height = H;
}
function DinamicDiv(id,W,H,X,Y,D) {
	var e = document.getElementById(id);
		e.style.position = 'absolute';
		e.style.left = (X+0) +'px';
		e.style.top  = (Y+0) +'px';
		e.style.width  = (W-0) +'px';
		e.style.height = (H-0) +'px';
		if(D){
			e.style.display = 'block';
		}else{
			e.style.display = 'none';
		}
	//var eH = e.clientHeight;
	//var eW = e.clientWidth;
}
var dinId = 0;
function CreateDiv(id,W,H,xS,iC){
	var r = "";
		dinId++;
		if(id == ""){
			id = "dinDIV_"+ dinId;
		}
		r = "<DIV id='"+ id +"' style='width:"+ W +"px; height:"+ H +"px;"+ xS +"'>"+ iC +"</DIV>";
	return r;
}
function CreateIFrame(id,src,xC,xS){
	var r = "";
		dinId++;
		if(id == ""){
			id = "dinIFrame_"+ dinId;
		}
		r = '<iframe id="'+ id +'" name="'+ id +'" marginwidth="0" marginheight="0" frameborder="0" allowtransparency="yes" hspace="0" vspace="0" '+ xC +' style="'+ xS +'" src="'+ src +'"></iframe>';
	return r;
}
function OverWriteContent(id,nC){
	if(document.getElementById(id)){
		var e = document.getElementById(id).innerHTML = nC;
	}
}
function openInFullScreen(url){
	//alert("Full");
	var fs=window.open(url,
	"FullScreenVideo","toolbar=no,width="+screen.availWidth+",height="+screen.availHeight
	+",status=no,resizable=yes,fullscreen=yes,scrollbars=no");
	fs.focus();
}


if(document.getElementById('area')){
	t = setTimeout("Analizar()",s); //Every 5 minutes
}
//-->
