



var IE = /*@cc_on!@*/false;
var IE6 = (IE && (navigator['appVersion'].indexOf('MSIE 6') > 0)) ? true : false;

var site = function() {

	$(document).ready(function() {

// === Góltotó teaser ===
 var gtHidden=true;
 var showTeaser = function () {
   $("#gtTeaser").animate({
     right: 0
     }, 300);
     gtHidden=false;
 };
 
 var hideTeaser = function () {
   $("#gtTeaser").animate({
     right: "-400px"
     }, 500);
     gtHidden=true;
 };

$(window).scroll(function () {
  var offset = $("#pagebottom").offset();

  if($("#tartalom_vege").length) offset = $("#tartalom_vege").offset();

  var bingo = $(window).scrollTop()+$(window).height()-offset.top;

 if (bingo > 0 && gtHidden) {
   showTeaser();
 }
 else if((bingo < 0 || $(window).scrollTop()==0) && !gtHidden) {
   hideTeaser();
 }
});

// === góltotó end...


// Táblázatok rendezése
$("table.sortable").tablesorter();

// Tooltip (Fotókatalógus)
$('.tt').betterTooltip();

// Klikkelhető táblázatsorok
$("tbody.klikk tr").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
});

// Facebook

window.fbAsyncInit = function() {
    FB.init({appId: 'your app id', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/hu_HU/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());

//=== slideshow ===

    //$(".paging").show();
    $(".paging a:first").addClass("active");

    var imageWidth = $(".window").width();
    var imageSum = $(".slides img").size();
    
    if(imageSum>0){
    var next=1;
    var prev=imageSum-1;
    var imageReelWidth = imageWidth * imageSum;
    var titles=$('.slides h3').get();
    var subtitles=$('.slides p').get();
    
    //Adjust image reel size
    $(".slides").css({'width' : imageReelWidth});

    $(".felirat").html(titles[0].innerHTML+'<p>'+subtitles[0].innerHTML);
    
    //Paging and Slider
    rotate = function(){

        var imgID = $active.attr("rel") - 1;
        var image_reelPosition = imgID * imageWidth;

        $(".paging a").removeClass('active');
        $active.addClass('active');

        $(".felirat").animate({opacity: 0.0}, "fast", function() {
        
          //Slider Animation
          $(".slides").animate({left: -image_reelPosition}, 300, function() {
           
            next=imgID+1+1;
            next=(next>imageSum)?1:next;
            prev=(imgID<1)?imageSum:imgID;

            $("#gomb_prev").attr('rel',prev);
            $("#gomb_next").attr('rel',next);

            $(".felirat").html(titles[imgID].innerHTML+'<p>'+subtitles[imgID].innerHTML);
            $(".felirat").animate({opacity: 0.7}, "slow" );
          
          });
        
        });
    };

    //Rotation and Timing
    rotateSwitch = function(){
        play = setInterval(function(){
            $active = $('.paging a.active').next();
            if ( $active.length === 0) {
                $active = $('.paging a:first');
            }
            rotate();
        }, 8000);
    };
    rotateSwitch();

    //On Hover (stop/resume rotation)
    $(".slides a").hover(function() {
        clearInterval(play);
    }, function() {
        rotateSwitch();
    });

    //On Click
    $(".paging a, a#gomb_prev, a#gomb_next").click(function(e) {
        e.preventDefault();
        $active = $(this);
        clearInterval(play);
        rotate();
        rotateSwitch();
    });

    // prev-next buttons
    $("#gomb_prev, #gomb_next").hover(
        function() {
          $(this).stop().animate({"opacity": "0.9"}, "fast");
        },
        function() {
          $(this).stop().animate({"opacity": "0.1"}, "slow");
    });

}
//===

		site.initialize();
	});

return {

		// IE fixes
		IEfix: function() {
			if (IE) {
				setTimeout(function() {
				}, 10);
			}
			return false;
		},

		initialize: function() {

			var a = null;
			var obj = null;
			var tmp = null;

			// menü
			setTimeout(function() {
			$('div#menu > ul > li').each(function(i) {
				var sm = $(this).find('div.submenu').eq(0);

					var sm_mi = $(this).find('div.submenu > div.menuitems').eq(0);
					var sm_ad = $(this).find('div.submenu > div.info').eq(0);

					if (sm_ad.find('div.promo').length == 0) {
						sm.append(sm_ad.find('div.keywords'));
						sm_ad.remove();
						sm_ad = Array();
					}

					sm.width( ((sm_mi.length > 0) ? sm_mi.outerWidth(true) : 0) + ((sm_ad.length > 0) ? sm_ad.outerWidth(true) : 0) );

					if ($(this).outerWidth() > sm.outerWidth()) {
						sm.width($(this).outerWidth() - (sm.outerWidth(true) - sm.width()));
					} else {
						if (sm.outerWidth()-$(this).outerWidth() < 48) {
							sm.width($(this).outerWidth() + 48 - (sm.outerWidth(true) - sm.width()));
						}
					}

					if (sm_mi.length > 0) {
						sm_mi.prepend('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');
					}

					var bg = '<div class="bg">';
          bg += '<div class="t" style="left: ' + $(this).outerWidth() + 'px; width: ' + (sm.outerWidth()-$(this).outerWidth() - 33 + 18) + 'px;"></div>';
					bg += '<div class="tr"></div>';
					bg += '<div class="r" style="top: 29px; height: ' + (sm.outerHeight() +  -33+4 - 35+24) + 'px;"></div>';
					bg += '<div class="br" style="top: ' + (sm.outerHeight()-11) + 'px;"></div>';
					bg += '<div class="b" style="top: ' + (sm.outerHeight()-11) + 'px; width: ' + (sm.outerWidth() - 33+10 - 33+18) + 'px;"></div>';
					bg += '<div class="bl" style="top: ' + (sm.outerHeight()-11) + 'px;"></div>';
					bg += '<div class="l" style="height: ' + (sm.outerHeight() - 35+24) + 'px;"></div>';
					bg += '<div class="c" style="width: ' + (sm.outerWidth()-16-20+1) + 'px; height: ' + sm.outerHeight() + 'px;"></div>';
					bg += '</div>';

					sm.append(bg);

			});


			}, 369);
			// menü vége


			// rounded
			//if (!IE6) {
				$('div.cont div.promo').prepend('<div class="tl"></div><div class="bl"></div>');
				$('img.rounded').wrap('<div class="rounded"></div>');
				$('.rounded:parent').append('<div class="tl"></div><div class="bl"></div><div class="tr"></div><div class="br"></div>');
			//}
			// /rounded

			//site.IEfix(); !!!!!!!!

		} // /init

	}
	// /return


}();
// /site

