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);
}