var xmlhttps= new Array();
function loadXMLdoc(url, id, attente) {
 var i= xmlhttps.length;
 if(attente != null) {
  document.getElementById(id).innerHTML= attente;
 }
 if(window.XMLHttpRequest) {
  xmlhttps[i]= new XMLHttpRequest();
  xmlhttps[i].onreadystatechange= function() { xmlhttpChange(i, url, id); };
  xmlhttps[i].open("GET", url, true);
  xmlhttps[i].send(null);
 }
 else if(window.ActiveXObject) {
  xmlhttps[i]= new ActiveXObject("Microsoft.XMLHTTP");
  if(xmlhttps[i]) {
   xmlhttps[i].onreadystatechange= function() { xmlhttpChange(i, url, id); };
   xmlhttps[i].open("GET", url, true);
   xmlhttps[i].send();
  }
 }
}

function xmlhttpChange(i, url, id) {
 if(xmlhttps[i].readyState==4) {
  if(xmlhttps[i].status == 200) {
   document.getElementById(id).innerHTML= xmlhttps[i].responseText;
   return(0);
   }
  else {
   document.getElementById(id).innerHTML= "[<span title=\""+url+"\">Erreur "+xmlhttps[i].status+"</span>]";
  }
 }
}

function loadXMLdoc_iti(url, id, attente) {
 var i= xmlhttps.length;
 if(attente != null) {
  document.getElementById(id).innerHTML= attente;
 }
 if(window.XMLHttpRequest) {
  xmlhttps[i]= new XMLHttpRequest();
  xmlhttps[i].onreadystatechange= function() { xmlhttpChange_iti(i, url, id); };
  xmlhttps[i].open("GET", url, true);
  xmlhttps[i].send(null);
 }
 else if(window.ActiveXObject) {
  xmlhttps[i]= new ActiveXObject("Microsoft.XMLHTTP");
  if(xmlhttps[i]) {
   xmlhttps[i].onreadystatechange= function() { xmlhttpChange_iti(i, url, id); };
   xmlhttps[i].open("GET", url, true);
   xmlhttps[i].send();
  }
 }
}

function xmlhttpChange_iti(i, url, id) {
 if(xmlhttps[i].readyState==4) {
  if(xmlhttps[i].status < 400) {
   document.getElementById(id).innerHTML= xmlhttps[i].responseText;
	GetSecteur(document.Frm.SectDep,document.Frm.LieuDep,document.Frm.InitD,document.Frm.SDP,0);
	GetSecteur(document.Frm.SectArr,document.Frm.LieuArr,document.Frm.InitA,document.Frm.SAP,1);
	make_via_sect();
  }
  else {
   document.getElementById(id).innerHTML= "[<span title=\""+url+"\">Erreur "+xmlhttps[i].status+"</span>]";
  }
 }
}

function loadXMLdoc_iti2(url, id, attente) {
 var i= xmlhttps.length;
 if(attente != null) {
  document.getElementById(id).innerHTML= attente;
 }
 if(window.XMLHttpRequest) {
  xmlhttps[i]= new XMLHttpRequest();
  xmlhttps[i].onreadystatechange= function() { xmlhttpChange_iti2(i, url, id); };
  xmlhttps[i].open("GET", url, true);
  xmlhttps[i].send(null);
 }
 else if(window.ActiveXObject) {
  xmlhttps[i]= new ActiveXObject("Microsoft.XMLHTTP");
  if(xmlhttps[i]) {
   xmlhttps[i].onreadystatechange= function() { xmlhttpChange_iti2(i, url, id); };
   xmlhttps[i].open("GET", url, true);
   xmlhttps[i].send();
  }
 }
}

function xmlhttpChange_iti2(i, url, id) {
 if(xmlhttps[i].readyState==4) {
  if(xmlhttps[i].status < 400) {
   document.getElementById(id).innerHTML= xmlhttps[i].responseText;
	GetSecteur(document.FrmPerso.SectDepPerso,document.FrmPerso.LieuDepPerso,document.FrmPerso.InitD,document.FrmPerso.SDP,0);
	GetSecteur(document.FrmPerso.SectArrPerso,document.FrmPerso.LieuArrPerso,document.FrmPerso.InitA,document.FrmPerso.SAP,1);
	make_via_sect();
  }
  else {
   document.getElementById(id).innerHTML= "[<span title=\""+url+"\">Erreur "+xmlhttps[i].status+"</span>]";
  }
 }
}

function loadXMLdoc3(url, id, attente) {
 var i= xmlhttps.length;
 if(attente != null) {
  document.getElementById(id).innerHTML= attente;
 }
 if(window.XMLHttpRequest) {/*Mozilla*/
  xmlhttps[i]= new XMLHttpRequest();
  xmlhttps[i].onreadystatechange= function() { xmlhttpChange3(i, url, id); };
  xmlhttps[i].open("GET", url, true);
  xmlhttps[i].send(null);
 }
 else if(window.ActiveXObject) {/*IE*/
  xmlhttps[i]= new ActiveXObject("Microsoft.XMLHTTP");
  if(xmlhttps[i]) {
   xmlhttps[i].onreadystatechange= function() { xmlhttpChange3(i, url, id); };
   xmlhttps[i].open("GET", url, true);
   xmlhttps[i].send();
  }
 }
}

function xmlhttpChange3(i, url, id) {
 if(xmlhttps[i].readyState==4) {
  if(xmlhttps[i].status < 400) {
 	parent.location.reload();
	}
 }
}

function make_widget_info(url,cat)
{
	ran = Math.floor(Math.random()*10)+(10*(Math.floor(Math.random()*10)))+(100*(Math.floor(Math.random()*10)))+(1000*(Math.floor(Math.random()*10)))+(10000*(Math.floor(Math.random()*10)))+(100000*(Math.floor(Math.random()*10)))+(1000000*(Math.floor(Math.random()*10)))+(10000000*(Math.floor(Math.random()*10)));
	document.getElementById("central_widget").style.visibility='visible';
	document.getElementById("central_widget").style.zIndex=99;
	loadXMLdoc(url,"central_widget","Chargement en cours....");
	my_a = url.split('.');
	cat = 'divers';
	make_no_script(ran);
	parent.frames['topframe'].location.href = 'top.php?tps='+Date().valueOf()+'&ord='+ran+'&s1='+cat;
	parent.frames['skyframe'].location.href = 'sky.php?tps='+Date().valueOf()+'&ord='+ran+'&s1='+cat;	
}

function updt_iti_widget(url,action,nom,raf,antic)
{
	loadXMLdoc_iti2(url+"?Action="+action+"&Nom="+nom+"&Raf="+raf+"&Antic="+antic,"central_widget","Loading....");
}

function menu(url,cat)
{
	ran = Math.floor(Math.random()*10)+(10*(Math.floor(Math.random()*10)))+(100*(Math.floor(Math.random()*10)))+(1000*(Math.floor(Math.random()*10)))+(10000*(Math.floor(Math.random()*10)))+(100000*(Math.floor(Math.random()*10)))+(1000000*(Math.floor(Math.random()*10)))+(10000000*(Math.floor(Math.random()*10)));
	//parent.frames['topframe'].location.href = 'top.php?tps='+Date().valueOf()+'&ord='+ran+'&s1='+cat;
	document.getElementById("central_widget").style.visibility='hidden';
	document.getElementById("central").style.visibility='visible';
	result = url.search(/iti_idf/);
	if (result != -1)
	{
	loadXMLdoc_iti(url,"central","Chargement en cours....");	
	}
	else
	{
		loadXMLdoc(url,"central","Chargement en cours....");	
	}
	document.cookie="link="+url;
	document.cookie="cat="+cat;
	make_no_script(ran);
	}

function menu_affi(url,cat) 
{
	ran = Math.floor(Math.random()*10)+(10*(Math.floor(Math.random()*10)))+(100*(Math.floor(Math.random()*10)))+(1000*(Math.floor(Math.random()*10)))+(10000*(Math.floor(Math.random()*10)))+(100000*(Math.floor(Math.random()*10)))+(1000000*(Math.floor(Math.random()*10)))+(10000000*(Math.floor(Math.random()*10)));
	//parent.frames['topframe'].location.href = 'top.php?tps='+Date().valueOf()+'&ord='+ran+'&s1='+cat;
	loadXMLdoc(url,"central","Chargement en cours....");	
	make_no_script(ran);
}

function set_cookie(url,cat) 
{
	document.cookie="link="+url;
	document.cookie="cat="+cat;
}

function make_iti_widget(url) 
{
	if (GetCookie('link'))
	{
	my_link = GetCookie('link');
	result = my_link.search(/iti_idf/);
	if (result != -1)
	{
		
	}

	}
	document.getElementById("central_widget").style.visibility='visible';
	document.getElementById("central_widget").style.zIndex=100;
	loadXMLdoc_iti2(url,"central_widget","Chargement en cours....");
}

function hide_widget_info() 
{
	if (GetCookie('link'))
	{
		my_link = GetCookie('link');
		result = my_link.search(/iti_idf/);
		if (result != -1)
		{
			document.getElementById("my_form_iti").style.visibility='visible';
		}
	}
	document.getElementById("central_widget").style.visibility='hidden';
}

function change_iti_div(url,params){
	document.getElementById("my_select").innerHTML='';
	loadXMLdoc(url+params,"iti_div","Chargement...");
}

function init_cookie()
{
	document.cookie="link=0";
	document.cookie="cat=0";
	document.cookie="mapx=null";
	document.cookie="mapy=null";
	document.cookie="zoomLevel=null";
	document.cookie="mapxfr=null";
	document.cookie="mapyfr=null";
	document.cookie="zoomLevelfr=null";
}

function hide_select_div(region)
{
	if (region == "IDF")
	{
		document.getElementById("my_select").style.visibility='hidden';
	}
}

function show_select_div(region)
{
	if (region == "IDF")
	{
			document.getElementById("my_select").style.visibility='visible';
	}
}

function submit_horaire_pref_form(Id)
{
	loadXMLdoc("perso/listegares.php?from=pref&Idt_Gare="+Id, "central_widget", "Chargement...");
}

function submit_horaire_div_form(Id)
{
	loadXMLdoc("perso/listegares.php?from=div&Idt_Gare="+Id, "central_widget", "Chargement...");
}
function refresh_horaire()
{
	loadXMLdoc("./ajax/get_horaires.php?AC="+Date().valueOf(), "horaires", "Chargement...");
}	

function make_meteo_div_form(raf,ville,cp)
{
 loadXMLdoc("perso/meteo.php?Raf="+raf+"&Ville="+ville+"&CP="+cp, "central_widget", "Chargement...");
}

function make_meteo_pref_form(raf,ville,cp)
{
 loadXMLdoc("perso/meteo.php?from=pref&Raf="+raf+"&Ville="+ville+"&CP="+cp+"", "central_widget", "Chargement...");
 }

function refresh_meteo()
{
 loadXMLdoc("./ajax/get_meteo.php", "meteo", "Chargement...");
}

function getCookieVal(offset) {
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)
      		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
                        return getCookieVal (j);
                i=document.cookie.indexOf(" ",i)+1;
                        if (i==0) break;}
	return null;
}

function change_page_loc(wwwroot)
 {
	init_cookie();
	 if (document.region.my_loc.selectedIndex==1)
	 {
		window.location = wwwroot+'route.php?region=IDF';
		document.cookie="loc=idf";
	 }
	 
	 if (document.region.my_loc.selectedIndex==0)
	 {
		 document.cookie="loc=fr";
		window.location = wwwroot+'route.php?region=FRANC';
	 }
	  if (document.region.my_loc.selectedIndex==2)
	 {
		 document.cookie="loc=centre";
		window.location = wwwroot+'route.php?region=CENTR';
	 }
	   if (document.region.my_loc.selectedIndex==3)
	 {
		 document.cookie="loc=ouest";
		window.location = wwwroot+'route.php?region=OUEST';
	 }
	  if (document.region.my_loc.selectedIndex==4)
	 {
		 document.cookie="loc=nord";
	window.location = wwwroot+'route.php?region=NORD';
	 }
	   if (document.region.my_loc.selectedIndex==5)
	 {
		 document.cookie="loc=est";
	window.location = wwwroot+'route.php?region=EST';
	 }
	   if (document.region.my_loc.selectedIndex==6)
	 {
		 document.cookie="loc=rhalp";
window.location = wwwroot+'route.php?region=RHALP';
	 }
	   if (document.region.my_loc.selectedIndex==7)
	 {
		 document.cookie="loc=sudest";
	window.location = wwwroot+'route.php?region=SDEST';
	 }
	   if (document.region.my_loc.selectedIndex==8)
	 {
		 document.cookie="loc=sudouest";
		window.location = wwwroot+'route.php?region=SWEST';
	 }

 if (GetCookie('loc') == 'fr')
 {
	 document.region.my_loc[0].selected = true;
 }
  if (GetCookie('loc') == 'idf')
 {
	document.region.my_loc[1].selected = true;
 }
 } 
 
 function GetSecteurPerso(ComboSecteurs, ComboLieux, CptInit, SectPrec, CodLieu){
   IdxSel = 0;
   for (var k=0; k<Secteurs.length ; k++){
    if (TabCodSect[k]==SectPrec.value)
      IdxSel = k;
    if (ComboSecteurs.selectedIndex == (k))
      ComboSecteurs.options[k] = new Option(TabSecteurs[k], TabSecteurs[k], true, true);
    else
      ComboSecteurs.options[k] = new Option(TabSecteurs[k], TabSecteurs[k], false, false);
  }
  if (ComboSecteurs.selectedIndex == -1)
    ComboSecteurs.selectedIndex = 0;
  if (CptInit.value>=0){
    ComboSecteurs.selectedIndex = CptInit.value;
    ComboSecteurs.selectedIndex = IdxSel;
    CptInit.value = -1;
  }
  var NSecteur = ComboSecteurs.selectedIndex;
  LoadLieuxPerso(NSecteur, ComboLieux, CodLieu);
}

function LoadLieuxPerso(Index, ComboLieux, CodeSel){
  if(Index>=0){
    ClearListPerso(ComboLieux);
    for (var k=0; k<Secteurs[Index].length/2; k++)
	  if (Secteurs[Index][k*2+1] == CodeSel)
        ComboLieux.options[k] = new Option(Secteurs[Index][k*2], Secteurs[Index][k*2+1], true, true);
      else
        ComboLieux.options[k] = new Option(Secteurs[Index][k*2], Secteurs[Index][k*2+1], false, false);
    if (ComboLieux.selectedIndex<0)
      ComboLieux.options[0].selected = true;
  }
}

function ClearListPerso(optionList){
  optionList.length = 0;
}
 
 function make_submit_iti(url)
{	
	loadXMLdoc_iti(url,"central","Loading....");
}
 function make_submit_iti2(url) 
{
	document.getElementById("central_widget").style.visibility='visible';
	document.getElementById("central_widget").style.zIndex=55;
	loadXMLdoc_iti2(url,"central_widget","Loading....");
}

function DetailsPlus(){
  var IndexDep = document.Frm.LieuDep.selectedIndex;
  var IndexArr = document.Frm.LieuArr.selectedIndex;
make_submit_iti("iti_idf.php?region="+document.Frm.region.value+"&MV=1&Dep="+document.Frm.LieuDep.options[IndexDep].value+"&Arr="+document.Frm.LieuArr.options[IndexArr].value+"&SDP="+TabCodSect[document.Frm.SectDep.selectedIndex]+"&SAP="+TabCodSect[document.Frm.SectArr.selectedIndex]+"&Via1="+document.Frm.Via1.value+"&Via2="+document.Frm.Via2.value+"&Via3="+document.Frm.Via3.value+"&"+document.Frm.AC.value);
}

function DetailsMoins(){
  var IndexDep = document.Frm.LieuDep.selectedIndex;
  var IndexArr = document.Frm.LieuArr.selectedIndex;
 make_submit_iti("iti_idf.php?region="+document.Frm.region.value+"&MV=-1&Dep="+document.Frm.LieuDep.options[IndexDep].value+"&Arr="+document.Frm.LieuArr.options[IndexArr].value+"&SDP="+TabCodSect[document.Frm.SectDep.selectedIndex]+"&SAP="+TabCodSect[document.Frm.SectArr.selectedIndex]+"&Via1="+document.Frm.Via1.value+"&Via2="+document.Frm.Via2.value+"&Via3="+document.Frm.Via3.value+"&"+document.Frm.AC.value);
}

 function SubmitIti(){
  var IndexDep = document.Frm.LieuDep.selectedIndex;
  var IndexArr = document.Frm.LieuArr.selectedIndex;
make_submit_iti("iti_idf.php?region="+document.Frm.region.value+"&Dep="+document.Frm.LieuDep.options[IndexDep].value+"&Arr="+document.Frm.LieuArr.options[IndexArr].value+"&SDP="+TabCodSect[document.Frm.SectDep.selectedIndex]+"&SAP="+TabCodSect[document.Frm.SectArr.selectedIndex]+"&Via1="+document.Frm.Via1.value+"&Via2="+document.Frm.Via2.value+"&Via3="+document.Frm.Via3.value+"&"+document.Frm.AC.value);
}

function SubmitItiPerso(url){
  var IndexDep = document.FrmPerso.LieuDepPerso.selectedIndex;
  var IndexArr = document.FrmPerso.LieuArrPerso.selectedIndex;
  if (document.FrmPerso.Nom.value=='')
    alert('Vous devez donner un nom à cet itinéraire. Par exemple : "Bureau - Maison", ou "Bureau > Client"');
  else 
	{ url=url+"perso/iti_idf.php?Action="+document.FrmPerso.Action.value+"&Nom="+document.FrmPerso.Nom.value+"&Dep="+document.FrmPerso.LieuDepPerso.options[IndexDep].value+"&Arr="+document.FrmPerso.LieuArrPerso.options[IndexArr].value+"&SDP="+TabCodSect[document.FrmPerso.SectDepPerso.selectedIndex]+"&SAP="+TabCodSect[document.FrmPerso.SectArrPerso.selectedIndex]+"&Via1="+document.FrmPerso.Via1Perso.value+"&Via2="+document.FrmPerso.Via2Perso.value+"&Via3="+document.FrmPerso.Via3Perso.value+"&Raf="+document.FrmPerso.Raf.value+"&"+document.FrmPerso.AC.value;
	make_submit_iti2(url);
	}
}


function OuvrirPopupSB(URL, Nom, W, H) {
  var top, left, height, width;
  width = Math.min(W, screen.availWidth-25);
  height = Math.min(H, screen.availHeight-50);
  top = (screen.availHeight-25 - height)/2;
  left = (screen.availWidth-10 - width)/2;
  Fenetre = window.open(URL,Nom,'location=no,toolbar=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,status=no,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',screenx=' + left + ',screeny=' + top);
  Fenetre.focus();
}

function pleinecran( adresseURL ){
fenetre = window.open( adresseURL , "Fenetre", "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
fenetre.focus();
}

function build_select(region,defaut)
{
	i = 0;
	j = 0;
	document.prefs.CarteIDF.options.length=0;
	while (Champs[region][j])
	{
			document.prefs.CarteIDF.options[i] = new Option(Champs[region][j+1],Champs[region][j]);
			if(Champs[region][j] == defaut){
			document.prefs.CarteIDF.selectedIndex=i;
		}
		i++;
		j = j+2;
	}
}

function submit_affil()
{
	if ((document.affi_form.url.value=="") && (document.affi_form.typesite[document.affi_form.typesite.selectedIndex].value != "Perso"))
		{
			alert("Merci de spécifier l'url de votre site");
		}
	else{
	my_email = document.affi_form.email.value;
	if (!check_email(my_email))
	{
		alert("Adresse email non valide");
	}
	else{
	if (document.affi_form.cgu.checked)
	{
		for (i=0;i<2;i++)
		{
			if (document.affi_form.orientation[i].checked == true)
			{
				my_orientation = document.affi_form.orientation[i].value;
			}
		}
		
		my_color = document.affi_form.ColorHex.value;
		my_url = document.affi_form.url.value;
		my_typesite = document.affi_form.typesite[document.affi_form.typesite.selectedIndex].value;
		my_zoneaff = document.affi_form.zoneaff[document.affi_form.zoneaff.selectedIndex].value;
		if (my_color == "")
		{
			alert("Veuillez preciser une couleur de fond");
		}
		else{
		menu_affi('webmaster_valid.php?url='+my_url+'&email='+my_email+'&orientation='+my_orientation+'&zoneaff='+my_zoneaff+'&typesite='+my_typesite+'&color='+my_color.substr(1,6));}
	}
	else
	{
		alert('Vous devez accepter les conditions générales d\'utilisation');
	}
}
	}
}

function my_redir(url)
{
	document.cookie="link="+url;
	window.location = "route.php?region=IDF";
}

function hide_affi_select()
{
	document.getElementById("select1").style.visibility='hidden';
	document.getElementById("select2").style.visibility='hidden';
}

function show_affi_select()
{
	document.getElementById("select1").style.visibility='visible';
	document.getElementById("select2").style.visibility='visible';
}
function header(){
	setTimeout('home()',900000);
}
function home(){
	var sURL = unescape(window.location.pathname);
	window.location.href=sURL;
}
function make_via2(id)
{
	if ((id == 150) || (id == 180) || (id == 156) || (id == 154) || (id == 214) || (id == 132) || (id == 134) || (id == 130) || (id == 145) || (id == 153) || (id == 201) || (id == 155) || (id == 173) || (id == 143) || (id == 184) || (id == 169) || (id == 183) || (id == 147))
	{
		document.Frm.Via2.length = 0;
		document.Frm.Via3.length = 0;
		j=0;
		 for (var k=0; k<TabVia[1].length ; k+=2){
          document.Frm.Via2.options[j] = new Option(TabVia[1][k], TabVia[1][k+1], false, false);
		  document.Frm.Via3.options[j] = new Option(TabVia[1][k], TabVia[1][k+1], false, false);
		  j++;
		}
  	}
	else
	{
		document.Frm.Via2.length = 0;
			j=0;
		 for (var k=0; k<TabVia[2].length ; k+=2){
          document.Frm.Via2.options[j] = new Option(TabVia[2][k], TabVia[2][k+1], false, false);
		  j++;
		 }
	}
}

function make_via3(id,id1)
{
	document.Frm.Via3.length = 0;
	if ((id == 150) || (id == 180) || (id == 156) || (id == 154) || (id == 214) || (id == 132) || (id == 134) || (id == 130) || (id == 145) || (id == 153) || (id == 201) || (id == 155) || (id == 173) || (id == 143) || (id == 184) || (id == 169) || (id == 183) || (id == 147) || (id1 == 150) || (id1 == 180) || (id1 == 156) || (id1 == 154) || (id1 == 214) || (id1 == 132) || (id1 == 134) || (id1 == 130) || (id1 == 145) || (id1 == 153) || (id1 == 201) || (id1 == 155) || (id1 == 173) || (id1 == 143) || (id1 == 184) || (id1 == 169) || (id1 == 183) || (id1 == 147))
	{
		j=0;
		 for (var k=0; k<TabVia[1].length ; k+=2){
          document.Frm.Via3.options[j] = new Option(TabVia[1][k], TabVia[1][k+1], false, false);
		  j++;
	}
  	}
	else
	{
			if ((id1 != 150) && (id1 != 180) && (id1 != 156) && (id1 != 154) && (id1 != 214) && (id1 != 132) && (id1 != 134) && (id1 != 130) && (id1 != 145) && (id1 != 153) && (id1 != 201) && (id1 != 155) && (id1 != 173) && (id1 != 143) && (id1 != 184) && (id1 != 169) && (id1 != 183) && (id1 != 147))
	{
			j=0;
		 for (var k=0; k<TabVia[2].length ; k+=2){
          document.Frm.Via3.options[j] = new Option(TabVia[2][k], TabVia[2][k+1], false, false);
		  j++;
		 }
	}
	}
}

function make_via2_perso(id)
{
	if ((id == 150) || (id == 180) || (id == 156) || (id == 154) || (id == 214) || (id == 132) || (id == 134) || (id == 130) || (id == 145) || (id == 153) || (id == 201) || (id == 155) || (id == 173) || (id == 143) || (id == 184) || (id == 169) || (id == 183) || (id == 147))
	{
		document.FrmPerso.Via2Perso.length = 0;
		document.FrmPerso.Via3Perso.length = 0;
		j=0;
		 for (var k=0; k<TabVia[1].length ; k+=2){
          document.FrmPerso.Via2Perso.options[j] = new Option(TabVia[1][k], TabVia[1][k+1], false, false);
		  document.FrmPerso.Via3Perso.options[j] = new Option(TabVia[1][k], TabVia[1][k+1], false, false);
		  j++;
		}
  	}
	else
	{
		document.FrmPerso.Via2Perso.length = 0;
			j=0;
		 for (var k=0; k<TabVia[2].length ; k+=2){
          document.FrmPerso.Via2Perso.options[j] = new Option(TabVia[2][k], TabVia[2][k+1], false, false);
		  j++;
		 }
	}
}

function make_via3_perso(id,id1)
{
	document.FrmPerso.Via3Perso.length = 0;
	if ((id == 150) || (id == 180) || (id == 156) || (id == 154) || (id == 214) || (id == 132) || (id == 134) || (id == 130) || (id == 145) || (id == 153) || (id == 201) || (id == 155) || (id == 173) || (id == 143) || (id == 184) || (id == 169) || (id == 183) || (id == 147) || (id1 == 150) || (id1 == 180) || (id1 == 156) || (id1 == 154) || (id1 == 214) || (id1 == 132) || (id1 == 134) || (id1 == 130) || (id1 == 145) || (id1 == 153) || (id1 == 201) || (id1 == 155) || (id1 == 173) || (id1 == 143) || (id1 == 184) || (id1 == 169) || (id1 == 183) || (id1 == 147))
	{
		j=0;
		 for (var k=0; k<TabVia[1].length ; k+=2){
          document.FrmPerso.Via3Perso.options[j] = new Option(TabVia[1][k], TabVia[1][k+1], false, false);
		  j++;
	}
  	}
	else
	{
			if ((id1 != 150) && (id1 != 180) && (id1 != 156) && (id1 != 154) && (id1 != 214) && (id1 != 132) && (id1 != 134) && (id1 != 130) && (id1 != 145) && (id1 != 153) && (id1 != 201) && (id1 != 155) && (id1 != 173) && (id1 != 143) && (id1 != 184) && (id1 != 169) && (id1 != 183) && (id1 != 147))
	{
			j=0;
		 for (var k=0; k<TabVia[2].length ; k+=2){
          document.FrmPerso.Via3Perso.options[j] = new Option(TabVia[2][k], TabVia[2][k+1], false, false);
		  j++;
		 }
	}
	}
}

function hide_itisel_select()
{
	document.getElementById("selectdep").style.visibility='hidden';
	document.getElementById("selectarr").style.visibility='hidden';
}

function show_itisel_select()
{
	document.getElementById("selectdep").style.visibility='visible';
	document.getElementById("selectarr").style.visibility='visible';
}

function View(color) {                  // preview color
  //document.getElementById("ColorPreview").style.backgroundColor = '#' + color;
  document.getElementById("ColorHex").value = '#' + color;
}

function Set(string) {                   // select color
  var color = ValidateColor(string);
  if (color == null) { alert("Invalid color code: " + string); }        // invalid color
  else {                                                                // valid color
    View(color);                          // show selected color
  
  }
}

function ValidateColor(string) {                // return valid color code
  string = string || '';
  string = string + "";
  string = string.toUpperCase();
  var chars = '0123456789ABCDEF';
  var out   = '';

  for (var i=0; i<string.length; i++) {             // remove invalid color chars
    var schar = string.charAt(i);
    if (chars.indexOf(schar) != -1) { out += schar; }
  }

  if (out.length != 6) { return null; }            // check length
  return out;
}

 function check_email(elm)
{
if (elm.indexOf("@") != "-1" &&
    elm.indexOf(".") != "-1" &&
    elm != "")
    return true;

return false;
}

function change_url()
{
	my_typesite = document.affi_form.typesite[document.affi_form.typesite.selectedIndex].value;
	if (my_typesite == 'Blog')
	{
		document.getElementById("url").innerHTML = "<ul><li>Url de votre site:</ul>";
	}
	if (my_typesite == 'Intranet')
	{
		document.getElementById("url").innerHTML = "<ul><li>Nom de votre société:</ul>";
	}
	if (my_typesite == 'E-Commerce')
	{
		document.getElementById("url").innerHTML = "<ul><li>Url de votre site:</ul>";
	}
	if (my_typesite == 'Information')
	{
		document.getElementById("url").innerHTML = "<ul><li>Url de votre site:</ul>";
	}
	if (my_typesite == 'High-Tech')
	{
		document.getElementById("url").innerHTML = "<ul><li>Url de votre site:</ul>";
	}
	if (my_typesite == 'Perso')
	{
		document.getElementById("url").innerHTML = "<ul><li>Url de votre site perso:</ul>";
	}

}

function make_no_script(my_ran){
//refresh top_banner
//test my_ran

}
