// JavaScript Document
$(document).ready(function(){
	
	// linqet
	$('#join').click(function(){
		window.location = '/eja';
	});
	
	// forumi
	$('#username').focus(function(){
		$(this).removeClass('empty');
		if($(this).attr('value') == $(this).next().attr('value')) $(this).attr('value', '');
	}).blur(function(){
		if($(this).attr('value') == ''){
			$(this).attr('value', $(this).next().attr('value')); 
			$(this).addClass('empty');
		}
	});
	
	$('#pwdmask').focus(function(){
		$(this).hide();
		$('#password').show().focus();
	});
	
	$('#password').blur(function(){
		if($(this).attr('value') == ''){
			$(this).hide();
			$('#pwdmask').show();
		}
	});

	$('#login').click(function(e){
		e.preventDefault();
		if($('#username').attr('value') == $('#username').next().attr('value')){
			$('#username').focus();
			return false;
		}	
		if($('#password').attr('value') == ''){
			$('#pwdmask').focus();
			return false;
		}
		$('#loginform').submit()
	});
	
	// kerkimi
	$('#kerko').click(function(){
		$('#search').submit();
	});
	
	$('#kw').focus(function(){
		$(this).removeClass('empty');
		if($(this).attr('value') == $(this).next().attr('value')) $(this).attr('value', '');
	}).blur(function(){
		if($(this).attr('value') == ''){
			$(this).attr('value', $(this).next().attr('value')); 
			$(this).addClass('empty');
		}
	});
	
	$('#search').submit(function(){
		if($('#kw').attr('value') == $('#kw').next().attr('value')){
			$('#kw').focus();
			return false;
		}
		var kw = $('#kw').val();
		console.log(kw);
		if(kw.length < 3){
			$('#kw').focus();
			return false;
		}
		return true;
	});
	
	// menyja
	$('#menu_tkz').hover(function(){
			$('#sm_tkz').show();
			$('#menu_tifozat').addClass('menu-tifozat-hover');
		}, 
		function(){
			$('#sm_tkz').hide();
			$('#menu_tifozat').removeClass('menu-tifozat-hover');
		}
	);
	
	// lajmet
	$('#marquee').width(2 * $('#marquee').width()+900);
	$('#marquee').hover(function(){clearTimeout(timerDown);}, function(){marquee();});
	marquee();
	
});

var timerDown;
function marquee(){
		clearTimeout(timerDown);
		$('#newsclip').scrollLeft($('#newsclip').scrollLeft()+1);
		timerDown=setTimeout("marquee()",20);
		if($('#newsclip').scrollLeft()>=$('#marquee').width()-1110){
			//alert("inner="+$('#marquee').innerWidth()+"; width="+$('#marquee').width());
			$('#newsclip').scrollLeft(0);
		}
	}

