//Boton
function creaboton(texto, resul){
 this.texto = texto;
 this.resul = resul;
}

function defineboton (num, texto, resul){
 switch (num)
	{
	case 1:
		this.boton1.texto = texto;
		this.boton1.resul = resul;
		break;
	case 2:
		this.boton2.texto = texto;
		this.boton2.resul = resul;
		break;
	case 3:
		this.boton3.texto = texto;
		this.boton3.resul = resul;
		break;
	}
}

function definenombre (texto){
 this.nombre=texto;
}

function definetitular (texto){
 this.titular=texto;
}

function definedescripcion (texto){
 this.descripcion=texto;
}

function definefondo (texto){
 this.imgfondo=texto;
}

function defineicono (texto){
 this.imgicono=texto;
}

function definelogo (texto){
 this.imglogo=texto;
}

function UserAlerta(){
//PROPIEDADES
	//Literales
	this.nombre = "";
	this.titular = "";
	this.descripcion = "";
	//Imagenes
	this.imgfondo = "/asp/avisos/img/fondobig.jpg";
	this.imgicono = "/asp/avisos/img/icono_info.gif";
	this.imglogo = "";
	//variables
	this.resultado = "";
	
//MÉTODOS	
	this.creaboton = creaboton;
	this.defineboton = defineboton;
	this.definenombre = definenombre;
	this.definetitular = definetitular;
	this.definedescripcion = definedescripcion;
	this.definefondo = definefondo;
	this.defineicono = defineicono;
	this.definelogo = definelogo;
	this.mostrar = mostrar;
	this.ocultar = ocultar;
	this.refrescar = refrescar;
	this.scroller = scroller;
	
//BOTONES
	this.boton1 = new creaboton("","");
	this.boton2 = new creaboton("","");
	this.boton3 = new creaboton("","");

	this.htmalert = "<div id=\"ventusuario\" style=\"position:absolute;top:0;left:0;width:100%;height:100%;display: block; visibility:hidden;z-index:10;\">";
	this.htmalert += "<table width=100% height=100% border=0 cellpadding=0 cellspacing=0 background=\"/asp/avisos/img/grey.gif\"><tr><td align=\"center\" valign=\"middle\">";
	
	this.htmalert += "<div style=\"width:350;height:160;display: block; visibility:inherit\">";

	//DEFINICIÓN DE LA IMAGEN DE CABECERA
	this.htmalert += "<table width=340 border=0 cellpadding=0 cellspacing=0 id=\"al_cabecera\">";
	this.htmalert += "	<td width=340 height=21 background=\"/asp/avisos/img/boton.gif\" class=\"txtsmallboldblue\" align=\"center\" id=\"al_txtcab\"></td>";	
	this.htmalert += "</table>"
	this.htmalert += "<table width=340 border=0 cellpadding=0 cellspacing=0 id=\"al_linea\">";
	this.htmalert += "	<tr><td width=340 height=1 bgcolor=\"#FFCC00\"></td></tr>";	
	this.htmalert += "</table>"
	
	this.htmalert += "<table width=340 border=0 cellpadding=0 cellspacing=0>";
	this.htmalert += "	<tr><td>";
	//EMPIEZA LA TABLA: DEFINICIÓN DEL FONDO
	this.htmalert += "<table id=\"al_imgfondo\" width=340 border=0 cellpadding=0 cellspacing=0>";
	this.htmalert += "	<tr>";
	this.htmalert += "		<td>";
	this.htmalert += "			<table width=340 height=150 border=0 cellpadding=0 cellspacing=0>";
	this.htmalert += "				<tr>";
	this.htmalert += "					<td height=5 bgcolor=\"#FFCC00\"></td>";
	this.htmalert += "					<td colspan=3 width=330 height=5></td>";
	this.htmalert += "					<td width=1 height=5 bgcolor=\"#FFCC00\"></td>";
	this.htmalert += "				</tr>";
	this.htmalert += "				<tr>";
	this.htmalert += "					<td width=1 bgcolor=\"#FFCC00\"></td>";
	this.htmalert += "					<td width=10></td><td width=318>";
	this.htmalert += "					";
	this.htmalert += "						<table width=318 height=150 border=0 cellpadding=0 cellspacing=0>";
	//ICONO y TITULAR
	this.htmalert += "							<tr><td width=40 height=40 class=\"txtsmallboldblue\" align=\"center\" valign=\"middle\"><span id=\"al_imgicono\"></span></td>";
	this.htmalert += "							<td width=4 height=40></td>";
	this.htmalert += "							<td width=250 height=40 align=\"left\" valign=\"center\" class=\"txtsmallboldblack\"><span id=\"al_titular\"></span></td></tr>";
	//DESCIPCION
	this.htmalert += "							<tr><td colspan=\"3\" height=\"5\"></td></tr>"; //separador
	this.htmalert += "							<tr><td colspan=\"3\" align=\"left\" valign=\"top\" class=\"txtsmallblack\"><span id=\"al_descripcion\"></span></td></tr>";
	this.htmalert += "							<tr><td colspan=\"3\" height=\"5\"></td></tr>"; //separador
	this.htmalert += "							<tr><td colspan=\"3\" height=\"20\">";
	//BOTONES
	this.htmalert += "								<table width=318 border=0 cellpadding=0 cellspacing=0><tr>";
	this.htmalert += "									<td align=\"center\" id=\"tdboton1\"></td>";
	this.htmalert += "									<td align=\"center\" id=\"tdboton2\"></td>";
	this.htmalert += "									<td align=\"center\" id=\"tdboton3\"></td>";
	//IMAGEN LOGO INFERIOR
//	this.htmalert += "									<td align=\"right\" width=121><span id=\"al_imglogo\"></span></td>";
	this.htmalert += "									</tr>";
	this.htmalert += "								</table>";
	this.htmalert += "	";
	this.htmalert += "							</td></tr>";
	this.htmalert += "						</table>";
	this.htmalert += "	";
	this.htmalert += "					</td>";
	this.htmalert += "					<td width=10></td>";
	this.htmalert += "					<td width=1 bgcolor=\"#FFCC00\"></td>";
	this.htmalert += "				</tr>";
	this.htmalert += "			</table>";
	this.htmalert += "		</td>";
	this.htmalert += "	</tr>";
	this.htmalert += "	<tr>";
	this.htmalert += "		<td>";
	this.htmalert += "			<table width=340 height=5 border=0 cellpadding=0 cellspacing=0>";
	this.htmalert += "				<tr>";
	this.htmalert += "					<td width=1 height=5 bgcolor=\"#FFCC00\" rowspan=2></td><td width=334 height=4></td>";
	this.htmalert += "					<td align=\"right\" valign=\"bottom\" rowspan=2><img src=\"/asp/avisos/img/cierre.gif\" width=5 height=5></td>";
	this.htmalert += "				</tr>";
	this.htmalert += "				<tr>";
	this.htmalert += "					<td width=334 height=1 bgcolor=\"#FFCC00\"></td>";
	this.htmalert += "				</tr>";
	this.htmalert += "			</table>";
	this.htmalert += "		</td>";
	this.htmalert += "	</tr>";
	this.htmalert += "</table>";
	this.htmalert += "";
	this.htmalert += "</td></tr></table>";
	this.htmalert += "</div>";
	
this.htmalert += "</td></tr></table>";
this.htmalert += "</div>";
document.write (this.htmalert);	
}

function mostrar(){
	scroller();
	document.getElementById("ventusuario").style.visibility = "visible";

	// Ocultamos los select por los problemas del render del IE
	var oSEL = document.getElementsByTagName("select");
	for (oS = 0; oS < oSEL.length; oS++ ) {
		oSEL[oS].style.display="none";
	}; 
}

function ocultar(){
	// Mostramos los select por los problemas del render del IE
	var oSEL = document.getElementsByTagName("select");
	for (oS = 0; oS < oSEL.length; oS++ ) {
		oSEL[oS].style.display="inline";
	}; 

	document.getElementById("ventusuario").style.visibility = "hidden";
}

function scroller()
{
var ie=document.all && !window.opera;
var dom=document.getElementById;
iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
objref=(dom)? document.getElementById("ventusuario") : document.all.ventusuario;
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset;
docheight=(ie)? iebody.clientHeight: window.innerHeight;
objheight=objref.offsetHeight;
objref.style.top=scroll_top+"px";
setTimeout("scroller()", 200);
}
function refrescar (){
 
 var contenido="";
 
 if (this.boton1.texto != "")
 	{
 	contenido =  "<table border=0 border=0 cellpadding=0 cellspacing=0 bgcolor=\"#f4ae20\" height=20 style=\"cursor:pointer;\" onclick=\"ocultar(); " + this.boton1.resul + "\">";
 	contenido += "<tr><td colspan=3 bgcolor=\"#f4ae20\" height=1></td></tr>";
 	contenido += "<tr><td width=1 bgcolor=\"#f4ae20\"></td><td class=\"txtsmallblue\" align=\"center\" bgcolor=\"#FFFFFF\">&nbsp;" + this.boton1.texto + "&nbsp;</td><td width=1 bgcolor=\"#f4ae20\"></td></tr>";
 	contenido += "<tr><td colspan=3 bgcolor=\"#f4ae20\" height=1></td></tr></table>";
 	}
 document.getElementById('tdboton1').innerHTML= contenido;
 contenido="";

 if (this.boton2.texto != "")
 	{
 	contenido =  "<table border=0 border=0 cellpadding=0 cellspacing=0 bgcolor=\"#f4ae20\" height=20 style=\"cursor:pointer;\" onclick=\"ocultar(); " + this.boton2.resul + "\">";
 	contenido += "<tr><td colspan=3 bgcolor=\"#f4ae20\" height=1></td></tr>";
 	contenido += "<tr><td width=1 bgcolor=\"#f4ae20\"></td><td class=\"txtsmallblue\" align=\"center\" bgcolor=\"#FFFFFF\">&nbsp;" + this.boton2.texto + "&nbsp;</td><td width=1 bgcolor=\"#f4ae20\"></td></tr>";
 	contenido += "<tr><td colspan=3 bgcolor=\"#f4ae20\" height=1></td></tr></table>";
 	}
 document.getElementById('tdboton2').innerHTML= contenido;
 contenido="";

 if (this.boton3.texto != "")
 	{
 	contenido =  "<table border=0 border=0 cellpadding=0 cellspacing=0 bgcolor=\"#f4ae20\" height=20 style=\"cursor:pointer;\" onclick=\"ocultar(); " + this.boton3.resul + "\">";
 	contenido += "<tr><td colspan=3 bgcolor=\"#f4ae20\" height=1></td></tr>";
 	contenido += "<tr><td width=1 bgcolor=\"#f4ae20\"></td><td class=\"txtsmallblue\" align=\"center\" bgcolor=\"#FFFFFF\">&nbsp;" + this.boton3.texto + "&nbsp;</td><td width=1 bgcolor=\"#f4ae20\"></td></tr>";
 	contenido += "<tr><td colspan=3 bgcolor=\"#f4ae20\" height=1></td></tr></table>";
 	}
 document.getElementById('tdboton3').innerHTML= contenido;
 contenido="";

//Si se ha definido nombre se pone la cabecera, si no se deja una linea naranja
	if (this.nombre != "") {
		document.getElementById('al_txtcab').innerHTML= this.nombre		;
		document.getElementById('al_linea').style.display="none";
	}else document.getElementById('al_cabecera').style.display="none";
 
 document.getElementById('al_titular').innerHTML= this.titular;
 document.getElementById('al_descripcion').innerHTML= this.descripcion;
 
 //document.getElementById('al_imglogo').innerHTML= "<img src=\"" + this.imglogo +"\">";
 //document.getElementById('al_imgfondo').style.background = "url("+ this.imgfondo+")";
 document.getElementById('al_imgfondo').style.background = "#FFFFFF";
 document.getElementById('al_imgicono').innerHTML= "<img src=\"" + this.imgicono +"\">";
 
}