//---------------------------------------------------------------------------------
function SetLayerHeight(QueDoc)
{
	var H=QueDoc.documentElement['clientHeight'];
	var W=QueDoc.documentElement['clientWidth'];
	if(H>400)
	{
		QueDoc.all.interno.height=H-281; //(144+116+21);
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=QueDoc.all.interno.height-2}
	}
	else
	{
		QueDoc.all.interno.height=120; 
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=118; }
	}
	
	//SetSubLayerHeight();
	
}

//---------------------------------------------------------------------------------
function SetLayerHeightOFF(QueDoc,Offset)
{
	var H=QueDoc.documentElement['clientHeight'];
	var W=QueDoc.documentElement['clientWidth'];
	if(H>400)
	{
		QueDoc.all.interno.height=H-Offset; //(144+116+21);
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=QueDoc.all.interno.height-2}
	}
	else
	{
		QueDoc.all.interno.height=120; 
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=118; }
	}
	
	//SetSubLayerHeight();
	
}

//---------------------------------------------------------------------------------
function SetScrollHeight(QueDoc,QueScroll)
{
	var H=QueDoc.documentElement['clientHeight'];
	var W=QueDoc.documentElement['clientWidth'];
	if(H>400)
	{
		QueDoc.all[QueScroll].style.height=H-281; //(144+116+21);
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=QueDoc.all.interno.height-2}
		//alert("H<=400");
	}
	else
	{
		QueDoc.all[QueScroll].style.height=120; 
		//alert("H<=400");
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=118; }
	}
	
	//SetSubLayerHeight();
	
}

//---------------------------------------------------------------------------------
function SetScrollHeightOFF(QueDoc,QueScroll,Offset)
{
	var H=QueDoc.documentElement['clientHeight'];
	var W=QueDoc.documentElement['clientWidth'];
	if(H>400)
	{
		QueDoc.all[QueScroll].style.height=H-Offset; //(144+116+21);
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=QueDoc.all.interno.height-2}
		alert("H<=400");
	}
	else
	{
		QueDoc.all[QueScroll].style.height=120; 
		alert("H<=400");
		alert(H);
		
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=118; }
	}
	
	//SetSubLayerHeight();
	
}

//---------------------------------------------------------------------------------
function SetSubLayerHeight(QueDoc,QueLayer)
{
	var H=QueDoc.documentElement['clientHeight'];
	var W=QueDoc.documentElement['clientWidth'];
	
	if (typeof(QueDoc.all[QueLayer])=="undefined") 
	{
		alert("No esta definido el layer");
	}
	else
	{
		//QueDoc.all.Layer1.style.height=H;	
		QueDoc.all[QueLayer].style.height=H;
	}
}


//---------------------------------------------------------------------------------
function SetRowHeight(QueDoc,QueID)
{
	var H=QueDoc.documentElement['clientHeight'];
	var W=QueDoc.documentElement['clientWidth'];
	if(H>400)
	{
		QueDoc.all[QueID].height=H-165; //(144+116+21);
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=QueDoc.all.interno.height-2}
	}
	else
	{
		QueDoc.all[QueID].height=120; 
		//if (QueDoc.all.Layer1.style.height)	{ QueDoc.all.Layer1.style.height=118; }
	}
	
	//SetSubLayerHeight();
	
}

//---------------------------------------------------------------------------------
function CaricaFoto(img)
{
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}

//---------------------------------------------------------------------------------
function Controlla(img)
{
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}

//---------------------------------------------------------------------------------
function viewFoto(img)
{
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
 var midY = (window.screen.availHeight-altez)/2;
 var midX = (window.screen.availWidth-largh)/2;
 var pp="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,"+stringa+",left="+midX.toString() +",top="+midY.toString();
 finestra=window.open(img,"",pp);
}


//---------------------------------------------------------------------------------
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

function ShowHide(lay)
{
	if (ie4) 
	{
		//if(document.all[lay].style.visibility="hidden")
		if(document.all[lay].style.visibility!="visible")
		{
			showlayer(lay);
			//document.all[lay].top="80";
			//document.all[lay].Left=50;
			//writetolayer(lay,"esto es una prueba")
		}
		else	{	hidelayer(lay)	}
			
	}
	if (ns4) 
	{
		if(document.layers[lay].visibility=="hide")
		{
			showlayer(lay);
		}
		else	{	hidelayer(lay)	}
	
	}
	if (ns6) 
	{
		if(document.getElementById([lay]).style.display == "none")
		{
			showlayer(lay);
		}
		else	{	hidelayer(lay)	}
	
	}
}

//---------------------------------------------------------------------------------
function hidelayer(lay)
{
	if (ie4 ) {document.all[lay].style.visibility = "hidden";}
	if (ns4 && document.layers[lay].visibility == "show") {document.layers[lay].visibility = "hide";}
	if (ns6 && document.getElementById([lay]).style.display == "block") {document.getElementById([lay]).style.display = "none";}
}

//---------------------------------------------------------------------------------
function showlayer(lay) 
{
	if (ie4) {document.all[lay].style.visibility = "visible";}
	if (ns4 && document.layers[lay].visibility == "hide") {document.layers[lay].visibility = "show";}
	if (ns6 && document.getElementById([lay]).style.display == "none") {document.getElementById([lay]).style.display = "block";}
}

//---------------------------------------------------------------------------------
function writetolayer(lay,txt) 
{
	if (ie4) 
	{
		document.all[lay].innerHTML = txt;
	}
	if (ns4)
	{
		document[lay].document.write(txt);
		document[lay].document.close();
	}
	if (ns6) 
	{
		over = document.getElementById([lay]);
		range = document.createRange();
		range.setStartBefore(over);
		domfrag = range.createContextualFragment(txt);
		while (over.hasChildNodes()) 
		{
			over.removeChild(over.lastChild);
		}
		over.appendChild(domfrag);
   	}
}


//---------------------------------------------------------------------------------
function SetTableHeight0(QueTabla)
{
	//document.all.Tabla.height="1000";
	//document.all.Tabla.height=document.Height;
	//document.all.Tabla.height=screen.Height;
	//var H=document.documentElement['clientHeight'];
	//var W=document.documentElement['clientWidth'];
	var H=QueTabla.documentElement['clientHeight'];
	var W=QueTabla.documentElement['clientWidth'];
	if(H>400)
	{
		QueTabla.all.interno.height=H-281; //(144+116+21);
	}
	else
	{
		QueTabla.all.interno.height=120;
	}
	//document.all.Tabla.height=H;
	//document.all.Tabla.width=W;
	
	//alert("Ancho="+String(W)+"\n Alto="+String(H));
}

//---------------------------------------------------------------------------------
function SetLayerHeight1(QueDoc,QueLayer)
{
	var H=QueDoc.documentElement['clientHeight'];
	var W=QueDoc.documentElement['clientWidth'];
	//var x=QueDoc.documentElement[QueLayer];
	
	//alert("Ancho="+String(W)+"\n Alto="+String(H));
	if(H>400)
	{
		//QueDoc.all.QueLayer.height=H-281; //(144+116+21);
		//x.height=H-281;
		if(QueLayer=="interno") QueDoc.all.interno.height=H-281; //(144+116+21);
		else if (QueLayer=="Layer1")
		{
			QueDoc.all.Layer1.style.height=H-5; //(144+116+21);
			//alert("Ancho="+String(QueDoc.all.Layer1.width)+"\n Alto="+String(QueDoc.all.Layer1.height));
			alert(String(H));
		}
	}
	else
	{
		//QueDoc.all.QueLayer.height=120;
		//x.height=120;
		if(QueLayer=="interno") QueDoc.all.interno.height=120; 
		else if (QueLayer=="Layer1")
		{
			//QueDoc.all.Layer1.height=120; 
			QueDoc.all.Layer1.style.height=120; 
			alert("menos de 400");
			//document.all.Layer1.style.width
			//alert("Ancho="+String(QueDoc.all.Layer1.width)+"\n Alto="+String(QueDoc.all.Layer1.height));
		}
	}
	//document.all.Tabla.height=H;
	//document.all.Tabla.width=W;
	//alert("Ancho="+String(W)+"\n Alto="+String(H));
	//alert("QueDoc="+String(QueDoc.documentElement['clientWidth']));
	//alert("QueDoc="+String(QueDoc.documentElement[QueLayer]));	
}

//---------------------------------------------------------------------------------

function WindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth+ 'Height = ' + myHeight);
}

//---------------------------------------- FUNCIONES WEBMAIL -----------------------------------------
function WebMail()
{
  //largh=650;
  //altez=290;
  largh=820;
  altez=260;
  //alert("ancho="+largh+"alto="+altez);
  ExtraWindowSize=60;
 //var midY = (window.screen.availHeight-altez-ExtraWindowSize)/2;
 var midY =100;
 var midX = (window.screen.availWidth-largh)/2;
 stringa="width="+largh.toString()+",height="+altez.toString()+",left="+midX.toString() +",top="+midY.toString();
 
 //var pp="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,"+stringa+",left="+midX.toString() +",top="+midY.toString();
 var pp="toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,"+stringa;
 //alert(pp);
 finestra=window.open("webmail.htm","",pp);
}

function DoLogin()
{
//alert(FLogin.user.value);
//alert(FLogin.pass.value);

	if(FLogin.TmpUser.value=="")
	{
		alert("Por Favor, ingrese el nombre de usuario de su cuente 'bajocontrol.com'");
		return;
	}	
	
	if(FLogin.pass.value=="")
	{
		alert("Por Favor, ingrese la contraseņa de acceso a su cuenta: "+FLogin.TmpUser.value+"@bajocontrol.com");
		return;
	}
	
	FLogin.user.value=FLogin.TmpUser.value+"@bajocontrol.com";	
	FLogin.submit();
	window.resizeTo(1024,800);
	window.moveTo((window.screen.availWidth-document.body.clientWidth)/2,50);
}

function LimpiarCampos()
{
	//alert("cargando")
	FLogin.TmpUser.value="";
	FLogin.pass.value="";
	FLogin.TmpUser.focus();
}

//-------------------------------------- FIN FUNCIONES WEBMAIL -----------------------------------------