﻿var nav = navigator.userAgent.toLowerCase();
var ie = nav.search("msie");
var ie6 = nav.search("msie 6");
var browserVer = parseInt(navigator.appVersion); 

function popupOpener(linkto)
{
  window.open(linkto,'popupwindow','scrollbars=yes,resizable,width=800,height=700');
}


function popup_withouttoolbar(linkto)
{
  window.open(linkto,'popupwindow','toolbar=no,scrollbars=yes,resizable,width=1000,height=700');
}

var win=null;
function openfenetre(mypage,myname,w,h,scroll,pos)
{
	if(pos=="random")
	    {LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center")
	    {LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null)
	    {LeftPosition=0;TopPosition=20}
	    
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	
	win=window.open(mypage,myname,settings);
}

var winpop=null;
function popWin(url,popname,w,h,pos,scrl,loc,dir,sts,mb,tbr,rsz)
{
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=100;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrl+',location='+loc+',directories='+dir+',status='+sts+',menubar='+mb+',toolbar='+tbr+',resizable='+rsz+'';
	winpop=window.open(url,popname,settings);
}

function popup(url,w,h,pos)
{
    popWin(url,'popupwin',w,h,pos,'yes','no','no','no','no','no','no');
    //return false;
}

function toggleDiv(total,bloc_width,id,flagit) 
{
    //var total = 7;
    /*
    var width_menu = 0;
    var margin_left = 0;
    var width_tblmenu = document.getElementById('tblMenu').offsetWidth;
    
    for (var i=0; i<total; i++) 
    {
        if (width_menu + bloc_width > width_tblmenu)
        {
            margin_left = width_menu + bloc_width - width_tblmenu;
            
            document.getElementById('menu1_' + i).style.marginLeft = "-" + margin_left + "px";
        }
            
        width_menu = width_menu + document.getElementById('menulink' + i).offsetWidth;
    }
    */
	if (flagit=="1")
	{    
		if (document.layers) document.layers[''+id+''].visibility = "show";
		else if (document.all) document.all[''+id+''].style.display = "block";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "block";
	}
	else
	{
		if (document.layers) document.layers[''+id+''].visibility = "hide";
		else if (document.all) document.all[''+id+''].style.display = "none";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "none";
	}
}

function showOrHideAllDropDowns(newState) 
{            
    var elements = document.documentElement.getElementsByTagName('select');
     
    for (var i=0; i < elements.length; i++) 
    {
        elements[i].style.visibility = newState;
    }
} 
 
function toggleBloc(id,flagit) 
{
	if (flagit=="1")
	{
		if (document.layers) document.layers[''+id+''].visibility = "show";
		else if (document.all) document.all[''+id+''].style.display = "";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "";
	}
	else
	{
		if (document.layers) document.layers[''+id+''].visibility = "hide";
		else if (document.all) document.all[''+id+''].style.display = "none";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "none";
	}
}

function toggleFieldsByCase(id,idToggle,FieldsToggle) 
{
    //alert(FieldsToggle);
	var arrFields = FieldsToggle.split("|");
	
	if (id == idToggle)
        flagit = 1;
    else
        flagit = 0;
    
	for (i=0;i<arrFields.length;i++)
	{
	    //alert(arrFields[i]);
	    toggleBloc("BlocToggle"+arrFields[i],flagit);
	}       
}

function closeDiv(id) 
{
	if (document.layers) document.layers[''+id+''].visibility = "hide";
	else if (document.all) document.all[''+id+''].style.display = "none";
	else if (document.getElementById) document.getElementById(''+id+'').style.display = "none";
}

function attribDiv(id,val) 
{
    document.getElementById(''+id+'').style.display = "block";
    document.getElementById(''+id+'').innerHTML = val;
}

function attribDiv1ToDiv2(id1,id2) 
{
    //alert(document.getElementById(''+id1+'').innerHTML);
    document.getElementById(''+id2+'').style.display = "block";
    document.getElementById(''+id2+'').innerHTML = document.getElementById(''+id1+'').innerHTML;
}

function replaceDivVal(id,val,red) 
{
    if (red == 1)
        document.getElementById(''+id+'').innerHTML = "<span style='color:red'>*</span> " + val;
    else
        document.getElementById(''+id+'').innerHTML = val;
}

function replaceInputVal(id,val) 
{
    document.getElementById(''+id+'').value = val;
}

function expandcontent(id,bullet) 
{
    //alert(document.getElementById(''+id+'').style.display);
    if (document.getElementById(''+id+'').style.display == "none" || document.getElementById(''+id+'').style.display == "")
    {
        document.getElementById(''+bullet+'').innerHTML = "-";
        document.getElementById(''+id+'').style.display = "block";
    }
    else
    {
        document.getElementById(''+bullet+'').innerHTML = "+";
        document.getElementById(''+id+'').style.display = "none";
    }
}

function Affichage_Service_Name(v_service)
{
   document.getElementById("Services_Description").innerHTML = v_service;
}


// Google Map par Tri ===========================================================================================================================
function init_googlemap(id_map,la,lo,zoom_size,marker_icon,marker_shadow,popup_info) 
{
    if (GBrowserIsCompatible()) 
    {
        //alert(lo);
	    var map = new GMap2(document.getElementById(id_map));

	    map.setCenter(new GLatLng(la,lo), zoom_size);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl()); 
    	
        var icon = new GIcon();
        icon.image = marker_icon;
        icon.iconSize = new GSize(26, 26);
        icon.iconAnchor = new GPoint(13, 13);
        icon.infoWindowAnchor = new GPoint(5, 1);
        
        if (marker_shadow != "")
        {
            icon.shadow = marker_shadow;
            icon.shadowSize = new GSize(37, 34);
            icon.infoShadowAnchor = new GPoint(18, 25);      
        }  
        
        var latlng = new GLatLng(la,lo);
        map.addOverlay(createMarker(latlng,map,icon,popup_info));	   

    }
}    

function createMarker(point,map,icon,info) 
{
    //var letteredIcon = new GIcon(icon);
    //letteredIcon.image = "/images_client/pic_train3.gif";

    // Set up our GMarkerOptions object
    markerOptions = { icon:icon };
    var marker = new GMarker(point, markerOptions);

    GEvent.addListener(marker, "click", function() 
        {
            marker.openInfoWindowHtml(info);
        }
    );
    return marker;    
}

function init_googlemap_multiple_markers(id_map,ary_la,ary_lo,zoom_size,marker_icon,marker_shadow,ary_popup_info) 
{
    if (GBrowserIsCompatible()) 
    {
        //alert(lo);
	    var map = new GMap2(document.getElementById(id_map));

	    map.setCenter(new GLatLng(ary_la[0],ary_lo[0]), zoom_size);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl()); 
    	
        var icon = new GIcon();
        icon.image = marker_icon;
        icon.iconSize = new GSize(26, 26);
        icon.iconAnchor = new GPoint(13, 13);
        icon.infoWindowAnchor = new GPoint(5, 1);
        
        if (marker_shadow != "")
        {
            icon.shadow = marker_shadow;
            icon.shadowSize = new GSize(37, 34);
            icon.infoShadowAnchor = new GPoint(18, 25);      
        }  
        
        for (i=0;i<ary_la.length;i++)
        {
            //alert(ary[i]);
            var latlng = new GLatLng(ary_la[i],ary_lo[i]);
            map.addOverlay(createMarker(latlng,map,icon,ary_popup_info[i]));	 
        }
    }
}    

/*
function yotri(ary)
{
   //alert(ary);
   for (i=0;i<ary.length;i++)
   {
        alert(ary[i]);
   }
}
*/

 function togglediv_mapgare(divid)
 {
    if(document.getElementById(divid).style.display == 'none')
    {
      document.getElementById(divid).style.display = 'block';
      document.images.images_fleches.src = "/images/puce_fleche_haut.gif";
    }
    else
    {
      document.getElementById(divid).style.display = 'none';
      document.images.images_fleches.src = "/images/puce_fleche_bas.gif";
    }
}
  
  function togglediv_mapgare_open(divid)
  {
   
      document.getElementById(divid).style.display = 'block';
      document.images.images_fleches.src = "/images/puce_fleche_haut.gif";
   
  }
  
  function ClearForm() 
{
    document.forms[0].ctl00_TextBox_Search.value = "";
}

function CheckStatus()
{
    if (document.forms[0].ctl00_TextBox_Search.value == "")
  {
      document.forms[0].ctl00_TextBox_Search.value = "Recherche";
  }
}
  
 function toggledivcmsfleche(divid,fleche)
 {
 //alert(fleche);
 
    if(document.getElementById(divid).style.display == 'none')
    {
      document.getElementById(divid).style.display = 'block';
      /*document.getElementById(fleche).src = "/images/puce_fleche_haut.gif";*/
      document.getElementById(divid).style.marginTop = '13px';
	  document.getElementById(divid).style.marginBottom = '13px';
      document.getElementById(fleche).className = "sous_titre_fleche_open";
      
     // document.fleche.className = "sous_titre_fleche_open";
      
    }
    else
    {
      document.getElementById(divid).style.display = 'none';
     /* document.getElementById(fleche).src = "/images/puce_fleche_bas.gif";*/
      
      document.getElementById(fleche).className = "sous_titre_fleche_close";
      
       //document.fleche.className = "sous_titre_fleche_open";
    }    
}

 function toggledivcmsfleche_correspondance(divid,fleche)
 {
 //alert(fleche);
 
    if(document.getElementById(divid).style.display == 'none')
    {
      document.getElementById(divid).style.display = 'block';
      document.getElementById(divid).style.marginTop = '13px';
	  document.getElementById(divid).style.marginBottom = '13px';
      document.getElementById(fleche).className = "sous_titre_fleche_correspondance_open";
            
    }
    else
    {
      document.getElementById(divid).style.display = 'none'; 
      document.getElementById(fleche).className = "sous_titre_fleche_correspondance_close";
    }
}

// Fonction utilisé pour l'affichage de l'horaire d'un circuit d'autobus
//**************************************************************************
function togglediv_ligne_horaire_autobus(divid, divid2, plus) {
    if (document.getElementById(divid).style.display == 'none')
     {
        document.getElementById(divid).style.display = 'block';
        document.getElementById(divid2).style.display = 'block';
        document.getElementById(plus).src = "/images/puce_moins.gif";
       // document.images.images_fleches.src = "/images/puce_fleche_haut.gif";
    }
    else 
    {
        document.getElementById(divid).style.display = 'none';
        document.getElementById(divid2).style.display = 'none';
        document.getElementById(plus).src = "/images/puce_plus.gif";
       // document.images.images_fleches.src = "/images/puce_fleche_bas.gif";
    }
}


 function toggledivcms(divid)
 {
    if(document.getElementById(divid).style.display == 'none')
    {
      document.getElementById(divid).style.display = 'block';
    }
    else
    {
      document.getElementById(divid).style.display = 'none';
    }
}

function toggledivcms_widget(divid, widget)
 {
 
    var v_image = "";
    var v_image_active = "";
    
   // alert(widget);
    
    switch(widget)
    {
      case "widget1" :
      {
        document.getElementById("div_outil2").style.display = 'none';
        document.getElementById("div_outil3").style.display = 'none';
        document.getElementById("widget2").src = "/images/img_widget_2.jpg";
        document.getElementById("widget3").src = "/images/img_widget_3.jpg";
        
        v_image = "/images/img_widget_1.jpg";
        v_image_active = "/images/img_widget_1_active.jpg";
        break;
      }
      
      case "widget2" :
      {
        document.getElementById("div_outil1").style.display = 'none';
        document.getElementById("div_outil3").style.display = 'none';
         document.getElementById("widget1").src = "/images/img_widget_1.jpg";
        document.getElementById("widget3").src = "/images/img_widget_3.jpg";
        
        v_image = "/images/img_widget_2.jpg";
        v_image_active = "/images/img_widget_2_active.jpg";
        break;
      }
      
      case "widget3" :
      {
        document.getElementById("div_outil1").style.display = 'none';
        document.getElementById("div_outil2").style.display = 'none';
         document.getElementById("widget1").src = "/images/img_widget_1.jpg";
        document.getElementById("widget2").src = "/images/img_widget_2.jpg";
        
        v_image = "/images/img_widget_3.jpg";
        v_image_active = "/images/img_widget_3_active.jpg";
        break;
      }
      
    }
 
    if(document.getElementById(divid).style.display == 'none')
    {
      document.getElementById(divid).style.display = 'block';
     document.getElementById(widget).src = v_image_active;
    }
    else
    {
      document.getElementById(divid).style.display = 'none';
      document.getElementById(widget).src = v_image;
     
    }
}

function toggledivcmsfleche(divid,fleche)
 {
 //alert(fleche);
 
    if(document.getElementById(divid).style.display == 'none')
    {
      document.getElementById(divid).style.display = 'block';
      /*document.getElementById(fleche).src = "/images/puce_fleche_haut.gif";*/
      document.getElementById(divid).style.marginTop = '13px';
	  document.getElementById(divid).style.marginBottom = '13px';
      document.getElementById(fleche).className = "sous_titre_fleche_open";
      
     // document.fleche.className = "sous_titre_fleche_open";
      
    }
    else
    {
      document.getElementById(divid).style.display = 'none';
     /* document.getElementById(fleche).src = "/images/puce_fleche_bas.gif";*/
      
      document.getElementById(fleche).className = "sous_titre_fleche_close";
      
       //document.fleche.className = "sous_titre_fleche_open";
    }    
}

