var $class = function(def) {
	 // pokud není konstruktor definován, použijeme nový (nechceme použít zděděný)
	 var constructor = def.hasOwnProperty('constructor') ? def.constructor : function() { };
	 // proces vytváření třídy rozdělíme do kroků
	 for (var name in $class.Initializers) {
		  $class.Initializers[name].call(constructor, def[name], def);
	 }
	 return constructor;
};

$class.Initializers = {
	 Extends: function(parent) {
		  if (parent) {
				var F = function() { };
				this._superClass = F.prototype = parent.prototype;
				this.prototype = new F;
		  }
	 },

	 Mixins: function(mixins, def) {
		  // kostruktoru přidáme metodu mixin
		  this.mixin = function(mixin) {
				for (var key in mixin) {
					 if (key in $class.Initializers) continue;
					 this.prototype[key] = mixin[key];
				}
				this.prototype.constructor = this;
		  };
		  // a přidanou metodu hned využijeme pro rozšíření prototype
		  var objects = [def].concat(mixins || []);
		  for (var i = 0, l = objects.length; i < l; i++) {
				this.mixin(objects[i]);
		  }
	 }
};

function include (filename) {
    var d = this.window.document;
    var isXML = d.documentElement.nodeName !== 'HTML' || !d.write; // Latter is for silly comprehensiveness
    var js = d.createElementNS && isXML ? d.createElementNS('http://www.w3.org/1999/xhtml', 'script') : d.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', filename);
    js.setAttribute('defer', 'defer');
    d.getElementsByTagNameNS && isXML ?
        (d.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'head')[0] ?
            d.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'head')[0].appendChild(js) :
            d.documentElement.insertBefore(js, d.documentElement.firstChild) // in case of XUL
        ):
        d.getElementsByTagName('head')[0].appendChild(js);
    // save include state for reference by include_once
    var cur_file = {};
    cur_file[this.window.location.href] = 1;

    // BEGIN REDUNDANT
    this.php_js = this.php_js || {};
    // END REDUNDANT
    if (!this.php_js.includes) {
        this.php_js.includes = cur_file;
    }
    if (!this.php_js.includes[filename]) {
        this.php_js.includes[filename] = 1;
    } else {
        this.php_js.includes[filename]++;
    }

    return this.php_js.includes[filename];
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

include("/data/js/dfx_essentials.js", "js");
addLoadEvent(main);

var dfE;



/******************************************************************************************************************************
	MAIN ONLOAD
*******************************************************************************************************************************/

var carBox;
var loaded = false;;

function main(){

	if(typeof(dfE) != 'object')	dfE = new DfxEssentials();

	dfE.getObject('imgContainer').innerHTML = '1';
	hidePreloader();

	if(!empty(dfE.getObject('homepage'))) hpAnimationFade();
	if(!empty(dfE.getObject('bakery'))) bkAnimationFade();
	if(!empty(dfE.getObject('food'))){
		dfE.setOpacity('imgBoxA1', 100);
		//dfE.setOpacity('imgBoxA3', 100);
	}

	if(!empty(dfE.getObject('contact'))){
		carBox = dfE.getObject('carBox');
		setTimeout('contCarMove()', 3000);
	}
	/*showStatBox();*/
	

}








/******************************************************************************************************************************
	BAKERY IMAGE TRASITIONS
*******************************************************************************************************************************/
var fadeImg = new Array();

function bkAnimationFade(){
	var fadeTime = new Array();

	for(i = 1; i <= 5; i++){
		setTimeout('fadeBk('+i+')', ((randomInt(1, 5) ) * 1250 * i));
	}
}
function fadeBk(imgId){
	do{
		num = randomInt(1, 54);
		num = (num < 10 ? '0' + num : num);
	} while (in_array(num, fadeImg, false))
	fadeImg[imgId] = num;

	var currPhoto = dfE.getObject('bkr-img-0' + imgId);
	var nextPhoto = dfE.getObject('bkr-img-0' + imgId + 'a');

	var sizes = new Array();
	sizes[1] = 356;
	sizes[2] = 128;
	sizes[3] = 292;
	sizes[4] = 156;
	sizes[5] = 292;



	nextPhoto.src = '/data/img/bakery/' + sizes[imgId] + '/' + fadeImg[imgId] + '.jpg';

	currPhoto.style.zIndex = '1';
	nextPhoto.style.zIndex = '10';
	dfE.setOpacity('bkr-img-0' + imgId + 'a', 0);
	nextPhoto.style.display = "block";
	dfE.fadeObject('bkr-img-0' + imgId + 'a', 0, 100, fd_log_slow);

	setTimeout('finishBkFade(' + imgId + ')', 1500);
}
function finishBkFade(imgId){
	var currPhoto = dfE.getObject('bkr-img-0' + imgId);
	var nextPhoto = dfE.getObject('bkr-img-0' + imgId + 'a');

	currPhoto.src = nextPhoto.src;
	nextPhoto.style.display = 'none';

	setTimeout('fadeBk('+imgId+')', (randomInt(2, 9) * 1300));
}

/******************************************************************************************************************************
	HOMEPAGE
*******************************************************************************************************************************/

function hpAnimationFade(){setInterval('fadeHp()', 3000);}

var hpImg = 1
var fd_log_slow = new Array();
	fd_log_slow['diff'] = 1.1;
	fd_log_slow['multiply'] = 1.4;
	fd_log_slow['graph'] = 'log';

function fadeHp(){

	if(hpImg == 4){
		hpImg = 0;
		prevImg = 4;
	} else {
		prevImg = hpImg;
	}
	hpImg++;

	var currPhoto = dfE.getObject('hp-photo' + prevImg);
	var nextPhoto = dfE.getObject('hp-photo' + hpImg);


		currPhoto.style.zIndex = '1';
		nextPhoto.style.zIndex = '10';
		dfE.setOpacity('hp-photo' + hpImg, 0);
		nextPhoto.style.display = "block";
		dfE.fadeObject('hp-photo' + hpImg, 0, 100, fd_log_slow);


	finishFade = function() {
		currPhoto.style.display = 'none';
	}
	setTimeout('finishFade()', 2200);
}


/******************************************************************************************************************************
	FOOD
*******************************************************************************************************************************/

var meniOver = new Array();

function showMniItem(eventObj, id, section, botStart, title, descr, prTitle1, prCont1, prTitle2, prCont2, prTitle3, prCont3, prTitle4, prCont4, prTitle5, prCont5){

var folder;
var boxId;

fd_log_fast = new Array();
fd_log_fast['diff'] = 3;
fd_log_fast['multiply'] = 6;
fd_log_fast['graph'] = 'log';

if(meniOver[id] != true){
	meniOver[id] = true;

	//Prebarveni textu v Meni
	node = eventObj.firstChild;
	while(!empty(node)){
		if(node.nodeName == 'P' || node.nodeName == 'p'){
			node.style.color = "#000";
		} else {
			if((node.nodeName == 'DIV' || node.nodeName == 'div') && node.className == 'boxPrices'){
				child = node.firstChild;
				while(!empty(child)){
					if(child.nodeName == 'DIV' || child.nodeName == 'div'){
						child2 = child.firstChild;
						while(!empty(child2)){
							if(child2.nodeName == 'P' || child2.nodeName == 'p'){
								child2.style.color = "#000";
							}
							child2 = child2.nextSibling;
						}
					}
					child = child.nextSibling;
				}
			}
		}
		node = node.nextSibling;
	}


	// >>> CREATE NEW IMAGE BOX =============================================================
	if(empty(botStart) || id < botStart ){
		folder = '315';
		boxId = 1;
	} else {
		folder = '270';
		boxId = 3;
	}


	folder = '315';
	boxId = 1;
	if(empty(dfE.getObject('meniDesc' + id))){

		var imgBox = document.createElement('div');
		imgBox.className = 'imgbox' + boxId;
		imgBox.id = 'meniDesc' + id;

			var photo = document.createElement('img');
			photo.src = '/data/img/food/' + section + '/' + folder + '/' + id + '.jpg';
			photo.setAttribute('alt', 'Bakeshop.cz : Food > ' + title);
			imgBox.appendChild(photo);

				var boxTitle = document.createElement('p');
				boxTitle.innerHTML = title;
				boxTitle.className = 'boxTitle';

				var boxDescr = document.createElement('p');
				boxDescr.className = 'boxDescr';
				boxDescr.innerHTML = descr;

			var boxText = document.createElement('div');
			boxText.className = 'boxText'
			boxText.appendChild(boxTitle);
			boxText.appendChild(boxDescr);

			var boxPrices = document.createElement('div');
			boxPrices.className = 'boxPrices';

			var boxPriceTit = document.createElement('div');
			boxPriceTit.className = 'boxPriceTit';
			var boxPrice = document.createElement('div');
			boxPrice.className = 'boxPrice';			
			
				
			if(!empty(prTitle1)){
				var priceT = document.createElement('p');
				priceT.innerHTML = prTitle1;

				var price = document.createElement('p');
				price.innerHTML = prCont1;

				boxPriceTit.appendChild(priceT);
				boxPrice.appendChild(price);
			}
			if(!empty(prTitle2)){
				var priceT2 = document.createElement('p');
				priceT2.innerHTML = prTitle2;

				var price2 = document.createElement('p');
				price2.innerHTML = prCont2;

				boxPriceTit.appendChild(priceT2);
				boxPrice.appendChild(price2);
			}
			if(!empty(prTitle3)){
				var priceT3 = document.createElement('p');
				priceT3.innerHTML = prTitle3;

				var price3 = document.createElement('p');
				price3.innerHTML = prCont3;

				boxPriceTit.appendChild(priceT3);
				boxPrice.appendChild(price3);
			}
			if(!empty(prTitle4)){
				var priceT4 = document.createElement('p');
				priceT4.innerHTML = prTitle4;

				var price4 = document.createElement('p');
				price4.innerHTML = prCont4;

				boxPriceTit.appendChild(priceT4);
				boxPrice.appendChild(price4);
			}
			if(!empty(prTitle5)){
				var priceT5 = document.createElement('p');
				priceT5.innerHTML = prTitle5;

				var price5 = document.createElement('p');
				price5.innerHTML = prCont5;

				boxPriceTit.appendChild(priceT5);
				boxPrice.appendChild(price5);
			}

			boxPrices.appendChild(boxPriceTit);
			boxPrices.appendChild(boxPrice);

			boxText.appendChild(boxPrices);
		
			imgBox.appendChild(boxText);

			imgBox.style.opacity = .0;
			imgBox.style.msFilter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + 0 + ")";
			imgBox.style.filter = 'alpha(opacity=' + 0 + ')';

			dfE.getObject('food').appendChild(imgBox);
	}


	dfE.fadeObject('meniDesc' + id, null, 100, fd_log_fast);

	setTimeout('hideImgBox(' + boxId + ')', 100);

	folder = '270';
	boxId = 3;
	if(empty(dfE.getObject('meniDesca' + id))){

		var imgBoxa = document.createElement('div');
		imgBoxa.className = 'imgbox' + boxId;
		imgBoxa.id = 'meniDesca' + id;

			var photoa = document.createElement('img');
			photoa.src = '/data/img/food/' + section + '/' + folder + '/' + id + '.jpg';
			photoa.setAttribute('alt', 'Bakeshop.cz : Food > ' + title);
			imgBoxa.appendChild(photoa);

				var boxTitlea = document.createElement('p');
				boxTitlea.innerHTML = title;
				boxTitlea.className = 'boxTitle';

				var boxDescra = document.createElement('p');
				boxDescra.className = 'boxDescr';
				boxDescra.innerHTML = descr;

			var boxTexta = document.createElement('div');
			boxTexta.className = 'boxText'
			boxTexta.appendChild(boxTitlea);
			boxTexta.appendChild(boxDescra);

			var boxPricesa = document.createElement('div');
			boxPricesa.className = 'boxPrices';

			var boxPriceTita = document.createElement('div');
			boxPriceTita.className = 'boxPriceTit';
			var boxPricea = document.createElement('div');
			boxPricea.className = 'boxPrice';	

			if(!empty(prTitle1)){
				var priceTa = document.createElement('p');
				priceTa.innerHTML = prTitle1;

				var pricea = document.createElement('p');
				pricea.innerHTML = prCont1;

				boxPriceTita.appendChild(priceTa);
				boxPricea.appendChild(pricea);
			}
			if(!empty(prTitle2)){
				var priceT2a = document.createElement('p');
				priceT2a.innerHTML = prTitle2;

				var price2a = document.createElement('p');
				price2a.innerHTML = prCont2;

				boxPriceTita.appendChild(priceT2a);
				boxPricea.appendChild(price2a);
			}
			if(!empty(prTitle3)){
				var priceT3a = document.createElement('p');
				priceT3a.innerHTML = prTitle3;

				var price3a = document.createElement('p');
				price3a.innerHTML = prCont3;

				boxPriceTita.appendChild(priceT3a);
				boxPricea.appendChild(price3a);
			}
			if(!empty(prTitle4)){
				var priceT4a = document.createElement('p');
				priceT4a.innerHTML = prTitle4;

				var price4a = document.createElement('p');
				price4a.innerHTML = prCont4;

				boxPriceTita.appendChild(priceT4a);
				boxPricea.appendChild(price4a);
			}
			if(!empty(prTitle5)){
				var priceT5a = document.createElement('p');
				priceT5a.innerHTML = prTitle5;

				var price5a = document.createElement('p');
				price5a.innerHTML = prCont5;

				boxPriceTita.appendChild(priceT5a);
				boxPricea.appendChild(price5a);
			}

			boxPricesa.appendChild(boxPriceTita);
			boxPricesa.appendChild(boxPricea);

			boxTexta.appendChild(boxPricesa);
			imgBoxa.appendChild(boxTexta);


		imgBoxa.style.opacity = .0;
		imgBoxa.style.msFilter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + 0 + ")";
		imgBoxa.style.filter = 'alpha(opacity=' + 0 + ')';

		dfE.getObject('food').appendChild(imgBoxa);
	}

	dfE.fadeObject('meniDesca' + id, null, 100, fd_log_fast);
    
	}
	setTimeout('hideImgBox(' + boxId + ')', 100);
    

}
function hideImgBox(boxId){
	fd_log_fast = new Array();
	fd_log_fast['diff'] = 3;
	fd_log_fast['multiply'] = 6;
	fd_log_fast['graph'] = 'log';
	
	dfE.fadeObject('imgBoxA' + boxId, null, 0, fd_log_fast);
}


var objOver = new Array();

function hideMniItem(id, obj, botStart){
    
    
	if(empty(botStart) || id < botStart){
		folder = '315';
		boxId = 1;
	} else {
		folder = '270';
		boxId = 3;
	}

	meniOver[id] = false;
	objOver[id] = obj;

	setTimeout('hideMniItem2(' + id + ', ' + boxId + ')', 100);
    
}

function hideMniItem2(id, boxId){
	if(meniOver[id] == false){

		obj = objOver[id];
		node = obj.firstChild;
		
		while(!empty(node)){
			if(node.nodeName == 'P' || node.nodeName == 'p'){
				if(node.className == 'meniItem'){
					node.style.color = "#f4f4ea";
				} else {
					node.style.color = "#55544f";
				}
			} else {
				if((node.nodeName == 'DIV' || node.nodeName == 'div') && node.className == 'boxPrices'){
					child = node.firstChild;
					while(!empty(child)){
						if(child.nodeName == 'DIV' || child.nodeName == 'div'){
							child2 = child.firstChild;
							while(!empty(child2)){
								if(child2.nodeName == 'P' || child2.nodeName == 'p'){
									child2.style.color = "#55544f";
								}
								child2 = child2.nextSibling;
							}
						}
						child = child.nextSibling;
					}
				}
			}
			node = node.nextSibling;
		}
		
		dfE.fadeObject('meniDesc' + id, null, 0, fd_log_fast);
		dfE.fadeObject('meniDesca' + id, null, 0, fd_log_fast);

		//dfE.fadeObject('imgBoxA' + boxId, null, 100, fd_log_fast);
		dfE.fadeObject('imgBoxA1', null, 100, fd_log_fast);
		dfE.fadeObject('imgBoxA3', null, 100, fd_log_fast);

		setTimeout('finishHide(' + id + ')', 500);
	}
}

function finishHide(id){
	if(meniOver[id] == false){
		dfE.RemObj('meniDesc' + id);
		dfE.RemObj('meniDesca' + id);
		meniOver[id] = false;
	}

}


var foodImgArr;
function fadeFood(imgId){
	var sections = new Array();
	sections[1] = 'bread';
	sections[2] = 'spreads';
	sections[3] = 'croissants';
	sections[4] = 'muffins';
	sections[5] = 'quiche-savory-pies';
	sections[6] = 'soups';
	sections[7] = 'other';
	sections[8] = 'sandwiches';
	sections[9] = 'toastini';
	sections[10] = 'salads';
	sections[11] = 'cakes';
	sections[12] = 'tarts-tortes-and-pies';
	sections[13] = 'loaf-cakes';
	sections[14] = 'sweets-n-stuff';
	sections[15] = 'drinks';
	sections[16] = 'fresh-press';
	sections[17] = 'merchandise';


	var imgQuant = new Array();
	imgQuant[1] = 15;
	imgQuant[2] = 5;
	imgQuant[3] = 6;
	imgQuant[4] = 5;
	imgQuant[5] = 8;
	imgQuant[6] = 8;
	imgQuant[7] = 11;
	imgQuant[8] = 23;
	imgQuant[9] = 4;
	imgQuant[10] = 26;
	imgQuant[11] = 12;
	imgQuant[12] = 11;
	imgQuant[13] = 10;
	imgQuant[14] = 9;
	imgQuant[15] = 29;
	imgQuant[16] = 5;
	imgQuant[17] = 10;

	var sizes = new Array();
	sizes[1] = 356;
	sizes[2] = 128;
	sizes[3] = 292;
	sizes[4] = 156;
	sizes[5] = 300;

	// >>> Nahodny los fotek
	do{
		folderId = randomInt(1, 17);
		pictId = randomInt(1, imgQuant[folder])
	} while (in_array(pictId, fdImgArr, false) && in_array(folderId, fdFolderArr, false))

	fdImgArr[imgId] = pictId;
	fdFolderArr[imgId] = folderId;

	var currPhoto = dfE.getObject('bkr-img-0' + imgId);



	// >>> CREATE NEW IMAGE BOX =============================================================

	if(empty(dfE.getObject('meniDesc' + id))){

		var imgBox = document.createElement('div');
		imgBox.className = 'imgbox' + boxId;
		imgBox.id = 'meniDesc' + id;

			var photo = document.createElement('img');
			photo.src = '/data/img/food/' + section + '/' + folder + '/' + id + '.jpg';
			photo.setAttribute('alt', 'Bakeshop.cz : Food > ' + title);
			imgBox.appendChild(photo);

				var boxTitle = document.createElement('p');
				boxTitle.innerHTML = title;
				boxTitle.className = 'boxTitle';

				var boxDescr = document.createElement('p');
				boxDescr.className = 'boxDescr';
				boxDescr.innerHTML = descr;

			var boxText = document.createElement('div');
			boxText.className = 'boxText'
			boxText.appendChild(boxTitle);
			boxText.appendChild(boxDescr);

			var boxPrices = document.createElement('div');
			boxPrices.className = 'boxPrices';

			if(!empty(prTitle1)){
				var priceT = document.createElement('p');
				priceT.className = 'boxPriceTit';
				priceT.innerHTML = prTitle1;

				var price = document.createElement('p');
				price.className = 'boxPrice';
				price.innerHTML = prCont1;

				boxPrices.appendChild(priceT);
				boxPrices.appendChild(price);
			}
			if(!empty(prTitle2)){
				var priceT2 = document.createElement('p');
				priceT2.className = 'boxPriceTit';
				priceT2.innerHTML = prTitle2;

				var price2 = document.createElement('p');
				price2.className = 'boxPrice';
				price2.innerHTML = prCont2;

				boxPrices.appendChild(priceT2);
				boxPrices.appendChild(price2);
			}
			if(!empty(prTitle3)){
				var priceT3 = document.createElement('p');
				priceT3.className = 'boxPriceTit';
				priceT3.innerHTML = prTitle3;

				var price3 = document.createElement('p');
				price3.className = 'boxPrice';
				price3.innerHTML = prCont3;

				boxPrices.appendChild(priceT3);
				boxPrices.appendChild(price3);
			}
			if(!empty(prTitle4)){
				var priceT4 = document.createElement('p');
				priceT4.className = 'boxPriceTit';
				priceT4.innerHTML = prTitle4;

				var price4 = document.createElement('p');
				price4.className = 'boxPrice';
				price4.innerHTML = prCont4;

				boxPrices.appendChild(priceT4);
				boxPrices.appendChild(price4);
			}
			if(!empty(prTitle5)){
				var priceT5 = document.createElement('p');
				priceT5.className = 'boxPriceTit';
				priceT5.innerHTML = prTitle5;

				var price5 = document.createElement('p');
				price5.className = 'boxPrice';
				price5.innerHTML = prCont5;

				boxPrices.appendChild(priceT5);
				boxPrices.appendChild(price5);
			}

			boxText.appendChild(boxPrices);
			imgBox.appendChild(boxText);


		imgBox.style.opacity = .0;
		imgBox.style.msFilter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + 0 + ")";
		imgBox.style.filter = 'alpha(opacity=' + 0 + ')';

		dfE.getObject('food').appendChild(imgBox);
	}



	var nextPhoto = dfE.getObject('bkr-img-0' + imgId + 'a');





	nextPhoto.src = '/data/img/bakery/' + sizes[imgId] + '/' + fadeImg[imgId] + '.jpg';

	currPhoto.style.zIndex = '1';
	nextPhoto.style.zIndex = '10';
	dfE.setOpacity('bkr-img-0' + imgId + 'a', 0);
	nextPhoto.style.display = "block";
	dfE.fadeObject('bkr-img-0' + imgId + 'a', 0, 100, fd_log_slow);

	setTimeout('finishBkFade(' + imgId + ')', 1500);
}
function finishFoodFade(imgId){
	var currPhoto = dfE.getObject('bkr-img-0' + imgId);
	var nextPhoto = dfE.getObject('bkr-img-0' + imgId + 'a');

	currPhoto.src = nextPhoto.src;
	nextPhoto.style.display = 'none';

	setTimeout('fadeBk('+imgId+')', (randomInt(2, 9) * 1300));
}


/******************************************************************************************************************************
	GALLERY
*******************************************************************************************************************************/

fd_log_fast = new Array();
fd_log_fast['diff'] = 3;
fd_log_fast['multiply'] = 6;
fd_log_fast['graph'] = 'log';

var thumbPage = 0;
var galFolder;
var galCount;
var lastPhotoId = 1;

function initGal(folder, count){
	galFolder = folder;
	galCount = count;

	for(i = 1; i <= 8 && i <= galCount; i++){
		var thumbLink = document.createElement('a');

		thumbLink.setAttribute('href', '/data/img/gallery/' + galFolder + '/' + i + '.jpg');
		thumbLink.onmouseover = new Function( "phFadeIn(" + i + "); phChange(" + i + ");" );
		thumbLink.onclick = new Function( "return false;" );

		var thumb = document.createElement('img');
		thumb.id = 'thumb' + i;
		thumb.src = "/data/img/gallery/" + galFolder + "/thumbs/" + i + ".jpg";
		thumb.alt = "Click to view image";
		thumb.className = "thumbimg";

		thumbLink.appendChild(thumb);

		var imgBox = dfE.getObject('thumbHider');
		imgBox.appendChild(thumbLink);

		if(i == lastPhotoId){
			dfE.setOpacity('thumb' + i, 40);
		} else {
			dfE.setOpacity('thumb' + i, 40);
		}
	}
	if(galCount <= 8){
		dfE.getObject('arrow-r').style.visibility = 'hidden';
	}

}


function phFadeIn(id){
	dfE.fadeObject('thumb' + id, null, 100, fd_log_fast);
}
function phFadeOut(id){
		setTimeout('fadeDelay('+ id +')', 400);
}
function fadeDelay(id){
	dfE.fadeObject('thumb' + id, null, 40, fd_log_fast);
}

function phChange(id){

	if(id != lastPhotoId){
		phChangeOut(lastPhotoId);
		setTimeout('fadeDelay('+ lastPhotoId +')', 400);
		lastPhotoId = id;

		var photo = document.createElement('img');
		photo.src = "/data/img/gallery/"+galFolder+"/" + id + ".jpg";
		photo.id = "bigphoto" + id;
		photo.className = "bigphoto";
		photo.style.opacity = .0;
		photo.style.msFilter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + 0 + ")";
		photo.style.filter = 'alpha(opacity=' + 0 + ')';

		var photoBox = dfE.getObject('photoBox');
		
		photoBox.appendChild(photo);

		dfE.fadeObject(photo.id, null, 100, fd_log_fast);
	}
	return false;

}

function phChangeOut(id){
	//dfE.fadeObject('bigphoto' + id, null, 0, fd_log_fast);
	setTimeout("dfE.RemObj('bigphoto"+id+"')", 1000);
}

function nextThumb(){
	// Delete images
	for(i = 8; i >= 1; i--){
		if(!empty(dfE.getObject("thumb" + i))){
			setTimeout("dfE.fadeObject('thumb" + i + "', null, 0, fd_log_fast);", (50 * i));
			setTimeout("dfE.RemObj('thumb" + i + "');", (50 * i + 800));
		}
	}
	thumbPage++;
	setTimeout("loadNextThumbs(" + i + ")", 1000);
}

function loadNextThumbs(i){
	if( ((thumbPage+1) * 8) >= galCount){
		dfE.getObject('arrow-r').style.visibility = 'hidden';
	} else {
		dfE.getObject('arrow-r').style.visibility = 'visible';
	}

	if(thumbPage == 0){
		dfE.getObject('arrow-l').style.visibility = 'hidden';
	} else {
		dfE.getObject('arrow-l').style.visibility = 'visible';
	}

	for(i = 1; (i <= 8 && (i + thumbPage * 8) <= galCount); i++){
		var thumbLink = document.createElement('a');

		thumbLink.setAttribute('href', '/data/img/gallery/'+galFolder+'/' + (thumbPage * 8 + i) + '.jpg');
		thumbLink.onmouseover = new Function( "phFadeIn(" + i + "); phChange(" + (thumbPage * 8 + i) + ");" );
		thumbLink.onclick = new Function( " return false;" );

		var thumb = document.createElement('img');
		thumb.id = 'thumb' + i;
		thumb.src = "/data/img/gallery/"+galFolder+"/thumbs/" + (thumbPage * 8 + i) + ".jpg";
		thumb.alt = "Click to view image";
		thumb.className = "thumbimg";

		thumb.style.opacity = .0;
		thumb.style.msFilter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + 0 + ")";
		thumb.style.filter = 'alpha(opacity=' + 0 + ')';

		thumbLink.appendChild(thumb);

		var imgBox = dfE.getObject('thumbHider');
		imgBox.appendChild(thumbLink);

	}
	for(i = 1; (i <= 8 && (i + thumbPage * 8) <= galCount); i++){
		setTimeout("dfE.fadeObject('thumb" + i + "', null, 40, fd_log_fast);", (50 * i + 200));
	}


}

function prevThumbs(){
	// Delete images
	for(i = 8; i >= 1; i--){
		if(!empty(dfE.getObject("thumb" + i))){
			setTimeout("dfE.fadeObject('thumb" + i + "', null, 0, fd_log_fast);", (50 * i));
			setTimeout("dfE.RemObj('thumb" + i + "');", (50 * i + 800));
		}
	}
	thumbPage--;
	setTimeout("loadNextThumbs(" + i + ")", 1000);
}

/******************************************************************************************************************************
	CONTACT
*******************************************************************************************************************************/

var mapW = 400;
var mapH = 243;
var mapL = 544;

var	mapStopW = 734;
var	mapStopH = 447;
var	mapStopL = 208;

var exp = 1;
var mapInt;
var rollin = false;
var direction;

function rollonmap(){
	direction = "plus";
	mapStopW = 734;
	mapStopH = 447;
	mapStopL = 208;
	exp = 1;

	if(!rollin){
		rollin = true;
		mapInt = setInterval('resizeMap()', 30);
	}
}

function resizeMap(){
	var map = dfE.getObject('map');

if(direction == 'plus'){
	exp = exp * 2;
	expH = parseInt(exp * 0.75);

	mapW = mapW + exp;
	mapH = mapH + expH;
	mapL = mapL - exp;

	if(mapStopW < mapW || mapStopH < mapH){
		map.style.width = mapStopW + 'px';
		map.style.height = mapStopH + 'px';
		map.style.left = mapStopL + 'px';

		mapW = mapStopW;
		mapH = mapStopH;
		mapL = mapStopL;

		map.src = '/data/img/contact/map-large.jpg';

		clearInterval(mapInt);
		rollin = false;
	} else {
		map.style.width = mapW + 'px';
		map.style.height = mapH + 'px';
		map.style.left = mapL + 'px';
	}

} else {
	exp = exp * 2;
	expH = parseInt(exp * 0.75);

	mapW = mapW - exp;
	mapH = mapH - expH;
	mapL = mapL + exp;

	if(mapStopW > mapW || mapStopH > mapH){
		map.style.width = mapStopW + 'px';
		map.style.height = mapStopH + 'px';
		map.style.left = mapStopL + 'px';

		mapW = mapStopW;
		mapH = mapStopH;
		mapL = mapStopL;

		map.src = '/data/img/contact/map-small.jpg';

		clearInterval(mapInt);
		rollin = false;
	} else {
		map.style.width = mapW + 'px';
		map.style.height = mapH + 'px';
		map.style.left = mapL + 'px';
	}
}


}
function rolloffmap(){
	direction = "minus";
	mapStopW = 400;
	mapStopH = 243;
	mapStopL = 544;
	exp = 1;

	if(!rollin){
		rollin = true;
		mapInt = setInterval('resizeMap()', 30);
	}

	
}


/* CAR ANIMATION */

var carL = 881;
var carExp = 30;
var step = 1;

var stopA = 200;
var maxSpeed = 30;

function contCarMove(){

setInterval('moveCar()', 25); //40 fps
}

function moveCar(){
/*	stats = dfE.getObject('stats');
	stats.innerHTML = 'step: '+step+'<br />exp: '+carExp
*/
	parseInt(carExp);

	carL = carL - parseInt(carExp);

	// >>> Step 1 Prijezd auta, zpomaleni ==========================
	if(step == 1){
		if(carL > stopA){
			carBox.style.left = carL + 'px';
		} else {
			step = 2
		}
	}
	if(step == 2){
		/* >>> zpomaleni */
		if(parseInt(carExp) > 0){
			carBox.style.left = carL + 'px';
			carExp = carExp / 1.2;
		} else {
			step = 3;
			delay = 1;
		}
	}

	// >>> Cekani ================================================
	if(step == 3){
		if(delay < 500){
			delay++;
		} else {
			step = 4;
			carExp = 1;
		}
	}

	// >>> Odjezd ================================================
	if(step == 4){
		if(carExp < maxSpeed){
			carBox.style.left = carL + 'px';
			carExp = carExp * 1.2;
		} else {
			step = 5;
			carExp = maxSpeed;
		}
	}

	if(step == 5){
		if(carL > -900 ){
			carBox.style.left = carL + 'px';
		} else {
			step = 6;
			delay = 1;
		}
	}

	// >>> Cekani ================================================
	if(step == 6){
		if(delay < 200){
			delay++;
		} else {
			step = 1;
			carExp = maxSpeed;
			carL = 881;
		}
	}

}








/******************************************************************************************************************************
	SHOW STATISTICS
*******************************************************************************************************************************/
var boxStats

	function showStatBox(){
		if(empty(dfE.getObject('stats'))){
			boxStats = document.createElement('div');
			boxStats.id = 'stats';

			boxStats.style.position = 'absolute';
			boxStats.style.fontSize = '12px';
			boxStats.style.backgroundColor = '#fff';
			boxStats.style.color = '#000';
			boxStats.style.padding = '20px';
			boxStats.style.border = '1px solid #fff';
			boxStats.style.zIndex = '100000';
			boxStats.style.top = '20px';
			boxStats.style.right = '20px';



			body = document.body;
			body.appendChild(boxStats);
			
			
			
			
			dfE.setOpacity('stats', 60);
		}
	}
	function addStats(text){
		dfE.getObject('stats').innerHTML = dfE.getObject('stats').innerHTML + '<br />' + text;
	}
	function clearStats(){
		dfE.getObject('stats').innerHTML = "";
	}









