
/** show **/
function show(id) {
	var d = document.getElementById(id);
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('smenu'+i)) {
				document.getElementById('smenu'+i).style.display='none';
			}
		}
	if (d) {
		d.style.display='block';
	}
}


function gmaps() {
	if(document.getElementById("map")!= null){
		var map = new GMap2(document.getElementById("map"));
		var latlng = new GLatLng(45.496749, -73.569815);
		map.setCenter(latlng, 15);
		map.addOverlay(new GMarker(latlng));
		map.openInfoWindowHtml( latlng , '<strong>Gainey Foundation</strong><br>1260 rue de la Gauchetiere West<br>Montreal, Quebec<br>H3B 5E8');
	}
}

// Adds event to window.onload without overwriting currently 
// assigned onload functions.
function addLoadEvent(func){    
    var oldonload = window.onload;
    if (typeof window.onload != 'function'){
        window.onload = func;
    }else{
        window.onload = function(){
            oldonload();
            func();
        };
    }
}

// Shorten the text length of a <textarea> to fit a fixed limit.
// objName is the id of a <textarea> (or any object who have a value attribute)
// maxLength is the maximum length of the text
// the function returns the number of remaining characters that can be added to the object
function limitTexareaLength(objName, maxLength)
{
    maxLength = parseInt(maxLength, 10);
    var remaining = 0;
    var textarea = document.getElementById(objName);

    if (textarea && maxLength > 0)
    {
        var remaining = maxLength - textarea.value.length;
        if (remaining < 0)
        {
            textarea.value = textarea.value.substr(0, maxLength);
            textarea.scrollTop = textarea.scrollHeight;
            remaining = 0;
        }
    }

    return remaining;
}

addLoadEvent(show);
addLoadEvent(gmaps);
