$(document).ready(function(){
	var x = escape($("#asz_tt > em").html());
	
	$("#asz_tt").html('<object type="application/x-shockwave-flash" data="/misc/tt.swf?t=' + x + '&r=1" width="500" height="170"><param name="movie" value="/misc/tt.swf?t=' + x + '&r=1" /><param name="wmode" value="transparent" /></object>');
	
	
	
	
	$("#asz_menu > ul > li > a").click(
		function() {
			if ($(this).parent().find("ul.ul_level2").length > 0) {				
				if (!$(this).parent("li").hasClass("active_bg")) {			
					$(this).parent().find("ul.ul_level2").slideToggle(100);
				}
				return false;
			}
		}	
	);
	
	$("#asz_menu > ul > li > ul > li > a").click(
		function() {
			/*if ($(this).parent().find("ul.ul_level3").length > 0) {
				$(this).parent().find("ul.ul_level3").slideToggle(100);
				return false;
			}*/
		}	
	);
	
	$("#angyali_app").submit(
		function() {
			$.ajax({
    	   		type: "POST",
 			    dataType: "json",
       			url: "/misc/app/",
			    data: $("#angyali_app").serialize(),
    	   		success: function(response) {
    	   		
    	   		
    	   			if (response.response == 'error') {
    	   			
    	   				$("#angyali_app_feedback").html(' &ndash; ' + response.msg);
    	   				if (response.focus) {
    	   					$("#"+response.focus).focus();
    	   				}
    	   			    	   			
    	   				$("#angyali_app_feedback").show();
    	   			}
    	   			if (response.response == 'mmmkay') {
    	   				$("#angyali_app").hide();
    	   				$("#angyali_app_okay").show();
    	   			}
    	   			
    	   			
       			}
	       	});	
	       	return false;	
		}	
	);
	
	$('#covers').click(function(){
	   window.location = 'http://egiuzenetek.hu/';
	});
	
	var index = 0, tarolo = $('#covers'), changeTime=5000, next = 0;
	
	function kepvalt(index) {
		
		if (next>3) {
		  next = 0;
        }
        
        pos = ((next*100)*-1);
        		
		$(tarolo).stop().animate(
			{backgroundPosition:"("+pos+"px 0)"}, 
			{duration:500});
        
        next++;
	}
	
	var indit = setInterval(function() { kepvalt(next); }, changeTime);
	
	
});
