function showLoadingImage(){
	var icon = $("LoadingImage");
	if( icon == undefined ){
		icon = document.createElement("img");
		icon.setAttribute("id" , "LoadingImage");
		icon.setAttribute("src", "/images/loading.gif");
		document.body.appendChild( icon );
		
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var top = arrayPageScroll[1] + (arrayPageSize[3] / 2) -16;
		var left = arrayPageScroll[0] + (arrayPageSize[2] / 2) -16;
		icon.style.position = "absolute";
		icon.style.top = top + "px";
		icon.style.left = left + "px";
		icon.style.background = "#ffffff";
		icon.style.border= "1px solid #333333;"
		icon.style.zIndex=3000;
	}
	Element.show( icon );
}

function hideLoadingImage(){
	var icon = $("LoadingImage");
	if( icon == undefined ){
		return;
	}
	Element.hide(icon);
}

Ajax.Responders.register({
	onCreate: function() {
		showLoadingImage();	
	},
	onComplete: function() {
		hideLoadingImage();
	}
});


var LinkTooltip = {
    initTooltip : function(){
    
        this.setTooltipToLinks();
        
        this.tip = document.createElement("div");
        
        this.tip.setAttribute("id","LinkTooltip");
        this.tip.setAttribute("class","LinkTooltip");
        
        this.tip.style.position = "absolute";
        this.tip.style.background = "#ffffff";
        this.tip.style.border= "1px solid #333333";
        document.body.appendChild( this.tip ); 
        this.tip.innerHTML = '<a id="NewWindowLink" target="_blank" href="">Open new window</a>';
        
        
        Element.hide(this.tip);
        
        Event.observe( this.tip , "mouseover", this.clearTimer.bind( this) , false);
        Event.observe( this.tip , "mouseout", this.registerHideTooltip.bind( this) , false);
        
        
    },

    setTooltipToLinks : function(){
        var x = document.links; 
        $A(x).each( function( l , i ){
            Event.observe( l , "mouseover", LinkTooltip.showTooltip.bind(l) , false);
            Event.observe( l , "mouseout", LinkTooltip.registerHideTooltip.bind( LinkTooltip) , false);
        });
            
    },

    showTooltip : function( e ){
        var tip = $("LinkTooltip");
        var link = $("NewWindowLink");

        if( tip == undefined || link == undefined) return;
               
        link.href= this.href;
        tip.style.top  = (Event.pointerY(e) + 5 ) + "px";
        tip.style.left = (Event.pointerX(e) + 5 ) +"px";
        Element.show(tip);
    },
    
    clearTimer : function(){
        if( LinkTooltip.timerID ){
            window.clearTimeout( LinkTooltip.timerID);
            LinkTooltip.timerID = undefined;
        }
    },

    registerHideTooltip : function( e ){
        var tip = $("LinkTooltip");
        
        if( tip == undefined ) return;
        LinkTooltip.timerID = window.setTimeout( LinkTooltip.hideTooltip.bind(LinkTooltip) ,1000);
    },
    
    hideTooltip : function (){
        Element.hide( LinkTooltip.tip);
        LinkTooltip.timerID = undefined;
    }
}

function toggleEntryExtended(entryID, entryLink, htmlObj) {
    extTextDivID = ('Text' + (entryID));
    extLinkDivID = ('Link' + (entryID));
    if( document.getElementById ) {
        if( document.getElementById(extTextDivID).style.display ) {
            if( entryLink != 0 ) {
                document.getElementById(extTextDivID).style.display = "block";
                document.getElementById(extLinkDivID).style.display = "none";
                htmlObj.blur();
            } else { 
                document.getElementById(extTextDivID).style.display = "none";
                document.getElementById(extLinkDivID).style.display = "block";
            }
            return false;
        } else {
            location.href = entryLink;
            return true;
        }
    } else {
        location.href = entryLink;
        return true;
    }
}

Event.observe( window , "load",LinkTooltip.initTooltip.bind(LinkTooltip)  , false);