// Adds return to top link to page.

addLoadEvent (function (){ new ReturnToTop (); });
			  
function ReturnToTop (){
	var content = document.getElementById ("Content");
	
	if (this.CheckOffset ()){
		var anchorname = "pagetop";
		
/*		var bodytemp = document.getElementsByTagName('body');*/
		
		var toplink = document.createElement("div");
		toplink.id = anchorname;
		
		document.body.insertBefore(toplink,document.body.firstChild);
		
		var returnLinkContainer = document.createElement ("div");
		returnLinkContainer.className = "returntotop clearall";
		
		var returnLink = document.createElement ("a");
		returnLink.href = "#"+anchorname;
		
		if (typeof(language) == 'undefined')
		{
		returnLink.innerHTML = "Top";
		}
		else if (language == "spanish")
		{
		returnLink.innerHTML = "Arriba";
		};
		
		
		returnLinkContainer.appendChild (returnLink);
		content.appendChild (returnLinkContainer);
	}

}

ReturnToTop.prototype.CheckOffset = function (){
	if (document.getElementById('Content').offsetHeight > 700) {
		return true;
	}
	return false;
}



/**
 * Helper function to allow multiple functions to execute on page load.
 * http://simon.incutio.com/archive/2004/05/26/addLoadEvent
 */

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}



