/** Background changer start */


$(function(){
	
	function startSlideShow() {
		if($('#backgroundChanger').length) {
			var Arrows = $('\
				<div id="backgroundChangerSwitch">\
					<a href="#" title="Előző" class="backgroundChanger-prev"></a>\
					<a href="#" title="Következő" class="backgroundChanger-next"></a>\
				</div>\
			');
			$('#backgroundChanger')
			//	.after(Arrows)		
				.cycle({
					fx: 'fade',
					timeout: 8000,
					speed: 5000,
					next: '.backgroundChanger-next',
					prev: '.backgroundChanger-prev',
					containerResize: 0,
					fit: 0,
					rev: 0
					
				});
			var status = 1;
			$('#backgroundChanger img').click(function(){
				$('#backgroundChanger').cycle('toggle');
			});
		}
	}
	
	
	$('ul#top_menu li:has(ul li a.active)').first().addClass('top_active');
	
	$('a[rel*=lightbox]').click(function() {
			var element = this;
			var src = $(element).attr('href');
        	var RE = new RegExp('^/');
        	src = src.replace(RE,'');        	
	   		var pictureLightbox = new CalcunLightbox({
	   			src : src,
	   			title : $(element).text(),
    			content: 'image',
                width: 800,
                height: 600
            });
            pictureLightbox.show();
            return false;
	});
	
	/**
	* KARACSONYI UDVOZLOLAP
	*/
	
/*	function forgat(){
		if(window.orientation!=0){
			$("#iphonecont").removeClass("forgatva");
		}
		else{
			$("#iphonecont").addClass("forgatva");
		}
	}
	
	
	
	if(true || (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
		//iphone
				forgat();
				$("#normal").html("");
				var sw=screen.width
		//teszt:
				sw=1024;
		
				if(sw==768 || sw==1024){
					var type="ipad";
					$("#iphone").html("");
				}
				else{
					var type="iphone";
					$("#ipad").html("");
				}
		
				var $id=$("#"+type);
				$id.css("display","block");
				var $id=$("#"+type);
				$id.css("display","block");
				$id.snowfall({
					flakeCount : 20,
					flakeColor : '#ffffff',
					flakeIndex: 999999,
					minSize : 1,
					maxSize : 10,
					minSpeed : 2,
					maxSpeed : 5
				});
		
				$id.find(".alap").fadeIn(2000,function(){
					$id.find(".csikok").fadeIn(2000,function(){
						$id.find(".kor1").fadeIn(1000,function(){
							$id.find(".kor2").fadeIn(1000,function(){						
								$id.find("._2012").fadeIn(2000,function(){
									$id.find(".szoveg").fadeIn(2000,function(){
										$id.find(".logo").fadeIn(2000,function(){
											$id.find(".hopihe1").fadeIn(2000,function(){
												pulzal($(this),4000);
											});
											$id.find(".hopihe2").fadeIn(2500,function(){
												pulzal($(this),3000);
											});
											$id.find(".hopihe3").fadeIn(3000,function(){
												pulzal($(this),2000);
											});
										})
									})
								})
							})
						})
					})						
				});
		
				var supportsOrientationChange = "onorientationchange" in window,
			    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
				window.addEventListener(orientationEvent, function() {
					forgat();
				}, false);
				
					
			}
			else{
			//normal
					$("#iphone").html("");
					$("#ipad").html("");
					$("#normal").css("display","block");
				}

	var wHeight = $(window).height();
	var cHeight = $('#iphonecont').height();	
	var top = parseInt((wHeight - cHeight) / 2);
	$('#iphonecont').css('margin-top', top);
	
	var fatyol = $('<div id="udvozlofatyol"></div>');
	fatyol.css('opacity', 0.8);
	
	
	
	$('#udvozlo').before(fatyol).css({'cursor': 'pointer', 'opacity': 0.8 }).click(function(){
		var udvozlo = $(this);
		$('#udvozlo, #udvozlofatyol').fadeOut(5000, function(){
			$(this).remove();
			startSlideShow();
		})
		return false;
	}).append('<p>Tovább az oldalra >></p>');
	
	
//	
		
	function pulzal($o,ms){
		$o.animate({opacity:0.2}, ms, function(){
			$o.animate({opacity:1}, ms, function(){
				pulzal($o,ms);
			})
		});
	}
	*/
	startSlideShow();	
});

/** Background changer end */
