/* ########################################################################### *
/* ***** DOCUMENT INFO  ****************************************************** *
/* ########################################################################### *
 * ##### NAME:  global.js
/* ########################################################################### *

/* ########################################################################### *
/* ***** INDEX *************************************************************** *
/* ########################################################################### *
/* ##### Global JS configuration
/* ##### Initialisation
/* ##### Article Slider
/* ##### Media player
/* ##### Jquery & other utilities
/* ########################################################################### */

/* ########################################################################### *
/* ##### GLOBAL JS CONFIGURATION
/* ########################################################################### */

/* ########################################################################### *
/* ##### INITIALISATION
/* ########################################################################### */

$(document).ready(ecl_init_global);

function ecl_init_global()
{
	ecl_init_dropDownNav();	
}


/* ########################################################################### *
/* ##### Navigation (Superfish)
/* ########################################################################### */

function ecl_init_dropDownNav()
{
	//if ($("#nav_primary").length > 0) 
	//{
		$("ul.nav_primary")
		.superfish()
		.find(">li:has(ul)")
			.mouseover(function(){
				$("ul", this).bgIframe({opacity:false});
			})
			.find("a")
				.focus(function(){
					$("ul", $("ul.nav_primary>li:has(ul)")).bgIframe({opacity:false});
				});
	//}
}


/* ########################################################################### *
/* ##### JQUERY & OTHER UTILITIES
/* ########################################################################### */

// Supply a query string and parse it into a key value pairs

jQuery.query = function(s) 
{
		var r = {};
		if (s) {
				var q = s.substring(s.indexOf('?') + 1); // remove everything up to the ?
				q = q.replace(/\&$/, ''); // remove the trailing &
				jQuery.each(q.split('&'), function() {
						var splitted = this.split('=');
						var key = splitted[0];
						var val = splitted[1];
						// convert numbers
						if (/^[0-9.]+$/.test(val)) val = parseFloat(val);
						// convert booleans
						if (val == 'true') val = true;
						if (val == 'false') val = false;
						// ignore empty values
						if (typeof val == 'number' || typeof val == 'boolean' || val.length > 0) r[key] = val;
				});
		}
		return r;
};

/* FIN */
