$(document).ready(function(){
	$('.submenu').hover(function() {
		$(this).children('ul').first().show();
	},function() {
		$(this).children('ul').first().hide();
	});
	$('.fancybox').fancybox();
	$("#news-ticker ul").newsTicker();
	
	
	
	$('#mc-embedded-subscribe-form').submit(function(e){
		$(this).children('input').each(function() {
			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			if($(this).val() == "" || ($(this).hasClass('email') && !emailReg.test($(this).val()))) {
				$(this).addClass('error');
				e.preventDefault();
			}
			$(this).change(function(){
				$(this).removeClass('error');
			});
		});
	});
	
	$("input, textarea").focusin(function(){
		if($(this).attr('type') != 'submit') {
			if(jQuery.support.opacity == true) $(this).prevAll('label').first().fadeTo(100, 0.1);
			else $(this).prevAll('label').first().css("display", "none");
		}
	});
	$("input, textarea").focusout(function(){
		if($(this).val() == "") {
			if(jQuery.support.opacity == true) $(this).prevAll('label').first().fadeTo(100, 1);
			else $(this).prevAll('label').first().css("display", "block");
		}
	});
	
	$("input, textarea").each(function(){
		if($(this).val() != "") {
			if(jQuery.support.opacity == true) $(this).prevAll('label').first().fadeTo(100, 0.1);
			else $(this).prevAll('label').first().css("display", "none");
		}
	});
	
	slideMainos();
	
});

function slideMainos() {
	var wrapperWidth = $('#wrapper').width();
	var windowWidth = $(window).width();
	var start = (windowWidth - wrapperWidth) / 2 + 235;
	var end = (windowWidth - wrapperWidth) / 2 + 10;
	$('.mainos').css('right', '-' + (start) + 'px');
	$('.mainos').animate({right: "-" + end + 'px'}, 1000, function(){
		$(this).delay('2000').animate({right: '-' + start + 'px'}, 1000);
	});
}
