function init() {
	// quit if this function has already been called
	if (arguments.callee.done) return;
	
	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;
	
	// create the "page loaded" message
	if(document.getElementById("NoScript"))
		document.getElementById("NoScript").style.display = "none";
	
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
};

/* for Mozilla */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
   document.write("<script defer src=/squelettes/blocs/js/ie_onload.js><"+"/script>");
/*@end @*/

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number')
		windowHeight = window.innerHeight;
	else
		if (document.documentElement && document.documentElement.clientHeight)
			windowHeight = document.documentElement.clientHeight;
		else
			if (document.body && document.body.clientHeight)
				windowHeight = document.body.clientHeight;
	
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number')
		windowWidth = window.innerWidth;
	else
		if (document.documentElement && document.documentElement.clientWidth)
			windowWidth = document.documentElement.clientWidth;
		else
			if (document.body && document.body.clientWidth)
				windowWidth = document.body.clientWidth;
	
	return windowWidth;
}
function getDocumentHeight() {
	var documentHeight = 0;
	
	if(document.getElementById('ContentMapSite'))
		var contentHeight = document.getElementById('ContentMapSite').offsetHeight + findPosY(document.getElementById('ContentMapSite'));
	else
		var contentHeight = document.getElementById('Content').offsetHeight + findPosY(document.getElementById('Content'));

	if(document.getElementById('ContentTools'))
		var ContentToolsHeight = document.getElementById('ContentTools').offsetHeight + findPosY(document.getElementById('ContentTools'));
	else
		var ContentToolsHeight = "";
	
	if(contentHeight > ContentToolsHeight)
		documentHeight = contentHeight;
	else
		documentHeight = ContentToolsHeight;
	
	return documentHeight;
}


function addLoadEvent(func) { // Manage Load Event
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function addResizeEvent(func) { // Manage Resize Event
    var oldonresize = window.onresize;
    if (typeof window.onresize != 'function') {
        window.onresize = func;
    } else {
        window.onresize = function() {
            oldonresize();
            func();
        }
    }
}

var Home;
var HP;
function setNoBodyScroll() { // Control body scroll
	if(Home == true) {
		document.getElementsByTagName('html')[0].style.overflowX = "hidden";
		var windowHeight = getWindowHeight();
		var contentHeight = document.getElementById('Content').offsetHeight + document.getElementById('Content').offsetTop;
		if(contentHeight <= windowHeight)
			document.getElementsByTagName('html')[0].style.overflowY = "hidden";
		else
			document.getElementsByTagName('html')[0].style.overflowY = "scroll";
	}
}

function insertHtmlAfter(element, html) { // Insert html element
	if (document.all) {
		element.insertAdjacentHTML("afterEnd", html);
	} else {
		var r = document.createRange();
		r.setStartBefore(element);

		var parsedNode = r.createContextualFragment(html);
		var parent = element.parentNode;
		if (element.nextSibling)
			parent.insertBefore(parsedNode, element.nextSibling);
		else
			parent.appendChild(parsedNode);
	}
}

function removeHtml(element) { // Remove html element
	if (document.all)
		element.outerHTML = '';
	else
		element.parentNode.removeChild(element);
}



var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all



function CheckResolution() {
	if(screen.width <= 800)
		alert('Es necesaria una resolución de 1024*768 para consultar la web');
	
	if(document.getElementById("NoScript"))
		document.getElementById('NoScript').style.display = 'none';
}

function findPosY(obj) {
	var posTop = 0;
	while (obj.offsetParent) {
		posTop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return posTop;
}
function findPosX(obj) {
	var posLeft = 0;
	while (obj.offsetParent) {
		posLeft += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return posLeft;
}


old = "programme1";


addResizeEvent(setNoBodyScroll);
