function validate(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(email);
}

function megaresize(){
	var width_navid=parseInt(404+200+200+200);
	var width_nav=parseInt(width_navid+20+20);
	var width_nav_add=parseInt(Math.round((($(window).width() >= 1250 ? 1250 : $(window).width()) - width_nav)/5));
	$('.b_small .bg-menu-navigation, .b_normal .bg-menu-navigation').each(function(){
		var new_css = parseInt(parseInt($(this).css("width")) + width_nav_add) +'px';
		$(this).css("width", new_css);
	});
	$('.b_big .bg-menu-navigation').each(function(){
		var new_css = parseInt(parseInt($(this).css("width")) + 2 * width_nav_add) +'px';
		$(this).css("width", new_css);
	});
	$('.menu-navigation').css("width", parseInt(width_navid + width_nav_add * 5 +20) + 'px');
}

$(document).ready(function(){
	var scroll=true;
  var _url = document.location.href;
  _url = _url.split("#");
  _url = "#" + _url[1];
  if (_url == "#undefined") {
    $('#navigation .navigation-content .tab_content').hide();
    $('#navigation .tab_caption:first').trigger('click');
  }
  else if (_url == "#fb") {
   	  $('.form-up-position').animate({right:'0px'}, 500);
			$('.form-up').animate({opacity:'1'}, 500); 
  } else {
    $(_url).parents(".tab_content").fadeIn("slow");
    $('body,html').animate({scrollTop: 900}, 800);

    scroll = false;
  }

	megaresize();
	$('.form-up-link').bind('click', function(){
		if ($('.form-up-position').css("right") == "-319px") {
			$('.form-up-position').animate({right:'0px'}, 500);
			$('.form-up').animate({opacity:'1'}, 500);
		} else {
			$('.form-up-position').animate({right:'-319px'}, 800);
			$('.form-up').animate({opacity:'0'}, 800);
		}
		return false;
	});

	$('#navigation .navigation-content .tab_caption').bind("click", function(){
		$('#navigation .navigation-content .tab_caption').removeClass("tab-current");
		$('.active').removeClass('active');
		$(this).addClass("tab-current");
		$('.tab-current h5').addClass('active');
		$('#navigation .navigation-content .tab_content').hide();
		$('#navigation .navigation-content .tab_content:eq('+$(this).index()+')').show();
		$('body,html').animate({
                scrollTop: 920
              }, 800);
		scroll = false;
	});

	$('.zoom').fancybox();
	$('a[rel=gallery]').fancybox({
	'overlayOpacity': 0.9,
	'overlayColor': '#000'
	});
	
	$('.top-menu ul li').hover(function(){
	  $(this).children('ul').css('display','block');
    $(this).children('ul').stop().animate({opacity:'1'}, 500);
  },
	function(){
    $(this).children('ul').animate({opacity:'0'}, 100);
    $(this).children('ul').css('display','none');
  });
  
});// document.ready

