function change_banner_auto () {
	hodnota = document.getElementById ( 'banner_1' ).style.display;
//	if(hodnota) { alert('alert: ' + hodnota);}
	if(hodnota == "none") {
		document.getElementById ( 'banner_1' ).style.display = "block";
		document.getElementById ( 'banner_2' ).style.display = "none";
		document.getElementById ( 'banner_button' ).className = "bannerButton1";
	} else if (hodnota == "block") {
		document.getElementById ( 'banner_1' ).style.display = "none";
		document.getElementById ( 'banner_2' ).style.display = "block";	
		document.getElementById ( 'banner_button' ).className = "bannerButton2";	
	}
}

function show_div () {
	hodnota = document.getElementById ( 'sel1' ).value;
//	if(hodnota) { alert('alert: ' + hodnota);}
	if(hodnota == 1) {
		document.getElementById ( 'div1' ).style.display = "block";
		document.getElementById ( 'div2' ).style.display = "none";
		document.getElementById ( 'div3' ).style.display = "none";
		document.getElementById ( 'div4' ).style.display = "none";
		document.getElementById ( 'div5' ).style.display = "none";
	} else if (hodnota == 2) {
		document.getElementById ( 'div1' ).style.display = "none";
		document.getElementById ( 'div2' ).style.display = "block";
		document.getElementById ( 'div3' ).style.display = "none";
		document.getElementById ( 'div4' ).style.display = "none";
		document.getElementById ( 'div5' ).style.display = "none";
	} else if (hodnota == 3) {
		document.getElementById ( 'div1' ).style.display = "none";
		document.getElementById ( 'div2' ).style.display = "none";
		document.getElementById ( 'div3' ).style.display = "block";
		document.getElementById ( 'div4' ).style.display = "none";
		document.getElementById ( 'div5' ).style.display = "none";
	} else if (hodnota == 4) {
		document.getElementById ( 'div1' ).style.display = "none";
		document.getElementById ( 'div2' ).style.display = "none";
		document.getElementById ( 'div3' ).style.display = "none";
		document.getElementById ( 'div4' ).style.display = "block";
		document.getElementById ( 'div5' ).style.display = "none";
	}else if (hodnota == 5) {
		document.getElementById ( 'div1' ).style.display = "none";
		document.getElementById ( 'div2' ).style.display = "none";
		document.getElementById ( 'div3' ).style.display = "none";
		document.getElementById ( 'div4' ).style.display = "none";
		document.getElementById ( 'div5' ).style.display = "block";
	}
}

function show_div2 () {
	hodnota = document.getElementById ( 'sel1' ).value;
	document.getElementById ( 'div' + hodnota ).style.display = "block";
	for (i=0; i<1000; i++) {
		if (hodnota != i) {
			document.getElementById ( 'div' + i ).style.display = "none";
		}
	}
}
function show_div3 (from,to) {
	hodnota = document.getElementById ( 'sel1' ).value;
	document.getElementById ( 'div' + hodnota ).style.display = "block";
	for (i=from; i<to; i++) {
		if (hodnota != i) {
			document.getElementById ( 'div' + i ).style.display = "none";
		}
	}
}


function zkontroluj_email(adresa)
 {
 // zjištění pozice znaku @
     var pozice_zavinace = adresa.indexOf("@");
 // kontrola pravidla 1, je aspoň jeden @ v adrese?
     if (pozice_zavinace < 0)
         return false;
 // získání částí před a po znaku @
     var cast_pred_zavinacem = adresa.substring(0,pozice_zavinace);
     var cast_po_zavinaci = adresa.substring(pozice_zavinace+1,adresa.length);
 // kontrola pravidla 1, zda tam není ještě další @
     if (cast_po_zavinaci.indexOf("@") >= 0)
         return false;
 // kontrola pravidla 2
     if (cast_pred_zavinacem.length <= 0)
         return false;
 // kontrola pravidla 3
     if (cast_po_zavinaci.length <= 0)
         return false;
 // zjištění pozice poslední tečky
     var pozice_posledni_tecky = cast_po_zavinaci.lastIndexOf(".");
 // kontrola pravidla 4
     if (pozice_posledni_tecky < 0)
         return false;
 // kolik znaků je ještě za poslední tečkou?
     var pocet_znaku_za_posledni_teckou = cast_po_zavinaci.length - pozice_posledni_tecky - 1;
 // kontrola pravidla 6
     if (pocet_znaku_za_posledni_teckou < 2  ||  pocet_znaku_za_posledni_teckou > 3)
         return false;
 // kontrola pravidla 7
     var pozice_dvou_tecek_vedle_sebe = adresa.indexOf("..");
     if (pozice_dvou_tecek_vedle_sebe >= 0)
         return false;
 // kontrola pravidla 5 u části před @
     if (cast_pred_zavinacem.charAt(0) == "."  ||  cast_pred_zavinacem.charAt(cast_pred_zavinacem.length-1) == ".")
         return false;
 // kontrola pravidla 5 u části po @
     if (cast_po_zavinaci.charAt(0) == "."  ||  cast_po_zavinaci.charAt(cast_po_zavinaci.length-1) == ".")
         return false;
 // pokud jsme se dostali až sem, vše je O.K.
     return true;
 }
 
 function valid_date1_orig(text) { 
 	if (/^\d{1,2}\.\d{1,2}.\d{4}$/.test(text)) { 
 		var dmy = text.split("."); 
 		var d = dmy[0] - 0; 
 		var m = dmy[1] - 1; 
 		var y = dmy[2] - 0; 
 		var date = new Date(y, m, d); 
 
 		return (date.getDate() == d && date.getMonth() == m && date.getFullYear() == y); 
 	} 
 
 	return false; 
 } 
 
function Cislo_smlouvy(str) { //cislo s pocetm cifer vetsim nebo rovnem 8
 	if (/^\d{8,}$/.test(str)) { 
 		return true; 
 	} 
 	return false; 
 } 
 
 function valid_date2_orig(str) { 
 	var regEx = /^((0?[1-9])|([1-2][0-9])|(3[01])).((0?[1-9])|(1[012])).\d{4}$/; 
 
 	if(!regEx.test(str)) { 
 		return false; 
 	} 
 
 	var arr = str.split('.'); 
 
 	var d = parseInt(arr[0], 10); 
 	var m = parseInt(arr[1], 10); 
 	var y = parseInt(arr[2], 10); 
 
 	var dt=new Date(y,m-1,d); 
 
 	if(dt.getFullYear()!=y || dt.getMonth()!=m-1 || dt.getDate()!=d) { 
 		return false; 
 	} 
 
 	return true; 
 }

 
 function valid_date(str) {
 	var regEx = /^((0?[1-9])|([1-2][0-9])|(3[01])).((0?[1-9])|(1[012])).\d{4}$/;

 	if(!regEx.test(str)) {
 		return false;
 	}

 	var arr = str.split('.');

 	var d = parseInt(arr[0], 10);
 	var m = parseInt(arr[1]-1, 10);
 	var y = parseInt(arr[2], 10);

 	var dt=new Date(y,m,d);
 	var dt_act=new Date(); //aktualni cas

 	dt_act.setTime(dt_act.getTime()+20*24*60*60*1000); //aktualni cas + 20 dnu

//	return dt.getFullYear() + "!=" + y + " || " + dt.getMonth() + "!= " + m + " || " + dt.getDate() + "!=" + d + " ----- " + dt_act.getFullYear() + " " + (dt_act.getMonth()) + " " + dt_act.getDate();
 	if(dt.getFullYear()!=y || dt.getMonth()!=m || dt.getDate()!=d) {
 		return 1;
 	}
 	if(dt.getTime()<dt_act.getTime()){ //pokud je zadany cas mensi nez aktualni + 21 dnu, tak chyba
 		return 2;
 	}

 	return 3;
 }
 
function testICO(x)
{
  try
  {
    var a = 0;
    if(x.length == 0) return true;
    if(x.length != 8) throw 1;
    var b = x.split('');
    var c = 0;
    for(var i = 0; i < 7; i++) a += (parseInt(b[i]) * (8 - i));
    a = a % 11;
    c = 11 - a;
    if(a == 1) c = 0;
    if(a == 0) c = 1;
    if(a == 10) c = 1;
    if(parseInt(b[ 7]) != c) throw(1);
  }
  catch(e)
  {
    alert('Zadané IČO není korektní!');
    return false;
  }
  return true;
}

function testDIC(x)
{
  try
  {
    if(x.length == 0) return true;
    var id = x.substr(0, 2).toUpperCase();
    x = x.substr(2);
    if((id == 'CZ') || (id == 'SK'))
    {
      if(x.length < 8) throw 1;
      if(x.length > 11) throw 1;
      if(x.length == 8)
      {
        return testICO(x);
      }
      else
      {
        return testRC(x, 18);
      }
      throw 1;
    }
    alert('Není možné zkontrolovat DIČ mimo Českou a Slovenskou republiku!');
    return true;
  }
  catch(e)
  {
    alert('Zadané DIČ není korektní!');
    return false;
  }
}

function testRC(x, age)
{
  if(!age) age = 0;
  try
  {
    if(x.length == 0) return true;
    if(x.length < 9) throw 1;
    var year = parseInt(x.substr(0, 2), 10);
    var month = parseInt(x.substr(2, 2), 10);
    var day = parseInt( x.substr(4, 2), 10);
    var ext = parseInt(x.substr(6, 3), 10);
    if((x.length == 9) && (year < 54)) return true;
    var c = 0;
    if(x.length == 10) c = parseInt(x.substr(9, 1));
    var m = parseInt( x.substr(0, 9)) % 11;
    if(m == 10) m = 0;
    if(m != c) throw 1;
    year += (year < 54) ? 2000 : 1900;
    if((month > 70) && (year > 2003)) month -= 70;
    else if (month > 50) month -= 50;
    else if ((month > 20) && (year > 2003)) month -= 20;
    var d = new Date();
    if((year + age) > d.getFullYear()) throw 1;
    if(month == 0) throw 1;
    if(month > 12) throw 1;
    if(day == 0) throw 1;
    if(day > 31) throw 1;
  }
  catch(e)
  {
//    alert('Zadané rodné číslo není korektní!');
    return false;
  }
  return true;
}