// JavaScript Document

function setpng(img) { if(document.all && (IEver=parseFloat(navigator.appVersion.split("MSIE")[1])) && (IEver>=5.5) && (IEver<7) && document.body.filters && img) {
	imgName=img.src.toUpperCase();
	if(imgName.substring(imgName.length-3,imgName.length)=="PNG") img.outerHTML=
		"<span "+(img.id?"id='"+img.id+"' ":"")+(img.className?"class='"+img.className+"' ":"")+(img.title?"title=\""+img.title+"\" ":"")
		+"style=\"width:"+img.width+"px;height:"+img.height+"px;"+(img.align=="left"?"float:left;":(img.align=="right"?"float:right;":""))
		+(img.parentElement.href?"cursor:hand;":"")+"display:inline-block;"+img.style.cssText+";"
		+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.src+"',sizingMethod='scale');\"></span>";
}}

/* Changements d'images navigation */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
/* ** */

function delete_contenu(form_name, field_name, default_value, delete_statut)
{
	if(delete_statut)
	{
		if(document.forms[form_name].elements[field_name].value == default_value)
		{
			document.forms[form_name].elements[field_name].value = '';
		}
		else return false;
	}
	else
	{
		if(document.forms[form_name].elements[field_name].value == '')
		{
			document.forms[form_name].elements[field_name].value = default_value;
		}
		else return false;	
	}
}

function afficher_info(el)
{
	if(el == "courrier")
	{
		document.getElementById("bloc_info_email").style.display = "none";
		document.getElementById("bloc_info_courrier").style.display = "";
		document.getElementById("bloc_info_gen2").style.display = "";
	}
	else
	{
		document.getElementById("bloc_info_courrier").style.display = "none";
		document.getElementById("bloc_info_email").style.display = "";
		document.getElementById("bloc_info_gen2").style.display = "";
	}
}

/* ZOOM IMAGE */
function afficher_zoom(fichier, lien_site)
{
	var so = new SWFObject(lien_site + "swf/zoom-image.swf", "zoomimage", "100%", "100%", "9", "");
	so.addParam("scale", "noscale");
	so.addParam("wmode", "transparent");
	so.addParam("FlashVars","fichier="+fichier);
	so.write("zoom_image");

	afficher("zoom_image","block");
	
	// masque du champs select pour IE6 >_<
	document.getElementById("pays").style.visibility = "hidden";
	
	window.scrollTo(0,0);
}

function afficher(info,etat)
{
	var object = info;
	
	if (document.layers && document.layers[object])
	{ 
		//document.layers[object].visibility = etat;
		document.layers[object].display = etat;
	} 
	else if (document.all)
	{ 
		//document.all[object].style.visibility = etat;
		document.all[object].style.display = etat;
	}
	else if (document.getElementById) 
	{
		//document.getElementById(object).style.visibility = etat; 
		document.getElementById(object).style.display = etat;
	} 
}

function fermer_zoom()
{
	afficher("zoom_image","none");
	
	// ré affichage du champs select pour IE6 >_<
	document.getElementById("pays").style.visibility = "visible";
}
/* */

/*******************************************************************************/
/**																			  **/
/**					FORMULAIRES												  **/
/**																			  **/
/*******************************************************************************/
function verif_form_enregistrement_produit(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_input("nom", '1', "Le nom\n", true);
	check_input("prenom", '1', "Le prenom\n", true);
	check_input("adresse", '', "L'adresse\n", true);
	check_input_codepostal("cp", "Le code postal\n", true);
	check_input("ville", '1', "La ville\n", true);
	check_input("region", '1', "La region\n", true);
	check_input("pays", '1', "Le pays\n", true);
	check_input("tel", '1', "Le telephone\n", true);
	check_input_email("email", "L'email\n", true);
	check_input("num_serie_produit", '1', "le numeroe de serie du produit\n", true);
	check_input("nom_revendeur", '1', "Le nom du revendeur\n", true);
	check_input("date_achat", '1', "La date d'achat\n", true);
	check_input("num_facture", '1', "le numero de facture\n", true);
	check_radio("optin", '1', "Si vous souhaitez etre inscrit a la newsletter\n", true);
	check_input("verif", '1', "Le code de verification\n", true);


	if (error == true) {
		//alert(error_message);
		document.getElementById('alert').style.display = 'block';
		window.location.href = "#alert";
		return false;
	} else {
		document.getElementById('alert').style.display = 'none';
		submitted = true;
		return true;
	}
}

function verif_form_contact(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_input("nom_contact", '1', "Le nom\n", true);
	check_input("prenom_contact", '1', "Le prenom\n", true);
	check_input_email("email_contact", "L'email\n", true);
	check_input("message_contact", '1', "Le message\n", true);
	check_radio("optin_contact", '1', "Si vous souhaitez etre inscrit a la newsletter\n", true);
	check_input("verif", '1', "Le code de verification\n", true);


	if (error == true) {
		//alert(error_message);
		document.getElementById('alert').style.display = 'block';
		window.location.href = "#alert";
		return false;
	} else {
		document.getElementById('alert').style.display = 'none';
		submitted = true;
		return true;
	}
}

function verif_form_documentation(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_radio("supportdoc", '1', "Le support de la documentation\n", true);
	
	if(valeurradio(form_name.supportdoc) == "courrier")
	{
		check_input("nom_doc_courrier", '1', "Le nom\n", true);
		check_input("prenom_doc_courrier", '1', "Le prenom\n", true);
		check_input_email("email_doc_courrier", "L'email\n", true);
		check_input("adresse_doc_courrier", '', "L'adresse\n", true);
		check_input_codepostal("cp_doc_courrier", "Le code postal\n", true);
		check_input("ville_doc_courrier", '1', "La ville\n", true);
		check_input("etat_doc_courrier", '1', "L'etat\n", true);
		check_input("region_doc_courrier", '1', "La region\n", true);
		check_input("pays_doc_courrier", '1', "Le pays\n", true);
	}
	else if(valeurradio(form_name.supportdoc) == "email")
	{
		check_input("nom_doc_email", '1', "Le nom\n", true);
		check_input("prenom_doc_email", '1', "Le prenom\n", true);
		check_input_email("email_doc_email", "L'email\n", true);
	}
	
	check_radio("optin_doc", '1', "Si vous souhaitez etre inscrit a la newsletter\n", true);
	check_input("verif", '1', "Le code de verification\n", true);


	if (error == true) {
		//alert(error_message);
		document.getElementById('alert').style.display = 'block';
		window.location.href = "#alert";
		return false;
	} else {
		document.getElementById('alert').style.display = 'none';
		submitted = true;
		return true;
	}
}

function verif_form_demonstration(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_input("nom_demo", '1', "Le nom\n", true);
	check_input("prenom_demo", '1', "Le prenom\n", true);
	check_input_email("email_demo", "L'email\n", true);
	check_input("tel_demo", '1', "Le telephone\n", true);
	check_input("adresse_demo", '', "L'adresse\n", true);
	check_input_codepostal("cp_demo", "Le code postal\n", true);
	check_input("ville_demo", '1', "La ville\n", true);
	check_input("region_demo", '1', "La region\n", true);
	check_input("pays_demo", '1', "Le pays\n", true);
	
	check_radio("optin_demo", '1', "Si vous souhaitez etre inscrit a la newsletter\n", true);
	check_input("verif", '1', "Le code de verification\n", true);


	if (error == true) {
		//alert(error_message);
		document.getElementById('alert').style.display = 'block';
		window.location.href = "#alert";
		return false;
	} else {
		document.getElementById('alert').style.display = 'none';
		submitted = true;
		return true;
	}
}

function verif_form_posez_question(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_input("nom_faq", '1', "Le nom\n", true);
	check_input("prenom_faq", '1', "Le prenom\n", true);
	check_input_email("email_faq", "L'email\n", true);
	check_input("question_faq", '', "L'adresse\n", true);
	
	check_radio("optin_faq", '1', "Si vous souhaitez etre inscrit a la newsletter\n", true);
	check_input("verif", '1', "Le code de verification\n", true);


	if (error == true) {
		//alert(error_message);
		document.getElementById('alert').style.display = 'block';
		window.location.href = "#alert";
		return false;
	} else {
		document.getElementById('alert').style.display = 'none';
		submitted = true;
		return true;
	}
}

function verif_form_newsletter_push(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_input_email("email_push", "L'email\n", false);

	if (error == true) {
		//alert(error_message);
		document.getElementById("email_push").style.background = "#cc3333";
		document.getElementById('txt_newsletter').style.display = 'none';
		document.getElementById('alert_push').style.display = 'block';
		window.location.href = "#alert_push";
		return false;
	} else {
		document.getElementById("email_push").style.background = "#222222";
		document.getElementById('alert_push').style.display = 'none';
		submitted = true;
		return true;
	}
}

function verif_form_newsletter_inscription(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_input_email("email_newsletter_inscription", "L'email\n", true);

	if (error == true) {
		//alert(error_message);
		document.getElementById('alert').style.display = 'block';
		window.location.href = "#alert";
		return false;
	} else {
		document.getElementById('alert').style.display = 'none';
		submitted = true;
		return true;
	}
}

function verif_form_newsletter_desinscription(form_name) {
	error = false;
	form = form_name;
	error_message = "Merci de remplir ou corriger les champs suivants\n\n";
	
	check_input_email("email_newsletter_desinscription", "L'email\n", true);

	if (error == true) {
		//alert(error_message);
		document.getElementById('alert').style.display = 'block';
		window.location.href = "#alert";
		return false;
	} else {
		document.getElementById('alert').style.display = 'none';
		submitted = true;
		return true;
	}
}
