// JavaScript Document

function Modal(id, mostrarBotones, onYesClick1, onNoClick1)
{
	var mySideEffect = new Fx.Tween($(id));
	var htmlModal = '<div id="' + id + '" style="width:250px; height:130px; position:absolute;z-index:10000"><table width="250" border="0" cellspacing="0" cellpadding="0">  <tr><td height="28" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="10"><img src="imagenes/mod_title_left.png" width="10" height="28" style="display:block"></td><td width="210px" background="imagenes/mod_title_repeat.jpg" class="tex_barra_blancos"><div id="titulo"></div></td><td width="2"><a id="cerrarModal' + id + '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'999\',\'\',\'imagenes/mod_cerrar2.png\',1);" style="cursor:pointer"><img src="imagenes/mod_cerrar.png" name="Image2" width="31" height="28" border="0" style="display:block"></a></td></tr></table></td></tr><tr><td valign="top" background="imagenes/mod_bg1.png" style="background-repeat:repeat-y; padding-left:10px; padding-top:10px; padding-right:13px;"><table width="100%" border="0"><tr><td class="tex_black_normal"><div id="mensaje' + id + '"></div></td></tr><tr><td align="center"><br /><div id="botonesModal' + id + '"><input name="btnSi" type="button" class="tex_black" id="btnSiModal' + id + '" value="Si" />&nbsp;<input name="btnNoModal' + id + '" type="button" class="tex_black" id="btnNoModal' + id + '" value="No" />&nbsp;</div></td></tr></table></td></tr><tr><td height="15" background="imagenes/mod_down1.png" valign="top" align="center"></td></tr></table></div>';
	
	//document.body.(htmlModal);
	
	if(mostrarBotones)
		document.getElementById(id+"PlaceHolder").innerHTML = htmlModal;
	else
		document.getElementById("placeHolder").innerHTML = htmlModal;
	//document.body.innerHTML = htmlModal;
	
	this.top = 0;
	this.left = 0;
	
	//tipo 0 indica mensaje, 1 indica confirmacion.
	this.tipo = 0;
	
	this.titulo = " ";
	this.mensaje = "mensaje";
	
	this.mostrarBotones = mostrarBotones;
	/*this.onYesClick = onYesClick;
	this.onNoClick = onNoClick;*/

	var _this = this;

	if(onYesClick1 != null)
		document.getElementById('btnSiModal'+id).onclick=onYesClick1;
	else
		document.getElementById('btnSiModal'+id).onclick=function(){_this.Hide();};
		
	if(onNoClick1 != null)
		document.getElementById('btnNoModal'+id).onclick=onNoClick1;	
	else
		document.getElementById('btnNoModal'+id).onclick=function(){_this.Hide();};
	
	document.getElementById('cerrarModal' + id).onclick=function(){_this.Hide();}; 
	
	$(id).setStyle("opacity", "0");
		
	this.Show = function(mensaje)
	{
		this.mensaje = mensaje;
		this.titulo = "";
		
		if(this.mostrarBotones != null)
		{
			if(this.mostrarBotones == true)
				document.getElementById('botonesModal'+id).style.display="block";
			else
				document.getElementById('botonesModal'+id).style.display="none";			
		}
		else
			document.getElementById('botonesModal'+id).style.display="none";			
		
		//Obtiene el punto X(left) y Y(top) en el cual esta ubicada el area de contenido(area de vision)
		//entre el alto total de la pagina.
		var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
			
		//Obtiene el alto del total del area de contenido.
		var clientHeight;
		if (window.innerHeight) {
			clientHeight = ((navigator.appCodeName === 'Safari') ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
		} else {
			clientHeight = document.documentElement.clientHeight;
		}
		
		//Obtiene el ancho del total del area de contenido.
		var clientWidth;
		if (window.innerWidth) {
			clientWidth = ((navigator.appCodeName === 'Safari') ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
		} else {
			clientWidth = document.documentElement.clientWidth;
		}
			
		this.top = obtenerAltoScroll()+((clientHeight-document.getElementById(id).offsetHeight)/2)+'px'
		this.left = obtenerAnchoScroll()+((clientWidth-document.getElementById(id).offsetWidth)/2)+'px';
		
		//document.getElementById("titulo").innerHTML = this.titulo;
		document.getElementById("mensaje"+id).innerHTML = this.mensaje;
		
		$(id).setStyle("top", this.top);
		$(id).setStyle("left", this.left);
		$(id).fade(1);
	};
	
	this.Hide = function()
	{
		$(id).fade(0);	
	};
	
	function obtenerAltoScroll() {
	  var scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	  }
	  return scrOfY;
	};
	
	function obtenerAnchoScroll() {
	  var scrOfX = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant    
		scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfX = document.documentElement.scrollLeft;
	  }
	  return scrOfX;
	};
}

function ModalProgreso(id)
{
	var modalEffect = new Fx.Tween($(id));
	
	$(id).setStyle("opacity", "0");
	
	this.top = 0;
	this.left = 0;
		
	this.Show = function()
	{		
	
		var div = document.createElement('div');
		div.innerHTML = document.getElementById("placeHolder1").innerHTML;

		var children = div.childNodes;
		document.getElementById("placeHolder1").innerHTML = "";
		for(var i=0;i<children.length;i++)
		document.getElementById("placeHolder1").appendChild(children[i]);

		//Obtiene el punto X(left) y Y(top) en el cual esta ubicada el area de contenido(area de vision)
		//entre el alto total de la pagina.
		var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
			
		//Obtiene el alto del total del area de contenido.
		var clientHeight;
		if (window.innerHeight) {
			clientHeight = ((navigator.appCodeName === 'Safari') ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
		} else {
			clientHeight = document.documentElement.clientHeight;
		}
		
		//Obtiene el ancho del total del area de contenido.
		var clientWidth;
		if (window.innerWidth) {
			clientWidth = ((navigator.appCodeName === 'Safari') ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
		} else {
			clientWidth = document.documentElement.clientWidth;
		}
	
		this.top = scrollTop+((clientHeight-document.getElementById(id).offsetHeight)/2)+'px'
		this.left = scrollLeft+((clientWidth-document.getElementById(id).offsetWidth)/2)+'px';
				
		$(id).setStyle("top", this.top);
		$(id).setStyle("left", this.left);
		$(id).fade(1);
		
		if (window.innerHeight && window.scrollMaxY) {// Firefox
			yWithScroll = window.innerHeight + window.scrollMaxY;
			xWithScroll = window.innerWidth + window.scrollMaxX;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			yWithScroll = document.body.scrollHeight;
			xWithScroll = document.body.scrollWidth;
		} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
			yWithScroll = document.body.offsetHeight;
			xWithScroll = document.body.offsetWidth;
		}

		
		$("divTapa1").setStyle("display", "block");
		$("divTapa1").setStyle("height", yWithScroll);
		$("divTapa1").setStyle("width", xWithScroll);
	};
	
	this.Hide = function()
	{
		$(id).fade(0);	
		$("divTapa1").setStyle("display", "none");
	};
	
	function obtenerAltoScroll() {
	  var scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	  }
	  return scrOfY;
	};
	
	function obtenerAnchoScroll() {
	  var scrOfX = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant    
		scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfX = document.documentElement.scrollLeft;
	  }
	  return scrOfX;
	};
}

function ModalEdicion(id)
{
	var modalEffect = new Fx.Tween($(id));
	
	$(id).setStyle("opacity", "0");
	
	this.top = 0;
	this.left = 0;
	
	this.Show = function()
	{		
		$(id).setStyle("display", "block");
		
		//Obtiene el punto X(left) y Y(top) en el cual esta ubicada el area de contenido(area de vision)
		//entre el alto total de la pagina.
		var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
			
		//Obtiene el alto del total del area de contenido.
		var clientHeight;
		if (window.innerHeight) {
			clientHeight = ((navigator.appCodeName === 'Safari') ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
		} else {
			clientHeight = document.documentElement.clientHeight;
		}
		
		//Obtiene el ancho del total del area de contenido.
		var clientWidth;
		if (window.innerWidth) {
			clientWidth = ((navigator.appCodeName === 'Safari') ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
		} else {
			clientWidth = document.documentElement.clientWidth;
		}
				
		this.top = scrollTop+((clientHeight-document.getElementById(id).offsetHeight)/2)+'px'
		this.left = scrollLeft+((clientWidth-document.getElementById(id).offsetWidth)/2)+'px';
		
		$(id).setStyle("top", this.top);
		$(id).setStyle("left", this.left);
		$(id).fade(1);
		
		if (window.innerHeight && window.scrollMaxY) {// Firefox
			yWithScroll = window.innerHeight + window.scrollMaxY;
			xWithScroll = window.innerWidth + window.scrollMaxX;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			yWithScroll = document.body.scrollHeight;
			xWithScroll = document.body.scrollWidth;
		} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
			yWithScroll = document.body.offsetHeight;
			xWithScroll = document.body.offsetWidth;
		}
		
		$("divTapa").setStyle("display", "block");
		$("divTapa").setStyle("height", yWithScroll);
		$("divTapa").setStyle("width", xWithScroll);
	
	};
	
	this.Hide = function()
	{
		$(id).fade(0);	
		$("divTapa").setStyle("display", "none");
	}
}


