var searchModeIndex = 0;
function searchMode(mode) {
	searchModeIndex = mode;
	var divs = $('searchModes').getElements('div');
	for(var i=0;i<divs.length;i++) {
		divs[i].setStyle('display', (mode==i ? '' : 'none'));
		// if mode==3: map is
	}
}
function showhide(a,id,className) {
	var div = document.getElementById(id);
	if(div.style.display=='none') {
		div.style.display = 'block';
		div.parentNode.className = 'bBg';
		if ( className != undefined )
		{
			div.parentNode.className += ' ' + className;
		}
		a.parentNode.className = 'close';
	} else {
		div.style.display = 'none';
		div.parentNode.className = 'bBg';
		a.parentNode.className = '';
	}
	a.blur();
}
function galleryShow(num,last) {
	for(var i=1;i<=last;i++) {
		document.getElementById('pgi-'+i).style.display = (i==num ? '' : 'none');
	}
}
function galleryImage(src,func) {
	var img = document.getElementById('poiGalleryImage');
	img.src = src;
	img.parentNode.onclick = func;
}
randomGallery = function(id,images) {
	this.images = images;
	this.obj = document.getElementById(id);
	this.pos = 0;
	this.slide(0);
}
randomGallery.prototype.slide = function(num) {
	//<a href="#"><img src="/pic_gal.jpg" width="90" height="90" alt="Budapest" /></a>
	this.pos += num;
	if(this.pos<0) this.pos = 0;
	if(this.pos>this.images.length-4) this.pos = this.images.length-4;

	while(this.obj.childNodes.length>0) this.obj.removeChild(this.obj.childNodes[0]);

	for(var i=this.pos;i<this.pos+4;i++) {
		if(this.images[i]==undefined) continue;
		var a = document.createElement('a');
		a.href = 'javascript:void(0);';
		a.onclick = this.images[i][1];
		var img = document.createElement('img');
		img.src = this.images[i][0];
		img.width = '90';
		img.height = '90';
		a.appendChild(img);
		this.obj.appendChild(a);
	}
}

function addToFavorites(poiId,lang) {
	new Request.HTML({
		method: 'get',
		autoCancel: true,
		url: '/ajax-favorites-add-'+poiId+'-'+lang,
		update: $('addToFavorites')
	}).send();
}

function searchByTitle(url,event,button) {
	if($('searchTitle').value != '' && (event.keyCode == 13 || button)) {
		location.href = url + $('searchTitle').value;
	}

	return false;
}

function searchByKeywords(url,tag) {
	if(tag != '') {
		location.href = url + tag;
	}
}

function searchByKeywordsAdd(tag,lang) {
	if(tag != '') {
		new Request.HTML({
			method: 'get',
			autoCancel: true,
			url: '/ajax-search-add-'+tag+'-'+lang,
			update: $('searchKeywords')
		}).send();
	}
}
