var rollIn;

//	JavaScript Document
//	filename: jquery-kc_rollInteaser.js
//	author: j.wessel
//
//	purpose: trigger navigation elements in the Alice Lounge - Mein Kundencenter
//	initial version, release date: 09.11.07

//	dimScreen()
//	by Brandon Goldman
//	edited by j.wessel
jQuery.extend({
	
	//dims the screen
	dimScreen: function(speed, opacity, callback) {
		
		if(jQuery('#__dimScreen').size() > 0) return;
		
		if(typeof speed == 'function') {
			callback = speed;
			speed = null;
		}
	
		if(typeof opacity == 'function') {
			callback = opacity;
			opacity = null;
		}
	
		if(speed < 1) {
			var placeholder = opacity;
			opacity = speed;
			speed = placeholder;
		}
	
		if(opacity >= 1) {
			var placeholder = speed;
			speed = opacity;
			opacity = placeholder;
		}
	
		speed = (speed > 0) ? speed : 500;
		opacity = (opacity > 0) ? opacity : 0.5;
		return jQuery('<div></div>').attr({
			id: '__dimScreen'
			,fade_opacity: opacity
			,speed: speed
			}).css({
				background: '#4D4D4D'
				//	,height: $(document).attr('height') + 'px'
				,height: $(window).height() + 'px'
				,left: '0px'
				,opacity: '0'
				,position: 'absolute'
				,top: '0px'
				//	,width: $(document).attr('width') + 'px'
				,width: $(window).width()+24  + 'px'
				,zIndex:'10'
			}).appendTo(document.body).fadeTo(speed, opacity, callback);
		},
	
		//stops current dimming of the screen
		dimScreenStop: function(callback) {
			var x = jQuery('#__dimScreen');
			var opacity = x.attr('fade_opacity');
			var speed = x.attr('speed');
			x.fadeOut(speed, function() {
			x.remove();
			if(typeof callback == 'function') callback();
			});
		}
});

//	trigger the teaser
jQuery(function($) {
	if (rollIn == true && typeof(rollIn) != 'undefined') {
		$('body').append('<div id="rollInTeaserTop"\><img src='+rollInTeaserTopPath+teaserTopID+'.'+filetype+' onclick="exitTeaser();" \></div>');
		$.dimScreen(1000, 0.5, function() {
			lWidth = $('#rollInTeaserTop').width();	//	width of the teaser
			$('#rollInTeaserTop').css('left',($(document).width()/2)-(lWidth/2));
			$('#rollInTeaserTop').animate(
				{			
					top: '70px'
				},700
			);
		});
	}
	//	console.log($(document).width()+','+$('#rollInTeaserTop').width());
});

//	stop the teaser and dim
function exitTeaser() {
	$('#rollInTeaserTop').remove();	
	$.dimScreenStop();
}