
		function searchManager() {
			oThis = this;

			this.oldalstart = 0;
			this.oldalszam = 10;
			this.maxoldal = 0;
			this.letszam = 0;
			this.megye = '';
			this.varos = '';
			this.kerulet = '';
			this.fogadas = '';
			
			this.oldaljelzo = document.getElementById('pozicio');
			this.elozogomb = document.getElementById('elozo');
			this.kovetkezogomb = document.getElementById('kovetkezo');
			this.keresogomb = document.getElementById('keresgomb');
			this.okerulet = document.getElementById('kerulet');
			this.ovaros = document.getElementById('varos');
			this.keresophp = "includes/helyszinek_keresobol.php";
			this.eredmenyphp = "includes/eredmeny.php";
			this.varosokphp = "includes/varosok.php";

			document.getElementById('megye').onchange = function() {
				oThis.setMegye(this.value);
			}	

			this.ovaros.onchange = function() {
				oThis.setVaros(this.value);
			}	

			this.okerulet.onchange = function() {
				oThis.setKerulet(this.value);
			}	

			document.getElementById('oldalszam').onchange = function() {
				oThis.setOldalSzam(this.value);
			}	

			this.keresogomb.onclick = function() {
				oThis.oldalstart = 0;
				oThis.getSearchData();
				oThis.showSearchLayer();
				//this.value='Frissítés';
			}	

			this.elozogomb.onclick = function() {
				oThis.elozo();
			}	

			this.kovetkezogomb.onclick = function() {
				oThis.kovetkezo();
			}	

		}

		searchManager.prototype.getSearchData = function() {

			document.getElementById('talalat').innerHTML = 'Találat: '+this.maxoldal+' helyszín';
			
			var vege = this.maxoldal-this.oldalstart-this.oldalszam;
			if(vege > 0) {
				this.oldaljelzo.value = (this.oldalstart+1) + '-' + ((this.oldalstart*1)+(this.oldalszam*1))+'/'+this.maxoldal;
			} else {
				this.oldaljelzo.value = (this.oldalstart+1) + '-' + ((this.oldalstart*1)+(this.oldalszam*1)+vege+'/'+this.maxoldal);
			}	

			var keresost = this.keresophp
									 + '?kerulet='+this.kerulet
									 + '&megye='+this.megye
									 + '&varos='+this.varos
									 + '&limit='+this.oldalszam
									 + '&start='+this.oldalstart
									 + '&letszam='+this.letszam
									 + '&fogadas='+this.fogadas
									 + '&rnd='+Math.random();

    	getHTTP('eredmenylayer',keresost,null,null,'');
    	
    	if(this.oldalstart == 0) {
    		this.elozogomb.style.display = "none";
    	} else {
    		this.elozogomb.style.display = "";
    	}	

			if(vege <= 0) {
    		this.kovetkezogomb.style.display = "none";
    	} else {
    		this.kovetkezogomb.style.display = "";
    	}	
    	
		}
		
		searchManager.prototype.showSearchLayer = function() {
			document.getElementById('egyebeskuvoikellekek').style.display = 'none';
			document.getElementById('fooldalhirek').style.display = 'none';
			if(document.getElementById('kulonlegeshelyszinek')) document.getElementById('kulonlegeshelyszinek').style.display = 'none';
			document.getElementById('kozepsobanner').style.display = 'none';
			document.getElementById('keresokontroll').style.display = 'block';
			document.getElementById('keresokontroll2').style.display = 'block';
			document.getElementById('eredmenylayer').style.display = 'block';
			document.getElementById('fooldalhelszinosszes').style.display = 'none';
		}

		searchManager.prototype.setLetszam = function(i) {
			this.letszam = i;
			this.showEredmeny();
		}

		searchManager.prototype.setMegye = function(st) {
			oThis = this;
			this.megye = st;
			this.kerulet = '';
			this.varos = '';
			this.okerulet.selectedIndex = 0;
			if(oThis.megye == 'budapest') {
				document.getElementById('varoslayer').style.display = 'none';
	   		document.getElementById('keruletlayer').style.display = 'block';
				oThis.showEredmeny(); 
			} else	{
	   		document.getElementById('keruletlayer').style.display = 'none';
				document.getElementById('varoslayer').style.display = 'block';
				getHTTP('varoslayer',this.varosokphp+'?megye='+st+'&rnd='+Math.random(),
					function() { 
						oThis.showEredmeny(); 
						document.getElementById('varos').onchange = function() {
							oThis.setVaros(this.value);
						}	
				},null,'');
			}
		}

		searchManager.prototype.setVaros = function(st) {
			this.varos = st;
			this.kerulet = '';
			this.okerulet.selectedIndex = 0;
			if(st == 'budapest') {
	   		document.getElementById('keruletlayer').style.display = 'block';
			} else	{
	   		document.getElementById('keruletlayer').style.display = 'none';
			}
			this.showEredmeny();
		}

		searchManager.prototype.setKerulet = function(st) {
			this.kerulet = st;
			this.showEredmeny();
		}

		searchManager.prototype.setFogadas = function(st) {
			this.fogadas = st;
			this.showEredmeny();
		}

		searchManager.prototype.setMaxOldal = function(pg) {
			this.maxoldal = pg;
		}

		searchManager.prototype.setOldalSzam = function(i) {
			this.oldalszam = i;
			this.oldalstart = 0;
			this.getSearchData();
		}

		searchManager.prototype.elozo = function() {
			if(this.oldalstart > 0) {
				this.oldalstart = (this.oldalstart*1) - (this.oldalszam*1);
				this.getSearchData();
			}
		}

		searchManager.prototype.kovetkezo = function() {
			if(this.oldalstart < this.maxoldal-this.oldalszam) {
				this.oldalstart = (this.oldalstart*1) + (this.oldalszam*1);
				this.getSearchData();
			}	
		}

		searchManager.prototype.showEredmeny = function() {
			oThis = this;
			var keresost = this.eredmenyphp
									 + '?kerulet='+this.kerulet
									 + '&megye='+this.megye
									 + '&varos='+this.varos
									 + '&letszam='+this.letszam
									 + '&fogadas='+this.fogadas
									 + '&rnd='+Math.random();

			//alert(this.letszam)	;
			
			getHTTP('',keresost,
				function(i) {
					oThis.maxoldal = i;
					if(i > 0) {
						oThis.keresogomb.value = i+' helyszín megtekintése';
						oThis.keresogomb.disabled = false;
						oThis.keresogomb.style.backgroundColor = '#dcdca9';
					} else {
						oThis.keresogomb.value = 'Nincs találat';
						oThis.keresogomb.disabled = true;
						oThis.keresogomb.style.backgroundColor = '#AAAAAA';
					}	
				},null,'');
		}
