var ie = document.all && (navigator.userAgent.toLowerCase().indexOf("msie") != -1);
var ie6 = document.all && (navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1);

// DOM READY
//===============================================
	$(function() {

	// MENU
	//===============================================
		if ( $("#mainmenu li.sel").length && ! ie6 ) {
			$("#mainmenu li.sel span.animfir").eq(0).delay(200).animate( {height: "36px"}, 1200, "easeOutExpo" );
		}
	
		if ( ie6 ) {
			
			$("#mainmenu").hover(function() {
				$(this).addClass("hover");
			}, function() {
				$(this).removeClass("hover");
			});
			
			$("#mainmenu li").hover(function() {
				
				if ( $(this).hasClass("hirek") ) {
					$(this).addClass("hover hover_hirek");
				} else if ($(this).hasClass("kozosseg")) {
					$(this).addClass("hover hover_kozosseg");
				} else if ($(this).hasClass("szorakozas")) {
					$(this).addClass("hover hover_szorakozas");					
				} else {
					$(this).addClass("hover");
				}
				
			}, function() {
				$(this).removeClass("hover hover_hirek hover_kozosseg hover_szorakozas");
			});
		}
	
		
	
	// CIKK ROTATOR
	//===============================================
		/*
			parameter objektum:
			fadespeed => a ket slide kozotti animacio sebessege, sima jquery-s animacios sebesseg (default: "normal")
			interval => a slideolas sebessege (default: 5000)
			captioneasing => a kephez tartozo szoveg sav animacios fuggvenye
		*/
		if ($("div.cikk_rotator").length) {
			
			$("div.cikk_rotator").cikkrotator({captioneasing: "easeOutExpo"});

			if ( ie6 ) {

				$('div.cikk_rotator div.share').live('mouseover mouseout', function(e) {
					if (e.type == 'mouseover') {
						$(this).addClass("hover");
					} else {
						$(this).removeClass("hover");
					}
				});

			}
			
		}
		
	// GALERIA ROTATOR
	//===============================================
		/*
			parameter objektum:
			fadespeed => a ket slide kozotti animacio sebessege, sima jquery-s animacios sebesseg (default: "normal")
			interval => a slideolas sebessege (default: 5000)
			captioneasing => a kephez tartozo szoveg sav animacios fuggvenye
		*/
		if ($("div.galeria_rotator").length) {
			
			$("div.galeria_rotator").galeriarotator({captioneasing: "easeOutExpo"});

			if ( ie6 ) {

				$('div.galeria_rotator div.share').live('mouseover mouseout', function(e) {
					if (e.type == 'mouseover') {
						$(this).addClass("hover");
					} else {
						$(this).removeClass("hover");
					}
				});

			}
			
		}
        
 	// SZORAKOZAS ROTATOR
	//===============================================
		/*
			parameter objektum:
			fadespeed => a ket slide kozotti animacio sebessege, sima jquery-s animacios sebesseg (default: "normal")
			interval => a slideolas sebessege (default: 5000)
			captioneasing => a kephez tartozo szoveg sav animacios fuggvenye
		*/
		if ($("div.szorakozas_rotator").length) {
			
			$("div.szorakozas_rotator").szorakozasrotator({captioneasing: "easeOutExpo"});
		}
        
 	// SZORAKOZAS JATEK ROTATOR
	//===============================================
		/*
			parameter objektum:
			fadespeed => a ket slide kozotti animacio sebessege, sima jquery-s animacios sebesseg (default: "normal")
			interval => a slideolas sebessege (default: 5000)
			captioneasing => a kephez tartozo szoveg sav animacios fuggvenye
		*/
		if ($("div.szorakozas_jatekok").length) {
			
			$("div.szorakozas_jatekok").szorakozasjatekrotator({captioneasing: "easeOutExpo"});
		}
        
	
	// ANIMGIF PRELOAD
	//===============================================
	
		var _anim_friss = new Image();
		_anim_friss.src = "/static/style/neon/i/_anim_friss.gif";
		var _anim_life = new Image();
		_anim_life.src = "/static/style/neon/i/_anim_life.gif";
		var _anim_fun = new Image();
		_anim_fun.src = "/static/style/neon/i/_anim_fun.gif";
		var _anim_celeb = new Image();
		_anim_celeb.src = "/static/style/neon/i/_anim_celeb.gif";
		var _anim_trend = new Image();
		_anim_trend.src = "/static/style/neon/i/_anim_trend.gif";
		var _anim_lovesex = new Image();
		_anim_lovesex.src = "/static/style/neon/i/_anim_lovesex.gif";
		
		var _anim_bg_twit = new Image();
		_anim_bg_twit.src = "/static/style/neon/i/_anim_bg_twit.gif";
	
	
	// HOZZASZOLAS FORM SLIDE
	//===============================================
		$("div.hozzaszolasok div.new_comment, div.hozzaszolasok_ures div.new_comment")
			.css({ height: "0" })
			.parent()
			.find("a.add_comment")
				.eq(0).click(function(e) {
					e.preventDefault();
					$(this).parent().parent().find("div.new_comment").stop().animate({height: "226px"});
				})
				.end().eq(1).click(function(e) {
					e.preventDefault();
					var $addComment = $("div.hozzaszolasok a.add_comment:eq(0), div.hozzaszolasok_ures a.add_comment:eq(0)");
					var pos = $addComment.offset();
					$('html').animate({scrollTop: pos.top - 20}, function() {
						$addComment.click();
					});
				})
				.end().end().find("a.cancel").click(function(e) {
					e.preventDefault();
					$("div.hozzaszolasok div.new_comment, div.hozzaszolasok_ures div.new_comment").stop().animate({height: "0"});
				});
                
    // CIKK HSZ SZAM KIJELZES
        var num = $(".hozzaszolasok .head .count").attr("rel");
        if (parseFloat(num)) {
            $("#cikk_comment_num").html(num);
        } else {
            $("#cikk_comment_num").html("0"); 
        }
                
                
                
    });
    
   
function tvpopup(what) {
    if (what == "javascript:;") return false;
	width=560;
	height=680;
	LeftPosition=(screen.width)?(screen.width-width)/2:200;
	TopPosition=(screen.height)?(screen.height-height)/2:100;
	winp = open (what, 'tvpopoup', "menubar=no, resizable=1, scrollbars=1, top="+TopPosition+", left="+LeftPosition+", status=no, titlebar=no, toolbar=no, width="+width+", height="+height);
	winp.focus();
} 

// Galeria szavazashoz szukseges fv-k

//ajax hivas a szavazohoz
	var i=1;
	function ajax_hivas(url,post_query,id){
		$.ajax({
		   type: "GET",
		   url: url,
		   data: post_query,
		   success: function(msg){
		   		if(id!=''){
					$("#"+id).html(msg);
					i++;
				}       
		   }
		});	
	}

	function galeria_like(galeria_id, ertek) {
		if (galeria_id) {
			ajax_hivas("index.php","block=neon_galeria_ertekel&ajax=1&galeria_id="+galeria_id+"&ertek="+ertek,"vote");
		}
	}

 
 	var bannernum = {};
	hideAds = function( mode ) {
		var arr = document.getElementsByTagName('iframe');

		for ( var i = 0, il = arr.length; i < il; i++ ) {
			if ( mode ) {
				if( ! bannernum[i] ) bannernum[i] = [arr[i].width,arr[i].height];
				arr[i].width = '0px';
				//arr[i].height = '1px';
			} else {
				try {
				arr[i].width = bannernum[i][0];
				//arr[i].height = bannernum[i][1];
				} catch (e) {}
			}
		}
        
		var arr = document.getElementsByTagName('embed');

		for ( var i = 0, il = arr.length; i < il; i++ ) {
			if ( mode ) {
				if( ! bannernum[i] ) bannernum[i] = [arr[i].width,arr[i].height];
				arr[i].width = '0px';
				//arr[i].height = '1px';
			} else {
				try {
				arr[i].width = bannernum[i][0];
				//arr[i].height = bannernum[i][1];
				} catch (e) {}
			}
		}

		/*@cc_on
		if ( @_jscript_version < 5.7 ) {
			var arrSelect = document.getElementsByTagName('select');
			for ( var e = 0, el = arrSelect.length; e < el; e++) {

				if ( mode ) {
					arrSelect[e].style.visibility = 'hidden';
				} else {
					arrSelect[e].style.visibility = 'visible';
				}

			}
		}
		@*/

	}

function toggleSendLayer(which, obj) {
	var sel = ($(obj).hasClass("sel"));
	if (sel) $(obj).removeClass("sel");
	else $(obj).addClass("sel"); 
	$('#'+which).toggle();
}

function showIt(obj) {
    var box = $(obj).find("> div");
    if (box.hasClass("opacity")) {
        box.removeClass("opacity");
    }
}

function hideIt(obj) {
    var box = $(obj).find("> div");
    if (!box.hasClass("opacity")) {
        if (!box.hasClass("fixed")) {
            box.addClass("opacity");
        }
    }
}

function cikkSubmit(where) {
    $.post('/?block=neon_cikk_kuldes&ajax=1', $('#'+where+"-form").serialize(), function(data) {
        $('#'+where+'-body').replaceWith(data);
        });
}

//Eltuntetjuk az ures hirdetes dobozokat, miutan a Goa bannerek is mar megjelentek
window.onGoa3Invocation = function( response ) {
	
	//Azert kell setTimeout, hogy biztos minden browserben megjelenjen mar a banner, mikor megnezzuk a magassagat.
	setTimeout(function() {
		$('.banner').each(function(i){
			if ($(this).height()<30) {
				$(this).css('display', 'none');
				$(this).html(''); //Ez csak sebesseg miatt. Nem kell nekunk a flash ha ugy se latjuk
			}
		});
	}, 1000);
	
};
