function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


var doneLoadingEffects = true;

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();
}

function menu_switchActiveItem(a_new_item,a_items)
{
	position_highlight = '0px -20px';
	position_normal = '0px 0px';
	item_prefix = 'menu_item_';

	for(i=0;i<a_items.length;i++) {
		if (typeof(document.getElementById(item_prefix + a_items[i])) != 'undefined') {
    		document.getElementById(item_prefix + a_items[i]).className = null;
    	}
    }
    
    document.getElementById(item_prefix+a_new_item).className = "active";
    
	return true;
}

function setCheckboxes(a_form, a_varname, a_elements, a_check)
{
	for(i=0;i<a_elements.length;i++) {
		if (typeof(document.forms[a_form].elements[a_varname + a_elements[i]]) != 'undefined') {
    		document.forms[a_form].elements[a_varname + a_elements[i]].checked = a_check;
    	}
    }

    return true;
}

function countChildsOfElement(a_parent)
{
	return document.getElementById(a_parent).childNodes.length;
}

function load() {
	return;
}

function GUnload() {
	return;
}


/**
@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);
}

function appearTableRow(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.Appear(cells[i],opts);
        }
    }
    new Effect.Appear(row,opts);
}

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);
		}
		else
		{
			new Effect.Fade('content',{ duration: 0.5 });
			window.setTimeout('xajax_delete_item(\'' + obj_type + '\',\'' + item_id + '\')',500);
			window.setTimeout('xajax_back_button()',500);
		}
	} 
	
	return check;
}

function confirmDeleteImage(msg,name,css_id,item_id,class_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_image(\'' + item_id + '\',\'' + class_id + '\')',1000);
		}
		else
		{
			new Effect.Fade('content',{ duration: 0.5 });
			window.setTimeout('xajax_delete_image(\'' + item_id + '\',\'' + class_id + '\')',500);
			//window.setTimeout('xajax_back_button()',500);
		}
	} 
	
	return check;
}

    function hideLoadingMessage()
    {
    	xajax.$('loadingMessage').style.display = 'none';
       
		if (doneLoadingEffects==true)
		{
			Element.hide('content');new Effect.Appear('content', { duration: 0.5 });
			window.setTimeout('sorttable.init()',1);
		}
		else
		{
			doneLoadingEffects = true;
		}
    }
    
    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();
	        }
	    }
	}