var Ajax;
if (Ajax && (Ajax != null)) {
	Ajax.Responders.register({
	  onCreate: function() {
        if($('spinner') && Ajax.activeRequestCount>0)
          Effect.Appear('spinner',{duration:0.5,queue:'end'});
	  },
	  onComplete: function() {
        if($('spinner') && Ajax.activeRequestCount==0)
          Effect.Fade('spinner',{duration:0.5,queue:'end'});
	  }
	});
}

// Add an onload event to focus on the query box
// If the page itself has an onload, it will run last.
//addEvent(window,'load',focusOnQuery);

function focusOnQuery() {
    var qElement = document.getElementById('query');

    if(qElement!=null) {    
        qElement.focus();
    }
}


/* Generic function to add an event to the page.
 * Eg for an equivalent to <body onload=""> do:
 *
 *  addEvent(window,'load',yourfunctionname);
 */
function addEvent(obj, evType, fn) 
{
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false); // Firefox
       return true;
    } 
    else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn); // IE
        return r;
    } 
    else {
        return false;
    }
}

/*
 *  Open a link in a new window.  
 *  The target attribute on <a> is not valid in xhtml
 */
function openInNewWindow(obj) {
    var newWindow = window.open(obj.getAttribute('href'), '_new');
    newWindow.focus();
    return false;
}
