/**
* Simple decorator that takes list items and gives them a more interactive feel. Integrated in the IPGUL Joomla template.
* @param parentDivId - Id of the parent div in wich the buttons have been injected.
*/
function decorateButtons(parentDivId){
	jQuery("#"+parentDivId+" a").each(function(){
		$node = jQuery(this);
		$node.hover(
			function(e){
				//_overHandler(e);
			},
			function(e){
				//_outHandler(e);
		});
	});
}

/**
* Handles the action when the pointer is over the list item.
*/
function _overHandler(event){
	var $elem = jQuery(event.target);
	$elem.css('color', '#666');
	$elem.parent().css('background-image', 'url(/ipgul/templates/ipgul/images/buttonBase-sm.png)');
}

/**
* Handles the event when the pointer goes out of the list item
*/
function _outHandler(event){
	var $elem = jQuery(event.target);
	$elem.css('color', 'white');
	$elem.parent().css('background-image', 'none');
}


function BannerChanger(imageUrls){
	this.images = imageUrls;
	this.numImages = this.images.length;
}

BannerChanger.prototype.getImage = function(target){
	if(this.numImages != 0){
    var num = Math.round(Math.random()*this.numImages);
    var picNum = num % this.numImages;
    var elem = document.getElementById(target);
    var image = document.createElement("img");
    image.setAttribute("src", this.images[picNum]);
    elem.appendChild(image);
	}
}
