

(function($){
		
	/* hoverIntent by Brian Cherne */
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
	
})(jQuery);

$(document).ready(function(){
$('#pageholder').hide();

$('.mask').animate({opacity:0},0);
$('.maskborder').animate({opacity:0},0);
$('.hall_th_maskimage').animate({opacity:0},0);
$('.halltitle').animate({bottom:'-40px'},0);
$('#userError,#emailError').hide();
var destroy = function(){
$('#sub2,#sub3,#sub4').hide();
}
destroy();

function sub2Down(){
	$(this).animate({color:'#ffffff','backgroundColor':'rgb(rgb(139,2,2))'},200)
	
	$(this).addClass("hover")

	$('#sub2').fadeIn(300);
	$('#sub2').css({color:'#000000'});
	}
function sub2Up(){	
	$(this).animate({color:'#000000','backgroundColor':'#f9f5ee'},200)
	$(this).removeClass("hover")
	$('#sub2').fadeOut(200);
	
	}
	
function sub3Down(){
	$(this).animate({color:'#ffffff','backgroundColor':'#8b0202'},200)
	$(this).addClass("hover")
	$('#sub3').fadeIn(300);
	$('#sub3').css({color:'#000000'});
	}
function sub3Up(){	
$(this).animate({color:'#000000','backgroundColor':'#f9f5ee'},200)
	$(this).removeClass("hover")
	$('#sub3').fadeOut(200);
	
	}

function sub4Down(){
	$(this).animate({color:'#ffffff','backgroundColor':'#8b0202'},200)
	$(this).addClass("hover")
	$('#sub4').fadeIn(300);
	$('#sub4').css({color:'#000000'});
	}
function sub4Up(){	
$(this).animate({color:'#000000','backgroundColor':'#f9f5ee'},200)
	$(this).removeClass("hover")
	$('#sub4').fadeOut(200);
	
	}
$('#menu2').hoverIntent({over: sub2Down,timeout: 300,out: sub2Up});
$('#menu3').hoverIntent({over: sub3Down,timeout: 300,out: sub3Up});
$('#menu4').hoverIntent({over: sub4Down,timeout: 300,out: sub4Up});

$('#menu1, #menu5').hover(function(){
							 $(this).animate({'color':'#ffffff','backgroundColor':'#8b0202'},200);
							 $(this).children('a').animate({'color':'#ffffff'},200);
							 },function(){
								$(this).animate({'color':'#000000','backgroundColor':'#f9f5ee'},400);
								$(this).children('a').animate({'color':'#000000'},400);
								 
							 })
$('.subItem li').hover(function(){
$(this).animate({color:'#aaaaaa'});
							 }, function(){
								$(this).animate({color:'#000000'});
							 })


$('#login').click(function(){
						   if ($(".login").is(":hidden")) {
$(".login").slideDown({duration:1000,easing:'easeInOutQuint'});
}else{
$(".login").slideUp({duration:1000,easing:'easeOutExpo'});
}
						   });

$('.news_img').hover(function(){
			$(this).children('.mask').animate({opacity:0.5},200);
			$(this).children('.maskborder').animate({opacity:1},400);
							  }, function(){
				$(this).children('.mask').animate({opacity:0},400);
				$(this).children('.maskborder').animate({opacity:0},600);
				}			  
								  )
								  
$('.news_title a').hover(function(){
			$(this).animate({color:'#8b0202'},200);
							  }, function(){
				$(this).animate({color:'#333333'},200);
				}			  
								  )
								  
$('.hall_th').hover(function(){
$(this).children('.hall_th_maskimage').animate({opacity:1},{duration:300,easing:'easeOutExpo'});
$(this).children('.halltitle').animate({bottom:'0px'},250);
}, function(){
$(this).children('.hall_th_maskimage').animate({opacity:0},{duration:150,easing:'easeOutExpo'});
$(this).children('.halltitle').animate({bottom:'-40px'},250);
})	
$('.pagleft').children('img').animate({width:'10px',height:'10px'},0);
$('.pagleftnon').children('img').animate({width:'10px',height:'10px'},0);
$('.pagright').children('img').animate({width:'10px',height:'10px'},0);
$('.pagrightnon').children('img').animate({width:'10px',height:'10px'},0);
$('.pagbutton, .pagselected, .pagleft, .pagright, .pagleftnon, .pagrightnon').hover(function(){
$(this).animate({width:'20px', marginLeft:'-5px', height:'20px', marginTop:'-5px'},150);
$(this).children('img').animate({width:'20px', height:'20px'},150);


}, function(){
$(this).animate({width:'10px',height:'10px', marginLeft:'0px', marginTop:'0px'},200);
$(this).children('img').animate({width:'10px', height:'10px'},200);
})	
$('.event_th').animate({opacity:0.7},0);
$('.event_th').hover(function(){
$(this).animate({opacity:1},300);
},function(){
$(this).animate({opacity:0.7},300);}
)
});
$(window).load(function(){
var bodyheight = document.body.scrollHeight;

//----------------------------------
$('#familyname').focus(function(){

if(document.getElementById('familyname').value=='Vezetéknév'){
document.getElementById('familyname').value='';
}
})
$('#familyname').blur(function() {

if(document.getElementById('familyname').value==''){
document.getElementById('familyname').value='Vezetéknév';
}else{

}
})


$('#nickname').focus(function(){

if(document.getElementById('nickname').value=='Felhasználónév'){
document.getElementById('nickname').value='';
}
})
$('#nickname').blur(function() {

if(document.getElementById('nickname').value==''){
document.getElementById('nickname').value='Felhasználónév';
}else{
checkUser(document.getElementById('nickname').value);
}
})

$('#password').focus(function(){

if(document.getElementById('password').value=='Jelszó'){
document.getElementById('password').type='password';
document.getElementById('password').value='';
}
})
$('#password').blur(function() {

if(document.getElementById('password').value==''){
document.getElementById('password').type='text';
document.getElementById('password').value='Jelszó';
}
})

$('#passwordagain').focus(function(){

if(document.getElementById('passwordagain').value=='Jelszó újra'){
document.getElementById('passwordagain').type='password';
document.getElementById('passwordagain').value='';
}
})
$('#passwordagain').blur(function() {

if(document.getElementById('passwordagain').value==''){
document.getElementById('passwordagain').type='text';
document.getElementById('passwordagain').value='Jelszó újra';
}
}) 

$('#email').focus(function(){

if(document.getElementById('email').value=='Email cím'){
document.getElementById('email').value='';
}
})
$('#email').blur(function() {

var va = document.getElementById('email').value

if(document.getElementById('email').value==''){
document.getElementById('email').value='Email cím';
}
})



$('#forename').focus(function(){

if(document.getElementById('forename').value=='Keresztnév'){
document.getElementById('forename').value='';
}
})
$('#forename').blur(function() {

var va = document.getElementById('forename').value

if(document.getElementById('forename').value==''){
document.getElementById('forename').value='Keresztnév';
}
})

//--------------------------------------

//-------------------------------------
})


function checkUser(usr)
{

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	document.innerHtml=xmlhttp.responseText;
	if(xmlhttp.responseText=='1'){
   $('#userError').fadeIn(200);
   t=1
	}else{
	$('#userError').fadeOut(200);
	t=0
	}
    }
  }
xmlhttp.open("GET","lib/checkUser.php?username="+usr,true);
xmlhttp.send();
}


function checkEmail(em)
{
 var csere = document.getElementById('email').value.replace( " ", "" );
	document.getElementById('email').value=csere;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	document.innerHtml=xmlhttp.responseText;
	if(xmlhttp.responseText=='1'){
   $('#emailError').fadeIn(200);
   t=1
	}else{
	$('#emailError').fadeOut(200);
	t=0
	}
    }
  }
xmlhttp.open("GET","lib/checkEmail.php?email="+em,true);
xmlhttp.send();
}

