// disable enter key on forms
document.onkeypress = function stopRKey(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text") || (node.type=="checkbox") || (node.type=="radio") ) {
        return false;
    }
}

// show or hide elements
function showhide(id, status)
{ 
    var style = document.getElementById(id).style 
    if(status) {
        style.visibility = status;
    } else {
        style.visibility = (style.visibility == 'hidden') ? 'visible' : 'hidden';
    }
}

function gotoURL(url) {
    window.location = url;
}

function loadURL(jQueryTargetId,url,params) {
    $(jQueryTargetId).load('/contentloader/'+url,params);
}

function reportMouseOver(me, bool) {
    me.className = (bool) ? 'report_selected' : 'report';
}

function array_remove(theArray, from, to) {
  var rest = theArray.slice((to || from) + 1 || theArray.length);
  theArray.length = from < 0 ? theArray.length + from : from;
  return theArray.push.apply(theArray, rest);
};

/**
 * print_array will convert and array to a readable string
 * var_dump makes use of print_array and create a popup with the data   
 */
function print_array(G,F,I,C){C=C||0;F=F||10;I=I||" ";if(C>F){return"[WARNING: Too much recursion]\n"}var D,A="",H=typeof G,B="";if(G===null){A+="(null)\n"}else{if(H=="object"){C++;for(D=0;D<C;D++){B+=I}if(G&&G.length){H="array"}A+="("+H+") :\n";for(D in G){try{A+=B+"["+D+"] : "+print_array(G[D],F,I,(C+1))}catch(E){return"[ERROR: "+E+"]\n"}}}else{if(H=="string"){if(G==""){G="(empty)"}}A+="("+H+") "+G+"\n"}}return A}
function var_dump(variable) { alert(print_array(variable));}
