$(document).ready(function(){
	
	
	$('#menu .left').css('visibility', 'hidden');
	$('#menu .right').css('visibility', 'hidden');
	
	/*
	$('a').each(
		function(){
			$(this).onfocus=blurLink;
		}
	);
	
	}

	function blurLink() {
		if (this.blur){
			
		this.blur();
		} 
	}
	*/
	
	$('#newsletterEmail').focus(
			function() {  
				if (this.value == "email'ınız"){  
					this.value = '';  
				}
				if (this.value == "email'ınızı kontrol ediniz."){  
					this.value = '';  
				}
				if (this.value == "email'ınız kaydedilmiştir."){  
					this.value = '';  
				}
				if (this.value == "please check your email address"){  
					this.value = '';  
				}
				if (this.value == "email address saved"){  
					this.value = '';  
				}
				if (this.value == "email address"){  
					this.value = '';  
				}
			}
		);

		$('#newsletterEmail').blur(
			function() {  
				if ($.trim(this.value) == ''){
					this.value = (this.defaultValue ? this.defaultValue : '');  
				}
			}
		);
	
	
	$('#newsletterFormSubmit').click(
		function(e){
			e.preventDefault();
			$('#newsletterForm').submit();
		}
	);
	
	
	$('#menu .link a').hover(
		function () {
			if ((!$(this).hasClass('active')) && (!$(this).hasClass('sub'))){
				$(this).parent().parent().children(":first").css('visibility', 'visible');
				$(this).parent().parent().children(":first").next().next().css('visibility', 'visible');
			}
			if ($(this).parent().next().next().hasClass('submenu')){
				$(this).parent().next().next().show();
			}
		},
		function () {
			if ((!$(this).hasClass('active')) && (!$(this).hasClass('sub'))){
				$(this).parent().parent().children(":first").css('visibility', 'hidden');
				$(this).parent().parent().children(":first").next().next().css('visibility', 'hidden');
			}
		}
	);
	
	$('#menu ul ul').hover(
		function(){
			$(this).parent().children(":first").css('visibility', 'hidden');
			$(this).parent().children(":first").next().css('visibility', 'hidden');
			$(this).parent().children(":first").next().next().css('visibility', 'hidden');
		},
		function(){
			$(this).hide();
			$(this).parent().children(":first").next().css('visibility', 'visible');
			if ($(this).parent().children(":first").next().children(":first").hasClass('active')){
				$(this).parent().children(":first").css('visibility', 'visible');
				$(this).parent().children(":first").next().next().css('visibility', 'visible');
			}
		}
	);
	
	$('#menu .active .left').css('visibility', 'visible');
	$('#menu .active .right').css('visibility', 'visible');
	$('#menu .active').children(":first").next().children('a').addClass('active');	
	
	$('#menu ul ul').hide();
	
	
	Cufon.replace('#menu a', {hover:true,hoverables:{a:true},fontFamily: 'Avenir Next LT Pro'});
	Cufon.replace('.cufon', {fontFamily: 'Avenir 95 Heavy Oblique TR'});
	Cufon.replace('.carouselItem .title', {fontFamily: 'Avenir 85 Heavy Oblique TR'});
	Cufon.replace('#vp a', {hover:true,hoverables:{a:true},fontFamily: 'Avenir Next LT Pro'});
	Cufon.replace('#vp .over .title', {hover:true,hoverables:{a:true},fontFamily: 'Avenir Next LT Pro'});
	
	$(window).resize(function() {
		windowResized2();
	});
	
	function windowResized2(){
		//$('#logo').css('left', (($(window).width() - 1049) / 2) + 42);
		$('#menu-background').css('width', Math.max($(window).width(), 1129));
		$('#footer').css('width', $(window).width());
		$('#footer #background').css('width', Math.max($(window).width() + 100, 1229));
		$('#footer #foreground').css('marginLeft', Math.max(($(window).width() - 945) / 2, 92));
	}
	
	windowResized2();
});
