var nav = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 5 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )));

/**
GENERAL
****************************************************************************************************************/
/**
Couleur des champs obligatoires
non saisis
***********************/
function couleur(obj)
{
	if (nav) obj.style.backgroundColor = "#E3E3E3";
}
/**
Chargement d'une page
***********************/
function chargement(val){
	if(val=="off"){ 
		document.getElementById('chargement').style.visibility='hidden';
		document.getElementById('chargement').style.height=0;
	}else{
		document.getElementById('chargement').style.visibility='visible';
	}
}

/**
Script des modules
****************************************************************************************************************/
/**
Sélectionne les sous thèmes 
associés aux thèmes
**********************/
function get_ss_theme(){
	
	var theme = "";
	var ss_theme = "";
	
	var themes = document.forms['recherche'].themes;	
	
	var ss_theme = document.forms['recherche'].ss_theme_select.value;
	
	for (i = 0; i < themes.options.length; i++) {
		if (themes.options[i].selected) {
			theme += themes.options[i].value;
		}
	}
	
	$('div#ss_themes').load('./ScriptsNorge/ss_themes.php?theme='+theme+'&ss_theme='+ss_theme);
}

/**
Sélectionne les sous sous thèmes 
associés aux sous thèmes
**********************/
function get_ss_ss_theme() {
	
	var ss_theme = "";
	
	var ss_themes = document.forms['recherche'].sous_theme;		
	
	var ss_ss_theme = document.forms['recherche'].ss_ss_theme_select.value;
	
	for (i = 0; i < ss_themes.options.length; i++) {
		if (ss_themes.options[i].selected) {
			ss_theme += ss_themes.options[i].value;
		}
	}
	$('div#ss_ss_themes').load('./ScriptsNorge/ss_ss_themes.php?ss_theme='+ss_theme+'&ss_ss_theme='+ss_ss_theme,'','');
}

/**
Sélectionne les types
**********************/
function get_type(origine) {

	var type = document.forms['recherche'].type_select.value;

	$('div#type').load('./ScriptsNorge/type.php?origine='+origine+'&type='+type,'','');	
}

/**
Sélectionne les sous types
associés aux types
**********************/
function get_ss_type() {

	var ss_type = document.forms['recherche'].ss_type_select.value;
	
	var types = document.forms['recherche'].type;
	var type = "";
	
	for (i = 0; i < types.options.length; i++) {
		if (types.options[i].selected) {
			type += types.options[i].value;
		}
	}
	$('div#ss_type').load('./ScriptsNorge/ss_type.php?type='+type+'&ss_type='+ss_type,'','');
	
}

/**
Script des formulaires
****************************************************************************************************************/
/**
Vérification du formulaire
des particuliers
***********************/
function verif_form_contact_particulier()
{
	var msg = "";
	var obj = document.formulaire;
	
	if (obj.nom.value == "")
	{
		msg += "Le champ 'Nom' est obligatoire\n";
		if (nav) couleur(obj.nom);
	}	
	
	if (obj.email.value != "")
	{
		indexAroba = obj.email.value.indexOf('@');
		indexPoint = obj.email.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))
		{			
			msg += "Le champ 'Email' est incorrect\n";
			if (nav) couleur(obj.email);
		}
	}
	else
	{		
		msg += "Le champ 'Email' est obligatoire\n";
		if (nav) couleur(obj.email);
	}
	
	if (obj.cp.value == "")
	{
		msg += "Le champ 'Code Postal' est obligatoire\n";
		if (nav) couleur(obj.cp);
	}
	
	if (obj.ville.value == "")
	{
		msg += "Le champ 'Ville' est obligatoire\n";
		if (nav) couleur(obj.ville);
	}
	
	if (obj.message.value == "")
	{
		msg += "Le champ 'Message' est obligatoire\n";
		if (nav) couleur(obj.message);
	}
		
	if (msg == "") obj.submit();
	else
	{
		alert(msg);
		return(false);
	}
}

/**
Vérification du formulaire
des professionnels
***********************/
function verif_form_contact_professionnel()
{
	var msg = "";

	if (document.formulaire.societe.value == "")
	{
		msg += "Le champ 'Société' est obligatoire\n";
		if (nav) document.formulaire.societe.style.backgroundColor = "#ff0000";
	}
	
	if (document.formulaire.nom.value == "")
	{
		msg += "Le champ 'Nom' est obligatoire\n";
		if (nav) document.formulaire.nom.style.backgroundColor = "#ff0000";
	}	
	
	if (document.formulaire.tel.value == "")
	{
		msg += "Le champ 'Téléphone' est obligatoire\n";
		if (nav) document.formulaire.tel.style.backgroundColor = "#ff0000";
	}
	
	if (document.formulaire.email.value != "")
	{
		indexAroba = document.formulaire.email.value.indexOf('@');
		indexPoint = document.formulaire.email.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))
		{
			if (nav) document.formulaire.email.style.backgroundColor = "#ff0000";
			msg += "Le champ 'Email' est incorrect\n";
		}
	}
	else
	{
		if (nav) document.formulaire.email.style.backgroundColor = "#ff0000";
		msg += "Le champ 'Email' est obligatoire\n";
	}
	
	if (document.formulaire.message.value == "")
	{
		msg += "Le champ 'Message' est obligatoire\n";
		if (nav) document.formulaire.message.style.backgroundColor = "#ff0000";
	}
		
	if (msg == "") document.formulaire.submit();
	else
	{
		alert(msg);
		return(false);
	}
}

/**
Vérification du formulaire
de connexion
***********************/
function verifNewsletter()
{	
	var msg = "";
	
	var obj=document.formNewsletter;
	
	if (obj.email.value != "")
	{
		indexAroba = obj.email.value.indexOf('@');
		indexPoint = obj.email.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))
		{
			if (nav) couleur(obj.email);
			msg += "Le champ 'Email' est incorrect\n";
		}
	}
	else
	{
		if (nav) couleur(obj.email);
		msg += "Le champ 'Email' est obligatoire\n";
	}
	
	if (obj.abo[0].checked == true){
	
		if (obj.nom.value == "")
		{
			msg += "Le champ 'Nom' est obligatoire\n";
			if (nav) couleur(obj.nom);
		}
		
		if (obj.prenom.value == "")
		{
			msg += "Le champ 'Prenom' est obligatoire\n";
			if (nav) couleur(obj.prenom);
		}
	
	}
		
	if (msg == "") obj.submit();
	else
	{
		alert(msg);
		return(false);
	}
}

/**
Vérification du formulaire
de connexion
***********************/
function verifLog(obj)
{	
	var msg = "";
	
	if (obj.identifiant.value != "")
	{
		indexAroba = obj.identifiant.value.indexOf('@');
		indexPoint = obj.identifiant.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))
		{
			if (nav) couleur(obj.identifiant);
			msg += "Le champ 'Email' est incorrect\n";
		}
	}
	else
	{
		if (nav) couleur(obj.identifiant);
		msg += "Le champ 'Email' est obligatoire\n";
	}
	
	if (obj.password.value == "")
	{
		msg += "Le champ 'Mot de passe' est obligatoire\n";
		if (nav) couleur(obj.password);
	}
		
	if (msg == "") obj.submit();
	else
	{
		alert(msg);
		return(false);
	}
}

/**
Vérification du formulaire
d'inscription
***********************/
function verifInscription()
{	
	var msg = "";
	var obj = document.form_inscription;
	
	for(i = 0; i<obj.id_groupe.length; i++)
	{		
		
		if (obj.id_groupe[i].checked == true && obj.id_groupe[i].value == 2 && obj.raison_sociale_cli.value=="") 
		{  
			msg += "Le champ 'Raison Sociale' est obligatoire\n"; 
			if (nav) couleur(obj.raison_sociale_cli);
		}
		
		if (obj.id_groupe[i].checked == true && obj.id_groupe[i].value == 2 && obj.description_pro.value=="") 
		{  
			msg += "Le champ 'Description' est obligatoire\n"; 
			if (nav) couleur(obj.description_pro);
		}
	
		if (obj.id_groupe[i].checked == true && obj.id_groupe[i].value == 2 && obj.siret_cli.value=="") {
			msg += "Le champ 'Siret' est obligatoire\n"; 
			if (nav) couleur(obj.siret_cli); 
		}
	}
	
	if (obj.nom_cli.value == "")
	{
		msg += "Le champ 'Nom' est obligatoire\n";
		if (nav) couleur(obj.nom_cli);
	}
	
	if (obj.prenom_cli.value == "")
	{
		msg += "Le champ 'Prenom' est obligatoire\n";
		if (nav) couleur(obj.prenom_cli);
	}
	
	if (obj.adresse_cli.value == "")
	{
		msg += "Le champ 'Adresse' est obligatoire\n";
		if (nav) couleur(obj.adresse_cli);
	}
	
	if (obj.cp_cli.value == "")
	{
		msg += "Le champ 'Code postal' est obligatoire\n";
		if (nav) couleur(obj.cp_cli);
	}
	
	if (obj.ville_cli.value == "")
	{
		msg += "Le champ 'Ville' est obligatoire\n";
		if (nav) couleur(obj.ville_cli);
	}
	
	if (obj.pays_cli.value == "")
	{
		msg += "Le champ 'Pays' est obligatoire\n";
		if (nav) couleur(obj.pays_cli);
	}
	
	if (obj.tel_cli.value == "")
	{
		msg += "Le champ 'Telephone' est obligatoire\n";
		if (nav) couleur(obj.tel_cli);
	}
	
	if (obj.email_cli.value != "")
	{
		indexAroba = obj.email_cli.value.indexOf('@');
		indexPoint = obj.email_cli.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))
		{
			if (nav) couleur(obj.email_cli);
			msg += "Le champ 'Email' est incorrect\n";
		}
	}
	else
	{
		if (nav) couleur(obj.email_cli);
		msg += "Le champ 'Email' est obligatoire\n";
	}
	
	if (obj.password_cli.value == "")
	{
		msg += "Le champ 'Mot de passe' est obligatoire\n";
		if (nav) couleur(obj.password_cli);
	}
	
	if (obj.password_cli.value != obj.password_confirm.value)
	{
		msg += "Votre mot de passe n'est pas identique a la confirmation\n";
		if (nav) couleur(obj.password_cli);
		if (nav) couleur(obj.password_confirm);
	}
		
	if (msg == "") obj.submit();
	else
	{
		alert(msg);
		return(false);
	}
}

/**
Vérification du formulaire
de modification du compte
***********************/
function verifModificationCompte(id_groupe)
{
	var msg = "";
	var obj = document.form_modification_compte;
	
	if (id_groupe == 2 && obj.raison_sociale_cli.value=="") 
	{  
		msg += "Le champ 'Raison Sociale' est obligatoire\n"; 
		if (nav) couleur(obj.raison_sociale_cli);
	}
	
	if (id_groupe == 2 && obj.description_pro.value=="")
	{ 
		msg += "Le champ 'Description' est obligatoire\n"; 
		if (nav) couleur(obj.description_pro);
	}

	if (id_groupe == 2 && obj.siret_cli.value=="") {
		msg += "Le champ 'Siret' est obligatoire\n"; 
		if (nav) couleur(obj.siret_cli); 
	}	
	
	if (obj.nom_cli.value == "")
	{
		msg += "Le champ 'Nom' est obligatoire\n";
		if (nav) couleur(obj.nom_cli);
	}
	
	if (obj.prenom_cli.value == "")
	{
		msg += "Le champ 'Prenom' est obligatoire\n";
		if (nav) couleur(obj.prenom_cli);
	}
	
	if (obj.adresse_cli.value == "")
	{
		msg += "Le champ 'Adresse' est obligatoire\n";
		if (nav) couleur(obj.adresse_cli);
	}
	
	if (obj.cp_cli.value == "")
	{
		msg += "Le champ 'Code postal' est obligatoire\n";
		if (nav) couleur(obj.cp_cli);
	}
	
	if (obj.ville_cli.value == "")
	{
		msg += "Le champ 'Ville' est obligatoire\n";
		if (nav) couleur(obj.ville_cli);
	}
	
	if (obj.pays_cli.value == "")
	{
		msg += "Le champ 'Pays' est obligatoire\n";
		if (nav) couleur(obj.pays_cli);
	}
	
	if (obj.tel_cli.value == "")
	{
		msg += "Le champ 'Telephone' est obligatoire\n";
		if (nav) couleur(obj.tel_cli);
	}
	
	if (obj.email_cli.value != "")
	{
		indexAroba = obj.email_cli.value.indexOf('@');
		indexPoint = obj.email_cli.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))
		{
			if (nav) couleur(obj.email_cli);
			msg += "Le champ 'Email' est incorrect\n";
		}
	}
	else
	{
		if (nav) couleur(obj.email_cli);
		msg += "Le champ 'Email' est obligatoire\n";
	}
	
	if (obj.password_cli.value == "")
	{
		msg += "Le champ 'Mot de passe' est obligatoire\n";
		if (nav) couleur(obj.password_cli);
	}
	
	if (obj.password_cli.value != obj.password_confirm.value)
	{
		msg += "Votre mot de passe n'est pas identique a la confirmation\n";
		if (nav) couleur(obj.password_cli);
		if (nav) couleur(obj.password_confirm);
	}
		
	if (msg == "") obj.submit();
	else
	{
		alert(msg);
		return(false);
	}
}

/**
Vérification du formulaire
de livraison
***********************/
function verifLivraison()
{	
	var msg = "";
	var obj = document.form_livraison;
	
	if (obj.nom_cli.value == "")
	{
		msg += "Le champ 'Nom' est obligatoire\n";
		if (nav) couleur(obj.nom_cli);
	}
	
	if (obj.prenom_cli.value == "")
	{
		msg += "Le champ 'Prenom' est obligatoire\n";
		if (nav) couleur(obj.prenom_cli);
	}
	
	if (obj.adresse_cli.value == "")
	{
		msg += "Le champ 'Adresse' est obligatoire\n";
		if (nav) couleur(obj.adresse_cli);
	}
	
	if (obj.cp_cli.value == "")
	{
		msg += "Le champ 'Code postal' est obligatoire\n";
		if (nav) couleur(obj.cp_cli);
	}
	
	if (obj.ville_cli.value == "")
	{
		msg += "Le champ 'Ville' est obligatoire\n";
		if (nav) couleur(obj.ville_cli);
	}
	
	if (obj.pays_cli.value == "")
	{
		msg += "Le champ 'Pays' est obligatoire\n";
		if (nav) couleur(obj.pays_cli);
	}
		
	if (msg == "") obj.submit();
	else
	{
		alert(msg);
		return(false);
	}
}

/**
Vérification du formulaire
des recrutements
***********************/
function verifRecrutement()
{
	var msg = "";
	var obj = document.form_recrutement;
	
	if (obj.fichier_recrutement.value == "")
	{
		msg += "Le champ 'CV' est obligatoire\n";
		if (nav) couleur(obj.fichier_recrutement);
	}
		
	if (msg == "") obj.submit();
	else
	{
		alert(msg);
		return(false);
	}
}
