/**
 * @version $Id$
 */
function RandomHeader() {
	this.set = {
		'headerDiv':'header',
		'imagePath':'/sites/images/header_%count%.jpg',
		'maxImageCount':'3'
	};
	
	this.init = function(set) {
		this.set = set;
	}
	this.loadRandomHeader = function() {
		// Load cookie value
		var cookieCount = jQuery.readCookie('RandomHeader_C');
		// If no cookie value exists, then write cookie value
		if ( cookieCount == null || cookieCount == 'undefined' || this.set['maxImageCount'] < cookieCount )
		{
			cookieCount = Math.ceil(Math.random()*this.set['maxImageCount']);
			jQuery.setCookie('RandomHeader_C',cookieCount,{});
		}
		// Update image
		jQuery("div#"+this.set['headerDiv']).css('background-image','url('+this.set['imagePath'].replace('%count%',cookieCount)+')');
	}
}

