var aPays = new Array();
aPays['Afghanistan'] = 'Afghanistan|93|00';
aPays['Afrique du Sud'] = 'Afrique du Sud|27|09';
aPays['Albanie'] = 'Albanie|355|00';
aPays['Algérie'] = 'Algérie|213|00';
aPays['Allemagne'] = 'Allemagne|49|00';
aPays['Andorre'] = 'Andorre|376|00';
aPays['Arabie saoudite'] = 'Arabie saoudite|966|00';
aPays['Argentine'] = 'Argentine|54|00';
aPays['Arménie'] = 'Arménie|374|374';
aPays['Australie'] = 'Australie|61|0011';
aPays['Autriche'] = 'Autriche|43|00';
aPays['Azerbaïdjan'] = 'Azerbaïdjan|994|00';
aPays['Bahamas'] = 'Bahamas|1|011';
aPays['Bahreïn'] = 'Bahreïn|973|00';
aPays['Bangladesh'] = 'Bangladesh|880|00';
aPays['Barbade'] = 'Barbade|1|011';
aPays['Belgique'] = 'Belgique|32|00';
aPays['Belize'] = 'Belize|501|00';
aPays['Bénin'] = 'Bénin|229|00';
aPays['Bermudes'] = 'Bermudes|1|00';
aPays['Bhoutan'] = 'Bhoutan|975|00';
aPays['Bolivie'] = 'Bolivie|591|00';
aPays['Bosnie-Herzégovine'] = 'Bosnie-Herzégovine|387|00';
aPays['Botswana'] = 'Botswana|267|00';
aPays['Brésil'] = 'Brésil|55|00';
aPays['Brunei'] = 'Brunei|673|01';
aPays['Bulgarie'] = 'Bulgarie|359|00';
aPays['Burkina'] = 'Burkina Faso|226|00';
aPays['Cambodge'] = 'Cambodge|855|00';
aPays['Cameroun'] = 'Cameroun|237|00';
aPays['Canada'] = 'Canada|1|011';
aPays['Cap-Vert'] = 'Cap-Vert|238|00';
aPays['Centrafrique'] = 'Centrafrique|236|00';
aPays['Chili'] = 'Chili|56|00';
aPays['Chine'] = 'Chine|86|00';
aPays['Chypre'] = 'Chypre|357|00';
aPays['Colombie'] = 'Colombie|57|009';
aPays['Comores'] = 'Comores|269|00';
aPays['Congo, r. démocratique'] = 'Congo, r. démocratique|243|00';
aPays['Congo'] = 'Congo|242|00';
aPays['Corée du Nord'] = 'Corée du Nord|850|00';
aPays['Corée du Sud'] = 'Corée du Sud|82|001';
aPays['Costa Rica'] = 'Costa Rica|506|00';
aPays['Côte d\'Ivoire'] = "Côte d'Ivoire|00|";
aPays['Croatie'] = 'Croatie|385|00';
aPays['Cuba'] = 'Cuba|53|011';
aPays['Danemark'] = 'Danemark|45|00';
aPays['Djibouti'] = 'Djibouti|253|00';
aPays['Égypte'] = 'Égypte|20|00';
aPays['Espagne'] = 'Espagne|34|00';
aPays['Estonie'] = 'Estonie|372|00';
aPays['États-Unis'] = 'États-Unis|1|011';
aPays['Finlande'] = 'Finlande|358|00';
aPays['France'] = 'France|33|00';
aPays['Gabon'] = 'Gabon|241|00';
aPays['Grèce'] = 'Grèce|30|00';
aPays['Guinée'] = 'Guinée|224|00';
aPays['Hong Kong'] = 'Hong Kong|852|001';
aPays['Hongrie'] = 'Hongrie|36|00';
aPays['Inde'] = 'Inde|91|00';
aPays['Indonésie'] = 'Indonésie|62|001';
aPays['Irak'] = 'Irak|964|00';
aPays['Iran'] = 'Iran|98|00';
aPays['Irlande'] = 'Irlande|353|00';
aPays['Islande'] = 'Islande|354|00';
aPays['Israël'] = 'Israël|972|00';
aPays['Italie'] = 'Italie|39|00';
aPays['Japon'] = 'Japon|81|001';
aPays['Kenya'] = 'Kenya|254|00';
aPays['Koweït'] = 'Koweït|965|00';
aPays['Lettonie'] = 'Lettonie|371|00';
aPays['Liban'] = 'Liban|961|00';
aPays['Lituanie'] = 'Lituanie|370|810';
aPays['Luxembourg'] = 'Luxembourg|352|00';
aPays['Malaisie'] = 'Malaisie|60|00';
aPays['Malawi'] = 'Malawi|265|00';
aPays['Mali'] = 'Mali|223|00';
aPays['Maroc'] = 'Maroc|212|00';
aPays['Maurice'] = 'Maurice|230|00';
aPays['Mauritanie'] = 'Mauritanie|222|00';
aPays['Mexique'] = 'Mexique|52|00';
aPays['Monténégro'] = 'Monténégro|382|99';
aPays['Népal'] = 'Népal|977|00';
aPays['Niger'] = 'Niger|227|00';
aPays['Nigeria'] = 'Nigeria|234|009';
aPays['Norvège'] = 'Norvège|47|00';
aPays['Nouvelle-Zélande'] = 'Nouvelle-Zélande|64|00';
aPays['Pakistan'] = 'Pakistan|92|00';
aPays['Pays-Bas'] = 'Pays-Bas|31|00';
aPays['Pérou'] = 'Pérou|51|00';
aPays['Philippines'] = 'Philippines|63|00';
aPays['Pologne'] = 'Pologne|48|00';
aPays['Polynésie française'] = 'Polynésie française|689|001';
aPays['Portugal'] = 'Portugal|351|00';
aPays['Roumanie'] = 'Roumanie|40|00';
aPays['Royaume-Uni'] = 'Royaume-Uni|44|00';
aPays['Russie'] = 'Russie|7|810';
aPays['aint-Pierre-et-Miquelon'] = 'Saint-Pierre-et-Miquelon|508|011';
aPays['Sénégal'] = 'Sénégal|221|00';
aPays['Serbie'] = 'Serbie|381|99';
aPays['Singapour'] = 'Singapour|65|001';
aPays['Slovaquie'] = 'Slovaquie|421|00';
aPays['Slovénie'] = 'Slovénie|386|00';
aPays['Sri Lanka'] = 'Sri Lanka|94|00';
aPays['Suède'] = 'Suède|46|00';
aPays['Suisse'] = 'Suisse|41|00';
aPays['Syrie'] = 'Syrie|963|0';
aPays['Taïwan'] = 'Taïwan|886|002';
aPays['Tchad'] = 'Tchad|235|00';
aPays['République tchèque'] = 'République tchèque|420|00';
aPays['Thaïlande'] = 'Thaïlande|66|001';
aPays['Togo'] = 'Togo|228|00';
aPays['Turquie'] = 'Turquie|90|00';
aPays['Ukraine'] = 'Ukraine|380|810';
aPays['Uruguay'] = 'Uruguay|598|00';
aPays['Venezuela'] = 'Venezuela|58|00';
aPays['Viêt Nam'] = 'Viêt Nam|84|00';
aPays['Zimbabwe'] = 'Zimbabwe|263|00';


// l'exception pour la zone 1 est déjà géré, celui la c pour un exemple
var aExceptions = new Array();
aExceptions['CA-CA'] = '|1';

function majPays()
{
    var f = document.myform;
		
    if(!f || !f.pays) return;
    var aVal = new Array();
    aVal['orig'] = '';
    aVal['pays'] = '';

    if(f.pays.value != '')
    {
        if(aExceptions['France-'+f.pays.value])
        {
            var parts = aExceptions['France-'+f.pays.value].split('|');
            aVal['orig'] = parts[0];
            aVal['pays'] = parts[1];
        }
        else if(aPays['France'] && aPays[f.pays.value])
        {
            var partsOrig = aPays['France'].split('|');
            aVal['orig'] = partsOrig[2];
            var partsDest = aPays[f.pays.value].split('|');
            aVal['pays'] = partsDest[1];
            if(partsOrig[1] == '1' && partsDest[1] == '1') aVal['orig'] = '';
        }
    }
	
	var rst = aVal['orig']+aVal['pays'];
	f.indicatif.value = rst;
	document.getElementById('indic_tel').innerHTML = 'Téléphone <span class="oblig">*</span> (+'+rst+') : '
	document.getElementById('indic_fax').innerHTML = 'Fax (+'+rst+') : '
}

function loadPays(defaut)
{
    var f = document.myform;
    if(!f || !f.pays) return;

    var aSelected = new Array();
    aSelected['pays'] = new Array();
    aSelected['pays']['default'] = defaut;
    aSelected['pays']['current'] = 0;

    var opt;
    for(codePays in aPays)
    {
        parts = aPays[codePays].split('|');
		
        opt = document.createElement('option');
        opt.value = codePays;
        opt.text = parts[0];
        if(aSelected['pays']['default'] == parts[0]) aSelected['pays']['current'] = f.pays.options.length;
        f.pays.options[f.pays.options.length] = opt;
    }

    f.pays.selectedIndex = aSelected['pays']['current'];
    majPays();
}

function cachertout()
{
	document.getElementById('f_etablissement').style.display = 'none';
	document.getElementById('f_civilite').style.display = 'none';
	
	document.getElementById('f_infos_contact').style.display = 'none';
	document.getElementById('f_contact').style.display = 'none';
	
	document.getElementById('f_dejaclient').style.display = 'none';
	document.getElementById('f_localisation').style.display = 'none';
	document.getElementById('f_communication').style.display = 'none';
	document.getElementById('f_envoyer').style.display = 'none';
}

function collectivite_entreprise()
{
	document.getElementById('f_etablissement').style.display = 'block';
	document.getElementById('f_civilite').style.display = 'block';
	
	document.getElementById('f_infos_contact').style.display = 'block';
	document.getElementById('f_contact').style.display = 'block';
	
	document.getElementById('f_dejaclient').style.display = 'block';
	document.getElementById('f_localisation').style.display = 'block';
	document.getElementById('f_communication').style.display = 'block';
	document.getElementById('f_envoyer').style.display = 'block';
}

function particulier_()
{
	document.getElementById('f_etablissement').style.display = 'none';
	document.getElementById('f_civilite').style.display = 'block';
	
	document.getElementById('f_infos_contact').style.display = 'none';
	document.getElementById('f_contact').style.display = 'block';
	
	document.getElementById('f_dejaclient').style.display = 'block';
	document.getElementById('f_localisation').style.display = 'block';
	document.getElementById('f_communication').style.display = 'block';
	document.getElementById('f_envoyer').style.display = 'block';
}
