var keresok = new Array('szallaskereso','utvonalkereso');
var keresofulek = new Array('szallaskeresoful','utvonalkeresoful');
var tol = new Array(0,2001,3001,4001,5001,6001,7001,8001,9001,10001);
var ig  = new Array(2000,3000,4000,5000,6000,7000,8000,9000,10000,'...');
var topr;
var rightr;

function SearchChanger(id){
	for(i=0;i<keresok.length;i++){
		if(id==keresok[i]){
			document.getElementById(keresok[i]).style.display='block';
			document.getElementById(keresofulek[i]).className='aktivkereso';
		}
		else{
			document.getElementById(keresok[i]).style.display='none';
			document.getElementById(keresofulek[i]).className='inaktivkereso';
		}
	}
}

function ArSzabalyozo(elem){
	tolval = document.getElementById('ar_tol').options[document.getElementById('ar_tol').selectedIndex].value;
	igval  = document.getElementById('ar_ig').options[document.getElementById('ar_ig').selectedIndex].value;
	
	if(elem.id == 'ar_tol') xx=0;
	else xx=1;
	
	
	var i=0;
	if(xx==0){
		window.field = 'ar_ig';
		var z=document.getElementById(field).length;
		while(i<=z){
			i=i+1;
			var x=document.getElementById(field);
			x.remove('0');
		}
		for(j=0;j<ig.length;j++){
			if(ig[j]>tolval){
				insertOption(ig[j],ig[j]);
			}
		}
		insertOption('...','...');
		var x=document.getElementById(field);
		for (i=0;i<x.length;i++)
		{
			if (x.options[i].value == igval) {
				x.options[i].selected = true;
			}
		}
	}
	else{
		window.field = 'ar_tol';
		var z=document.getElementById(field).length;
		while(i<=z){
			i=i+1;
			var x=document.getElementById(field);
			x.remove('0');
		}
		/*insertOption(' ', 0);*/
		if(igval=='...'){
			for(j=0;j<tol.length;j++){
				insertOption(tol[j],tol[j]);
			}
		}
		else{
			for(j=0;j<tol.length;j++){
				if(tol[j]<igval){
					insertOption(tol[j],tol[j]);
				}
			}
		}
		var x=document.getElementById(field);
		for (i=0;i<x.length;i++)
		{
			if (x.options[i].value == tolval) {
				x.options[i].selected = true;
			}
		}
	}
}


function topRotator(topr) {
	window.topr = topr;
	//Set the opacity of all images to 0
	$('div#rotator'+topr+' ul li').css({opacity: 0.0});
	$('div#rotator'+topr+' ul li span').css('visibility','hidden');
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator'+topr+' ul li:first').css({opacity: 1.0});
	$('div#rotator'+topr+' ul li:first span').css('visibility','visible');
	
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	topinterv = setInterval('toprotate()',6000);
}


function toprotate() {
	//Get the first image
	var current = ($('div#rotator'+topr+' ul li.show')?  $('div#rotator'+topr+' ul li.show') : $('div#rotator'+topr+' ul li:first'));
	var currentspan = $('li.show span');
	
	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator'+topr+' ul li:first') :current.next()) : $('div#rotator'+topr+' ul li:first'));
	var nextid = next.attr('id');
	var nextli = document.getElementById(nextid);
	
	currentspan.css('visibility','visible');
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	nextli.getElementsByTagName('span')[0].style.visibility = 'visible';
	

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	currentspan.css('visibility','hidden');

};



function rightRotator(rightr) {
	window.rightr = rightr;
	//Set the opacity of all images to 0
	$('div#rotator'+rightr+' ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator'+rightr+' ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	rightinterv = setInterval('rightrotate()',6000);
}


function rightrotate() {
	//Get the first image
	var current = ($('div#rotator'+rightr+' ul li.show')?  $('div#rotator'+rightr+' ul li.show') : $('div#rotator'+rightr+' ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator'+rightr+' ul li:first') :current.next()) : $('div#rotator'+rightr+' ul li:first'));
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

function ForgoStop(){
	clearInterval(topinterv);
	document.getElementById('forgostart').style.display='inline';
	document.getElementById('forgonext').style.display='inline';
	document.getElementById('forgoprev').style.display='inline';
	document.getElementById('forgostop').style.display='none';
	
}

function ForgoStart(){
	topinterv = setInterval('toprotate()',6000);
	document.getElementById('forgostop').style.display='inline';
	document.getElementById('forgostart').style.display='none';
	document.getElementById('forgonext').style.display='none';
	document.getElementById('forgoprev').style.display='none';
}

function ForgoPrev(){
	var lis=document.getElementById('rt').getElementsByTagName('li');
	var prev;
	for(i=0;i<lis.length;i++){
		if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Windows") != -1){
			if(lis[i].style.filter == 'alpha(opacity=100)'){
				if(i>0) k = i-1;
				else k=lis.length-1;
				prev = lis[k].id;
			}
		}
		else{
			if(lis[i].style.opacity == 1){
				if(i>0) k = i-1;
				else k=lis.length-1;
				prev = lis[k].id;
			}
		}
	}
	for(i=0;i<lis.length;i++){
		if(lis[i].id === prev){
			ViewForgoPic(lis[i].id);
		}
		else{
			HideForgoPic(lis[i].id);
		}
	}
}

function ForgoNext(){
	var lis=document.getElementById('rt').getElementsByTagName('li');
	var next;
	for(i=0;i<lis.length;i++){
		if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Windows") != -1){
			if(lis[i].style.filter == 'alpha(opacity=100)'){
				if(i<lis.length-1) k = i+1;
				else k=0;
				next = lis[k].id;
			}
		}
		else{
			if(lis[i].style.opacity == 1){
				if(i<lis.length-1) k = i+1;
				else k=0;
				next = lis[k].id;
			}
		}
	}
	for(i=0;i<lis.length;i++){
		if(lis[i].id === next){
			ViewForgoPic(lis[i].id);
		}
		else{
			HideForgoPic(lis[i].id);
		}
	}
}

function ViewForgoPic(id){
	$('#'+id).css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	document.getElementById(id).getElementsByTagName('span')[0].style.visibility = 'visible';
}

function HideForgoPic(id){
	$('#'+id).animate({opacity: 0.0}, 1000)
	.removeClass('show');
	document.getElementById(id).getElementsByTagName('span')[0].style.visibility = 'hidden';
}

function Close(id){
	document.getElementById(id).style.display = 'none';
}