// funciones comunes

function go2(url,msg)
{
	if(msg==undefined || msg=='')
	{
		window.location.href=url;
	}
	else
	{
		if(confirm(msg))
		{
			window.location.href=url;
		}
	}
}

function ajaxGet(target,url)
{
	new Ajax.Updater(
			target,
			url,
			{
				method: 'get'
				// onSuccess: function(t) { Element.show(target); }
			}
		)
}

function ajaxCarga(target,url)
{
	new Ajax.Request(
			url,
			{
				method: 'get',
				parameters: { iesux: new Date().getTime() },
				onCreate: function() { Element.update(target,'<img src="imagenes/loading.gif" alt="Cargando..." />'); },
				onSuccess: function(t) { Element.setOpacity(target,0.001); Element.update(target,t.responseText); new Effect.Appear(target); },
				onFailure: function() { Element.update(target,''); }
			}
		)
}

function ver(e)
{
	if(!Element.visible(e)) new Effect.Appear(e,{duration:0.5, queue: {position: 'front', scope: 'qfade'} });
}

function verS(e)
{
	if(!Element.visible(e)) new Effect.BlindDown(e,{duration:0.5, queue: {position: 'front', scope: 'qslide'} });
}

function ocul(e)
{
	if(Element.visible(e)) new Effect.Fade(e,{duration:0.25, queue: {position: 'front', scope: 'qfade'} });
}

function oculS(e)
{
	if(Element.visible(e)) new Effect.BlindUp(e,{duration: 0.5, queue: {position: 'end', scope: 'qslide', limit: 1} });
}

function verTog(e,ef)
{
	if(ef == undefined) ef = 'appear';
	new Effect.toggle(e,ef);
}

/*
// esta rehacer pa que sea mas generica (rotar todo dentro de una clase?)
function rotar(id)
{
	var ela = $(id).down('.rotactive');
	var eln;

	if(ela == undefined)
	{
		ela = $(id).down();
		if(ela == undefined) // no hay nada
		{
			return false;
		}
	}
	eln = ela.next();
	if(eln == undefined)
	{
		eln = $(id).down();
	}
	ela.removeClassName('rotactive');
	eln.addClassName('rotactive');
	if(ela != eln)
	{
		new Effect.Fade(ela, {duration: 0.5, afterFinish: function(){
			new Effect.Appear(eln, {duration: 0.5}); } });
	}
}
*/

function dAlert(msg)
{
	// Dialog.alert(msg);
	alert(msg);
	
}

function dConfirm(msg,ops)
{
	// Dialog.confirm(msg,ops);
	confirm(msg,ops);
}


/*
// ejecutar ahora

Ajax.Responders.register({
  onCreate: function() {
	Element.show('loading');
  },
  onComplete: function() {
	Element.hide('loading');
  }
});
*/
