// JavaScript Document

$(document).ready(function() {
	
	jQuery("#formID").validationEngine();
	
	var slideshow = $('#bgslider').cycle({
	fx: 'fade',
	startingSlide: 0,
	timeout: 30000,
	pause: true,
	pager:  '#bgcyclenav',
	speed:  1000
	});
	var slideshow = $('#cycle').cycle({
	fx: 'fade',
	startingSlide: 0,
	timeout: 10000,
	pause: true,
	pager:  '#cyclenav',
	speed:  1000
	});
	
	
	$('.light, .border, .pagecloselight, .felbukkanobtlight').css({opacity: 0 });
	$('.felezo:last-child').css({ marginRight : 0 });
	$('#navigation li:last-child').css({ marginRight : 0 });
	$(".felbukkano").css({ width : 0, height : 0, opacity: 0 });
	$("#pagecontainer").css({ overflow: 'hidden' });
	$("#pagescroll").css({ width: '16000px' });

	
	
	$("#facebookbt").click(function(){
		if( $("#facebook").hasClass('facecurrent') ) {
			$("#facebook").removeClass("facecurrent").stop(true, false).animate({ top: -60},{duration: 400,easing: 'easeOutBack'});
		} else {
			$("#facebook").addClass("facecurrent").stop(true, false).animate({ top: 0},{duration: 400,easing: 'easeOutBounce'});
		}
	});
	
	
	
	$("#navigation li").mouseenter(function(){
		if(!$(this).hasClass('licurrent') ) {
			$(this).stop().animate({ marginTop: 5 },300);
			$(".light",this).stop().animate({ opacity: 1 },300);
	} else {
	}
	});
	$("#navigation li").mouseleave(function(){
		if(!$(this).hasClass('licurrent') ) {
			$(this).stop().animate({ marginTop: 20 },300);
			$(".light",this).stop().animate({ opacity: 0 },300);
	} else {
	}
	});
	
	
	$('#navigation li').click(function(){

		var nav = $(this).index()+1;
		var pagepos = $("#pagescroll .page:nth-child("+(nav)+")").position();
		var scrolltopos = 0-pagepos.left;
		
	$('#cycle').cycle('pause');
	
	$(".light").stop().animate({ opacity: 0 },300);
	$("#navigation li.licurrent").removeClass('licurrent').animate({ marginTop: 20 },300);
	$(this).addClass('licurrent').animate({ marginTop: 5 },300);
	$(".light",this).stop().animate({ opacity: 1 },300);
	$('#banner').stop().animate({ height : 0, opacity: 0},{duration: 400,easing: 'easeOutQuart'});
	$('#pagecontainer').stop().animate({height : 300},{duration: 400,easing: 'easeOutQuart'});
	$('.border').animate({ opacity: 1}, 400);
	if( $("#pagecontainer").innerHeight() > 0 ) {
		$('#pagescroll').stop().animate({left: scrolltopos},900);
		} else{
		$('#pagescroll').stop().delay(800).animate({left: scrolltopos},900);
		}
	});
	
	
	$('.pageclosebt').click(function(){
	
	$('#cycle').cycle('resume'); 

	$("#navigation li.licurrent").removeClass('licurrent').animate({ marginTop: 20 },300);
	$(".light").stop().animate({ opacity: 0 },300);
	$('#banner').stop().delay(300).animate({ height : 300, opacity: 1},{duration: 300,easing: 'easeOutQuart'});
	$('#pagecontainer').stop().delay(300).animate({height : 0},{duration: 300,easing: 'easeOutQuart'}).animate({borderTop: '0px', borderBottom: '0px'},100);
	$('.border').delay(300).animate({ opacity: 0}, 400);
	$('#pagescroll').stop().delay(700).animate({left: 0},0);
	});
	
	
	$(".pageclosebt").mouseenter(function(){
		$(this).stop().animate({ top: 9 },150).animate({ top: 7 },150);
		$(this).children('.pagecloselight').stop().animate({ opacity: 1 },150);
	});
	$(".pageclosebt").mouseleave(function(){
		$(this).stop().animate({ top: 5 },150);
		$(this).children('.pagecloselight').stop().animate({ opacity: 0},150);
	});
	
	$("#page4 a").mouseover(function(){
		$(this).stop().animate({ marginLeft: 10, color: '#FFF' },150).animate({ color: '#999', marginLeft: 5 },150);
	});
	$("#page4 a").mouseout(function(){
	$(this).stop().animate({ marginLeft: 0, color: '#999' },200);
	});
	
	
	$(".felbukkanobt").click(function(){
	
		var title = $(this).attr("title");
		$("#"+(title)+"").animate({  width: '100%', height: '100%'},0).animate({  opacity: 1},300);
		$("#"+(title)+"").children('div').stop().delay(600).animate({ width: 700, paddingTop: 70 , paddingLeft: 50, paddingRight: 50, paddingBottom: 50, border: '1px solid #fff'},300);
		
});

$('.felbukkanoclose').click(function(){
	
		$(this).parent('.felbukkanocontent').stop().animate({ padding: 0, width: 0, border: '0px'},300);
		$(this).parent().parent('.felbukkano').stop().delay(600).animate({  opacity: 0},300).animate({  width: 0, height: 0},0);
		
});

$(".felbukkanobt").mouseenter(function(){
		
		$(".felbukkanobtlight",this).animate({ opacity: 0.8 },150);
		$(this).stop().animate({ marginLeft: 10 },150).animate({ marginLeft: 5 },150);
		
});
	
$(".felbukkanobt").mouseleave(function(){

		$(".felbukkanobtlight",this).animate({ opacity: 0 },150);
		$(this).stop().animate({ marginLeft: 0 },200);
		
});

$(".szerkesztobt").mouseenter(function(){
		
		$(".felbukkanobtlight",this).animate({ opacity: 0.8 },150);
		$(this).stop().animate({ marginLeft: 10 },150).animate({ marginLeft: 5 },150);
		
});
	
$(".szerkesztobt").mouseleave(function(){

		$(".felbukkanobtlight",this).animate({ opacity: 0 },150);
		$(this).stop().animate({ marginLeft: 0 },200);
		
});

$("#bejelentkezeskulcs").click(function(){
		if( $("#bejelentkezes").hasClass('bejcurrent') ) {
			$("#bejelentkezes").removeClass("bejcurrent").stop(true, false).animate({ right: -240},{duration: 400,easing: 'easeOutBack'});
		} else {
			$("#bejelentkezes").addClass("bejcurrent").stop(true, false).animate({ right: 0},{duration: 400,easing: 'easeOutBounce'});
		}
	});


$("body").keydown(function(e) {
  if(e.keyCode == 39) { // left
  	var licurrent = $("#navigation li.licurrent").index()+1;
	
	if( licurrent == 7 ) {
	
	} else{
		
		$(".light").stop().animate({ opacity: 0 },300);
	$("#navigation li.licurrent").removeClass('licurrent').animate({ marginTop: 20 },300).next().addClass('licurrent').animate({ marginTop: 5 },300);
	$("#navigation li.licurrent").children('.light').stop().animate({ opacity: 1 },300);
	
	var licurrent = $("#navigation li.licurrent").index()+1;
		var pagepos = $("#pagescroll .page:nth-child("+(licurrent)+")").position();
		var scrolltopos = 0-pagepos.left;
		$('#pagescroll').stop().animate({left: scrolltopos},900);
		
	}
	
  }
  else if(e.keyCode == 37) { // right
  
  var licurrent = $("#navigation li.licurrent").index()+1;
	
	if( licurrent == 1 ) {
	
	} else{
  
    $(".light").stop().animate({ opacity: 0 },300);
	$("#navigation li.licurrent").removeClass('licurrent').animate({ marginTop: 20 },300).prev().addClass('licurrent').animate({ marginTop: 5 },300);
	$("#navigation li.licurrent").children('.light').stop().animate({ opacity: 1 },300);
	
	var licurrent = $("#navigation li.licurrent").index()+1;
		var pagepos = $("#pagescroll .page:nth-child("+(licurrent)+")").position();
		var scrolltopos = 0-pagepos.left;
		$('#pagescroll').stop().animate({left: scrolltopos},900);
	
	}
	
  }
});




	
	
});
