
$(window).load(function() {
	//$(".CycleContainerHome").addClass('AlphaZero');
	//$(".CycleContainerHome").fadeTo(0, 0);
	fixDottedLinksOutline('.SubMenu a');
	
	$(".CycleContainerHome").fadeIn(3000, function() {
		hideLoading();								   
		//alert($(this).attr('class'));
		$(this).cycle({
			fx:     'scrollUp',
			easing: 'easeOutExpo',
			//easeOut: 'none',
			requeueOnImageNotLoaded: 'true',
			timeout: 8000, 
			delay:  -2000,
			speed: 1200
		});
		
													
	});
});

$(document).ready(
	function() {

		//------------------
		// INPUT fields default values
		//------------------

		$('INPUT[onempty]').focus(
			function() {
				var obj = $(this).get(0);
				if(obj.value == $(this).attr('onempty')) { obj.value = ''; $(this).removeClass('Dim');}
			}
		)

		$('INPUT[onempty]').blur(
			function() {
				var obj = $(this).get(0);
				if(obj.value == '') { obj.value = $(this).attr('onempty'); $(this).addClass('Dim'); }
			}
		)
		
		
		// DROPSHADOW
		//$(".DetailTitle h1").dropShadow({left: 1, top: 1, blur: 5, opacity: 0.4});
		//$(".DetailTitle h2").dropShadow({left: 1, top: 1, blur: 5, opacity: 0.4});


		// CYCLE
		$(this).find('.CycleContainer').cycle({
			fx:     'scrollDown',
			easeIn: 'easeOutSine',
			easeOut: 'easeOutSine',
			timeout: 8000, 
			delay:  -2000,
			speed: 1000
		});
		$(this).find('.CycleContainer').removeClass('Hidden');
		
		
		$(".CycleContainerHome").css({display:'none'});
		


		// OWG DROPDOWNS
		$('.MainMenu .OwgDropDown').each(function() {
			var $position = $(this).find('.OwgDropDown_Position');
			var $image = $(this).find('.OwgDropDown_Image');
			var $links = $(this).find('.OwgDropDown_Links');
			var sImageUrl = $image.attr('src');
			var iPositionTop = "-12px";
			var iPositionBottom = "66px";
			
			$links.hide();
			
			$(this).bind("mouseenter", function(e) {
				$links.show();
												
				$(this).stop();
				$position.stop();
				$(this).fadeTo("fast", 0.8);
				$position.animate({ top: iPositionTop }, 200, 'swing' );
				$image.attr('src', sImageUrl.replace('/images/mainmenu/','/images/mainmenu/hover/'));
			});
	
			$(this).bind("mouseleave", function(e) {
				$links.hide();

				$(this).stop();
				$position.stop();
				$(this).fadeTo("fast", 1.0);
				$position.animate({ top: iPositionBottom }, 200, 'swing', function() { $image.attr('src', sImageUrl); } );
			});

		});
		
		DocumentReady(document);

	}
);

function fixDottedLinksOutline(domChunk) {	$(domChunk).focus(function(){this.blur();});  }

function DocumentReady(obj) {
	
	// FADE
	$(".FadeArticle").fadeTo("fast", 0.0);
	FadeFastSel();

	$(".FadeArticle").hover(function(){		
			//$(this).stop();
			$(this).fadeTo("fast", 0.8);
		},function(){
			//$(this).stop();
			$(this).fadeTo("fast", 0.0);
	});

	$(".FadeFast").hover(function(){
			//$(this).stop();
			$(this).fadeTo("fast", 1.0);
		},function(){
			//$(this).stop();
			if(!$(this).parents('.Sel').length) { $(this).fadeTo("fast", 0.4); }
	});
	
	if(obj!=document) {
		$(obj).find('a.thickbox, area.thickbox, input.thickbox').each(function() {
			tb_init(this);
		});
	}
}

function FadeFastSel() {
	$(".FadeFast").each(function() {
		if(!$(this).parents('.Sel').length) { $(this).fadeTo("fast", 0.4); }
		else {$(this).fadeTo("fast", 1);}
	})
}

//----------------------
// LOADING ICON
//----------------------

function showLoading(domChunk) {
	var offset = $(domChunk).offset();
	$('#LoadingIcon').css({
		position:	'absolute',
		top:	offset.top+($(domChunk).height()/2),
		left:	offset.left+($(domChunk).width()/2)
	});
	$('#LoadingIcon').show();	
}

function showLoadingGroup(domChunk) {
	var offset = $(domChunk).offset();
	$('#LoadingIcon').css({
		position:	'absolute',
		top:	offset.top+(100),
		left:	offset.left+($(domChunk).width()/2)
	});
	$('#LoadingIcon').show();	
}

function hideLoading() {
	$('#LoadingIcon').hide('fast');	
}

//----------------------
// FAQ
//----------------------

function SwitchFAQ(iQuestion) {
	$('.Question').css('font-weight','normal');
	$('.Answer').hide('fast');
	$('#Q' + iQuestion).css('font-weight','bold');
	$('#A' + iQuestion).show('fast');
}
