function showAdress(id, url, id2) {
  document.getElementById('img_' + id).src = document.getElementById(id).style.display == 'none' ? url+'/btn_show_checkbox.jpg' : url+'/btn_hidden_checkbox.jpg';
  document.getElementById(id).style.display = document.getElementById(id).style.display == 'none' ? 'block' : 'none';
  
  if (eval('document.form.' + id2 + '.value') == 1) { 
  	eval('document.form.' + id2 + '.value=0');
   }
   else eval('document.form.' + id2 + '.value=1');
  
  return false;
}

function showInfo(id) {  
  document.getElementById(id).style.display = document.getElementById(id).style.display == 'none' ? 'block' : 'none';  
  return false;
}

function kontrola(formular) {
	var status = 0;
	var globStatus = 0;

	for (t=1; t < kontrola.arguments.length; t++) {
		status = 0;
		// osetreni checkboxu
		if (eval('formular.' + kontrola.arguments[t] + '.type') == 'checkbox') {
			if (!eval('formular.' + kontrola.arguments[t] + '.checked')) {
				status = 1;
			}
		}
		else {
			// zbyle elementy (text, textarea, password)
			var hodnota = eval('formular.' + kontrola.arguments[t] + '.value');

			switch (eval('formular.' + kontrola.arguments[t] + '.type')) {
				case 'text':
				if (isBlank(hodnota)) {
					status = 2;
				}
				else {
					switch(kontrola.arguments[t]) {
						case 'email':
							if(!isEmail(hodnota))
								status = 21;								
							break;
						case 'phone':
							break;
					}
				}			
				
				break;
				case 'textarea':
				if (isBlank(hodnota)) {
					status = 3;
				}
				break;
				case 'password':
				if (isBlank(hodnota)) {
					status = 4;
				}
				break;
			}
		}
		if (status) {
			eval('formular.'+ kontrola.arguments[t] + '.style').border = '1px solid red';
			globStatus = 1;
		}
	}

	if (globStatus) {
		alert('Formulář je chybně vyplněný!');
		return false;
	}

	return true;
}

function isBlank(val) {
	if(val==null){
		return true;
	}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i) != ' ') && (val.charAt(i) != "\t") && (val.charAt(i) != "\n") && (val.charAt(i) != "\r")){return false;}
	}
	return true;
}

function isEmail(argvalue) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(argvalue);
}

/* zobrazovani aktualit (crossfade efekt) - využívá jquery 1.4.4 */

var Perioda = 5000; // rychlost přepínání mezi aktualitami

var Dalsi = 0; // nasledujici aktualita, zvysuje se do "nekonecna" a následně modulo
var PromoSwitch = 1; // oznacuje aktivni div, ve kterem je aktualita
function aktualne(_dalsi) {
    if (_dalsi > 0) {
        nexthop = _dalsi;
        Dalsi = _dalsi;
        MujInterval= clearInterval(MujInterval);
        MujInterval = window.setInterval("aktualne(0)", Perioda);
        PromoSwitch = 1;
        _dalsi = -1;
    }
    else {
        Dalsi = Dalsi + 1;
        nexthop = Dalsi;
    }
    
    if (PromoSwitch == 1) {
        oldPromoSwitch = 1;
        PromoSwitch = 2;
    }
    else {
        oldPromoSwitch = 2;
        PromoSwitch = 1;
    }

    if (_dalsi < 0) {
        jQuery('#promo-switch' + oldPromoSwitch).hide();
        jQuery('#promo-switch' + PromoSwitch).load('aktualne.php?next=' + nexthop);
        jQuery('#promo-switch' + oldPromoSwitch).load('aktualne.php?next=' + (nexthop+1));
        jQuery('#promo-switch' + PromoSwitch).show();
        Dalsi = Dalsi + 1;
    }
    else {
        jQuery('#promo-switch' + PromoSwitch).fadeIn('slow', 'swing');
        jQuery('#promo-switch' + oldPromoSwitch).fadeOut('slow', 'swing', function() { jQuery('#promo-switch' + oldPromoSwitch).load('aktualne.php?next=' + nexthop)});
    }
}



