 // --Sekce Kontakt 
function VyplnDotazFormAction()
{					  
	var FormElement = document.getElementById("PosliEmailForm");

	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 

	if (FormElement != undefined){
		FormElement.action = BASE__URL+'tools/add_mess.php?AuthKey=' + NahodneCislo; 	
	}
	
}

 //-----------------------------------------------------------------------------------
 function VyplnPrihlaskaFormAction()
{					  
	var FormElement = document.getElementById("PosliEmailForm");
	var prav = document.getElementById("prav").checked;
	var fyz = document.getElementById("fyz").checked;

	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	var error = false;
	var tmp;

	var agree = document.getElementById("agree").checked;
	if (agree == false){
				document.getElementById("agreeText").style.color = 'red';
				Ext.MessageBox.show({
			           title: 'Nezadané pole',
			           msg: 'Pro dokončení registrace musíte souhlasit se stanovami ČSVE.',
			           buttons: Ext.MessageBox.OK,
			           icon: Ext.MessageBox.WARNING
			        });
			    return false; 
	}
	
	tmp = document.getElementById("jmeno").value;
	if (tmp == '') error = true;
	tmp = document.getElementById("prijmeni").value;
	if (tmp == '') error = true;
	tmp = document.getElementById("dn").value;
	if (tmp == '') error = true;
	tmp = document.getElementById("rc").value;
	if (tmp == '') error = true;
	tmp = document.getElementById("adresa").value;
	if (tmp == '') error = true;
	tmp = document.getElementById("email").value;
	if (tmp == '') error = true;
	
	if (prav == 'true') {
		tmp = document.getElementById("ic").value;
		if (tmp == '') error = true;
		tmp = document.getElementById("company").value;
		if (tmp == '') error = true;
	}	
	
	if (error){
				Ext.MessageBox.show({
			           title: 'Nezadané pole',
			           msg: 'Nejsou zadány všechny povinné položky.',
			           buttons: Ext.MessageBox.OK,
			           icon: Ext.MessageBox.WARNING
			        });
			    return false;    
	} else {
		if (FormElement != undefined){
			FormElement.action = BASE__URL+'tools/registrace.php?AuthKey=' + NahodneCislo; 	
		}
		return true;
	}
} 
 //-----------------------------------------------------------------------------------
 
function odesliForm( urlPrefix ){
	var formular = document.getElementById('formular');
	var sel = document.getElementById('formsel').value;
	formular.action = urlPrefix + sel;
	formular.submit();
}

 //-----------------------------------------------------------------------------------
 
function showLostPass()
{
	document.getElementById('loginLink').style.display = 'none';
	document.getElementById('lostPassLink').style.display = 'inline';
	
	document.getElementById('loginBox').style.display = 'none';
	document.getElementById('lostPassBox').style.display = 'inline';
}

 //-----------------------------------------------------------------------------------
 
function showLogin()
{
	document.getElementById('lostPassLink').style.display = 'none';
	document.getElementById('loginLink').style.display = 'inline';
	
	document.getElementById('lostPassBox').style.display = 'none';
	document.getElementById('loginBox').style.display = 'inline';
	
}

 //-----------------------------------------------------------------------------------
 
function initializeInputItem( defaultText, elementId ) {
	var value = document.getElementById(elementId).value;
	if (value == defaultText)
		document.getElementById(elementId).value = "";
	else if (value == "")
	    document.getElementById(elementId).value = defaultText;
	return false;    
}

//-----------------------------------------------------------------------------------

function testInput( defaultText, elementId, alertText ){
	
	if (document.getElementById(elementId).value == "" || document.getElementById(elementId).value == defaultText){
		alert (alertText);
		return false;
	} else {
		return true;
	}
	
}

function odesliKviz()
{
	
	
	if ($('#jmeno').val() == ''){
		alert('Vyplňte, prosím, svoje jméno.');
		
	} else if ($('#email').val() == ''){
		alert('Vyplňte, prosím, svůj email.');
		
	} else if ($('#potvrzeni').attr('checked') != true){
		alert('Musíte souhlasit s podmínkami soutěže.');
		
	} else {
		document.getElementById('forum').submit();
	}	
}
