/**
 * AUDI JavaScript library: core
 * 
 * @projectDescription	Animation class providing basic helper functions
 * @namespace			animation
 *
 * @author 				$Author: hhoettecke $
 * @version				$Revision: 6416 $
 * @copyright			NEUE DIGITALE GmbH, Berlin
 * 
 * @jslint: 2008-10-31
 * 
 * @file:				audi_ngw.animation.js
 * $URL: https://svn.pvtool.org/svn/day_audi_ngw/trunk/ngw_base/frontend/js/audi/audi.animation.navdistributor3col.teaser.js $
 */

/* create namespace */
audi_ngw.namespace(audi_ngw,'animation.navdistributor3col.teaser');

/**
 * set up 
 * @return {Void}
 */
audi_ngw.animation.navdistributor3col.teaser.prepareContent = function () {
	if (!jQuery('.distributor_teaser li.has_teaser_css').size()) { return false; }
	jQuery('.distributor_teaser li.has_teaser_css').removeClass('has_teaser_css').addClass('has_teaser');
	jQuery('.distributor_teaser img.has_teaser').bind('mouseover.teaser',audi_ngw.animation.navdistributor3col.teaser.show);
	jQuery('.distributor_teaser img.has_teaser').siblings('span.teaser').bind('mouseout.teaser',audi_ngw.animation.navdistributor3col.teaser.hide);
};

/**
 * Show function
 * @param {Event} event
 * @return {Void}
 */
audi_ngw.animation.navdistributor3col.teaser.show = function(event) {
	event.stopPropagation();
	jQuery('.distributor_teaser li.has_teaser.hover').removeClass('hover').find('> img');
	if (jQuery(this).siblings('span.teaser').size() !== 0 && jQuery(this).siblings('span.teaser').text() !== '') {
		jQuery(this).parents('li.has_teaser').addClass('hover');
	}
		

};
/**
 * Hide function
 * @param {Event} event
 * @return {Void}
 */
audi_ngw.animation.navdistributor3col.teaser.hide = function(event) {
	event.stopPropagation();
	jQuery(this).parents('li.has_teaser').removeClass('hover');
};

/**
 * Custom Event: wil be fired as soon as we filled the ajax-content into the modal layer, just before "xhrReallocate"
 * @param {Object} event
 * @param {Object} xhr
 */
audi_ngw.animation.navdistributor3col.onAjaxModalContentReady = function(event,xhr){
	// check if this xhr-response contains valid content
	if (!audi_ngw.url.hasXHRContent(xhr,event.timeStamp)) {return false;}
	// execute funtions on new content
 	audi_ngw.animation.navdistributor3col.teaser.prepareContent();
	
	// trigger event 
	audi_ngw.event.trigger('ajaxModalContentPrepared');
};
/**
 * Contructor
 * @return {Void}
 */
audi_ngw.animation.navdistributor3col.teaser.initialize = function() {
	
	this.__className =  'audi_ngw.animation.navdistributor3col.teaser';
	this.__classVersion= '1.2';
	
	audi_ngw.animation.navdistributor3col.teaser.prepareContent();
	
	// register ajaxModalContentReady event
	audi_ngw.event.bind('ajaxModalContentReady.animationNavdistributor3col',audi_ngw.animation.navdistributor3col.onAjaxModalContentReady);
};



