doneLoadingEffects = 'true';
div_id = '';

function setDivId(a_id)
{
	div_id = a_id;
}

function wopen(url, w, h)
{
        // Fudge factors for window decoration space.
	// In my tests these work well on all platforms & browsers.
        w += 26;
        h += 46;
	var win = window.open(url,
		'popup', 
		'width=' + w + ', height=' + h + ', ' +
		'location=no, menubar=no, ' +
		'status=no, toolbar=no, scrollbars=no, resizable=yes');
	//win.resizeTo(w, h);
	win.focus();
}

btn_close = new Image();
btn_close.src = "images/btn_cierra_form.jpg";
btn_close_over = new Image();
btn_close_over.src = "images/btn_cierra_form_over.jpg";

function btn_out()
{
	document.getElementById('btn_close').src = btn_close.src;
}

function btn_over()
{
	document.getElementById('btn_close').src = btn_close_over.src;
}

function hideLoadingMessage() {

	if (doneLoadingEffects) {
		Element.hide(div_id);
		new Effect.Appear(div_id, { duration: 0.5 });
	}
}
   
function showLoadingMessage() {
	//</xajax.$('loadingMessage').style.display = 'block';
}
   
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			
			func();
		}
	}
}

function loadScripts() {
    xajax.loadingFunction = showLoadingMessage;
    xajax.doneLoadingFunction = hideLoadingMessage;
}

function confirmDelete(msg,name,css_id,obj_type,item_id)
{
	var check=window.confirm(msg + '\n' + name);

	if (check==true)
	{
		if (css_id!=0)
		{
			doneLoadingEffects = false; 
			fadeTableRow(css_id, { duration: 0.5 });
			window.setTimeout('xajax_delete_item(\'' + obj_type + '\',\'' + item_id + '\')',1000);
		}
	} 
	
	return check;
}

/**
@param string rowid the id o fthe row you want to make disappear
@param oject  opts  Effect options such as {duration:3}
*/
function fadeTableRow(rowid,opts){
    if(!opts){
        opts = {};
    }
    var row  = $(rowid);
    var cells= row.childNodes;
    for(i=0;i<cells.length;i++){
        if(cells[i].tagName == 'td'){
            new Effect.Fade(cells[i],opts);
        }
    }
    new Effect.Fade(row,opts);
}