// Allow HTML5 tags to be styled in IEs
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('footer');

var curvyCornersVerbose = false;

sVars = {
	over:				0
}

$(document).ready(function(){
	$('#mainNav .second').css('display','none');
	$('#mainNav .first').css('display','none');
	
	$('.overlay').animate({opacity: 0},{duration: 200, queue: false});
	$('.overlay').hide();
	$('#mainNav .children').hover(
		function() {
			$(this).children('.first').css('display','block');
			$('.second').css('display','none');
		},
		function() {
			$(this).children('.first').css('display','none');
		}
	);	
	$('#mainNav .firstlvl').hover(
		function() {
			$(this).children('.second').css('display','block');
		},
		function() {
			$(this).children('.second').css('display','none');
		}
	);	
	$('.overlay .inside .text').hide();
	$('.features .feature').hover(
		function() {
			sVars.over = 1;
			var featID = $(this).attr('id').substr(8,1);
			if (featID < 5) {
				$('.overlay.left').show();
				$('.overlay.left').animate({opacity: 1},{duration: 200, queue: false});
				var newText = $('#feature-text-' + featID).html();
				$('.overlay.left .inside .main-text').animate({opacity: 0},{duration: 200, queue: false, complete: function() {
					$('.overlay.left .inside .main-text').html(newText);
					$('.overlay.left .inside .main-text').animate({opacity: 1},{duration: 200, queue: false});
				}});
			} else {
				$('.overlay.right').show();
				$('.overlay.right').animate({opacity: 1},{duration: 200, queue: false});
				var newText = $('#feature-text-' + featID).html();
				$('.overlay.right .inside .main-text').animate({opacity: 0},{duration: 200, queue: false, complete: function() {
					$('.overlay.right .inside .main-text').html(newText);
					$('.overlay.right .inside .main-text').animate({opacity: 1},{duration: 200, queue: false});
				}});
			}
		},
		function() {
			sVars.over = 0;
			setTimeout('HideOverlay()', 200);
		}
	);
	
});

	function HideOverlay() {		
		if (sVars.over == 0) {
			$('.overlay').animate({opacity: 0},{duration: 200, queue: false, complete: function() {
				if (sVars.over == 0) {
					$('.overlay').hide();
					$('.overlay .inside .main-text').animate({opacity: 0},{duration: 200, queue: false});
				}
			}});
		}
	}
