/*
 * runOnLoad.js: portable registration for onload event handlers.
 * 
 * This module defines a single runOnLoad() function for portably registering
 * functions that can be safely invoked only when the document is fully loaded
 * and the DOM is available.
 *
 * Functions registered with runOnLoad() will not be passed any arguments when
 * invoked. They will not be invoked as a method of any meaningful object, and
 * the this keyword should not be used.  Functions registered with runOnLoad()
 * will be invoked in the order in which they were registered.  There is no
 * way to deregister a function once it has been passed to runOnLoad().
 *
 * In old browsers that do not support addEventListener() or attachEvent(),
 * this function relies on the DOM Level 0 window.onload property and will not
 * work correctly when used in documents that set the onload attribute
 * of their <body> or <frameset> tags.
 */
function runOnLoad(f) {
    if (runOnLoad.loaded) f();    // If already loaded, just invoke f() now.
    else runOnLoad.funcs.push(f); // Otherwise, store it for later
}

runOnLoad.funcs = []; // The array of functions to call when the document loads
runOnLoad.loaded = false; // The functions have not been run yet.

// Run all registered functions in the order in which they were registered.
// It is safe to call runOnLoad.run() more than once: invocations after the
// first do nothing. It is safe for an initialization function to call
// runOnLoad() to register another function.
runOnLoad.run = function() {
    if (runOnLoad.loaded) return;  // If we've already run, do nothing

    for(var i = 0; i < runOnLoad.funcs.length; i++) {
        try { runOnLoad.funcs[i](); }
        catch(e) { /* An exception in one function shouldn't stop the rest */ }
    }
    
    runOnLoad.loaded = true; // Remember that we've already run once.
    delete runOnLoad.funcs;  // But don't remember the functions themselves.
    delete runOnLoad.run;    // And forget about this function too!
};

// Register runOnLoad.run() as the onload event handler for the window
if (window.addEventListener) window.addEventListener("load", runOnLoad.run, false);
else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
else window.onload = runOnLoad.run;

function viewMenu(id,obj)
{
	var elemento = $(obj);
	var posicion = elemento.position();
	$('#laempresa').css({display: 'block', top: posicion.top+25, left: posicion.left });
	//alert( "left: " + posicion.left + ", top: " + posicion.top );
	//--- ejemplo de web para que no se salga del contenedor principal
	/*
	01  (e.pageX) ? x = e.pageX : x = e.clientX + d.scrollLeft;
	02	(e.pageY) ? y = e.pageY : x = e.clientY + d.scrollTop;
	03	 
	04	//Código añadido
	05	var menuW = menu.width();
	06	var parentRightPosition = $(this).position().left+$(this).width();
	07	if((x+menuW) > parentRightPosition)
	08	{
	09	     x -= menuW;
	10	}
	11	//fin código añadido
	12	// Show the menu
	13	$(document).unbind('click');
	14	$(menu).css({ top: y, left: x }).fadeIn(o.inSpeed);
	*/
	
}
function hideMenu(id)
{
	//$('#'+id).fadeOut(3000);
	$('#'+id).delay(1000).fadeOut(500);
}
function view(ventana){
	ocultartodas();
	document.getElementById(ventana).style.display = "block";	
}
function ocultartodas(){
	document.getElementById('inicio').style.display = "none";
	document.getElementById('laempresa').style.display = "none";
	document.getElementById('filosofia').style.display = "none";
	document.getElementById('quehacemos').style.display = "none";
	document.getElementById('portfolio').style.display = "none";
}
/*
function loadfile(){
	var myWidth = 0, myHeight = 0;
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	document.getElementById('body_mensajes').className = 'mensajeFullscreen';
	document.getElementById('body_mensajes').style.width = "100%";
	document.getElementById('body_mensajes').style.height = "100%";
	document.getElementById('body_mensajes').style.top = "0px";
	document.getElementById('body_mensajes').style.left = "0px";
	
	var DIVwinalertW = document.getElementById('WinAlert').style.width;
	var DIVwinalertH = document.getElementById('WinAlert').style.height;
	var DIVwinalertAnch = DIVwinalertW.split("px");
	var DIVwinalertAlt = DIVwinalertH.split("px");
	DIVwinalertW = (DIVwinalertAnch[0]/2);
	myRWidth = (myWidth/2)-DIVwinalertW;
	DIVwinalertH = (DIVwinalertAlt[0]/2);
	myRHeight = (myHeight/2)-DIVwinalertH;
	document.getElementById('WinAlert').style.marginLeft = myRWidth+"px";
	document.getElementById('WinAlert').style.marginTop = myRHeight+"px";
	document.getElementById('body_mensajes').style.display = 'block';
	document.getElementById('WinAlert').style.display = 'block';
}
*/
