/*
EKIMONDO scripts
Copyright 2007 Inpix.ca / macharron@inpix.ca
Last edit: 2007-11-23
*/

var gid = function(leid) { return document.getElementById(leid);}
var Y = YAHOO.util;

/*******************************************************************************
    fonction pour simuler un input type="submit" pour les anchors
 ******************************************************************************/
    function formSubmit(lethis)
    {
        if (lethis.nodeName != "FORM")
            formSubmit(lethis.parentNode);
        if (lethis.nodeName == "FORM") // pour ne pas faire les callbacks
            document.getElementById(lethis.id).submit();
    }



window.onload = function() {
	
	// add mouseover, mouseoff and click event on ekistops  //index
	var color = "#cf8400";
	var over_color = "#000";
	var over_bgcolor = "#f5e9c7";
	
	var eki = gid("ekistops");
	if((gid("accueil") || gid("ekistop") || gid("explorateur")) && eki)
	{
		var eki_dl = eki.getElementsByTagName("dl");
		Y.Event.addListener(eki_dl,"mouseover",ekistop_on);
		Y.Event.addListener(eki_dl,"mouseout",ekistop_off);
		Y.Event.addListener(eki_dl,"click",ekistop_link)
	}
	
	// mouseover on ekistops, change background color and link color
	function ekistop_on()
	{
		Y.Dom.setStyle(this, "background", over_bgcolor);
		var h4_link = this.getElementsByTagName("h4")[0].getElementsByTagName("a") [0];
		Y.Dom.setStyle(h4_link, "color", over_color);
		Y.Dom.setStyle(h4_link, "text-decoration", "underline");
	}
	
	// mouseout on ekistops, change background color and link color
	function ekistop_off()
	{
		Y.Dom.setStyle(this, "background", "none");
		var h4_link = this.getElementsByTagName("h4")[0].getElementsByTagName("a") [0];
		Y.Dom.setStyle(h4_link, "color", color);
		Y.Dom.setStyle(h4_link, "text-decoration", "none");
	}
	
	// click on ekistops, add link of the h4
	function ekistop_link() 
	{ 
		var url = this.getElementsByTagName("a")[0];
		window.location = url;
	}
	
	//-----------------------------------------------------------------------
	
	// add mouseover, mouseoff and click event on blog post  //index
	var blog = gid("blogue");
	if(gid("accueil") && blog)
	{
		var blog_div = blog.getElementsByTagName("div");
		Y.Event.addListener(blog_div,"mouseover",blog_on);
		Y.Event.addListener(blog_div,"mouseout",blog_off);
		Y.Event.addListener(blog_div,"click",blog_link)
	}
	
	// mouseover on blog post, change background color and link color
	function blog_on()
	{
		Y.Dom.setStyle(this, "background", over_bgcolor);
		var h4_link = this.getElementsByTagName("h4")[0].getElementsByTagName("a") [0];
		Y.Dom.setStyle(h4_link, "color", over_color);
		Y.Dom.setStyle(h4_link, "text-decoration", "underline");
	}
	
	// mouseout on blog post, change background color and link color
	function blog_off()
	{
		Y.Dom.setStyle(this, "background", "none");
		var h4_link = this.getElementsByTagName("h4")[0].getElementsByTagName("a") [0];
		Y.Dom.setStyle(h4_link, "color", color);
		Y.Dom.setStyle(h4_link, "text-decoration", "none");
	}
	
	// click on blog post, add link of the h4
	function blog_link() 
	{ 
		var url = this.getElementsByTagName("a")[0];
		window.location = url;
	}
		
}
