//Affiche ou masque un ou plusieurs elements html en fonction de leur etat
function Js_GenericShowOrHide(){

	if (arguments == undefined) return;
    
	var e = null;
	
    for (i = 0; i < arguments.length; i++)
	{
		e = document.getElementById(arguments[i]);
		
		if (e != undefined)
			e.style.display=(e.style.display=='none')?'block':'none';		
	}
}

//Affiche ou masque un element html en fonction de son etat et produit l'effet inverse sur un autre élément.
function Js_GenericShowOrHideWithTwoElement(id1,id2){
    if (document.getElementById(id1).style.display=='none'){
        document.getElementById(id1).style.display='';
        document.getElementById(id2).style.display='none';
    }else {
        document.getElementById(id1).style.display='none';
        document.getElementById(id2).style.display='';
    }
}

function Js_GenericShowOrHideWithNElement() {
    if (arguments == undefined) return;
    var e = null;
    for (i = 0; i < arguments.length; i++)
    {
        if (i == 0) {
            var d = document.getElementById(arguments[0]);
            if (d != undefined) {
                d.style.display = (d.style.display == 'block') ? 'none' : 'block';
            }
        }
        else {
            e = document.getElementById(arguments[i]);
            if (e != undefined) {
                e.style.display = 'none';
            }
        }
    }
//    if (document.getElementById(id1).style.display == 'none') {
//        document.getElementById(id1).style.display = '';
//        document.getElementById(id2).style.display = 'none';
//    } else {
//        document.getElementById(id1).style.display = 'none';
//        document.getElementById(id2).style.display = '';
//    }
}

//Imprime et ferme la fenetre
function imprime_zone(titre, obj){
    var f=apercu( titre, obj )
    f.window.print();
    f.window.close();
    return true;
}
function apercu(titre, obj){
	// Définie la zone à imprimer
	var zi = document.getElementById(obj).innerHTML;

	// Ouvre une nouvelle fenetre
	var f = window.open("", "ZoneImpr", "height=500, width=600,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");
	f.document.body.innerHTML += " " + zi + " ";
	return f;
}
function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
}
function Js_VerifCheckBox(id,msg){
    var chkAcceptCgu=document.getElementById(id);    
    if (!chkAcceptCgu) return false;
    if (chkAcceptCgu.checked==false){
        alert(msg);
        return false;
    }
    return true;
}
function MM_preloadImages(){
    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 MM_swapImage(id){
	if(document.getElementById(id).src == document.MM_p[0].src)
		document.getElementById(id).src = document.MM_p[1].src;
	else
		document.getElementById(id).src = document.MM_p[0].src;
}
//Pour les captures ecrans dans les fiches produits, onglet Captures ecrans
function CaptureEcran(id1, id2, src){
    document.getElementById(id1).style.display='block';
	document.getElementById(id2).style.display='block';
	document.getElementById('CaptureGrand').src=src;
}

/*
Fonction:OnCPChange
Rule: When the zip Code change, this function call an Ajax funtion to change the country
Space: Used by Formulaires/FormAdressPostal.ascx */
function OnCPChange(id_codepostal, id_combo) {
    if (FormAdressPostal == null)
        return;

    var ctrl = document.getElementById(id_codepostal);
    var ctrlcombo = document.getElementById(id_combo);

    if (ctrl == null)
        return;
    if (ctrlcombo == null)
        return;

    var tab = FormAdressPostal.ChangeCodePostal(ctrl.value);

    for (var i = 0; i < ctrlcombo.options.length; i++) {
        if (ctrlcombo.options[i].value == tab.value) {
            ctrlcombo.options[i].selected = true;
            break;
        }
    }
}
//pour ajouter un favori, mais ne fonctionne que sur IE et FF, projet landing page Facile
function favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("Ciel Assistance Online","http://www.ciel.com/assistance-facile-accueil-ciel.aspx",""); }
else { window.external.AddFavorite("http://www.ciel.com/assistance-facile-accueil-ciel.aspx","Ciel Assistance Online"); } }
