﻿
/* background image resize */	
function resizeImg() {
	// width & height of browser window
	var winWidth = $(window).width(); 
	var winHeight = $(window).height();
	
	// width & height of main image
	var imgWidth = $('#background_image').width();
	var imgHeight = $('#background_image').height();

	// scaling ratio
	var widthRatio = winWidth / imgWidth;
	var heightRatio = winHeight / imgHeight;

	if(widthRatio > heightRatio) {
		// image is taller
		$('#background_image').width( imgWidth*widthRatio ).height( imgHeight*widthRatio );
		$('body').css({'width':winWidth,'height':winHeight});
		// fixing position
		var numY = (imgHeight*widthRatio - winHeight) / 2 * -1;
		$('#background_image').css({'top': numY, 'left' : 0});	
	}
	else {
		// image is wider 
		$('#background_image').width( imgWidth*heightRatio ).height( imgHeight*heightRatio );
		$('body').css({'width':winWidth,'height':winHeight});
		// fixing position
		var numX = (imgWidth*heightRatio - winWidth) / 2 * -1;	
		$('#background_image').css({'top': 0, 'left' : numX});
	}
}


/*
function show() {
		document.getElementById('body_txt').style.display = 'block';
		document.getElementById('body_txt').style.cursor = 'pointer';
		document.getElementById('body_txt').onclick = hide;
}
*/

function show() {
		
		if(document.getElementById('body_txt').style.display == 'block')
		{
			document.getElementById('body_txt').style.display = 'none';
			//document.getElementById('body_txt').style.cursor = 'pointer';
			//document.getElementById('body_txt').onclick = hide;
		}
		else 
		{
			document.getElementById('body_txt').style.display = 'block';
			document.getElementById('body_txt').style.cursor = 'pointer';
			document.getElementById('body_txt').onclick = hide;
		}
}




function hide() {
	this.style.display = 'none';	
}

/* listing images */
function changeImg(obrazky) {
	currImg = 1;
	var totalImg = obrazky.length;
	$('span.current_image').html('0'+currImg);
	
	if(totalImg > 9) {
		$('span.total_images').html(totalImg);	
	} else {
		$('span.total_images').html('0'+totalImg);	
	}
	
	
	
	
	$('#prevImg').click( function(e) {
		$("div#page_content").append("<img id='preloader' src='../images/layout/preloader.gif' width='150' height='5' border='0' alt='preloader' />");
		if((currImg-1) == 0) {
			currImg = totalImg;
		} else {
			currImg--;
		}
		
		$("#background_image").attr("src", obrazky[currImg-1]).load(function() {$("#preloader").remove();});
		if(currImg > 9) {
			$('.current_image').html(currImg);	
		} else {
			$('.current_image').html('0'+currImg);	
		}
		return false;
	});
	
	$('#nextImg').click( function(e) {
		$("div#page_content").append("<img id='preloader' src='../images/layout/preloader.gif' width='150' height='5' border='0' alt='preloader' />");
		if((currImg+1) > totalImg) {
			currImg = 1;
		} else {
			currImg++;
		}
		$("#background_image").attr("src", obrazky[currImg-1]).load(function() {$("#preloader").remove();});
		if(currImg > 9) {
			$('.current_image').html(currImg);	
		} else {
			$('.current_image').html('0'+currImg);	
		}
		return false;
	});	
	
}	
