/*------------------------------------------------------------------------------*/
function javascriptAppBootstrap()
{
	if(globalBootsrapCounter == 1)
		appLoadOnce();
	appLoadEveryTime();
	appLoadEveryTimeWithContext(globalBootsrapContextReloaded);
	globalBootsrapCounter++;
}

/*------------------------------------------------------------------------------*/
function appLoadEveryTime()
{
	improveAppUI();
}

/*------------------------------------------------------------------------------*/
function appLoadOnce()
{
	intiFavLinkContainerFollowing();
}

/*------------------------------------------------------------------------------*/
function appLoadEveryTimeWithContext(contextReloaded)
{

}


/*------------------------------------------------------------------------------*/
function improveAppUI()
{
	if($.support.opacity)
	{
		$(".mycontents_apps_installed").corner("5px");
		$(".mycontents_apps_not_installed").corner("5px");
	}
}

/*------------------------------------------------------------------------------*/
function checkFormAddUser(form)
{
	var result = true;
	var indice = "";
	
	if(!checkEmptyValue(form.user_login))
	{
		indice += "\n+ Login incorrect";
		result = false;	
	}
	
	if(!checkEmptyPwdValue(form.user_password))
	{
		indice += "\n+ Mot de passe incorrect";
		result = false;	
	}
	
	if(!checkEmptyValue(form.prenom))
	{
		indice += "\n+ Prénom incorrect";
		result = false;	
	}
	
	if(!checkEmptyValue(form.nom))
	{
		indice += "\n+ Nom incorrect";
		result = false;	
	}
	
	if(!checkEmptySelect(document.getElementsByName("id_roles[]")[0]))
	{
		indice += "\n+ Roles incorrects";
		result = false;	
	}
		
	if(result)
		return true;
	else
	{
		alert("Formulaire incorrect :\n"+indice);
		return false;
	}
}

/*------------------------------------------------------------------------------*/
function checkFormMyAccount(form)
{
	var result = true;
	var indice = "";
	
	if(!checkEmptyValue(form.user_login))
	{
		indice += "\n+ Login incorrect";
		result = false;	
	}
	
	if(!checkEmptyPwdValue(form.user_password))
	{
		indice += "\n+ Mot de passe incorrect";
		result = false;	
	}
	
	if(!checkEmptyValue(form.prenom))
	{
		indice += "\n+ Prénom incorrect";
		result = false;	
	}
	
	if(!checkEmptyValue(form.nom))
	{
		indice += "\n+ Nom incorrect";
		result = false;	
	}
		
	if(result)
		return true;
	else
	{
		alert("Formulaire incorrect :\n"+indice);
		return false;
	}
}


/*------------------------------------------------------------------------------*/
function warningDeleteUser()
{
	return confirm("Voulez-vous vraiment supprimer cet utilisateur ?");
}

/*------------------------------------------------------------------------------*/
function warningInstall()
{
	return confirm("Etes vous sûr de lancer la procédure d'installation ?");
}

/*------------------------------------------------------------------------------*/
function warningConfiguration()
{
	return confirm("Etes vous sûr de vouloir modifier le fichier de configuration ?");
}

/*------------------------------------------------------------------------------*/
function warningUninstall()
{
	return confirm("Etes vous sûr de lancer la procédure de désinstallation ?");
}

/*------------------------------------------------------------------------------*/
function warningInstallReset()
{
	return confirm("Etes vous sûr de lancer la procédure de réinstallation ?");
}

/*------------------------------------------------------------------------------*/
function expandTranslationBlocksCommand()
{
	$('#expandTranslationBlocksCommand').hide();
	$('#collapseTranslationBlocksCommand').show();
	$('.translationBlock').each(function(){
		toggleSubtitle($(this));
	});
}

/*------------------------------------------------------------------------------*/
function collapseTranslationBlocksCommand()
{
	$('#expandTranslationBlocksCommand').show();
	$('#collapseTranslationBlocksCommand').hide();	
	$('.translationBlock').each(function(){
		toggleSubtitle($(this));
	});
}

/*------------------------------------------------------------------------------*/
function initTranslationBlocks()
{
	$('#expandTranslationBlocksCommand').hide();				
}

/*------------------------------------------------------------------------------*/
function checkFormStart(form)
{
	var result = true;
	var indice = "";
	
	if(!checkEmptyValue(form.login_admin))
	{
		indice += "\n+ Login incorrect";
		result = false;	
	}
	
	if(!checkEmptyValue(form.password_admin))
	{
		indice += "\n+ Mot de passe incorrect";
		result = false;	
	}
	
	if(!checkEmptyValue(form.email_admin))
	{
		indice += "\n+ Email incorrect";
		result = false;	
	}
	
	
	if(!checkEmptyValue(form.DB_HOST))
	{
		indice += "\n+ Serveur incorrect";
		result = false;	
	}
	
	if(!checkEmptyValue(form.DB_DATABASE))
	{
		indice += "\n+ Base incorrecte";
		result = false;	
	}
	
	if(!checkEmptyValue(form.DB_USER))
	{
		indice += "\n+ Utilisateur incorrect";
		result = false;	
	}
			
	if(result)
		return true;
	else
	{
		alert("Formulaire incorrect :\n"+indice);
		return false;
	}
}

/*------------------------------------------------------------------------------*/
function testBase()
{
	url = makeUrlAjax("installation","startTestBase",new Array($('#DB_HOST').val(),$('#DB_DATABASE').val(),$('#DB_USER').val(),$('#DB_PASSWORD').val()));
	ajaxGet(
		url,
		".trap",
		function(data){
			if(jQuery.parseJSON(data).msg=='ok') 
			{
				$('#baseResultOK').show();
				$('#baseResultKO').hide();
			} 
			else 
			{				
				$('#baseResultKO').show();
				$('#baseResultOK').hide();
			}
		}
	);
}

/*------------------------------------------------------------------------------*/
function warningStart()
{
	return confirm("Etes vous sûr de lancer le démarrage ?");
}
