function men(uli){
	ul = document.getElementById(uli);
	al = document.getElementById(uli + '-a');
	if (ul.style.display == '') {
    	ul.style.display = 'none';
    	al.className = 'viceli';
	} else {
		document.getElementById('zachrana-dat').style.display = 'none';
		document.getElementById('dalsi-sluzby').style.display = 'none';
		document.getElementById('o-nas').style.display = 'none';
		document.getElementById('par-pr').style.display = 'none';
		ul.style.display = '';
		document.getElementById('zachrana-dat-a').style.background.image = 'url(../img/vicelip.gif)';
		document.getElementById('dalsi-sluzby-a').style.background.image = 'url(../img/vicelip.gif)';
		document.getElementById('o-nas-a').style.background.image = 'url(../img/vicelip.gif)';
		document.getElementById('par-pr-a').style.background.image = 'url(../img/vicelip.gif)';
	    al.className = 'viceli-down';
	}
}

function schovej(uli){
	ul = document.getElementById(uli);
	ul.style.display = 'none';
}

function ukaz(id)
{
document.getElementById(id).style.visibility = 'visible';
}
function skryj(id)
{
document.getElementById(id).style.visibility = 'hidden';
}
function vypln(id,valuee){
	document.getElementById(id).value = valuee;
}



nazvypper = new Array('jmenof','nazevspol','adresaf','korespond','ico','telefonf','emailf','kodf','dodavatelf','zipp','zipb','vat');
nazvyfir = new Array('jmeno','adresa','telefon','email','kod','dodavatel','zip');
seda="#ECE9D8";
norm="#F3F7FB";

nazvyjejich = new Array('zd_sn','zd_size');

function sed(){
	/*if (document.getElementById("pper").checked){
		for (i=0; i<nazvypper.length; i++){
			document.getElementById(nazvypper[i]).readOnly=true;
			document.getElementById(nazvypper[i]).style.backgroundColor=seda;
		}
		for (i=0; i<nazvyfir.length; i++){
			document.getElementById(nazvyfir[i]).readOnly=false;
			document.getElementById(nazvyfir[i]).style.backgroundColor=norm;
		}
	}
	if (document.getElementById("firm").checked){
		for (i=0; i<nazvyfir.length; i++){
			document.getElementById(nazvyfir[i]).readOnly=true;
			document.getElementById(nazvyfir[i]).style.backgroundColor=seda;
		}
		for (i=0; i<nazvypper.length; i++){
			document.getElementById(nazvypper[i]).readOnly=false;
			document.getElementById(nazvypper[i]).style.backgroundColor=norm;
		}
	}
	
	*/
	
	
	if (document.getElementById("zd_medium_sve").checked){
		document.getElementById("zd_koupit").disabled=true;
		for (i=0; i<nazvypper.length; i++){
			document.getElementById(nazvyjejich[i]).readOnly=false;
			document.getElementById(nazvyjejich[i]).style.backgroundColor=norm;
		}
		
	}
	if (document.getElementById("zd_medium_nase").checked){
		document.getElementById("zd_koupit").disabled=false;
		for (i=0; i<nazvypper.length; i++){
			document.getElementById(nazvyjejich[i]).readOnly=true;
			document.getElementById(nazvyjejich[i]).style.backgroundColor=seda;
		}
		
	}
}
function kontrolaPrazdna(id) {
  if (!jePrazdny(document.getElementById(id).value)) {
      document.getElementById(id).style.background = '#CAFBC0';
      document.getElementById(id).style.border = '1px solid #30FF00';
    return true;
  } else {
      document.getElementById(id).style.background = '#FBC0C0';
      document.getElementById(id).style.border = '1px solid #FF0000';
    return false;
  }
}

function kontrolaMailu(id) {
    value=document.getElementById(id).value;
		reg_vyraz=/^.+@.+\..{2,4}$/;
		if (reg_vyraz.test(value)) {
        document.getElementById(id).style.background = '#CAFBC0';
        document.getElementById(id).style.border = '1px solid #30FF00';
      return true;
    } else {
        document.getElementById(id).style.background = '#FBC0C0';
        document.getElementById(id).style.border = '1px solid #FF0000';
      return false;
    }
}

function jePrazdny(retezec)
    {
      for(var i = 0; i < retezec.length; i++) {
        var znak = retezec.charAt(i);
        if ((znak != ' ') && (znak != '\n') && (znak != '\t')) return false;
      }
      return true;
    }

function spam() {
  if ( document.getElementById('kontrola') ) { 

              document.getElementById('kontrola').value = '123';

            }

            

            if ( document.getElementById('kontrola-div') ) { 

              document.getElementById('kontrola-div').style.visibility = 'hidden';

              document.getElementById('kontrola-div').style.display = 'none';

            }
}

// -- KONTROLA CELEHO FORMULARE ------------------------------------------------
function kontrolaFormulare() {
  var kontrola = true;
  if (!kontrolaPrazdna('jmeno')) {kontrola=false;}
  if (!kontrolaPrazdna('telefon')) {kontrola=false;}
  if (!kontrolaPrazdna('email')) {kontrola=false;}
  if (!kontrolaPrazdna('pozadovanyTermin')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_jmeno')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_prijmeni')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_firma')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_telefon')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_email')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_ulice')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_psc')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_mestourci')) {kontrola=false;}
  if (!kontrolaPrazdna('svoz_kolik')) {kontrola=false;}
  if (kontrola == false) {alert('Špatně vyplněný formulář! \n\nZkontroluje zdali máte správně vyplněny všechny povinné položky.');}
  return kontrola; 
}

//Honza Schenk - preklikavani ve formulari prvni kroky

function pravniStatut(statut){
  if (document.getElementById){
		if (statut == 'soukromaOsoba') {
			document.getElementById('soukromaOsoba').style.display = 'block';
			document.getElementById('firma').style.display = 'none';
			document.getElementById('pper').checked	= 1;
			document.getElementById('firm').checked	= 0;
			
		}
			else {
			document.getElementById('soukromaOsoba').style.display = 'none';
			document.getElementById('firma').style.display = 'block';
			
			document.getElementById('firm').checked	= 1;
			document.getElementById('pper').checked	= 0;
			
			}
		
	}
	  
}

function popiszavady(jaky){
  if (document.getElementById){
		if (jaky == 'zjednoduseny') {
			document.getElementById('zjednoduseny').style.display = 'block';
			document.getElementById('podrobny').style.display = 'none';
		
			
		}
			else {
			document.getElementById('zjednoduseny').style.display = 'none';
			document.getElementById('podrobny').style.display = 'block';
			
			
			}
		
	}
	  
}
function kontrolaPrazdna(id) {
  if (!jePrazdny(document.getElementById(id).value)) {
      document.getElementById(id).style.background = '#CAFBC0';
      document.getElementById(id).style.border = '1px solid #30FF00';
    return true;
  } else {
      document.getElementById(id).style.background = '#FBC0C0';
      document.getElementById(id).style.border = '1px solid #FF0000';
    return false;
  }
}
function kontroladata() {
  var kontrola = true;
  if (!kontrolaPrazdna('jmeno')) {kontrola=false;}
  if (!kontrolaMailu('mail')) {kontrola=false;}
  if (!kontrolaPrazdna('telefon')) {kontrola=false;}
  if (!kontrola) {alert('Špatně vyplněný formulář! \n\nZkontroluje zdali máte správně vyplněny všechny povinné položky.');}
  return kontrola; 
}
function kontrolaRadio(id, idLabel) {
  var radio = document.getElementById(id);
  var radioLabel = document.getElementById(idLabel);
  if (radio.checked) {
	  if (radioLabel != null) {
		  radioLabel.style.background = '#CAFBC0';
		  radioLabel.style.border = '1px solid #30FF00';
	  }
    return true;
  } else {
	  if (radioLabel != null) {
		  radioLabel.style.background = '#FBC0C0';
		  radioLabel.style.border = '1px solid #FF0000';
	  }
    return false;
  }
}



// ------------ SKRITPY PRO FOTOGALERII ---------------
var fotogalerie_fotka;

function nastav_titulek(titulek) {
	if (titulek == undefined) titulek = 'Centrála Datahelp';
	var div = document.getElementById("nazev");
	div.innerHTML = titulek;
}

function ukaz_fotku(fotka) {
	fotogalerie_fotka = fotka;
	var div = document.getElementById("nahled");
	div.innerHTML = '<img src="../img/galerie/galerie/large/'+fotka+'.jpg" id="foto_nahled" alt="" width="320" height="240" />';
	var fotka = document.getElementById('foto_nahled');
	var mala = document.getElementById(fotogalerie_fotka);
	fotka.setAttribute('alt', mala.getAttribute('alt'));
	
	var popis = document.getElementById('popis');
	popis.innerHTML = fotka.getAttribute('alt');
	
	// testuje, jestli nejsme na prvni fotce
	var predchozi = document.getElementById("predchozi");	
	if (fotogalerie_fotka <= 1) {
		predchozi.innerHTML = '';
	} else {
		predchozi.innerHTML = '<a href="#" title="Předchozí fotografie" onclick="ukaz_predchozi()">&lt;&lt;</a>';
	}
	
	// testuje, jestli nejsme na konci galerie
	var dalsi = document.getElementById("dalsi");	
	if (fotogalerie_fotka >= 4) {
		dalsi.innerHTML = '';
	} else {
		dalsi.innerHTML = '<a href="#" title="Další fotografie" onclick="ukaz_dalsi()">&gt;&gt;</a>';
	}
}

function ukaz_dalsi() {
	if (fotogalerie_fotka == undefined) {
		fotogalerie_fotka = 1;
	}
	fotogalerie_fotka++;
	ukaz_fotku(fotogalerie_fotka);
}
		
function ukaz_predchozi() {
	if (fotogalerie_fotka == undefined) {
		fotogalerie_fotka = 1;
	} else {
		fotogalerie_fotka--;
		ukaz_fotku(fotogalerie_fotka);
	}
}	


// ------------ KONTROLA FORMULARE prvni-kroky ---------------
function kontrolaFormularePrvniKroky() {
	var kontrola = true;
	if (!kontrolaPrazdna('jmeno') && !kontrolaPrazdna('jmenof')) {kontrola=false;}
	if (!kontrolaRadio('doprava-osobne', 'doprava-label') && 
		!kontrolaRadio('doprava-poslu', 'doprava-label') &&
		!kontrolaRadio('doprava-vyzvednout', 'doprava-label')) {kontrola=false;}
	if (!kontrolaRadio('zasilani_901', 'zasilani-label') && 
		!kontrolaRadio('zasilani_902', 'zasilani-label') &&
		!kontrolaRadio('zasilani_903', 'zasilani-label')) {kontrola=false;}
	if (kontrola == false) {alert('Špatně vyplněný formulář! \n\nPole: \n"Jméno",\n"Doprava",\n"Zasílání informací prostřednictvím"\n jsou povinné položky.');}
	return kontrola; 	
}

// --- schovani/zobrazeni adresy
function toggleAddress() {
     $("#fakturacni-adresa").slideToggle("slow");
     if($('a#fakturacni-adresa-toggle').text().indexOf('Zobrazit') > -1) {
         $('a#fakturacni-adresa-toggle').text('Skrýt fakturační údaje');
     }else{
         $('a#fakturacni-adresa-toggle').text('Zobrazit fakturační údaje');
     }
}
