(function(){ //alles kapseln wegen window scope



//--- class --- --- --- --- --- --- ---
var tabFader_ax = (function tabFader_ax(){

	jQuery.fn.extend({	

	  tglFadeIn2: function(speed, callback){
		  //wie fadeIn, aber geeignet für fade Toggling (z.b. item faded-out und während fading soll er wieder einfaden)
	
	  	//methode: faded von 0-100
	  	return this.stopp().hide().opacity(1).fadeIn(speed,callback); //opacity = ziel-opacity!
	  }

	});


	G8.worx.addGlobalListener("domChange", _reinitTabFades);

	function _reinitTabFades(scope){
		$Self(".tabFadeLink",scope).each(function(){
			var linkObj = $(this);
			_extendTabFadeLink(linkObj);
		});		
	}

	function _extendTabFadeLink(linkObj){

		//extend only if not already extended
		if(!linkObj.hasClass(".js_isTabFaded")){
				
			linkObj.addClass("js_isTabFaded");
		
			//simply don't extend special-marked imgs for IE (due to transparency bug)
			if($.browser.msie && linkObj.hasClass(".noFadeMsie")) {
				//todo: bind standard hovering & tooltip handling for this img
			
			} else {
				
				linkObj.css({
					position:"relative",
					zIndex:3
				});
				
				tabFadeBox = linkObj.parent();
				
				tabFadeBox.css({
					position:"relative"
				});
				
				//set img to parent
				var origTabImg = linkObj.find("img")
					.addClass("js_TabfadeImg_Lo")
					.appendTo(tabFadeBox)
					.css({
						position:"absolute",
						left:0,
						top:0,
						zIndex:1
					});
				
				//clone tabImg
				var hiTabImg = origTabImg.clone()
					.appendTo(tabFadeBox)
					.removeClass("js_TabfadeImg_Lo")
					.addClass("js_TabfadeImg_Hi")
					.imgSetHi()
					.hide()
					.css({
						zIndex:2
					});

				tabFadeBox
				//bind hovering
				.bindOnce("mouseenter", {show:true}, _fad_hov_tglTabFade)
				.bindOnce("mouseleave", {show:false}, _fad_hov_tglTabFade);
			}
		}

	}	
	function _fad_hov_tglTabFade(e){
		//das lo img sitzt unter dem hi img
		
		var speed = 300;
		var show = e.data.show;
		var tabFadeBox = $(this);
		var loImgObj = tabFadeBox.find(".js_TabfadeImg_Lo");
		var hiImgObj = tabFadeBox.find(".js_TabfadeImg_Hi");
		
		if(loImgObj.attr("src").hasStr("_lo.")){
			show? hiImgObj.tglFadeIn2(speed) : hiImgObj.tglFadeOut(speed); //bug: funzt nicht mit tglFadeIn (bild faded sprunghaft. warum?). deshalb tglFadeIn2()
		}
	}


	//--- return public methods & properties --- --- --- --- --- --- ---
	return {
	};

})();

//--- class --- --- --- --- --- --- ---
var iframeResizer_ax = (function iframeResizer_ax(){

	G8.worx.addGlobalListener("domChange", _reinitIframeHeight);

	function _reinitIframeHeight(scope){
		
		//--- if called by iframe itself
		$Self(".iframeBody",scope).each(function(){
			
			//todo: wie greife ich nur auf mich selbst zu (also eigener iframe)
			var iframe1 = $("#iframeEmailNewsletter", parent.document);
			var iframe2 = $("#iframeSmsNewsletter", parent.document);
			
			_setIframeHeight(iframe1);
			_setIframeHeight(iframe2);
		});		

		//--- if called by parent: double check by bind load handler (to prevetn wrong height if content not fully loaded etc.)
		$Self("#iframeEmailNewsletter, #iframeSmsNewsletter",scope).bindOnce("load", _loa_setIframeHeight);
		
	}
	
	function _loa_setIframeHeight(e){
		var iframeObj = $(this);
		_setIframeHeight(iframeObj);
	}
	
	function _setIframeHeight(iframeObj){
		iframeObj.height(iframeObj.contents().find("body").height()+20);
	}

	//--- return public methods & properties --- --- --- --- --- --- ---
	return {
	};

})();


//+++ onload ++++++++++++++++++++++++++++++++++++++++
$(function(){
	
	//do some
	$(document).trigger("domChange");

});

})();
