/**
 * AUDI JavaScript library: core
 * 
 * @projectDescription	Animation class providing basic helper functions
 * @namespace			animation
 *
 * @author 				$Author: jkonzack $
 * @version				$Revision: 01 $
 * @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.teaserclicktip.js $
 */
/* create namespace */
audi_ngw.namespace(audi_ngw, 'animation.teaserclicktip');

/**
 * set up 
 * @return {Void}
 */
audi_ngw.animation.teaserclicktip.prepareContent = function () {
	if (!jQuery('.teaserclicktip li.has_teaser_css').size()) { return false; }
	
	
	jQuery('li.has_teaser_css')
					.removeClass('has_teaser_css')
					.addClass('has_teaser');
	
	jQuery('a.teaserclicktip_more').one('mouseover', audi_ngw.animation.teaserclicktip.show);
};

/**
 * Show function
 * @param {Event} event
 * @return {Void}
 */
audi_ngw.animation.teaserclicktip.show = function(event) {
	
	event.stopPropagation();
	
	jQuery('li.has_teaser').removeClass('hover');
	
	if (jQuery(this).children('span').size() !== 0 && jQuery(this).children('span').text() !== '') {
		jQuery(this).parent('div.innerteaser').parent('li.has_teaser').addClass('hover');
		jQuery(this).one('mouseout', audi_ngw.animation.teaserclicktip.hide);
	}
};
/**
 * Hide function
 * @param {Event} event
 * @return {Void}
 */
audi_ngw.animation.teaserclicktip.hide = function(event) {
	
	event.stopPropagation();
	
	jQuery(this).parent().parent().removeClass('hover');
	
	jQuery(this).one('mouseover', audi_ngw.animation.teaserclicktip.show);
	
};

/**
 * 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.teaserclicktip.onAjaxModalContentReady = function(event,xhr){
	// check if this xhr-response contains valid content
	if (!audi_ngw.url.hasXHRContent(xhr,event.timeStamp)) {return false;}
	//audi_ngw.log("-> "+audi_ngw.event.ajaxModalContentReadyCount+" EVENT - ajaxModalContentReady:audi_ngw.animation.teaserclicktip.onAjaxModalContentReady",arguments);
	// execute funtions on new content
 	audi_ngw.animation.teaserclicktip.prepareContent();
	// trigger event 
	audi_ngw.event.trigger('ajaxModalContentPrepared');
};
/**
 * Contructor
 * @return {Void}
 */
audi_ngw.animation.teaserclicktip.initialize = function() {
	
	this.__className =  'audi_ngw.animation.teaserclicktip';
	this.__classVersion= '1.2';
	
	// register ajaxModalContentReady event
	audi_ngw.event.bind('ajaxModalContentReady.animationTeaserClickTip', audi_ngw.animation.teaserclicktip.onAjaxModalContentReady);
	
	audi_ngw.animation.teaserclicktip.prepareContent();
	
	
};

