/**
 * madChickBannerAreaMenu
 * ImageLayer, listed from madChickMenu
 *
 * @author Sebastian Roming, hitcom new media gmbh
 **/
 
madChickBannerAreaMenu = function(settings) {

	/**
	 * global variables
	 **/
	s={
		_topNaviItem:'#topNaviItem_2 ul li a',
		_imageId:'#homeImageOver',
		_linkId:'#homeImageLinks',
		_linksClass:'homeImageLink',
		_cEasyUrl:'http://www.foto-kasenbacher.de',
		_width:975,
		_height:420
	};

	resources = new Array();
	resources['0']  = 298;
	resources['21'] = 241;
	resources['22'] = 239;
	resources['23'] = 240;
	resources['24'] = 242;
	resources['25'] = 243;
	resources['26'] = 236;
	resources['27'] = 244;
	resources['28'] = 238;
	resources['29'] = 237;
	resources['30'] = 261;
	resources['31'] = 245;
	
	cPageId = new Array();
	cPageId['21'] = 21;
	cPageId['22'] = 22;
	cPageId['23'] = 23;
	cPageId['24'] = 24;
	cPageId['25'] = 25;
	cPageId['26'] = 26;
	cPageId['27'] = 27;
	cPageId['28'] = 28;
	cPageId['29'] = 29;
	cPageId['30'] = 30;
	cPageId['31'] = 31;

	/**
	 * local variables
	 **/
	var that={};
	var _menuItems=[];
	var t = 0;

	// -------------------------------------------------------------------------
	that.init=function() {
		that._getAllMenuItems();
		that._showLinksForImages();
	}

	// -------------------------------------------------------------------------
	that._getAllMenuItems=function() {
		jQuery(s._topNaviItem).each(function() {

			var _menuItem=[];
			_menuItem.push(that._getIdOfString(this.href));
			_menuItem.push(this.innerHTML);
			_menuItems.push(_menuItem);

		});
	}

	// -------------------------------------------------------------------------
	that._showLinksForImages=function() {
		jQuery.each(_menuItems, function(k, v) {
			jQuery(s._linkId).append("<div class='" + s._linksClass + "' id='banner_" + v[0] + "'><div>" + v[1] + "</div></div>");
			jQuery(s._imageId).append("<div style='display:none;' id='bannerContainer_" + v[0] + "'><img src='" + s._cEasyUrl + "/ceasy/modules/core/resources/main.php5?view=publish&item=resource&id=" + resources[v[0]] + "' style='border:none;' /></div>");
		});
	}

	// -------------------------------------------------------------------------	
	that._getIdOfString=function(f) {
		var u = f.split("=");
		return u[1];
	}

	return that;

}();


/**
 * run
 **/
if ('undefined' != typeof cEasyJs) {
	cEasyJs.load('jQuery', function() {
		jQuery(document).ready(function() {
			madChickBannerAreaMenu.init();
		
			var _current;
		
			jQuery(".homeImageLink").mouseover(function() {
				_current = jQuery(this).attr("id");
				_bannerId = jQuery(this).attr("id");
				t = setTimeout(function() {
					if (_current == _bannerId) {
		
						jQuery("#homeImageOver").children(".active").fadeOut(100, function() {
							var oldId = jQuery(this).attr("id");
		
							jQuery("#bannerContainer_" + _bannerId.split("_")[1]).fadeIn(100, function() {
								jQuery("#bannerContainer_" + _bannerId.split("_")[1]).addClass('active');
							});
		
							_current = null;
							jQuery("#" + oldId).removeClass('active');
						});
		
					} else {
						_current = null;
					}
				}, 110);
			});
			
			jQuery(".homeImageLink").click(function() {
				var cPageId = jQuery(this).attr("id").split("_")[1];
				
				document.location.href = 'http://www.foto-kasenbacher.de/ceasy/modules/cms/main.php5?cPageId=' + cPageId;
			});
		});
	});
}
