function VyplnFormAction(skript)
{					  
	var FormElement = document.getElementById("PosliEmailForm");

	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	
	if (FormElement != undefined){
		FormElement.action = baseUrl + 'tools/'+skript+'?AuthKey=' + NahodneCislo; 	
	}
	
}

 //-----------------------------------------------------------------------------------
 
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 otevriPanel( divId )
{
	div = document.getElementById(divId);
	
	if (div.style.display=='block') {
		document.getElementById(divId).style.display='none';
	} else {
		document.getElementById(divId).style.display='block';
	}
}

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

function VyplnNapisNamFormAction(skript)
{					  
	var FormElement = document.getElementById("PosliEmailForm");

	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	
	jmeno = document.getElementById("jmeno").value;
	email = document.getElementById("email").value;
	mess = document.getElementById("mess").value;
	
	if (!jmeno) {
		return ohlaschybu('Vyplňte prosím jméno.');
	}
	if (!mess) {
		return ohlaschybu('Vyplňte prosím zprávu.');
	}
	if (!email) {
		return ohlaschybu('Vyplňte prosím email.');
	}
	
	if (FormElement != undefined){
		FormElement.action = BASE__URL + 'tools/'+skript+'?AuthKey=' + NahodneCislo; 	
	}
	
}
//-----------------------------------------------------------------------------------
function ohlaschybu(str){
   Ext.MessageBox.show({
	   title: 'Informace',
	   msg: str,
	   buttons: Ext.MessageBox.OK,
	   icon: Ext.MessageBox.INFO
	});		
	return false;
}

//-----------------------------------------------------------------------------------
function FBautorizuj(formId)
{
	odesliForm(formId, '');
//	
//	FB.init({
//	     appId  : '291768114170915',
//	     status : true, // check login status
//	     cookie : true, // enable cookies to allow the server to access the session
//	     xfbml  : true, // parse XFBML
//	     oauth : true // enables OAuth 2.0
//	   });
//	
//	FB.login(function(response) {
//		console.log(response.authResponse);
//	   if (response.authResponse) {
//	     
//	     FB.getLoginStatus(function(response) {
//		  if (response.authResponse) {
//		  	console.log(response);
//		  	
//		  	odesliForm(formId, response.authResponse.accessToken);
////		  	var body = document.getElementById('fbMess').value;
////			FB.api('/126387950732581/feed', 'post', { message: body }, function(response2) {
////			  if (!response2 || response2.error) {
////			  	alert('bed');
////			  	odesliForm(formId, response.authResponse.accessToken);
////			  } else {
////			  	// -- nemusi se odesilat, uz je ulozeno.
////			  	alert('nemusim');
////			  }
////			});
//		  	
//		   	 
//		  } 
//	     });
//	   } else {
//	     
//	   }
//	 }, {scope:'publish_stream'});

}
//-----------------------------------------------------------------------------------
function odesliForm(formId, accessToken)
{
	document.getElementById('token').value=accessToken;
	var FormElement = document.getElementById( formId );
	
	/**
	 * uploaduju normalni textovy formular
	 */
	if (FormElement != undefined){
		FormElement.submit();
	}

}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
