function getCookie(c_name, options) {
		if ( (typeof options != 'undefined') && (options.indexOf('=') != -1) ) {
				OptionArray = options.split(',');
				re = /\s*(\w*)\s*=\s*(.*)\s*/;
				for (opt in OptionArray) {
						var thisone = OptionArray[opt];
						re.exec(thisone);
						eval("var " + RegExp.$1 + " = '" + RegExp.$2 + "';");
				}
		}
		if (document.cookie.length>0) {
				c_start = document.cookie.indexOf(c_name + "=");
				if (c_start!=-1) { 
						c_start=c_start + c_name.length+1;
						c_end=document.cookie.indexOf(";",c_start);
						if (c_end==-1) { c_end = document.cookie.length; }
						return unescape(document.cookie.substring(c_start,c_end));
						//return document.cookie.substring(c_start,c_end);
				} 
		}
		return null;
}

function setCookieVille() 
{
	var date_exp = new Date();
	date_exp.setTime(date_exp.getTime()+(315360000000));
	SetCookie("wooville", "Valide=1|Nom="+ville+"|Code="+ville,date_exp,"/",".orange.fr");
	alert("Votre ville a été enregistrée comme ville favorite, vous aurez désormais la météo et une actualité de votre ville en page d'accueil www.orange.fr");
}
var villeNotdefined = false;
var random_number="ord="+(Math.round(Math.random()*10000000000))+"?";
if( typeof ville != 'undefined' && ville ) {
    // Header ville
    var maville = new Array();
    var nomville = ''; 
    var pubville = '';
    pubville = (typeof vpub[ville] != 'undefined')?vpub[ville]:ville;
    nomville = (typeof vname[ville] != 'undefined')?vname[ville]:capitalizeMe(ville);
    dev = ( document.domain.indexOf(".prog.c.dev.") != -1 ) ? true : false ;

    var dns = (dev) ? '.villes.prog.c.dev.orange.fr' : '.ville.orange.fr';
    var dnsWebcam = (dev) ? 'webcam.en-ville.prog.dev.orange.fr' : 'webcam.en-ville.orange.fr';
    if(ville != '') var villeFl = listeVilles[ville];
    else var villeFl = '';
    document.write('<table width="780" border="0" cellpadding="0" cellspacing="0" class="header" id="h_enville">'+
            '<tr>'+
            '<td width="465">' + headVille('http://c.orange.fr/Ville/headerVille.swf',villeFl,32,'#992222',445,41) + '</td>' +
            '<td width="180" class="deca"><a href="http://en-ville.orange.fr" onclick="setCookieVille();return false;">Choisir cette ville comme favorite</a></td>'+
            '<td width="135" class="deca"><a href="http://en-ville.orange.fr">Choisir une autre ville</a></td>'+
            '</tr>'+
            '</table>');
    document.write('<div class="nav" style="width: 990px;;">'+
            '<table width="780" cellpadding="0" cellspacing="0" border="0">'+
            '<tr>'+
            '<td class="accueil"><a href="http://'+ville+dns+'" target="_top" class="accueil_link">Accueil</a></td>'+
            '<td class="ong_l"> </td>'+
            '<td class="direct"><a href="http://'+ville+dns+'/direct" target="_top">En direct</td>'+
            '<td class="ong_m"> </td>'+
            '<td class="pratique"><a href="http://'+ville+dns+'/pratique" target="_top">Pratique</a></td>'+
            '<td class="ong_m"> </td>'+
            '<td class="ensemble"><a href="http://'+ville+dns+'/ensemble" target="_top">La ville ensemble</a></td>'+
            '<td class="ong_m"> </td>'+
            '<td class="cinema"><a href="http://www.fra.sortie.ville.orange.fr/cinema_'+ listeVilles[ville]['cityvox'] +'/'+ listeVilles[ville]['cityvox'] +'_/Cinema" target="_top">Cin&eacute;ma</a></td>'+
            '<td class="ong_m"> </td>'+
            '<td class="restos"><a href="http://www.fra.sortie.ville.orange.fr/bonnes-adresses_'+listeVilles[ville]["cityvox"]+'/'+listeVilles[ville]["cityvox"]+'_/AccueilLieux" target="_top">Restos, bars, bo&icirc;tes</a></td>'+
            '<td class="ong_m"> </td>'+
            '<td class="sorties"><a href="http://www.fra.sortie.ville.orange.fr/agenda_'+listeVilles[ville]["cityvox"]+'/'+listeVilles[ville]["cityvox"]+'_/MaVille" target="_top">Sorties, &eacute;v&egrave;nements</a></td>'+
            '<td class="ong_m"> </td>'+
            '<td class="sports"><a href="http://'+ville+dns+'/sport" target="_top">Sports</a></td>'+
            '<td class="ong_r"> </td>'+
            '<td > </td>'+
            '</tr>'+
            '</table>'+
        '</div>');

    // SousNav
    var strSousNav = '';
    switch( document.body.id)
    {
        case "direct":
            strSousNav += '<div class="sous_nav">';
        strSousNav += '<span class="accueil"><a href="http://'+ville+dns+'/direct/">Accueil En direct</a></span>';
        if( listeVilles[ville]["cams"])
            strSousNav += '<span class="webcams"><a href="http://'+ville+'.'+dnsWebcam+'/'+webcamType[ville]+'/'+ville+'/index.html">Webcams</a></span>';
        if( ville == "lyon")
            strSousNav += '<span class="telelyon"><a href="http://'+ville+dns+'/direct/telelyon.html">Le journal vidéo</a></span>';
        //if( listeVilles[ville]["photos"])
        //    strSousNav += '<span class="photos"><a href="http://'+ville+dns+'/direct/photo_ville.html">Photos de ville</a></span>';
        strSousNav += '</div>';
        break;
        case "pratique":
            strSousNav += '<div class="sous_nav">';
        strSousNav += '<span class="accueil"><a href="http://'+ville+dns+'/pratique/">Accueil pratique</a></span>';
        strSousNav += '<span class="meteo"><a href="http://'+ville+dns+'/pratique/meteo4j.html">M&eacute;t&eacute;o</a></span>';
        strSousNav += '<span class="trafic"><a href="http://'+ville+dns+'/pratique/trafic.html">Trafic</a></span>';
       // strSousNav += '<span class="plans"><a href="http://'+ville+dns+'/pratique/plan_iti.html">Plans et itinéraires</a></span>';
        strSousNav += '<span class="annuaire"><a href="http://local.search.ke.voila.fr/S/searchproxi?profil=orange_enville&ville='+ville+'&loc='+listeVilles[ville]["vname"]+'">Annuaire</a></span>';
        strSousNav += '<span class="pa"><a href="http://'+ville+dns+'/pratique/petites_annonces.html">Petites annonces</a></span>';
        strSousNav += '</div>';
        break;
        case "ensemble":
            strSousNav += '<div class="sous_nav">';
        strSousNav += '<span class="accueil"><a href="/ensemble/">Accueil Ville Ensemble</a></span>';
        if( listeVilles[ville]["cartes"])
            strSousNav += '<span class="cartespostales"><a href="http://cartespostales1900.ville.orange.fr'+listeVilles[ville]["cartes"]+'">Cartes postales 1900</a></span>';
        strSousNav += '<span class="viequotidienne"><a href="/Relaxnews/home_vie_quotidienne.html">Vie quotidienne</a></span>';
        strSousNav += '</div>';
        break;
        case "cinema":
            if(listeVilles[ville]["cinema"])
            {
                strSousNav += '<div class="sous_nav">';
                strSousNav += '<span class="accueil"><a href="/cinema/">Accueil cinéma</a></span>';
                strSousNav += '<span class="films"><a href="/cgi/cine_films.php">Tous les films</a></span>';
                strSousNav += '<span class="salles"><a href="/cgi/cine_salles.php">Toutes les salles</a></span>';
                strSousNav += '<span class="sorties"><a href="/cinema/sortiessemaine.html">Sorties de la semaine</a></span>';
                strSousNav += '</div>';
            }
        break;
        case "sports":
            if( typeof listeVilles[ville]["sports"] != "undefined")
            {
                strSousNav +=	'<div class="sous_nav">';
                strSousNav += '<span class="accueil"><a href="/sport/">Accueil sport</a></span>';
                if( typeof listeVilles[ville]["sports"]["football"] != "undefined")
                    strSousNav += '<span class="football"><a href="/sport/football.html">Football</a></span>';
                if( typeof listeVilles[ville]["sports"]["rugby"] != "undefined")
                    strSousNav += '<span class="rugby"><a href="/sport/rugby.html">Rugby</a></span>';
                if( typeof listeVilles[ville]["sports"]["basket"] != "undefined")
                    strSousNav += '<span class="basket"><a href="/sport/basket.html">Basket</a></span>';
                if( typeof listeVilles[ville]["sports"]["volley"] != "undefined")
                    strSousNav += '<span class="volley"><a href="/sport/volley.html">Volley</a></span>';
                if( typeof listeVilles[ville]["sports"]["handball"] != "undefined")
                    strSousNav += '<span class="handball"><a href="/sport/handball.html">Handball</a></span>';
                if( typeof listeVilles[ville]["sports"]["autres"] != "undefined")
                    strSousNav += '<span class="autres"><a href="/sport/autres.html">Autres</a></span>';
                strSousNav += '</div>';
            }
        break;
        default:
        break;
    }
    document.write( strSousNav);	
}
else
{
    var cookie_ville = getCookie("wooville");
    if (cookie_ville) {
        var temp = new Array();
        temp = cookie_ville.split('|');
        ville= temp[1].substr(4);
        nom_ville = (typeof vname[ville] != 'undefined')?vname[ville]:capitalizeMe(ville);
    } else {
        ville="bron";
        nom_ville = "";
    }
    villeNotdefined = true;

    // Header MaVille
//   document.write('<link rel="stylesheet" href="http://c.wanadoo.fr/Css/woo2.css" type="text/css">'+
//           '<style>'+
//           '.c922, .c922:hover {color:#922;text-decoration:underline;}'+
//           '</style>');	
    var mess = 'Un oeil sur ma ville favorite : ';
    mess += '<a href="http://'+ville+'.ville.orange.fr" class="c922 u">'+nom_ville+'</a>';
//   document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%" id="h_maville">'+
//           '<tr>'+
//           '<td class="header">'+headVille('http://c.orange.fr/Ville/headerVille.swf','',45,'#992222',445,41)+'</td>'+
//           '</tr>'+
//           '<tr>'+
//           '<td style="color:#333;font-family:arial; font-size:11px; padding: 3px 0px 0px 18px; height: 21px; background-color:#EEE;" class="bandeauCont">'+mess+'</td>'+
//           '</tr>'+
//           '</table>');

    document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%" id="h_maville">');
    document.write('<tr><td class="header">');
	document.write(headVille('http://c.orange.fr/Ville/headerVille.swf','',45,'#992222',445,41));

    //document.write('gris</td><tr>');
    document.write('<tr><td style="color:#333;font-family:arial; font-size:11px; padding: 3px 0px 0px 18px; height: 21px; background-color:#EEE;" class="bandeauCont">'+mess+'</td></tr>');
    document.write('</table>');
}

