
//defino las funciones

//funcion openAlert abre una ventana con el mensaje especificado en el parametro y se bloquea la ventana.
function openAlert(mensaje) 
{
	Dialog.alert(mensaje, {destroyOnClose:"true", recenterAuto:"true", width:250, height:150, className: "alphacube",  okLabel:"close", closable:"true", draggable:"true" }) 
} 

//funcion openConfirm dispara un mensaje y ofrece confirmacion, si es OK efectua el evento indicado y bloquea la pantalla
function openConfirm(mensaje, evento) 
{ 
	evento1 = 'E'+ evento +'.' ;
	Dialog.confirm(mensaje, 
		{ onCancel:function FALSE() {return false;}, 
		ok:function OK(){GX_setevent(evento1);self.document.forms[0].submit();}, 
		destroyOnClose:"true", 
		recenterAuto:"true", 
		width:250, 
		height:150, 
		destroyOnClose:"true",  
		className: "alphacube", 
		okLabel: "Yes", 
		cancelLabel:"No"}); 
} 

//funcion opneInfoDialog muestra un mensaje y un relojito y bloquea la pantalla hasta que el procesamiento termina
function openInfoDialog(mensaje) 
{ 
	var vmen = mensaje;
	if (vmen == "") 
	{
		vmen = 'Please Wait ...';
	}
	Dialog.info(vmen, {destroyOnClose:"true",  recenterAuto:"true", width:250, height:150, className:"alphacube", showProgress:"true", zIndex:999}); 
	return true; 
} 

//cierra el bloqueo de pantalla
function closeInfoDialog() 
{ 
	Dialog.closeInfo(); 
} 


//abre una ventana con la URL especificada, si se indica 1 es una ventana del prototype si es 0 es normal
function openUrl(vtipo, vclass, vtitle, vtop, vleft, vwidth, vheight, vurl, vmax, vmin, vdrag, vrecenter) 
{ 
	var x = Math.floor(Math.random()*999); 
	y = x.toString(); 
	if (vmax == "true" || vmin=="true")
	{ 
		resiz = 1; 
	} 
	else 
	{	
		resiz = 0; 
	} 
	var carac = "width=" + vwidth + ",height=" + vheight + ",top=" + vtop + ",left=" + vleft + ",scrollbars=yes,resizable=" + resiz ;
	if (vtipo == 1) 
	{
		var win1 = new Window({top:vtop, 
					left:vleft, 
					className: vclass, 
					title: vtitle, 
					destroyOnClose:"true", 
					recenterAuto:vrecenter, 
					width:vwidth, 
					height:vheight, 
					url: vurl, 
					draggable:vdrag, 
					maximizable:vmax, 
					minimizable:vmin, 
					showEffectOptions: {duration:1.5}});
		win1.show();
	} 
	else 
	{
		var win1 = window.open(vurl, y, carac);
	} 
	if (vrecenter == "true") 
	{ 
		vl = (screen.availWidth - vwidth) / 2; 
		vt = (screen.availHeight - vheight) / 2; 
		win1.moveTo(vl, vt); 
	} 
	win1.resizeTo(vwidth, vheight); 
	win1.focus(); 
} 

function openUrlMax(vurl, vtitle, vclose) 
{ 
	var x = Math.floor(Math.random()*999); 
	y = x.toString(); 
	var widthmax = screen.availWidth - 10;
	if (widthmax < 910)
	{
		widthmax = 920;
	}
	var heightmax = screen.availHeight - 40;
	var carac = "width=" + widthmax + ",height=" + heightmax + ",scrollbars=yes,resizable=no";
	var win1 = window.open(vurl, y, carac);
	//win1.resizeTo(widthmax, heightmax); 
	win1.moveTo(0,0);
	win1.focus(); 
	if (vclose == "true")
	{
		window.open('','_self');
		window.close();
	}
} 
/*OCULTO="none";
VISIBLE="block";*/

//funcion mostrar muestra un DIV que este oculto y un div donde se hace click para ocultar y oculta el div con el link de mostrar
function mostrar(idDiv,idDivTxt) 
{
	veroff="ver_off" + idDivTxt;
	veron="ver_on" + idDivTxt; 
	//document.getElementById(idDiv).style.display=VISIBLE;
	
	$(idDiv).appear({duration: 2, from: 0, to: 1});
	//Effect.toggle(idDiv, 'blind');
	//document.getElementById(veroff).style.display=VISIBLE;
	$(veroff).show();
	//document.getElementById(veron).style.display=OCULTO;
	$(veron).hide();
	//new Draggable('TABLA_CARINFORMATION', { scroll: window });
	return true;
}

//funcion ocultar oculta un DIV que este visible y un div donde se hace click para mostrar y oculta el div con el link de ocultar
function ocultar(idDiv,idDivTxt) 
{
	veroff="ver_off" + idDivTxt;
	veron="ver_on" + idDivTxt; 
	//document.getElementById(idDiv).style.display=OCULTO;
	$(idDiv).fade({duration: 2, from: 1, to: 0});
	//Effect.toggle(idDiv, 'blind'); 	
	//document.getElementById(veroff).style.display=OCULTO;
	$(veroff).hide();
	//document.getElementById(veron).style.display=VISIBLE;
	$(veron).show();
	return true;
}

function hide(idDiv)
{
	if ($(idDiv).visible())
	{
		$(idDiv).fade({duration: 2, from: 1, to: 0});
	}
	return true;
}

function show(idDiv)
{
	if (!$(idDiv).visible())
	{
		$(idDiv).appear({duration: 2, from: 0, to: 1});
	}
	return true;
}
//funcion muestro_oculto muestra un elemento oculto u oculta un elemento visible
function toggle(idDiv) {
/*	if (document.getElementById(idDiv).style.display!=OCULTO) 
	{
		//document.getElementById(idDiv).style.display=OCULTO;
		$(idDiv).fade({duration: 2, from: 1, to: 0});
		
	}
	else
	{
		//document.getElementById(idDiv).style.display=VISIBLE;
		$(idDiv).appear({duration: 2, from: 0, to: 1});
	}*/
	Effect.toggle(idDiv, 'appear');
	return true;
}



//muestra u oculta de aucerdo al estado actual 2 elementos
function toggle2(idDiv1, idDiv2) {
/*	if (document.getElementById(idDiv).style.display!=OCULTO) 
	{
		//document.getElementById(idDiv).style.display=OCULTO;
		$(idDiv).fade({duration: 2, from: 1, to: 0});
		
	}
	else
	{
		//document.getElementById(idDiv).style.display=VISIBLE;
		$(idDiv).appear({duration: 2, from: 0, to: 1});
	}*/
	Effect.toggle(idDiv1, 'appear');
	Effect.toggle(idDiv2, 'appear');
	return true;
}

//updateAjax ejecuta la url indicada y el html resultante lo inserta en el div indicado
//metodo puede ser get o post
//frecuencia es la cantidad de segundos entre cada ejecucion
//decay indica como se va multiplicando el tiempo, si es 1 el tiempo siempre sigue segun frecuencia, si es 2 el tiempo se va duplicando y asi sucesivamente
function updateAjax(idDiv, url, metodo, frecuencia, decay) 
{
	new Ajax.PeriodicalUpdater(idDiv, url, {   method: metodo, frequency: frecuencia, decay: decay }); 
}

function update(idDiv, contenido)
{
	$(idDiv).update(contenido); 

}
