$(document).ready (function () {
	
	//$('.DocumentList ul').jScrollPane({showArrows:true, scrollbarWidth:11, scrollbarMargin:0, dragMaxHeight:20});
	
	/* Lekerekítések */
	
	$(".NewsFeed").corner("5px");
	
	$("#sidebar .SideMenu ul li").corner("5px");
	
	$("#sidebar .SideMenu ul li a").corner("5px");
	
	$(".SuperNavigation .box").corner("5px");
	
	$("div.SuperNavigation>ul>li>div").corner("5px");
	
	$(".TextBox").corner("5px");
	
	$("#content").corner("bottom 5px");
	
	$("#content-company").corner("top 5px");
	
	$("#main-content").corner("5px");
	
	$("#groupmates").corner("5px");
	
	$(".img-container").corner("5px");
	
	$(".box").corner("5px");
	
	$("#jobs").corner("5px");
	
	$("#offer").corner("5px");
	
	$("div#content div#rightbar .NewsFeed .circle-img").corner("30px");
	
	$(".firmpic").corner("5px");
	
	$(".firmpic .overlay").corner("5px");
	
	$("div#content div#rightbar .NewsFeed h2").corner("top 5px");
	
	$("div#content div#main-content .PageTitle h1").corner("top 5px");
	
	$("#Brands h2").corner("top 5px");
	
	$("div#main div.content div.NewsFeed h2").corner("top 5px");
	
	$("div.NewsFeed h2").corner("top 5px");
	
	$("div#content div#main-content .PageTitle h2").corner("top 5px");
	
	$(".desc").corner("5px");
	
	$("#jobs h2").corner("top 5px");
	
	$("#offer h2").corner("top 5px");
	
	/* Aloldalon a menü animációja */
	
	$("#menu-toggle").toggle(
      function () {
        $("#nav .LinkList ul").show('slow');
		$(".LinkListLanguage").animate({
			width: '620px'
		}, 1000);
      },
      function () {
        $("#nav .LinkList ul").hide('slow');
		$(".LinkListLanguage").animate({
			width: '1150px'
		}, 1000);
      }
    );

	/* Sidebar accordition */
	
	$('.sidebar .Sectors>ul li.has-children>a').mouseenter(function() {
		if ( ! $(this).parent().hasClass('open')){
			$('.sidebar .Sectors>ul li.has-children').children('ul').hide();
			$('.sidebar .Sectors>ul li.has-children').removeClass('open');
		}
		$(this).parent().children('ul').toggle('slow');
		$(this).parent().toggleClass('open');
		return false;
	}).children('ul').hide();
	
	// Cégcsoport oldal overlay
	
	$("#groupmates .firmpic").mouseenter( function() {
		$(this).children('.overlay').css("display","inline-block");
		$(this).children('.overlay').css("opacity","0.8");
	});
	
	$("#groupmates .firmpic").mouseleave( function() {
		$(this).children('.overlay').css("opacity","0");
	});

	
	// Cégcsoport sidebar
	
	$(".SideMenu .sub").hide();
	
	var path = location.pathname;
	
	$(".SideMenu ul li a").each(function() {
		if ($(this).attr('href') == path){
			$(this).addClass('active');
			if ($(this).parents('.has-children')){
				$(this).parents('.has-children').addClass('open');
				$(this).parents('.sub').show();
			}
		}
	});
	
	$(".SideMenu .has-children a").mouseenter(function() {
		$(this).parent().children("ul.sub").toggle("slow");
		$(this).parent().toggleClass('open');
	});
	
	// hide
	$("a span").hide();


});

// Slideshow - position after resize
$(window).resize(function(){
	/*$('#Slideshow img').css ("top", $('#Slideshow').offset().top+"px");
	$('#Slideshow img').css ("left", $('#Slideshow').offset().left+"px");*/
});

// Open map is dialog

function OpenMap (e) {
		e.preventDefault();
		var $this = $(this);
		var horizontalPadding = 20;
		var verticalPadding = 20;
		$('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
			title: ($this.attr('title')) ? $this.attr('title') : 'Térkép',
			autoOpen: true,
			width: 620,
			height: 420,
			modal: true,
			resizable: false,
			autoResize: false,
			overlay: {
				opacity: 0.5,
				background: "black"
			}
		}).width(620 - horizontalPadding).height(420 - verticalPadding);            
	}

// Slideshow

function slideSwitchNext() {

	if ($('#navigateNext').hasClass("active")) {
	
		$('#navigateNext').removeClass('active');
		var $active = $('#Slideshow img.active');
		$('.Box_Slideshow .navigate p').html($active.attr('alt'));
	
		if ( $active.length == 0 ) $active = $('#Slideshow img:last');

		var $next =  $active.next().length ? $active.next()
							: $('#Slideshow img:first');

		$active.addClass('last-active');
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active.removeClass('active last-active');
				$('#navigateNext').addClass('active');
			});
	}
}

function slideSwitchPrev() {

	if ($('#navigatePrev').hasClass("active")) {

		$('#navigatePrev').removeClass('active');
		var $active = $('#Slideshow img.active');
		$('.Box_Slideshow .navigate p').html($active.attr('alt'));
	
		if ( $active.length == imgCount ) $active = $('#Slideshow img:first');

		var $next =  $active.prev().length ? $active.prev()
							: $('#Slideshow img:last');

		$active.addClass('last-active');
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active.removeClass('active last-active');
				$('#navigatePrev').addClass('active');
			});
	}
}

// Hover

function toggleSprite (selector) {

	jQuery.each(jQuery.browser, function(i) {
  		if($.browser.safari){
			$(selector).bind("mouseover",function(e){	
     			$(this).css ("background-position", "0px -"+($(this).height()+5)+"px");
			});
  		}else{
			$(selector).bind("mouseover",function(e){	
     			$(this).css ("background-position", "0px -"+$(this).height()+"px");
			});
  		}
	});


    $(selector).bind("mouseleave",function(e){	
     	$(this).css ("background-position", "0px 0px");
	});

}

// Popup

function openPopup( url, name, width, height, scroll, resize ) {
    if ( width < 1 ) { width = 600; }
    if ( height < 1 ) { height = 700; }
    if ( scroll == 1 ) { scrollbar = 'yes'; } else { scrollbar = 'no'; }
    if ( resize == 1 ) { resizable = 'no'; } else { resizable = 'no'; }
    
    w=window.open( url, name, 'width='+width+',height='+height+',directories=no,location=no,menubar=no,scrollbars='+scrollbar+',status=yes,resizable='+resizable+',toolbar=no,top=50,left=50' );
    w.focus();

}

// Print page

function PrintPage () {

    PrintWindow = window.open ("", "mywindow1","directories=1,fullscreen=1,location=1,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,width=800,height=600");
    PrintWindow.document.write ($('#content').html ());
    PrintWindow.document.write ('<p style="clear:both">Az oldal az alábbi linken érhető el: '+window.location.href+'</p>');

}

// Input default content del

function delDefault(e,o){
	if ( o.firstTime ) {
			return
	}
	o.firstTime=true;
	o.value="";
}

// Navigation

function ShowPanel (selector) {
	$(".MenuNavigation ul li ul").hide(); 
	ResetSwitch();
	
	if ($("#"+selector).parent().hasClass("first")) {
		$("#"+selector).siblings("a.switch").css("background-position", "0px -38px");
	} else if ($("#"+selector).parent().hasClass("last")) {
		$("#"+selector).siblings("a.switch").css("background-position", "0px -41px");
	} else {
		$("#"+selector).siblings("a.switch").css("background-position", "0px -32px");
	} 	
	$("#"+selector).show();
	$("#"+selector).css("position","absolute");
	$("#"+selector).css("margin-left","209px");
	$("#"+selector).css("top",$(".MenuNavigation").offset().top+"px");

	$(".off").hide(); 
	$("#"+selector.substring(4)).show();
	$("#"+selector.substring(4)).css("top",($(".MenuNavigation").offset().top+3)+"px");
	$("#"+selector.substring(4)).css("left",($(".MenuNavigation").offset().left+748)+"px");

}

function HidePanel (selector) {
	$(".off").hide();
	ResetSwitch();
	$("#"+selector).hide();
}

function ResetSwitch () {

	$("a.switch").css("background-position", "0px 0px");

	$("a.switch").bind("mouseover",function(e){	
     	$(this).css ("background-position", "0px -32px");
	});
    $("a.switch").bind("mouseleave",function(e){	
    	if ($(this).siblings("ul.sub").css("display")=="none") {$(this).css ("background-position", "0px 0px");}
	});
	$(".first a.switch").bind("mouseover",function(e){	
     	$(this).css ("background-position", "0px -38px");
	});
    $(".first a.switch").bind("mouseleave",function(e){	
    	if ($(this).siblings("ul.sub").css("display")=="none") {$(this).css ("background-position", "0px 0px");}
	});
	$(".last a.switch").bind("mouseover",function(e){	
     	$(this).css ("background-position", "0px -41px");
	});
    $(".last a.switch").bind("mouseleave",function(e){	
    	if ($(this).siblings("ul.sub").css("display")=="none") {$(this).css ("background-position", "0px 0px");}
	});
}

// Font-size adjust

function SetFontSize(){  
	var fontsize = $.cookie('FontSize');  
	if(fontsize != null) {  
		fontsize = parseFloat(fontsize);  
		$("div#article_content").css({"font-size":(fontsize)+"px","line-height":(fontsize+7)+"px"});
    	$("div#article_content").find("*").each(function(){$(this).css({"font-size":(fontsize)+"px","line-height":(fontsize+7)+"px"});});
	}  
}   

function FontSizeUp(){  
	var fontsize = (parseFloat($("div#article_content").css("font-size"))+2);
	$("div#article_content").css({"font-size":(fontsize)+"px","line-height":(fontsize+7)+"px"});
    $("div#article_content").find("*").each(function(){$(this).css({"font-size":(fontsize)+"px","line-height":(fontsize+7)+"px"});});
	$.cookie('FontSize', (fontsize), { expires: 7, path: '/'}); 
}  
  
function FontSizeDown(){  
	var fontsize = (parseFloat($("div#article_content").css("font-size"))-2);
	$("div#article_content").css({"font-size":(fontsize)+"px","line-height":(fontsize+7)+"px"});
    $("div#article_content").find("*").each(function(){$(this).css({"font-size":(fontsize)+"px","line-height":(fontsize+7)+"px"});});
	$.cookie('FontSize', (fontsize), { expires: 7, path: '/'}); 
} 