// JavaScript Document
// détection navigateur
var detect = navigator.userAgent.toLowerCase();
//alert(detect);
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
//--------------------------------------------------------------------

function effacer_form1() {

	document.form1.clefs.value = '';
// --------------------------------------------------------------------
}
function effacer_form1_submit() {

	document.form1.clefs.value = '';
	document.form1.ref_categorie.value = 'Toutes';
	document.form1.submit();

}
// --------------------------------------------------------------------
function form1_submit() {
	
	document.form1.submit();
}
// --------------------------------------------------------------------
function check_form(text) {
	
	if (document.form_payer.checkbox.checked == true) {
		document.form_payer.submit();
	}
	else {
		alert(text);
	}
}
// --------------------------------------------------------------------
function check_dp(text) {

	d = document;
	
	if(d.saisie_dp.prenom.value.length < 3 || d.saisie_dp.nom.value.length < 3 || d.saisie_dp.adresse_1.value.length < 3 || d.saisie_dp.code_postal.value.length < 3 || d.saisie_dp.ville.value.length < 3 ) { 

		alert(text);
	}
	else if (!d.saisie_dp.checkbox_livraison.checked && (d.saisie_dp.prenom_livraison.value.length < 3 || d.saisie_dp.nom_livraison.value.length < 3 || d.saisie_dp.adresse_1_livraison.value.length < 3 || d.saisie_dp.code_postal_livraison.value.length < 3 || d.saisie_dp.ville_livraison.value.length < 3)) {
		
		alert('V\351rifiez l\'adresse de livraison, svp.\nPruefen Sie die Lieferadresse.\nPlease check the delivery address.');
	}
	else if ((document.saisie_dp.elements['pays'].options[document.saisie_dp.elements['pays'].selectedIndex].value == 'ETATS-UNIS D\'AMERIQUE' || document.saisie_dp.elements['pays'].options[document.saisie_dp.elements['pays'].selectedIndex].value == 'UNITED STATES OF AMERICA' || document.saisie_dp.elements['pays'].options[document.saisie_dp.elements['pays'].selectedIndex].value == 'VEREINIGTE STAATEN VON AMERIKA') && document.saisie_dp.elements['etat'].options[document.saisie_dp.elements['etat'].selectedIndex].value == '') {
			alert ('S\351lectionnez un \351tat, svp.\nBitte W\344hlen Sie einen Staat.\nPlease select a State.');
	}
	else if ((document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'ETATS-UNIS D\'AMERIQUE' || document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'UNITED STATES OF AMERICA' || document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'VEREINIGTE STAATEN VON AMERIKA') && document.saisie_dp.elements['etat_livraison'].options[document.saisie_dp.elements['etat_livraison'].selectedIndex].value == '') {
			alert ('S\351lectionnez un \351tat, svp.\nBitte W\344hlen Sie einen Staat.\nPlease select a State.');
	}
	else {
		
		d.saisie_dp.submit();
	}
}
// --------------------------------------------------------------------
function set_state_select_disabled($nom) {
	
	if ($nom == 'pays') {
	
		document.getElementById('etat').disabled = !(document.saisie_dp.elements['pays'].options[document.saisie_dp.elements['pays'].selectedIndex].value == 'ETATS-UNIS D\'AMERIQUE' || document.saisie_dp.elements['pays'].options[document.saisie_dp.elements['pays'].selectedIndex].value == 'UNITED STATES OF AMERICA' || document.saisie_dp.elements['pays'].options[document.saisie_dp.elements['pays'].selectedIndex].value == 'VEREINIGTE STAATEN VON AMERIKA');
	}
	
	else if ($nom == 'pays_livraison') {
	
		document.getElementById('etat_livraison').disabled = !(document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'ETATS-UNIS D\'AMERIQUE' || document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'UNITED STATES OF AMERICA' || document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'VEREINIGTE STAATEN VON AMERIKA');
	}
}
// -----------------------------------------------------------------
function set_adresse_livraison_disabled () {

	document.getElementById('prenom_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	document.getElementById('nom_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	document.getElementById('adresse_1_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	document.getElementById('adresse_2_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	document.getElementById('code_postal_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	document.getElementById('ville_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	document.getElementById('pays_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	
	if (document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'ETATS-UNIS D\'AMERIQUE' || document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'UNITED STATES OF AMERICA' || document.saisie_dp.elements['pays_livraison'].options[document.saisie_dp.elements['pays_livraison'].selectedIndex].value == 'VEREINIGTE STAATEN VON AMERIKA') {
		document.getElementById('etat_livraison').disabled = document.getElementById('checkbox_livraison').checked;
	}
}
//---------------------------------------------------------------------
function check_uncheck($hidden_input_id) {
	
/*	if (document.getElementById($hidden_input_id).value == 'true') {
		document.getElementById($hidden_input_id).value == 'false';
	}
	else
		document.getElementById($hidden_input_id).value == 'true',
		
*/	document.getElementById('modif_newsletter').submit();
}
//------------------------------------------------------------
function submit_form($form_id) {
	
	document.getElementById($form_id).submit();
}
//-------------------------------------------------------------
function commentaire() {
	
	if (document.getElementById("boite_commentaire").style.height == '0px') {
		
		document.getElementById("boite_commentaire").style.height = '70px';
		document.getElementById("plus_moins").innerHTML = '&nbsp;-&nbsp;';
	}
	else {
		document.getElementById("boite_commentaire").style.height = '0px';
		document.getElementById("plus_moins").innerHTML = '&nbsp;+&nbsp;';
	}
}
//----------------------------------------------------------------------------
var ACTIVE_VIDEO_ID;


function play_video(VIDEO_ID) {
	
	if (!ACTIVE_VIDEO_ID) {
		
		ACTIVE_VIDEO_ID = document.getElementById("extrait_id").innerHTML;
	}
	
	if (VIDEO_ID != ACTIVE_VIDEO_ID) {
	
		chaine1 = '<object width="520" height="410"><param name="movie" value="http://www.youtube.com/v/';
		chaine2 = '&hl=fr_FR&fs=1&color1=0xFAF1E1&color2=0xFAF1E1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/';
		chaine3 = '&hl=fr_FR&fs=1&color1=0xFAF1E1&color2=0xFAF1E1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="520" height="410"></embed></object>';
		chaine = chaine1 + VIDEO_ID + chaine2 + VIDEO_ID + chaine3;
		
		document.getElementById("objet_youtube").innerHTML = chaine;
		
		document.getElementById(ACTIVE_VIDEO_ID).innerHTML = '<img src="/gif_png/video_play.png" border="0" alt="Play" title="Play" class="alpha" />';
		document.getElementById(VIDEO_ID).innerHTML = '<img src="/gif_png/video_stop.png" border="0" alt="Stop" title="Stop" class="alpha" />';
		
		ACTIVE_VIDEO_ID = VIDEO_ID;
	}
	
}
//------------------------------------------------------------------------------
var ACTIVE_AUDIO_ID;
var ACTIVE_COMPOSITEUR;
var ACTIVE_TITRE;


function play_audio(AUDIO_ID, COMPOSITEUR, TITRE) {
	
	if (AUDIO_ID != ACTIVE_AUDIO_ID) {
		
		if (ACTIVE_AUDIO_ID) {
			
			document.getElementById('div_lecteur_audio').style.visibility = "hidden";
		}
		document.getElementById('div_lecteur_audio').style.visibility = "visible";
		
		document.getElementById('div_lecteur_audio').innerHTML = '<table cellpadding="0" cellspacing="0" border="0" class="shadow"><tr><td style="padding-left:4px; padding-right:4px;">'+'<embed src="WTMP3-light.swf" quality="high" wmode="transparent" width="250" height="40" type="application/x-shockwave-flash" flashvars="mp3=/mp3/'+AUDIO_ID+'&autoplay=1&bgcolor=0xCCCCCC&showtime=1&volume=100" pluginspage="http://www.macromedia.com/go/getflashplayer"></td><td style="padding-left:4px; padding-right:8px;"><span class="repertoire_compositeur"><span class="courier">&nbsp;</span>'+COMPOSITEUR+'</span><br /><span class="repertoire_titre_oeuvre"><span class="courier">&nbsp;</span>'+TITRE+'</span></td></tr></table>';

		ACTIVE_AUDIO_ID = AUDIO_ID;
		ACTIVE_COMPOSITEUR = COMPOSITEUR;
		ACTIVE_TITRE = TITRE;
	}
	
}
//--------------------------------------------------------------------------------
var objTimer;

function photo_ouvrir(PHOTO_URL, PHOTO_LARGEUR, PHOTO_HAUTEUR) {
	
	var _div_principal = document.getElementById('div_principal');
	var _div_masque = document.getElementById('div_masque');
	var _div_photo = document.getElementById('div_photo');
	var _div_bouton_fermer = document.getElementById('div_bouton_fermer');
	
	MARGE_min = 54;

	FENETRE_LARGEUR = _div_masque.clientWidth;
	FENETRE_HAUTEUR = _div_masque.clientHeight;
	
	LARGEUR_max = FENETRE_LARGEUR - (MARGE_min * 2);
	HAUTEUR_max = FENETRE_HAUTEUR - (MARGE_min * 2);
	
	LARGEUR_ratio = LARGEUR_max / PHOTO_LARGEUR;
	HAUTEUR_ratio = HAUTEUR_max / PHOTO_HAUTEUR;
	
//		alert (LARGEUR_ratio+' - '+HAUTEUR_ratio);
	
	if (LARGEUR_ratio <= HAUTEUR_ratio && LARGEUR_ratio <= 1) {
		
		WIDTH = PHOTO_LARGEUR * LARGEUR_ratio;
		HEIGHT = parseInt(PHOTO_HAUTEUR / PHOTO_LARGEUR * WIDTH);
	}
	else if (HAUTEUR_ratio < 1) {
		
		
		HEIGHT = PHOTO_HAUTEUR * HAUTEUR_ratio;
		WIDTH = parseInt(PHOTO_LARGEUR / PHOTO_HAUTEUR * HEIGHT);
	}
	else {
		
		WIDTH = PHOTO_LARGEUR;
		HEIGHT = PHOTO_HAUTEUR;
	}
	
//		alert (WIDTH+' - '+HEIGHT);

	_div_masque.style.visibility = "visible";
	_div_photo.style.visibility = "visible";
	_div_photo.style.left = String(((FENETRE_LARGEUR - WIDTH) / 2) + 'px');
	_div_photo.style.top = String(((FENETRE_HAUTEUR - HEIGHT) / 2) + 'px');

	_div_photo.innerHTML = '<img src="'+PHOTO_URL+'" width="'+WIDTH+'" height="'+HEIGHT+'" border="0" /><div align="center" style="bottom:0px;"></div>';
	
	if (browser == "Safari") {
		
		objTimer = setTimeout("photo_ouvrir('"+PHOTO_URL+"', "+PHOTO_LARGEUR+", "+PHOTO_HAUTEUR+")", 50);
	}
}
function photo_fermer() {
	
	window.clearTimeout(objTimer);
	objTimer = null;
	
	document.getElementById('div_masque').style.visibility = "hidden";
	document.getElementById('div_photo').style.visibility = "hidden";
	document.getElementById('div_photo').innerHTML = '';
}
