$(document).ready(function() {
	$('.nyomtat').click(function() {
		window.print();
		return false;
	});
	
	
	$(".msg").dialog({
	buttons: {
		"OK" : function () { 
			$(this).dialog("close");	
			document.location.href='/';
		}},
		resizable: false,
		modal: true,
		title: "Üzenet"
	});

	$(".fw_msg").dialog({
	buttons: {
		"OK" : function () { 
			$(this).dialog("close");	
		}},
		resizable: false,
		modal: true,
		title: "Üzenet"
	});
	$("#fw_dialog").dialog({
		title:"Hír továbbküldése E-mailben",
		autoOpen:false
	});
	
	$(".fw a").click(function() {
		var link = $(this);
		$("#fw_dialog").load("/tovabbkuld-ajax?Link="+link.attr("rel"),function() {
			$("#fw_dialog").dialog("open");
			$("#Link").val(link.attr("rel"));
		});
	});
	
	$("#kerdoiv").submit(function() {
		if ($("input[name=1]:checked").size()>0 && $("input[name=3]:checked").size()>0 && $("input[name=4]:checked").size()>0) {
			return true;
		}else{
			alert("Minden kérdésre választ kell adni!");
			return false;
		}
	});
	
	function emailCheck(emailf) {
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailf.val()))
			return (true);
		else{
			alert("Hibás email cím formátum!");
			return (false);
		}
	}
	function strCheck (ez) {
		if (ez.val()!='') {
			return true;
		}else{
			alert("A Név mezőt kötelező kitölteni!");
			return false;
		}


	}
	$("#feliratkozas").submit(function() {
		if (emailCheck($(this).find("#email")) && strCheck($(this).find("#nev"))) {
			return true;
		}else{
			return false;
		}
	});
	
	$("#szotar dt a").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'hideOnContentClick': true
	});
	
	swfobject.embedSWF("/ofc/open-flash-chart.swf", "jarvanygrafikon_swf",
	"690", "250", "9.0.0", "/ofc/expressInstall.swf",
	{"data-file":"/jarvanygrafikon_xml.php","loading":"Adatok betöltése..."});

	swfobject.embedSWF("/ofc/open-flash-chart.swf", "jarvanygrafikon_swf2",
	"690", "250", "9.0.0", "/ofc/expressInstall.swf",
	{"data-file":"/jarvanygrafikon_xml2.php","loading":"Adatok betöltése..."});
	
	swfobject.embedSWF(
	"/ofc/open-flash-chart.swf", "grafikon",
	"690", "400", "9.0.0", "/ofc/expressInstall.swf",
	{"data-file":"/jarvanygrafikon_xml4.php"} );


	swfobject.embedSWF(
	"/ofc/open-flash-chart.swf", "grafikon",
	"690", "400", "9.0.0", "/ofc/expressInstall.swf",
	{"data-file":"/jarvanygrafikon_xml4.php"} );
	
		
	jQuery('a[href*=#]').click(function() {  
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')  
        && location.hostname == this.hostname) {  
            var $target = jQuery(this.hash);  
            $target = $target.length && $target || jQuery('[name='+this.hash.slice(1)+']');  
            if ($target.length) {  
                var targetOffset = $target.offset().top;  
                jQuery('html,body').animate({scrollTop: targetOffset}, 800);  
                return false;  
            }  
        }  
    });


	jQuery("#embed_codes input").click(function() {
		this.select();
	});



	

// FEJLEC	
	var i=0;

	function rotate () {
		switch(i%4){
			case 0:
				$("#header_2").fadeIn("slow");
			break;	

			case 1:
				$("#header_3").fadeIn("slow");
			break;

			case 2:
				$("#header_4").fadeIn("slow");
			break;
			
			case 3:
				$("#header_2").hide();
				$("#header_3").hide();
				$("#header_4").fadeOut("slow");
			break;	
		}
		i++;
	}

	setInterval(rotate,5000);

$("#teszt").hover(function() {
	$("#megyunk").stop().animate({
		top: "0px"
		},300);
});
$("#hirek").hover(function() {
	$("#megyunk").stop().animate({
		top: "-337px"
		},300);
});
$("#influenza").hover(function() {
	$("#megyunk").stop().animate({
		top: "-674px"
		},300);

});
$("#megelozes").hover(function() {
	$("#megyunk").stop().animate({
		top: "-1011px"
		},300);

});
$("#teendok").hover(function() {
	$("#megyunk").stop().animate({
		top: "-1348px"
		},300);
});

   jQuery("a[href^=http]").each(function(){
   if(this.href.indexOf(location.hostname) == -1) {
      jQuery(this).attr({
         target: "_blank"
      });
	}
	});

});