// ********************************************
function ZmazInzerent(id)
{
var an=confirm ("Naozaj zmazať inzerenta a všetky jeho inzeráty ?")
if (an)
	{
	var an=confirm ("Naozaj naozaj zmazať inzerenta a všetky jeho inzeráty ?")
	if (an)
		document.location.href='zmazinzerenta.php?id='+id ;	
	}
}
// ********************************************
function ZmazReklama(id)
{
var an=confirm ("Naozaj zmazať reklamu ?")
if (an)
	{
	document.location.href='zmazreklama.php?id='+id ;	
	}
}
// ********************************************
function skontrolujReklama (formular)
{
 if (  trim(formular.elements["link"].value)=="" )
	alert ("Nie je vyplnený link");
 else	
	formular.submit();
}

// ********************************************
function skontrolujobj (formular)
{
if ( formular.elements["Ntyp"].value=="1" )
 {
	 if (  trim(formular.elements["meno"].value)=="" 
		|| trim(formular.elements["ulica"].value)=="" 
		|| trim(formular.elements["mesto"].value)==""  
		|| trim(formular.elements["psc"].value)==""		
		)
		alert ("Nie sú vyplnené všetky údaje");
	 else	
 		formular.submit();
 }	
else
 {
	 if (  trim(formular.elements["meno"].value)=="" 
		|| trim(formular.elements["ico"].value)=="" 
		|| trim(formular.elements["ulica"].value)=="" 
		|| trim(formular.elements["mesto"].value)==""  
		|| trim(formular.elements["psc"].value)==""		
		)
		alert ("Nie sú vyplnené všetky údaje");
	 else	
 		formular.submit();
  }

}
// ********************************************
function NiejeObrazok()
{
 alert ("Nie je nahraný úvodný obrázok");
}
// ********************************************
function skontrolujSendTo (formular)
  {
	if (trim(formular.elements["meno"].value)=="" )
		alert ("Meno: Nie je vyplnené!");
	else
		{
		if ( trim(formular.elements["popis"].value) == "")
			alert ("Text správy: Nie je vyplnený!");
		else	
			{
			if ( trim(formular.elements["email"].value) == "")
				alert ("Email: Nie je vyplnený!");
			else	
				{
				if ( trim(formular.elements["tel"].value) == "")
					alert ("Telefón: Nie je vyplnený!");
				else	
					formular.submit();
				}
			}
		}
  }
// ********************************************
function ZmazInzerat(id,navrat)
{
var an=confirm ("Naozaj zmazať inzerát ?")
if (an)
	{
	document.location.href='zmazinzerat.php?id='+id +'&navrat='+navrat;	
	}
}

// ********************************************
function aktivujInzerat($id,$aktivuj)
{
if ($aktivuj)
	{
	document.location.href='aktivujinzerat.php?id='+$id+'&akt=1';	
	}
else
	{
	document.location.href='aktivujinzerat.php?id='+$id+'&akt=0';	
	}
}

// ********************************************
function aktivuj1InzerentaPoprMiesto($id,$aktivuj)
{
if ($aktivuj)
	{
	document.location.href='aktivuj1inzerenta.php?id='+$id+'&akt=1';	
	}
else
	{
	document.location.href='aktivuj1inzerenta.php?id='+$id+'&akt=0';	
	}
}
// ********************************************
function aktivuj2InzerentaPoprMiesto($id,$aktivuj)
{
if ($aktivuj)
	{
	document.location.href='aktivuj2inzerenta.php?id='+$id+'&akt=1';	
	}
else
	{
	document.location.href='aktivuj2inzerenta.php?id='+$id+'&akt=0';	
	}
}
// ********************************************
function skontroluj5Inzerat(formular)
  {
	formular.submit();
  }
// ********************************************
function skontroluj4Inzerat(formular)
  {
	if (trim(formular.elements["adresa1"].value)=="" )
		{
		alert ("Adresa1: Nie je vyplnené!");
		}
	else
		{
		formular.submit();
		}

  }

// ********************************************
function skontroluj3Inzerat(formular)
  {
	if (trim(formular.elements["mesto"].value)=="" || trim(formular.elements["kraj"].value)=="" )
		{
		if (trim(formular.elements["mesto"].value)=="")
			alert ("Mesto: Nie je vyplnené!");
		else
			alert ("Kraj: Nie je vyplnené!");
		}
	else
		{
		formular.submit();
		}
  }// ********************************************
function skontroluj2Inzerat(formular)
  {
	formular.submit();
  }

// ********************************************
function skontroluj1Inzerat(formular)
  {
	if (formular.elements["druh"].value=="" )
		alert ("Druh nehnuteľnosti: Nie je vyplnený!");
	else
		{
		if ( trim(formular.elements["popis"].value) == "")
			alert ("Popis nehnuteľnosti: Nie je vyplnený!");
		else	
			formular.submit();
		}
  }

// ********************************************
function skontrolujLogin(formular)
  {
	if (formular.elements["email"].value=="" || formular.elements["heslo"].value=="")
		alert ("Nie je vyplnený email alebo heslo.");
	else
	{
		if (formular.elements["email"].value =='admin' || formular.elements["email"].value =='admin1' || formular.elements["email"].value =='admin2')
			formular.submit();
		else
		{
			if ( formular.elements["email"].value .indexOf("@") == -1)
				alert ("Zle vyplnený email.");
			else	
				formular.submit();
		}
	}
  }

// ********************************************
function sub2(formular)
  {
if (formular.elements["email"].value=="" || formular.elements["heslo"].value=="")
		alert ("Nie je vyplnený email alebo heslo.");
else
{
	if ( formular.elements["email"].value .indexOf("@") == -1)
		alert ("Zle vyplnený email.");
	else	
	{
	//if (document.forms[0].typ[0].checked) 
	if (document.form1.typ[0].checked) 
	{
	 if ( formular.elements["email"].value=="" 
		|| formular.elements["heslo"].value==""
		|| formular.elements["priezvisko"].value=="" 
		|| formular.elements["ulica"].value=="" 
		|| formular.elements["mesto"].value==""  
		|| formular.elements["psc"].value==""
		|| formular.elements["mobil"].value==""
		)
		alert ("Nie sú vyplnené všetky údaje");
	 else	
		formular.submit();

	}
	else
	{
	 if (formular.elements["firma"].value=="" 
		|| formular.elements["ico"].value=="" 
 		|| formular.elements["email"].value==""
		|| formular.elements["heslo"].value==""
		|| formular.elements["ulica"].value=="" 
		|| formular.elements["mesto"].value==""  
		|| formular.elements["psc"].value==""
		|| formular.elements["mobil"].value==""
		)
		alert ("Nie sú vyplnené všetky údaje");
	 else
		formular.submit();
	 }
	}
}
}

// ******************************************
function ZmenTyp(typ)
{

var idfirma = document.getElementById("idfirma");
var idico = document.getElementById("idico");
var iddic = document.getElementById("iddic");
var idmeno = document.getElementById("idmeno");

if(typ==1 )
{
document.form1.firma.value="";
document.form1.firma.disabled=true;
idfirma.style.display="none";
document.form1.ico.value="";
document.form1.ico.disabled=true;
idico.style.display="none";

document.form1.dic.value="";
document.form1.dic.disabled=true;

iddic.style.display="none";
idmeno.style.display="";
}
else
{
document.form1.firma.disabled=false;

idfirma.style.display="";

document.form1.ico.disabled=false;
document.form1.dic.disabled=false;

idico.style.display="";
iddic.style.display="";
idmeno.style.display="none";

document.form1.meno.value="";
document.form1.priezvisko.value="";
document.form1.titul.value="";
document.form1.titul2.value="";

}
}

// ******************************************
function ZmenTypInz()
{
var druh=document.getElementById("druh").value;
var izby=document.getElementById("izby");
var stav=document.getElementById("stav");
var rozloha1=document.getElementById("rozloha1");
var rozloha2=document.getElementById("rozloha2");

if (druh=="1" || druh=="2" || druh=="3")
	izby.style.display="";
else
	{
	document.inz1.pocetizieb.value='';
	izby.style.display="none";
	}
if (druh=='')
	{
	document.inz1.stavnehnutelnosti.value='';
	document.inz1.rozlohanehnutelnosti.value='';
	stav.style.display="none";
	rozloha1.style.display="none";
	}
else
	{
	stav.style.display="";
	rozloha1.style.display="";
	}
if (druh=="2" || druh=="3")
	rozloha2.style.display="";
else
	{
	document.inz1.rozlohapozemku.value='';
	rozloha2.style.display="none";
	}

}
// Trim function in javascript 

// ******************************************
function trim(str)
{
    while (str.substring(0,1) == ' ') // check for white spaces from beginning
    {
       str = str.substring(1, str.length);
    }
    while (str.substring(str.length-1, str.length) == ' ') // check white space from end
    {
        str = str.substring(0,str.length-1);
    }
    return str;
}


// ************************************************************
function SetOkres(ff,dajprazdny) {

   var kraj = ff.kraj; //document.inz3.kraj;

   
   // Clear out the list of teams
   ClearOptions(ff.okres);

   if (dajprazdny==1)
      AddToOptionList(ff.okres, "", "");
   
   if (kraj[kraj.selectedIndex].value == "1") {
      AddToOptionList(ff.okres, "Banská Bystrica", "Banská Bystrica");
      AddToOptionList(ff.okres, "Banská Štiavnica", "Banská Štiavnica");
      AddToOptionList(ff.okres, "Brezno", "Brezno");
      AddToOptionList(ff.okres, "Detva", "Detva");
      AddToOptionList(ff.okres, "Krupina", "Krupina");
      AddToOptionList(ff.okres, "Lučenec", "Lučenec");
      AddToOptionList(ff.okres, "Poltár", "Poltár");
      AddToOptionList(ff.okres, "Revúca", "Revúca");
      AddToOptionList(ff.okres, "Rimavská Sobota", "Rimavská Sobota");
      AddToOptionList(ff.okres, "Veľký Krtíš", "Veľký Krtíš");
      AddToOptionList(ff.okres, "Zvolen", "Zvolen");
      AddToOptionList(ff.okres, "Žarnovica", "Žarnovica");
      AddToOptionList(ff.okres, "Žiar nad Hronom", "Žiar nad Hronom");
   }

   if (kraj[kraj.selectedIndex].value == "2") {
      AddToOptionList(ff.okres, "Bratislava I", "Bratislava I");
      AddToOptionList(ff.okres, "Bratislava II", "Bratislava II");
      AddToOptionList(ff.okres, "Bratislava III", "Bratislava III");
      AddToOptionList(ff.okres, "Bratislava IV", "Bratislava IV");
      AddToOptionList(ff.okres, "Bratislava V", "Bratislava V");
      AddToOptionList(ff.okres, "Malacky", "Malacky");
      AddToOptionList(ff.okres, "Pezinok", "Pezinok");
      AddToOptionList(ff.okres, "Senec", "Senec");
   }

   if (kraj[kraj.selectedIndex].value == "3") {
      AddToOptionList(ff.okres, "Gelnica", "Gelnica");
      AddToOptionList(ff.okres, "Košice I", "Košice I");
      AddToOptionList(ff.okres, "Košice II", "Košice II");
      AddToOptionList(ff.okres, "Košice III", "Košice III");
      AddToOptionList(ff.okres, "Košice IV", "Košice IV");
      AddToOptionList(ff.okres, "Košice - okolie", "Košice - okolie");
      AddToOptionList(ff.okres, "Michalovce", "Michalovce");
      AddToOptionList(ff.okres, "Rožňava", "Rožňava");
      AddToOptionList(ff.okres, "Sobrance", "Sobrance");
      AddToOptionList(ff.okres, "Spišská Nová Ves", "Spišská Nová Ves");
      AddToOptionList(ff.okres, "Trebišov", "Trebišov");

   }
   if (kraj[kraj.selectedIndex].value == "4") {
      AddToOptionList(ff.okres, "Komárno", "Komárno");
      AddToOptionList(ff.okres, "Levice", "Levice");
      AddToOptionList(ff.okres, "Nitra", "Nitra");
      AddToOptionList(ff.okres, "Nové Zámky", "Nové Zámky");
      AddToOptionList(ff.okres, "Šaľa", "Šaľa");
      AddToOptionList(ff.okres, "Topoľčany", "Topoľčany");
      AddToOptionList(ff.okres, "Zlaté Moravce", "Zlaté Moravce");
   }
   if (kraj[kraj.selectedIndex].value == "5") {
      AddToOptionList(ff.okres, "Bardejov", "Bardejov");
      AddToOptionList(ff.okres, "Humenné", "Humenné");
      AddToOptionList(ff.okres, "Kežmarok", "Kežmarok");
      AddToOptionList(ff.okres, "Levoča", "Levoča");
      AddToOptionList(ff.okres, "Medzilaborce", "Medzilaborce");
      AddToOptionList(ff.okres, "Poprad", "Poprad");
      AddToOptionList(ff.okres, "Prešov", "Prešov");
      AddToOptionList(ff.okres, "Sabinov", "Sabinov");
      AddToOptionList(ff.okres, "Snina", "Snina");
      AddToOptionList(ff.okres, "Stará Ľubovňa", "Stará Ľubovňa");
      AddToOptionList(ff.okres, "Stropkov", "Stropkov");
      AddToOptionList(ff.okres, "Svidník", "Svidník");
      AddToOptionList(ff.okres, "Vranov nad Topľou", "Vranov nad Topľou");
   }
   if (kraj[kraj.selectedIndex].value == "6") {
      AddToOptionList(ff.okres, "Bánovce nad Bebravou", "Bánovce nad Bebravou");
      AddToOptionList(ff.okres, "Ilava", "Ilava");
      AddToOptionList(ff.okres, "Myjava", "Myjava");
      AddToOptionList(ff.okres, "Nové Mesto nad Váhom", "Nové Mesto nad Váhom");
      AddToOptionList(ff.okres, "Partizánske", "Partizánske");
      AddToOptionList(ff.okres, "Považská Bystrica", "Považská Bystrica");
      AddToOptionList(ff.okres, "Prievidza", "Prievidza");
      AddToOptionList(ff.okres, "Púchov", "Púchov");
      AddToOptionList(ff.okres, "Trenčín", "Trenčín");
   }
   if (kraj[kraj.selectedIndex].value == "7") {
      AddToOptionList(ff.okres, "Dunajská Streda", "Dunajská Streda");
      AddToOptionList(ff.okres, "Galanta", "Galanta");
      AddToOptionList(ff.okres, "Hlohovec", "Hlohovec");
      AddToOptionList(ff.okres, "Piešťany", "Piešťany");
      AddToOptionList(ff.okres, "Senica", "Senica");
      AddToOptionList(ff.okres, "Skalica", "Skalica");
      AddToOptionList(ff.okres, "Trnava", "Trnava");
   }
   if (kraj[kraj.selectedIndex].value == "8") {
      AddToOptionList(ff.okres, "Bytča", "Bytča");
      AddToOptionList(ff.okres, "Čadca", "Čadca");
      AddToOptionList(ff.okres, "Dolný Kubín", "Dolný Kubín");
      AddToOptionList(ff.okres, "Kysucké Nové Mesto", "Kysucké Nové Mesto");
      AddToOptionList(ff.okres, "Liptovský Mikuláš", "Liptovský Mikuláš");
      AddToOptionList(ff.okres, "Martin", "Martin");
      AddToOptionList(ff.okres, "Námestovo", "Námestovo");
      AddToOptionList(ff.okres, "Ružomberok", "Ružomberok");
      AddToOptionList(ff.okres, "Turčianske Teplice", "Turčianske Teplice");
      AddToOptionList(ff.okres, "Tvrdošín", "Tvrdošín");
      AddToOptionList(ff.okres, "Žilina", "Žilina");
   }

}
// ***************************
function ClearOptions(OptionList) {

   // Always clear an option list from the last entry to the first
   for (x = OptionList.length; x >= 0; x = x - 1) {
      OptionList[x] = null;
   }
}
// ***************************
function AddToOptionList(OptionList, OptionValue, OptionText) {
   // Add option to the bottom of the list
   OptionList[OptionList.length] = new Option(OptionText, OptionValue);
}

// ***************************
function NastavOkres(okr,ff)
{
var myselect=ff.okres;
//alert (myselect.options[0].value);
for (var i=0; i<myselect.options.length; i++){
 if (myselect.options[i].value==okr){
   myselect.options[i].selected=true ; 
   break;
 }
}
}


