$(function() {
	if( $(".top100line").width() < 1020 ) {
		$(".top100line").width(1030);
	}
	
	//search
	var org = $(".s-input").val();
	$(".s-input").focus(function() {
		if( $(this).val() != '') {
			if( $(this).val() == org  ) {
				$(this).val('');
			}
		}
	}).blur(function() {
		if( $(this).val() == '' ) {
			$(this).val( org );
		}
	});
	
	$('.s-submit').click(function(event) {
		event.preventDefault();
		var query_value = $(this).prev('[name=query]').val();
		if( query_value != '') {
			if( query_value != org && query_value.length > 2  ) {
				$(this).parent().trigger('submit');
			}
		}
	})
		
	$('.search-cont').submit(function(event) {		
		var query_value = $('.s-input').val();
		if( query_value != '') {
			if( query_value != org && query_value.length > 2  ) {
				return true;
			} else { return false; }
		} else { return false; }
	})
	
	//top meniu
	$('.t-item').hover(
	function(){
		$(this).find("span").eq(0).css({ background:"url(./client/img/t-item-left.png) no-repeat center center" });
		$(this).find("span").eq(1).css({ background:"url(./client/img/t-item-center.png) repeat-x" });
		$(this).find("span").eq(2).css({ background:"url(./client/img/t-item-right.png) no-repeat center center" });
	}, 
	function(){
		$(this).find("span").eq(0).css({ backgroundImage:"none" });
		$(this).find("span").eq(1).css({ backgroundImage:"none" });
		$(this).find("span").eq(2).css({ backgroundImage:"none" });
	})
	
	//function-block title
	$('.function-block').hover(
	function(){
		$(this).css({ background:"url(./client/img/function-block-bg.gif) no-repeat center center" });
		$(this).find("a").eq(0).css({ color: "#653b71" });
		$(this).find("a > b").eq(0).css({ color: "#653b71" });
		$(this).find("span.function-block-bg-b").show();
	}, 
	function(){
		$(this).css({ backgroundImage:"none" });
		$(this).find("a").eq(0).css({ color: "#333333" });
		$(this).find("a > b").eq(0).css({ color: "#333333" });
		$(this).find("span.function-block-bg-b").hide();
	})
	
	//equal 'content' column height
	$(".function-block").equalHeights(150,304).css({ overflow:"hidden" });
	
	//function-block-link-cont position
	$(".function-block").each(function() {		
		if( $(this).find("span.function-block-text").height() < 164 ) {
			if( $(this).find("span.function-block-link").height() < 32 ) {
				$(this).find("span.function-block-link-cont").css({ top: 150-$(this).find("span.function-block-text").height() });
			} else {
				$(this).find("span.function-block-link-cont").css({ top: 148-$(this).find("span.function-block-text").height() });
			}
		}
	});
	
	//left nav height
	if( $('.left-nav').height() < $('.inner_center').height() ) { $('.left-nav').height( $('.inner_center').height() ); }
	
	//dynamic login handler
	$('#dynamic-login').hover(
		function() {
			$('.d-login').fadeIn(300);
		},
		function() {
			$('.d-login').fadeOut(200);
			$(".d-login-username").blur();
		}
	);
	
	$('.d-login-pasword').focus(function() {
		$(this).hide();
		$('.d-login-pasword-psw').show().focus();
	});
	
	$('.d-login-pasword-psw').blur(function() {
		if( $(this).val() == '' ) {
			$(this).hide();
			$('.d-login-pasword').show();
		}
	})
	
	var org2 = $(".d-login-username").val();
	$(".d-login-username").focus(function() {
		if( $(this).val() != '') {
			if( $(this).val() == org2  ) {
				$(this).val('');
			}
		}
	}).blur(function() {
		if( $(this).val() == '' ) {
			$(this).val( org2 );
		}
	});
	
	//news letter
	var org3 = $(".news-subsc-form").val();
	$(".news-subsc-form").focus(function() {
		if( $(this).val() != '') {
			if( $(this).val() == org3  ) {
				$(this).val('');
			}
		}
	}).blur(function() {
		if( $(this).val() == '' ) {
			$(this).val( org3 );
		}
	});
	
	
});
