function nextsibling(item){
	if(item.nextSibling.nodeType==3)var sibling=item.nextSibling.nextSibling; 
	else var sibling=item.nextSibling;
	
	if(sibling.style.display=='none'){
		sibling.style.display='block';
	}else{
		sibling.style.display='none';
	}
}

function showfoto(){
  var fotodiv=document.getElementById('fotografie');
  var mapadiv=document.getElementById('mapa');
  var fotoa=document.getElementById('a_foto');
  var mapaa=document.getElementById('a_map');
  
  mapadiv.style.display='none';
  fotodiv.style.display='block';
  
  mapaa.setAttribute("class", "right"); 
  fotoa.setAttribute("class", "left active"); 
}

function showmap(){
  var fotodiv=document.getElementById('fotografie');
  var mapadiv=document.getElementById('mapa');
  var fotoa=document.getElementById('a_foto');
  var mapaa=document.getElementById('a_map');
  
  mapadiv.style.display='block';
  fotodiv.style.display='none';
 
  mapaa.setAttribute("class", "right active"); 
  fotoa.setAttribute("class", "left"); 
}

function poptavkaShow(){
  var popdiv=document.getElementById('poptavka');
  popdiv.style.display='block';
}

function poptavkaHide(){
  var popdiv=document.getElementById('poptavka');
  popdiv.style.display='none';
}

function IsNumeric(sText){
  var ValidChars = "0123456789., ";
  var IsNumber=true;
  var Char;
  for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1)IsNumber = false;
  }
  return IsNumber;
}

function IsDatum(sText){
  var IsDatum=true;
  if(IsNumeric(sText.charAt(0))==false)IsDatum=false;
  if(IsNumeric(sText.charAt(1))==false)IsDatum=false;
  if(sText.charAt(2)!='.')IsDatum=false;
  if(IsNumeric(sText.charAt(3))==false)IsDatum=false;
  if(IsNumeric(sText.charAt(4))==false)IsDatum=false;
  if(sText.charAt(5)!='.')IsDatum=false;
  if(sText.charAt(6)!='2')IsDatum=false;
  if(sText.charAt(7)!='0')IsDatum=false;
  if(IsNumeric(sText.charAt(8))==false)IsDatum=false;
  if(IsNumeric(sText.charAt(9))==false)IsDatum=false;
  return IsDatum;
}


function steponeverify(form){
  //if(form.delkapronajmu.value==''){alert('Vyplňte délku pronájmu');return false;}
  //if(IsNumeric(form.delkapronajmu.value)==false){alert('Délka pronájmu musí být pouze číselná hodnota.');return false;}
  if(form.cena.value==''){alert('Vyplňte cenu');return false;}
  if(IsNumeric(form.cena.value)==false){alert('Cena musí být pouze číselná hodnota.');return false;}
  if(form.poplatky.value==''){alert('Vyplňte měsíční poplatky');return false;}
  if(IsNumeric(form.poplatky.value)==false){alert('Poplatky musí být pouze číselná hodnota.');return false;}
  if(form.kdispozici.value==''){alert('Vyplňte od kdy je pronájem k dispozici');return false;}
  if(IsDatum(form.kdispozici.value)==false){alert('Datum musí mít formát dd.mm.yyyy, například: 21.02.2012');return false;}
  if(form.plocha.value==''){alert('Vyplňte plochu');return false;}
  if(IsNumeric(form.plocha.value)==false){alert('Plocha musí být pouze číselná hodnota.');return false;}
  return true;
}
function steptwoverify(form){
  if(form.mesto.value==''){alert('Vyplňte město');return false;}
  if(form.ulice.value==''){alert('Vyplňte ulici');return false;}
  if(form.delka.value==''){alert('Vyplňte GPS Longtitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  if(form.sirka.value==''){alert('Vyplňte GPS Latitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  if(form.delka.value==0){alert('Vyplňte GPS Longtitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  if(form.sirka.value==0){alert('Vyplňte GPS Latitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  return true;
}

function steponepoptavkaverify(form){
  if(form.delkapronajmu.value==''){alert('Vyplňte délku pronájmu');return false;}
  if(IsNumeric(form.delkapronajmu.value)==false){alert('Délka pronájmu musí být pouze číselná hodnota.');return false;}
  if(form.cenaod.value==''){alert('Vyplňte minimální měsíční poplatky');return false;}
  if(IsNumeric(form.cenaod.value)==false){alert('Poplatky musí být pouze číselná hodnota.');return false;}
  if(form.cenado.value==''){alert('Vyplňte maximální měsíční poplatky');return false;}
  if(IsNumeric(form.cenado.value)==false){alert('Poplatky musí být pouze číselná hodnota.');return false;}
  if(form.kdispozici.value==''){alert('Vyplňte od kdy je pronájem k dispozici');return false;}
  if(IsDatum(form.kdispozici.value)==false){alert('Datum musí mít formát dd.mm.yyyy, například: 21.02.2012');return false;}
  if(form.plochaod.value==''){alert('Vyplňte minimální plochu');return false;}
  if(IsNumeric(form.plochaod.value)==false){alert('Plocha musí být pouze číselná hodnota.');return false;}
  if(form.plochado.value==''){alert('Vyplňte maximální plochu');return false;}
  if(form.jmeno.value==''){alert('Vyplňte jméno');return false;}
  if(form.email.value==''){alert('Vyplňte e-mail');return false;}
  if(form.telefon.value==''){alert('Vyplňte telefon');return false;}
  if(IsNumeric(form.plochado.value)==false){alert('Plocha musí být pouze číselná hodnota.');return false;}
  if(IsNumeric(form.telefon.value)==false){alert('Telefon musí být pouze z čísel.');return false;}
  return true;
}

function steptwopoptavkaverify(form){
  if(form.mesto.value==''){alert('Vyplňte město');return false;}
  if(form.delka.value==''){alert('Vyplňte GPS Longtitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  if(form.sirka.value==''){alert('Vyplňte GPS Latitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  if(form.delka.value==0){alert('Vyplňte GPS Longtitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  if(form.sirka.value==0){alert('Vyplňte GPS Latitude. Nejjednoduššeji klikutím na tlačítko Potvrdit adresu.');return false;}
  return true;
}

function stepthreeverify(form){
  if(form.popis_cz.value==''){alert('Vyplňte krátký popis pronájmu');return false;}
  return true;
}

function regformVerify(form){
  if(form.podminky.checked!=true){alert('Přečtěte si podmínky a potvrďte prosím jejich přeštení zaškrtnutím');return false;}
  if(form.email.value==''){alert('Vyplňte e-mail');return false;}
  if(form.telefon.value==''){alert('Vyplňte telefon');return false;}
  if(form.jmeno.value==''){alert('Vyplňte jméno');return false;}
  if(form.prijmeni.value==''){alert('Vyplňte přijmení');return false;}
  if(form.heslo.value==''){alert('Vyplňte heslo');return false;}
  if(form.heslo.value!=form.hesloznovu.value){alert('Zadaná hesla vzájemně nesouhlasí');return false;}
  if(form.heslo.value.length<6){alert('Heslo musí mít alespoň 6 znaků');return false;}
  return true;
}
function regformVerifyFirma(form){
  if(form.podminky.checked!=true){alert('Přečtěte si podmínky a potvrďte prosím jejich přeštení zaškrtnutím');return false;}
  if(form.email.value==''){alert('Vyplňte e-mail');return false;}
  if(form.telefon.value==''){alert('Vyplňte telefon');return false;}
  if(form.jmeno.value==''){alert('Vyplňte název společnosti');return false;}
  if(form.ulice.value==''){alert('Vyplňte ulici');return false;}
  if(form.obec.value==''){alert('Vyplňte obec');return false;}
  if(form.psc.value==''){alert('Vyplňte psč');return false;}
  if(form.stat.value==''){alert('Vyplňte stát');return false;}
  if(form.ic.value==''){alert('Vyplňte IČ');return false;}
  if(form.heslo.value==''){alert('Vyplňte heslo');return false;}
  if(form.heslo.value!=form.hesloznovu.value){alert('Zadaná hesla vzájemně nesouhlasí');return false;}
  if(form.heslo.value.length<6){alert('Heslo musí mít alespoň 6 znaků');return false;}
  return true;
}
function updformVerify(form){
  if(form.email.value==''){alert('Vyplňte e-mail');return false;}
  if(form.telefon.value==''){alert('Vyplňte telefon');return false;}
  if(form.jmeno.value==''){alert('Vyplňte jméno');return false;}
  if(form.prijmeni.value==''){alert('Vyplňte přijmení');return false;}
  return true;
}
function passformVerify(form){
  if(form.heslo.value==''){alert('Vyplňte heslo');return false;}
  if(form.heslo.value!=form.hesloznovu.value){alert('Zadaná hesla vzájemně nesouhlasí');return false;}
  if(form.heslo.value.length<6){alert('Heslo musí mít alespoň 6 znaků');return false;}
  return true;
}

    var map = null;
    var geocoder = null;
    var address;
    

function getAddress(overlay, latlng) {
  
  if (latlng != null) {
    //address = latlng;
    geocoder.getLocations(latlng, showAddress);
  }
}
/*
function showAddress(response){
  if (!response || response.Status.code != 200) {
    alert("Status Code:" + response.Status.code);
  } else {
    place = response.Placemark[0];alert(latlng);
    marker.openInfoWindowHtml(place.address.replace(/, /gi,'<br />'));
    var latInput=document.getElementById('sirka');
          var lngInput=document.getElementById('delka');
    latInput.value=place.Point.coordinates[1];
    lngInput.value=place.Point.coordinates[1];
  }
}
*/
    function initialize(delka,sirka) {
    var defaultSirka = 15.5700;
    var defaultDelka = 49.8000;
    
      if (sirka == null || sirka==0 || sirka=='')sirka = defaultSirka;
      if (delka == null || delka==0 || delka=='')delka = defaultDelka;
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        geocoder = new GClientGeocoder();
        map.setUIToDefault();
        if(delka==defaultDelka && sirka==defaultSirka)map.setCenter(new GLatLng(delka, sirka), 7); //7
        else {
          map.setCenter(new GLatLng(delka, sirka), 13);  
          //map.addControl(new GSmallMapControl());
          //map.addControl(new GMapTypeControl());
          var point = new GLatLng(delka, sirka);
          var marker = new GMarker(point, {draggable: true});
          GEvent.addListener(marker, "dragstart", function() {map.closeInfoWindow();});
          GEvent.addListener(marker, "dragend", function() {var ll=marker.getLatLng(); getAddress(marker,ll);});
         // GEvent.addListener(map, "click", getAddress);
          map.addOverlay(marker); 
        }       
      }
    }

    function initialize2(delka,sirka) {
    var defaultSirka = 15.5700;
    var defaultDelka = 49.8000;
      if (sirka == null || sirka==0 || sirka=='')sirka = defaultSirka;
      if (delka == null || delka==0 || delka=='')delka = defaultDelka;
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas_small"));
        geocoder = new GClientGeocoder();
        
        if(delka==defaultDelka && sirka==defaultSirka)map.setCenter(new GLatLng(delka, sirka), 7);
        else {
          map.setCenter(new GLatLng(delka+0.03, sirka-0.04), 12);  
          map.addControl(new GSmallMapControl());
          //map.addControl(new GMapTypeControl());
          var point = new GLatLng(delka, sirka);
          var marker = new GMarker(point);
         // GEvent.addListener(map, "click", getAddress);
          map.addOverlay(marker); 
        }
      }
    }
    
    function initialize3(delka2,sirka2) {
    var defaultSirka = 15.5700;
    var defaultDelka = 49.8000;
      if (sirka2 == null || sirka2==0 || sirka2=='')sirka2 = defaultSirka;
      if (delka2 == null || delka2==0 || delka2=='')delka2 = defaultDelka;
      if (GBrowserIsCompatible()) {
        map3 = new GMap2(document.getElementById("map_canvas_area"));
        geocoder = new GClientGeocoder();
        map3.setUIToDefault();
        if(delka2==defaultDelka && sirka2==defaultSirka)map3.setCenter(new GLatLng(delka2, sirka2), 7);
        else {
          map3.setCenter(new GLatLng(delka2, sirka2), 12);  
          //var point2 = new GLatLng(delka2, sirka2);
          //var newIcon = MapIconMaker.createLabeledMarkerIcon({addStar: true, label: "x",labelSize: 6, primaryColor: "#00ff00"});
          //var marker2 = new GMarker(point2, {icon: newIcon});
          //map3.addOverlay(marker2); 
        }
      }
    }
    
    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            var latInput=document.getElementById('sirka');
            var lngInput=document.getElementById('delka');
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point, {draggable: true});
              GEvent.addListener(marker, "dragstart", function() {map.closeInfoWindow();});
              GEvent.addListener(marker, "dragend", function() {marker.openInfoWindowHtml(address.replace(/, /gi,'<br />'));var npoint=marker.getLatLng();latInput.value=npoint.lat();lngInput.value=npoint.lng();});
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address.replace(/, /gi,'<br />'));
              latInput.value=point.lat();
              lngInput.value=point.lng();
            }
          }
        );
      }
    }
    
    function showAddress2(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            var latInput=document.getElementById('sirka');
            var lngInput=document.getElementById('delka');
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 11);
              
            }
          }
        );
      }
    }
    
    




