var pageTitles = new Hash();
pageTitles['botanics.html'] = 'botanika';
pageTitles['cultivation.html'] = 'uprawa';
pageTitles['ineurope.html'] = 'w Europie';
pageTitles['races.html'] = 'w OBUWr';
pageTitles['curiosities.html'] = 'ciekawostki';



goToBotanics = function() {
	window.location = 'botanics.html';
}

goToCultivation = function() {
	window.location = 'cultivation.html';
}

goToInEurope = function() {
	window.location = 'ineurope.html';
}

goToRaces = function() {	
	window.location = 'races.html';
}

goToCuriosities = function() {
	window.location = 'curiosities.html';
}

goToMain = function() {
	window.location = 'main.html';

	/*if (!pageIsChanging()) {
		Effect.Fade($('pageTitle'));
		new Ajax.Updater('contentNormal', 'mainContent.html');
		Element.hide($('navigation'));
		Effect.Appear($('headerMainRight'));
		window.scrollTo(0,0);
		$('contentNormal').style.paddingBottom='9px';
		location.hash = '#';
		setHeaderLinksCursor(false);
	}*/
	
}

setHeaderLinksCursor = function(active) {
	var activeStyle = {cursor: 'pointer'};
	var passiveStyle = {cursor: 'default'};
	var toSet = active ? activeStyle : passiveStyle;
	
	$('headerUpperLeft').setStyle(toSet);
	$('headerUpperRight').setStyle(toSet);
	$('headerDownLeft').setStyle(toSet);
	$('headerDownRight').setStyle(toSet);
	
}

afterPictureHiding = function() {
	pictureHiding = false;
}
afterTitleShowing = function() {
	titleShowing = false;	
}

var pictureHiding = false;
var titleShowing = false;

pageIsChanging = function() {
	return pictureHiding || titleShowing;
}

changePage = function(pageFile) {
	/*window.location = pageFile;*/
	pictureHiding = true;	
	titleShowing = true;	
	Effect.Fade($('headerMainRight'), {afterFinish: afterPictureHiding});
	Element.hide($('pageTitle'));
	Element.update($('pageTitle'), pageTitles[pageFile]);
	
	Effect.Appear($('pageTitle'), {afterFinish: afterTitleShowing});
	/*new Ajax.Updater('contentNormal', pageFile, {evalScripts: true, onComplete: onChangePage});
	urchinTracker(pageFile);*/
	Element.show($('navigation'));
	/*window.scrollTo(0,0);*/
	$('contentNormal').style.paddingBottom='110px';	
	//location.hash = pageFile;	
	setHeaderLinksCursor(true);
}

onChangePage = function() {
	if (myLightbox != null) {
		myLightbox.updateImageList();
	}
}


highlightCurrent = function(div) {
	
}

var highlighting = new Hash();
var clearing = new Hash();
var toClear = new Hash();
var toShow = new Hash();
var isMouseOver = new Hash();

afterClearHighlight = function(effect) {
	var div = effect.element.id;
	clearing[div] = false;
	if (isMouseOver[div]) {
		highlight(div);
	}
}

afterHighlight = function(effect) {	
	var div = effect.element.id;
	highlighting[div] = false;
	if (!isMouseOver[div]) {
		clearHighlight(div);
	}
}

highlight = function(div) {
	isMouseOver[div] = true;
	if (clearing[div]) {
		return;
	}
	highlighting[div] = true;
	
		new Effect.Morph(div, {
			style:
	    		'width: 170px; color: #FFBCFF;',
	    	duration: 0.1,
	    	afterFinish: afterHighlight
		});		
	
}

clearHighlight = function(div) {
	isMouseOver[div] = false;
	if (highlighting[div]) {
		return;
	}
	clearing[div] = true;
		new Effect.Morph(div, {
			style:
	    		'width: 161px;color: #ffffff;',
	    	duration: 0.1,
	    	afterFinish: afterClearHighlight
		});		
	
}




analyzeHash = function() {	
	if (location.hash != '') {
		var page = location.hash.substr(1);		
		if (pageTitles[page] != null) {
			changePage(page);
		} else {
			location.hash = '';
		}
	}
}