/**
 * checkboxAdresseClick
 */
function checkboxAdresseClick() {
	inverseModifiable( "raison_sociale" );
	inverseModifiable( "adresse" );
	inverseModifiable( "code_postal" );
	inverseModifiable( "ville" );
	inverseModifiable( "pays" );
}

/**
 * checkboxAdresseLivraisonClick
 */
function checkboxAdresseLivraisonClick() {
	inverseModifiable( "raison_sociale_livraison" );
	inverseModifiable( "adresse_livraison" );
	inverseModifiable( "code_postal_livraison" );
	inverseModifiable( "ville_livraison" );
	inverseModifiable( "pays_livraison" );
}

/**
 * Méthode qui active ou désactive un composant en fonction de son id
 *
 * @param int idComposant
 */
function inverseModifiable( idComposant ) {
	// on récupére le composant
	composant = document.getElementById( idComposant );

	if ( composant.disabled == true ) {
		composant.disabled = false;
	} else {
		composant.disabled = true;
	}
}

/**
 * Méthode qui Masque ou Affiche un composant en fonction de son id
 *
 * @param int idComposant
 */
function inverseVisibilite( idComposant ) {
	// on récupère le composant
	composant = document.getElementById( idComposant );

	if ( composant.style.display == "none" ) {
		composant.style.display = "";
	} else {
		composant.style.display = "none";
	}
}

/**
 * Fonction qui renvoie la valeur du radio sélectionné
 *
 * @param objRadio objet radio en html
 *
 * @return string
 */
function getRadionValue( objRadio ) {
	if( !objRadio ) {
		return "";
	}
	var radioLength = objRadio.length;
	if ( radioLength == undefined ) {
		if ( objRadio.checked ) {
			return objRadio.value;
		} else {
			return "";
		}
	}
	for( var i = 0; i < radioLength; i++ ) {
		if( objRadio[i].checked ) {
			return objRadio[i].value;
		}
	}
	return "";
}

/**
 * Fonction protège l'affichage des adresse email
 *
 * @param email
 */
function protegerEmail(email) {
	email = email.replace('*a*', '@');
	email = email.replace('*b*', '.');
	document.write( email );
}

/**
 * Fonction gère l'affichage des menus
 *
 * @param menu
 */
function afficheMenu($menu) {
	if(document.getElementById($menu).style.display == 'none') {
		document.getElementById($menu).style.display = 'block';
	} else {
		document.getElementById($menu).style.display = 'none';
	}
}

/**
 * ouvrirContenuPhotos
 */
function ouvrirContenuPhotos() {
	// on récupère le composant

	document.getElementById( 'contenu_photos' ).style.display = '';
	document.getElementById( 'contenu_infos' ).style.display = 'none';

	document.getElementById( 'onglet_photos' ).className = 'onglet';
	document.getElementById( 'onglet_infos' ).className = 'onglet non_selectionne';
}
/**
 * ouvrirContenuInfos
 */
function ouvrirContenuInfos() {
	// on récupère le composant

	document.getElementById( 'contenu_photos' ).style.display = 'none';
	document.getElementById( 'contenu_infos' ).style.display = '';

	document.getElementById( 'onglet_photos' ).className = 'onglet non_selectionne';
	document.getElementById( 'onglet_infos' ).className = 'onglet';
}

var saveRecherche = null;

/**
 *	isKeyEntrer
 *
 * @param e
 * @param String recherche
 * @return boolean true si la touche est "entrée"
 */
function isKeyEntrer(e, recherche) {
	var event;
	var key;
//	var keychar;

	if (window.event) {
		event = window.event;
		key = window.event.keyCode;
	} else if (e) {
		event = e;
		key = event.which;
	}

//	var keychar = String.fromCharCode(key);
	// control keys
	if ( key == 13 && recherche != saveRecherche ) {
		saveRecherche = recherche;
		return true;
	} else {
		return false;
	}
}


function OuvrirPop(url,nom,haut,Gauche,largeur,hauteur,options) {
	ouvpop=window.open(url,nom,"top="+haut+",left="+Gauche+",width="+largeur+",height="+hauteur+", resizable=no, scrollbars=yes");
}

