$(function() {
		   
	// remove ALT-texts in IE
	if ($.browser.msie) {
		$('img[alt]:not([title])').attr('title','');
	}
		   
	// activate Tabs
	$('#tabs').tabs();
	
	// fade in content
	$('.index #curtain').each(function() { $(this).height($(this).height()-305); });
	$('#curtain').fadeOut(1200);
	//$('#content').hide().css({visibility:'visible'}).fadeIn(1500);
	
	// animate red wave
	$('#teaser>div').each(function() {
		var el=$(this);							   
		el.parent().find('h1').hide();								   
		el.css({bottom:-$(this).height()});
		setTimeout(function() {
			el.animate({bottom:-1},600,'easeOutQuart');
			el.parent().find('h1').show(500);			   
		},500);
	});
	
	// setup of offsets for indexpage c2ap distance
	var indexMargin=46;
	var indexPadding=75;
	switch ($('body').attr('lang')) {
		case 'ru':
			indexMargin=35;
			indexPadding=52;
			break;		
		case 'fr':
			indexMargin=29;
			break;		
	}
	if ($.browser.msie) indexMargin-=4;
	
	// nice menu animation	
	$('#navigation>ul>li>a, a[href=index.php]').click(function() {
		$(this).blur();
		var isHome = $('body.index').length>0;
		var isTargetHome = $(this).attr('href')=='index.php';
		var li=$(this).parent();
		if ((li.find('ul').length==0)&&($('#navigation>ul>li.active>ul').length==0)&&(!isHome)&&(!isTargetHome)) return true; // no sub in 'from' and 'to'
		old=$('#navigation>ul>li.active').not(li).find('ul');
		jump=function() {
			jump=null;
			if (li.find('ul').length==0) { // no subs in 'to' -> jump direct to link
				var url=li.find('a').attr('href');
				if (url) location.href=url;
			}
		};
		if (isTargetHome) {
			$('#navigation #c2ap').animate({marginTop:indexMargin, paddingTop:indexPadding},'slow',jump);
		}
		if (old.length>0) old.animate({height:'hide'},'slow',function() { // hide subs in 'from'
			li.removeClass('active'); 
			if (jump) jump();
		});
		if (!isTargetHome) {
			if (li.hasClass('active')) { // close active sub menu
				if ($(this).attr('href')!='#') return true; // Hauptmenupunkt akiver inhalt
				li.find('ul').animate({height:'hide'},'slow',function() { 
					li.removeClass('active'); 
				});
			} else  { // open new sub menu
				jump=function() {
					jump=null;
					var url=li.find('a').attr('href');
					if (url) location.href=url;
				}
				if (isHome) {
					$('#navigation #c2ap').animate({marginTop:26, paddingTop:24},'slow',jump);
				}
				li.find('ul').animate({height:'show'},'slow',jump);
				li.addClass('active');
			}
		}
		return false; // deactivate standard href link
	 });

	// red & white color animation, horizontal animation
	$('#navigation ul>li>a').hover(
		function() {
			$(this).animate({paddingLeft:6},'fast').css({color:'#ce1126'}).animate({color:'#ffffff'},{queue:false, duration:'slow'});
		}, function() {
			var col=$(this).parent().hasClass('active')?'#ffffff':'#666666';
			$(this).stop().animate({paddingLeft:0,color:col},'fast');
		});
	
	
	//load flash at index.php
/*	if ($('#clouds').size()>0) {
		if (jQuery.isFunction($.fn.flash )) {
			$('#clouds').flash({ 
				src: 'flash/clouds_old.swf',
				width: 749,
				height: 239,
				name: 'clouds'
			},
			{
				version: 8,
				update:false
			});
		}
	}
*/
	// rolling text at index.php
	if ($('#rolling').size()>0) {
		$('#rolling').css({marginTop:5}).prev().css({marginBottom:0}); /* workaround for IE6-Bug */
		(function() {
			var selfcall=arguments.callee;
			window.setTimeout(function() {
				var li=$('#rolling>li:first');
				li.animate({marginTop:-li.outerHeight()}, 600,	function() {
					li.appendTo(li.parent()).css({marginTop:0});
					selfcall();
				}); 
		   },3000);
		})();
	}

	// form label highlighting
	$('form label').hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); });
	

	// Lightbox
	if (jQuery.isFunction($.fn.lightBox )) $('#gallery .lightbox a').lightBox({
		overlayBgColor: '#000000',
		overlayOpacity: 0.7,
		imageLoading: 'images/lightbox/loading.gif',
		imageBtnClose: 'images/lightbox/close.gif',
		imageBtnPrev: 'images/lightbox/prev.gif',
		imageBtnNext: 'images/lightbox/next.gif',
		imageBlank: 'images/lightbox/blank.gif',
		containerBorderSize:   10,
		containerResizeSpeed: 400,
		containerResizeSpeed: 350,
		txtImage: 'Image',
		txtOf: 'of',
		keyToClose: 'c',
		keyToPrev: 'p',
		keyToNext: 'n'
   });

	// Printstyle Header
	var txt='www.VistaJet.com';
	$('#navigation ul>li.active>a').each(function(){ txt+=' - '+$(this).text(); });
	$('#content').before('<div class="print_header"><img src="images/vistajet_logo_print.gif" width="221" height="47"><span>'+txt+'</span></div>');




});

