function rotate_logos() {
	var logok = $('#sponsors_div ul li');
	logok.eq(0).animate({
			marginLeft: -logok.eq(0).outerWidth(),
			opacity: 0
		},{
			duration: 2000,
			easing: 'easeOutExpo',
			queue: false,
			complete: function() {
				$(this).parent().append($(this).clone().css({
					marginLeft: 0,
					opacity: 1
				}));
				$(this).remove();
				rotate_logos();
			}
		}
	);
};
function show_popup() {
	//popup_under
	$('#popup_under_div').css({
		"opacity": "0.7"
	});
	$('#popup_under_div').fadeIn('slow');
	//popup
	var mainWidth = $('#main').width();
	var mainHeight = $('#main').height();
	var popupWidth = $('#popup_div').width();
	var popupHeight = $('#popup_div').height();
	/*if (menu=='') {
		$('#popup_div').css({
			"position": "absolute"
			,"left": mainWidth/2-660/2
			,"top": -100
			,"width": 660
			,"background": "white url(img/papir_hatter.jpg) top no-repeat"
		});
	} else {*/
		$('#popup_div').css({
			"position": "absolute"
			,"left": mainWidth/2-popupWidth/2
			,"top": mainHeight/2-popupHeight/2
		});
	/*}*/
	if (220 + $('#popup_div').height() > $('body').height()) $('body').css({"height": 220 + $('#popup_div').height()});
	$('#popup_div').fadeIn('slow');
};
function close_popups() {
	$('#popup_under_div').fadeOut('slow');
	$('.popup_div_class').fadeOut('slow');
	$('body').css({
		"height": "100%"
	});
};

var act_vid = 0;

var menus = new Array();
menus.push({
	name: 'program', x: 310
});
menus.push({
	name: 'helyszin', x: 405
});
menus.push({
	name: 'video', x: 500
});
menus.push({
	name: 'videotar', x: 565
});
menus.push({
	name: 'golden', x: 740
});
menus.push({
	name: 'face', x: 875
});

function hover_menu(i) {
	/*for(var j in menus) if (j!=i) {
		$('#menu_'+menus[j].name).stop(true, true).animate({
			'left': menus[j].x - ((Math.abs(i-j)<3)?Math.floor(10/(i-j)):0)
		},'fast');
	}*/
	$('#menu_'+menus[i].name+'_akt').stop(true, true).fadeTo('fast',1);
	$('#menu_'+menus[i].name+'_inakt').stop(true, true).fadeTo('fast',0);
};
function unhover_menu(i) {
	/*for(var j in menus) {
		$('#menu_'+menus[j].name).stop(true, true).animate({
			'left': menus[j].x,
		},'fast');
	}*/
	$('#menu_'+menus[i].name+'_akt').stop(true, true).fadeTo('fast',0);
	$('#menu_'+menus[i].name+'_inakt').stop(true, true).fadeTo('fast',1);
};
function select_day(d) {
	$('#nap_link_'+d).addClass('aktiv_link');
	$('#nap_link_'+(27+28-d)).removeClass('aktiv_link');
	$('#nap_lista_'+d).show();
	$('#nap_lista_'+(27+28-d)).hide();
	$('.program_reszletek_class').hide();
	return false;
};
function select_program(p) {
	$('.program_reszletek_class').hide();
	$('#program_reszletek_'+p).show();
	$('.program_nyito_ikon_class').attr('src','img/program_nyito.png');
	$('#program_nyito_ikon_'+p).attr('src','img/program_zaro.png');
	return false;
};
function open_program(p) {
	$('.leiras_popup_class').hide();
	$('#leiras_popup_'+p).css({"margin-top": -$('#leiras_popup_'+p).height()/2});
	$('#leiras_popup_'+p).show();
	return false;
};
function close_program() {
	$('.leiras_popup_class').hide();
	return false;
};
$(document).ready(function() {
	DD_belatedPNG.fix('.frame');
	//
	$('#menu_'+menus[0].name).hover(function() {hover_menu(0);},function() {unhover_menu(0);});
	$('#menu_'+menus[1].name).hover(function() {hover_menu(1);},function() {unhover_menu(1);});
	$('#menu_'+menus[2].name).hover(function() {hover_menu(2);},function() {unhover_menu(2);});
	$('#menu_'+menus[3].name).hover(function() {hover_menu(3);},function() {unhover_menu(3);});
	$('#menu_'+menus[4].name).hover(function() {hover_menu(4);},function() {unhover_menu(4);});
	$('#menu_'+menus[5].name).hover(function() {hover_menu(5);},function() {unhover_menu(5);});
	//
	$('.close_icon').click(function() {close_popups();this.blur();return false;});
	$('#popup_under_div').click(function() {close_popups();this.blur();return false;});
	$('.popup_clickzone').click(function() {show_popup();this.blur();return false;});
	//
	$('.program_reszletek_class').each(function(index) {
		$(this).css({"top": 190-$(this).height()/2});
	});
	//
	$('#video_prev_button').click(function() {
		if (act_vid>0) {
			act_vid--;
			$('#video_thumbs_div').animate({marginLeft: -165*act_vid}, 500);
		}
		this.blur();
		return false;
	});
	$('#video_next_button').click(function() {
		if (act_vid<max_act_vid) {
			act_vid++;
			$('#video_thumbs_div').animate({marginLeft: -165*act_vid}, 500);
		}
		this.blur();
		return false;
	});
	//
	setTimeout(rotate_logos,5000);
	//
	//if (menu=='') show_popup();
});
