(function($){
    //Adjust image size
    $.fn.resizenow = function() {
        //Define starting width and height values for the original image
        var startwidth = 1600;
        var startheight = 1064;
        //Define image ratio
        var ratio = startheight/startwidth;
        //Gather browser dimensions
        var browserwidth = $(window).width();
        var browserheight = $(window).height();
        //Resize image to proper ratio
        if ((browserheight/browserwidth) > ratio) {
            $(this).height(browserheight);
            $(this).width(browserheight / ratio);
            $(this).children().height(browserheight);
            $(this).children().width(browserheight / ratio);
        } else {
            $(this).width(browserwidth);
            $(this).height(browserwidth * ratio);
            $(this).children().width(browserwidth);
            $(this).children().height(browserwidth * ratio);
        }
        //Make sure the image stays center in the window
        $(this).children().css('left', (browserwidth - $(this).width())/2);
        $(this).children().css('top', (browserheight - $(this).height())/2);
    };
})(jQuery)



var sizeBig = false;
var sizeInit = true;







function changeSize() {
	if ($(window).width() > 1280) {
	// if (true) {

		/*
		var t=$('#supersize img');
		var initSrc = t.attr('src'); // initial src
		var initPath = initSrc.substring(0, initSrc.lastIndexOf('/')+1); // initial path
		var FileName = initSrc.substring(initSrc.lastIndexOf('/')+1, initSrc.lastIndexOf('.')); // file name without extension
		alert(FileName);
		t.attr('src', initPath + FileName+ 'B.' + /[^.]+$/.exec(initSrc)); //last part is for extension
		*/

		if (!sizeBig) {
			// nagy méret

			$('#hasab_menu').css('width', '244px');
			$('#div_scroll').css('width', '660px');
			$('#div_cont_bg').css('width', '660px');
			$('#div_scroll_padd').css('padding', '0px 50px 10px 50px');
			$('#chef').css('padding', '70px 0px 114px 0'); // 124 lenne a tuti
			$('#chef').css('font-size', '17px');
			$('#chef img').css('width', '276px');
			$('body').css('font-size', '15px');
			$('h1').css('font-size', '18px');
			$('h2').css('font-size', '15px');
			$('.datum').css('font-size', '15px');
			$('#hasab_cont').css('left','244px');
			$('#contact_form').css('background-image','url(/img/front/cont/contact/bg-form-b.png)');
			$('.kep').css('height','420px');
			$('.video').css('height','356px');
			
			

			/*
			$('div.logo-pic img').attr('src', 'tpls/_img/logo-picB.png');
			$('div.logo-text img').attr('src', 'tpls/_img/logo-textB.png');
			$('div.logo-info img').attr('src', 'tpls/_img/logo-infoB.png');

			$('div.siteItem').css('padding-left', '147px');
			$('div.siteItem').css('padding-top', '92px');
			$('div.siteItem').css('font-size', '25px');
			$('div.siteItem').css('line-height', '27px');
			*/

			sizeBig = true;

		}

	} else {

		if ((sizeBig) || (sizeInit)) {
			// kis méret
			
			$('#hasab_menu').css('width', '139px');
			$('#div_scroll').css('width', '500px');
			$('#div_cont_bg').css('width', '500px');
			$('#div_scroll_padd').css('padding', '0px 30px 10px 30px');
			$('#chef').css('padding', '50px 0 71px 0'); // 81 px lenne a jó, ha pont képpel kezdődik...
			$('#chef').css('font-size', '15px');
			$('#chef img').css('width', '220px');
			$('body').css('font-size', '13px');
			$('h1').css('font-size', '16px');
			$('h2').css('font-size', '14px');
			$('.datum').css('font-size', '14px');
			$('#hasab_cont').css('left','139px');
			$('#contact_form').css('background-image','url(/img/front/cont/contact/bg-form.png)');
			$('.kep').css('height','330px');
			$('.video').css('height','280px');
			
			
			/*
			$('div.logo-pic img').attr('src', 'tpls/_img/logo-pic.png');
			$('div.logo-text img').attr('src', 'tpls/_img/logo-text.png');
			$('div.logo-info img').attr('src', 'tpls/_img/logo-info.png');

			$('div.siteItem').css('padding-left', '84px');
			$('div.siteItem').css('padding-top', '57px');
			$('div.siteItem').css('font-size', '16px');
			$('div.siteItem').css('line-height', '18px');
			*/
			
			sizeBig = false;
			sizeInit = false;

		}
	}

}

/*
function changeBg(fileName) {
	if (sizeBig) {
		bgType = "big_";
	} else {
		bgType = "mid_";
	}
	$('#supersize img').attr('src', 'http://www.bloodmountain.org/pics/item/'+bgType+fileName);
}
*/





/*
$(document).ready(function() {
	$("a.zoom").fancybox();
	
	$('div.siteItem a').mouseover(function(){
		$('div.siteItem a').each(function(){
			$(this).css('color', '#b0b1b1');
		});
		$(this).css('color', 'black');
	});
	changeSize();
});
*/

function scrollresize() {
	
	
	var pane = $('.scroll-pane');
	pane.jScrollPane(
		{
			showArrows: false
		}
	);
	
	
	var api = pane.data('jsp');
	
	var throttleTimeout;
	
	if ($.browser.msie) {
		// IE fires multiple resize events while you are dragging the browser window which
		// causes it to crash if you try to update the scrollpane on every one. So we need
		// to throttle it to fire a maximum of once every 50 milliseconds...
		if (!throttleTimeout) {
			throttleTimeout = setTimeout(
				function() {
					
										
					api.reinitialise();
					throttleTimeout = null;
					if (sizeBig) {
						$('.jspVerticalBar').css('width', '14px');
						// ha van görgetősáv, akkor annak szélességével toljuk balra a nyelvválasztót és a láblécet
						if (api.getIsScrollableV()) {
							$('#lang').css('right', '29px');
							$('#foot').css('right', '29px');
						}else{
							$('#lang').css('right', '15px');
							$('#foot').css('right', '15px');
						}
					}else{
						$('.jspVerticalBar').css('width', '9px');
						// ha van görgetősáv, akkor annak szélességével toljuk balra a nyelvválasztót és a láblécet
						if (api.getIsScrollableV()) {
							$('#lang').css('right', '24px');
							$('#foot').css('right', '24px');
						}else{
							$('#lang').css('right', '15px');
							$('#foot').css('right', '15px');
						}
					}
				},
				50
			);
		}
	} else {
		
		api.reinitialise();
		if (sizeBig) {
			$('.jspVerticalBar').css('width', '14px');
			// ha van görgetősáv, akkor annak szélességével toljuk balra a nyelvválasztót és a láblécet
			if (api.getIsScrollableV()) {
				$('#lang').css('right', '29px');
				$('#foot').css('right', '29px');
			}else{
				$('#lang').css('right', '15px');
				$('#foot').css('right', '15px');
			}
		}else{
			$('.jspVerticalBar').css('width', '9px');
			// ha van görgetősáv, akkor annak szélességével toljuk balra a nyelvválasztót és a láblécet
			if (api.getIsScrollableV()) {
				$('#lang').css('right', '24px');
				$('#foot').css('right', '24px');
			}else{
				$('#lang').css('right', '15px');
				$('#foot').css('right', '15px');
			}
		}
		
		
	}
}



