/* Drop Down Menus */
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').css('visibility', 'visible');
}

function jsddm_close()
{
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}

function jsddm_timer()
{
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;   
	}
}

$(document).ready(function() {
		$('#jsddm > li').bind('mouseover', jsddm_open);
		$('#jsddm > li').bind('mouseout',  jsddm_timer);
		$(document).bind('click', jsddm_close);
});


/* CE */
/* Associates roll over */
$(document).ready(function() {
	$('#footerAssoc ul li img').each(function(i, img) {
		$(img).bind('mouseover', function(e) {
			this.src = this.src.replace('up','over');
		});
		$(img).bind('mouseout', function(e) {
			this.src = this.src.replace('over','up');
		});
	});
});

/* Adverts */
var ads = [];
var ad = 0;
var adTimeout = 30000;

function changeAd()
{
	$(ads[ad]).hide();
	ad = (ad + 1) % ads.length;
	$(ads[ad]).show();
	window.setTimeout( changeAd, adTimeout );
}

$(document).ready(function() {
	$('#contentRightAdvert img').each(function(i, img) {
		ads.push( img );
	});
	if (ads.length > 1)
	{
		ad = Math.floor(Math.random() * ads.length);
		$(ads).hide();
		$(ads[ad]).show();	
		window.setTimeout( changeAd, adTimeout );
	}
});


