ie = document.all?1:0

function $S(v) { return(document.getElementById(v).style); }

function confirmLink(theLink, theSqlQuery)
{
    var is_confirmed = confirm(theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function

function getidlayer(id) {
        return document.getElementById(id);
}

function showlayer(e) {
        if (e) {
                e.style.display = 'block';
        }
}
function hidelayer(e) {
        if (e) {
                e.style.display = 'none';
        }
}

function CA(nombre,objeto){
	for (var i=0;i<document.frmlistado.elements.length;i++)
	{
		var elemento = document.frmlistado.elements[i];
		if ((elemento.name == nombre) && (elemento.type=='checkbox'))
		{
			elemento.checked = objeto.checked;
			if (objeto.checked)
				hL(elemento);
			else
				dL(elemento);
		}
	}
}

function CCA(CB){
if (CB.checked)
	hL(CB);
else
	dL(CB);
var TB=TO=0;
	for (var i=0;i<document.frmlistado.elements.length;i++)
	{
		var e = document.frmlistado.elements[i];
		if ((e.name !='allbox' ) && (e.type=='checkbox'))
		{
			TB++;
			if (e.checked)
				TO++;
		}
	}
if (TO==TB)
	document.frmlistado.allbox.checked=true;
else
	document.frmlistado.allbox.checked=false;
}

function hL(E){
	if (ie)
	{
		while (E.tagName!="TR")
		{E=E.parentElement;}
	}
	else
	{
		while (E.tagName!="TR")
		{E=E.parentNode;}
	}
}

function dL(E){
	if (ie)
	{
		while (E.tagName!="TR")
			{E=E.parentElement;}
	}
	else
	{
		while (E.tagName!="TR")
		{E=E.parentNode;}
	}
}

var animation_colors = Array("#ffc387", "#ffc891", "#ffcd9c", "#ffd2a6", "#ffd7b0", "#ffddba", "#ffe7cf", "#ffecd9", "#fff1e3", "#fff6ed", "#fffbf7", "transparent");
var colors_max = animation_colors.length - 1;

function fadeOut(filaid,where) {
	var obj=document.getElementById(filaid).style;
	if (where <=colors_max) {
		obj.backgroundColor=animation_colors[where];
		where += 1;
		setTimeout("fadeOut('"+filaid+"',"+where+")", 50);
	}
}
function rowFade(filaid)
{
	fadeOut(filaid,1);
}
function resizeLayer(divid,divwidth,divheight) {
	boxdimensions = document.getElementById (divid);
	boxdimensions.style.width = divwidth+'px';
	boxdimensions.style.height = divheight+'px';
}
function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}
function ChequeaUsuario(o){
  if(/[^0-9A-Z]/.test(o.value)){
    o.value=o.value.toLowerCase().replace(/([^0-9a-z])/g,"");
  }
}
function mostrar_busqueda_avanzada(){
	xajax_ajax_showdialog('busqueda');
}
function mostrar_verificar(id,url){
	xajax_ajax_showdialog('verificar',id,url);
}
function mostrar_mensaje(usuario){
	xajax_ajax_showdialog('mensaje',usuario);
}
function mostrar_fotos(tipo,id){
	xajax_ajax_showdialog('album_'+tipo,id);
}
function enviar_mensaje(){
	xajax_ajax_mensaje(xajax.getFormValues("formulario_mensaje"));
	return false;
}
function borrar_imagen(id,tipo,fichero,from){
	var is_confirmed = confirm("¿Esta seguro de que desea borrar el fichero "+fichero+"?");
	if (is_confirmed) {
		xajax_ajax_borrar_imagen(id,tipo,fichero,from);
	}
	return false;
}
function mostrar_pagina(id,tipo,from,mb){
	xajax_ajax_mostrar_imagenes(id,tipo,from,'',mb);
}
function key_buscar(event){
	if (event.keyCode == 13) {
		gaccion_buscar();
	}
}

function show_flip(layer1,layer2){
	$S(layer1).display='block';
	$S(layer2).display='none';
}
