(function($){
	
	$.confirm2 = function(title, msg, url){

		var markup = [
			'<div id="confirmOverlay">',
			'<div id="confirmBox">',
			'<h3>'+title+'</h3>',
			'<p>'+msg,
			'<div id="confirmButtons"><a id="button_ok" class="orange awesome">törlés</a> <a id="button_cancel" class="awesome">mégse</a></div>',
      '</div></div>'
		].join('');
		
		$(markup).hide().appendTo('body').fadeIn();
		//$(markup).appendTo('body');
		toppos = $('#confirmBox').css('top');
		$('#confirmBox').css('top', 0);
		$('#confirmBox').animate({top: toppos},"fast");

	}
					
	$.confirm2.hide = function(){
		$('#confirmOverlay').fadeOut(function(){
			$(this).remove();
		});
	}
	
	$('#button_cancel').live('click', function(){
		$('#confirmOverlay').fadeOut(function(){
			$(this).remove();
			return false;
		});
	});
	
	$('#button_ok').live('click', function(){
			window.location=url;
			return false;
	});
})(jQuery);


var IE = /*@cc_on!@*/false;
var IE6 = (IE && (navigator['appVersion'].indexOf('MSIE 6') > 0)) ? true : false;

var site = function() {

	$(document).ready(function() {

// Confirm box

	$('.confirmthis').click(function(){
    url = $(this).attr("href");
    var title = 'Figyelem!';
    var msg = $(this).attr("title");
    
		$.confirm2(title, msg, url);
    return false;
	});

// Galéria
$("a[rel^='galeria']").prettyPhoto({overlay_gallery: false, show_title: false});

// Táblázatok rendezése
$("table.sortable").tablesorter();

// Tooltip (Pl. fotóknál)
//$('.tt').betterTooltip();

// Klikkelhető táblázatsorok
$("tbody.klikk tr").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
});

	


//=== 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() {
        $(".slides").animate({opacity: 0.0}, "slow", function() {
        
          //Slider Animation
          $(".slides").css({'left' : -image_reelPosition});
          $(".slides").animate({opacity: 1}, "slow", 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

