    function convDate(date, a, m, d) {


        /*var reg=new RegExp("^[0-9]{2}[/]{1}[0-9]{2}[/]{1}[0-9]{4}$","g");

        if (reg.test(date)) {*/

            var jour = parseInt(date.substr(0,2), 10)+d;
            var mois = parseInt(date.substr(3,2), 10)+m;
            var annee = parseInt(date.substr(6,4), 10)+a;




            der  = new Date(annee,mois-1,jour);
            //alert(der);
            return der;
        /*}
        else
        return 0;*/
    }

    CLASSE_ERREUR = new Array();
    GARE = false;

    function unset(array, valueOrIndex){
            var output=[];
            for(var i in array){
                    if (i!=valueOrIndex)
                            output[i]=array[i];
            }
            return output;
    }

    function getBaseURL() {
        var url = location.href;
        var baseURL = url.substring(0, url.indexOf('/', 14));

        if (baseURL.indexOf('http://localhost') != -1) {
            var pathname = location.pathname;
            var index1 = url.indexOf(pathname);
            var index2 = url.indexOf("/", index1 + 1);
            var baseLocalUrl = url.substr(0, index2);

            return baseLocalUrl;
        }
        else {
            return baseURL;
        }

    }

    function showPopup(titre, content) {
        var wwidth = screen.availWidth;
        var wheight = screen.availHeight;
        var pwidth = 562;

        var pleft = Math.round((wwidth-pwidth)/2);
        var ptop = 100;

        $('#popup').css('left', pleft+'px');
        $('#popup').css('top', ptop+'px');

        $('#overlay').show();
        $('body').css('overflow', 'hidden');

        $('#popup').show('scale', 'slow');

    }

    function showPlanGrand() {
        if ($('#planGranPopup').css('display')!='block') {
            var contenu = jQuery('#planGrand').html();

            $('body').append('<div id="overlay" class="planGranOverlay" align="center"><div id="planGranPopup">'+contenu+'</div></div>');

            $('body').css('overflow', 'hidden');

            $("#overlay").css('top', $(window).scrollTop());

            $("#planGranPopup").fadeIn('fast');
            $("#overlay").click(function () {
                 $('body').css('overflow', 'auto');
                $(this).remove();
            });
        }
    }


    function  consultation_compte() {
        window.scrollTo(0,0);
        $('#overlay').fadeIn();
        $("#popup.capricorne").show();
    }


    function makeSublist(parent,child,defaut,childVal)
    {
            $("body").append("<select style='display:none' id='"+parent+child+"'></select>");

            if ($("#"+child+" optgroup").length)
            $('#'+parent+child).html($("#"+child+" optgroup"));
            else
            $('#'+parent+child).html($("#"+child+" option"));

                    var parentValue = $('#'+parent).attr('value');

                    if ($("#"+parent+child+" optgroup").length) {
                        $('#'+child).html($("#"+parent+child+" optgroup").clone());
                        $('#'+child+' option').map(function () {

                            if (!$(this).hasClass(parentValue))
                            $(this).remove();
                        });
                        $('#'+child+' optgroup:empty').remove();
                    }
                    else
                    $('#'+child).html($("#"+parent+child+" ."+parentValue).clone());

             $('#'+child).prepend("<option value='0'>"+defaut+"</option>");
                $("#"+child).val(0);
                /*if ($("#"+child+' option').length==1)
                $("#"+child).hide();
                else
                $("#"+child).show();*/
            childVal = (typeof childVal == "undefined")? "" : childVal ;
            if (childVal)
            $("#"+child).val(childVal);
            function parentChange(ss)
                    {

                            var parentValue = $('#'+parent).attr('value');

                            if ($("#"+parent+child+" optgroup").length) {

                                $('#'+child).html($("#"+parent+child+" optgroup").clone());
                                $('#'+child+' option').map(function () {

                                    if (!$(this).hasClass(parentValue))
                                    $(this).remove();
                                });
                                $('#'+child+' optgroup:empty').remove();

                            }
                            else
                            $('#'+child).html($("#"+parent+child+" ."+parentValue).clone());

                            $('#'+child).prepend("<option value='0' selected='selected'>"+defaut+"</option>");
                             $("#"+child).val(0);
                             /*if ($("#"+child+' option').length==1)
                             $("#"+child).hide();
                             else
                             $("#"+child).show();*/

                                if (ss!=1)
                                $('#'+child).trigger("change");
                            $('#'+child).focus();
                    }
            $('#'+parent).change(parentChange);
                parentChange(1);

    }


$(document).ready(function () {
    jQuery('body').show();
    jQuery('a#c1037').remove();

    jQuery('#piedPrecedent').attr('href', 'javascript:void(0);');
    jQuery('#piedSuivant').attr('href', 'javascript:void(0);');

    jQuery('#piedSuivant').click(function () {

        ul = $('#jcarouselPied').find('ul.colonne');

        lim =ul.children('li').length*154-4*154;


        var x = parseInt(ul.css('left'));
        if ((x-154)<-lim)
        x=-lim+154;

        ul.animate({'left': (x-154)+'px'}, 300, 'swing');

    });

    jQuery('#piedPrecedent').click(function () {

        ul = $('#jcarouselPied').find('ul.colonne');

        var x = parseInt(ul.css('left'));
        if (x+154>0)
        x=-154;
        ul.animate({'left': (x+154)+'px'}, 300, 'swing');

    });

    jQuery('#piedToggle').click(function () {

                if ($(this).attr('toggle')=='false')
                $('#chaussette').slideDown();
                else
                $('#chaussette').slideUp();

        });


    jQuery('.accordeon').accordion({
        header: 'h2',
        autoHeight: false
    });





    $('#fermer_popup').click(function () {
                $('body').css('overflow', 'auto');
                $('#popup').hide("scale", "slow", function () {
                    $('#overlay').hide()
                    document.aeorport_popup_form.submit();
                });


     });


    $("#visite_avion a").click(function () {
        if ($('#visite360popup').css('display')!='block') {

            $('body').append('<div id="overlay" class="planGranOverlay" align="center"><div id="visite360popup"></div></div>');
            $("#overlay").css('top', $(window).scrollTop());

            $('#visite360popup').load($(this).attr("title"), function () {

                $('body').css('overflow', 'hidden');



                $("#visite360popup").fadeIn('fast');

            });

            $("#overlay, #visite360popup a").click(function () {
                 $('body').css('overflow', 'auto');
                $(this).remove();
            });
        }
    });

    /************** bouton article *****************/

    $('#bt_amoins').click(function () {

        $("#colonne_milieu").find("h1, .chapo, h3,dt,p,a").each(function () {
            var tp = parseInt($(this).css('font-size'));
            if (tp>10) {
                $('#bt_amoins').css('opacity', '1');
                $(this).css('font-size', (tp-1)+'px');
            }
            else {
                $('#bt_amoins').css('opacity', '0.5');
            }

        });
    });

    $('#bt_aplus').click(function () {

        $("#colonne_milieu").find("h1, .chapo, h3,dt,p,a, li").each(function () {
            var tp = parseInt($(this).css('font-size'));
            if (tp<22) {
                $('#bt_aplus').css('opacity', '1');
                $(this).css('font-size', (tp+1)+'px');
            }
            else {
                $('#bt_aplus').css('opacity', '0.5');
            }

        });
    });

    $('#bt_print').click(function () {
        window.print();
    });

    $('#bt_email').click(function () {
        $('#email_box').load('fileadmin/templates/envoi_ami.php', function () {
            $('#email_box').fadeIn('slow');
        });
    });



    var curl = document.location.href;
    if (curl.indexOf('select_route=1')>0) {

		$('select[id*="destination"]').each(function () {
			var offset = $(this).offset();
			var select_fake = '<a href="#" to="'+$(this).attr('id')+'" style="position:absolute;left:'+(offset.left)+'px;top:'+(offset.top)+'px;" class="select_fake">'+$(this).find('option:selected').html()+'</a>';

			$(this).after(select_fake);

		});

    	$('a.select_fake').click(function (e) {
    		e.preventDefault();

    		$('body').unbind('click');
    		var the_sel = $('select#'+$(this).attr('to'));
    		var the_a = $(this);
    		$('#route_tabs').remove();
    		var lcontinent = new Array();
    		var lpays = new Array();
    		var lvia = new Array();
    		var laero = {};
    		the_sel.find('optgroup').each(function (e, dome) {

    			var ct = $(dome).attr("class");
    			var pays = $(dome).attr('label');
    			//console.log($.inArray(ct, lcontinent));
    			if ($.inArray(ct, lcontinent)==-1)
    			lcontinent.push(ct);



    			$(this).find('option').each(function (r,rome) {
    				if (laero[ct]==undefined)
    				laero[ct]=new Array();
    				var via = $(rome).attr('title');

    				laero[ct].push({pays:pays, nom:$(rome).text(),value:$(rome).attr('value'), via: via});
    				if ($.inArray(via, lvia)==-1)
    				lvia.push(via);

    				if ($.inArray(pays, lpays)==-1)
    				lpays.push(pays);

    			});


    		});

    		var div_continent ='<div class="dmenu"><ul>';
    			for(i=0;i<lcontinent.length;i++)
    			div_continent+='<li><a href="#tab-'+i+'">'+lcontinent[i]+'</a></li>';
    		div_continent+='</ul></div>';


    		var div_aero = '';
    		var o =0;

    		for(lc in laero) {
    			var multicol =0;
    			div_aero+='<div id="tab-'+o+'" class="rtetab">';
    			var py = '';
    			var lp = laero[lc];
    			div_aero+="<div class='tpays'>";
	    			for(i=0;i<lp.length;i++) {
	    				if ((multicol/13)-Math.floor(multicol/13)==0) {
	    					//if (multicol!=0)
	    					div_aero+='</div>';
		    				div_aero+="<div class='tpays'>";

		    			}

		    				if (lp[i].pays!=py) {

		    					div_aero+='<h3>'+lp[i].pays+'</h3>';
		    					py = lp[i].pays;
		    					multicol+=1;
		    				}

		    				if (lp[i].via)
		    				via_class= stpchr(lp[i].via);
		    				else
		    				via_class= "";

		    				div_aero+='<a href="#'+lp[i].value+'" class="aero_choose '+via_class+'">'+lp[i].nom+'</a>';
		    				multicol++;
		    		}

		    		div_aero+='</div>';
		    	div_aero+='</div>';
	    		o++;
    		}


    		//via
    		var div_via = '';
    		if (lvia.length) {
    			div_via = '<div class="via">';
    			for(i=0;i<lvia.length;i++) {
    				div_via+='<div class="'+stpchr(lvia[i])+'">'+lvia[i]+'</div>';
    			}
    			div_via += '</div>';
    		}



    		the_sel.after('<div id="route_tabs">'+div_continent+div_aero+div_via+'</div>');
    		//the_sel.parent().css('position', 'relative');
    		var offset = $(this).offset();
    		 $('#route_tabs').css('top', offset.top+20);
    		  $('#route_tabs').css('left', offset.left);
    		$('#route_tabs #tab-0').css('display','block');
			$('#route_tabs ul a').eq(0).attr('class', 'selected');
    		$('#route_tabs ul a').click(function (e) {
    			e.preventDefault();
				var idt = $(this).attr('href').substr($(this).attr('href').length-6,6);

    			$('#route_tabs').find('.rtetab').css('display','none');
    			$('#route_tabs').find(idt).css('display','block');
    			$('#route_tabs ul a').attr('class', '')
    			$(this).attr('class', 'selected');
    		});

    		var sel = the_sel;
    		$('#route_tabs a.aero_choose').click(function (e) {
    			e.preventDefault();

				sel.val($(this).attr('href').substr($(this).attr('href').length-3,3));

				sel.change();

				$('select[id*="destination"]').each(function () {
					var aa = $('a[to="'+$(this).attr('id')+'"]');
					aa.text($(this).find('option:selected').text());
				})


    			/*sel.val($(this).attr('href').substr(1,20));*/

    			$('#route_tabs').remove();
    		});


    		$('#route_tabs').show('fast', function () {
    			$('body').one('click',function(e) {
				    $('#route_tabs').remove();
				 });
    		});



			$('#route_tabs').click(function (e) {
				e.stopPropagation();
			});



    	});
    }

/*** melanie ***/
    if (curl.indexOf('select_route=old')>0) {

		$('select[id*="destination"]').each(function () {
			var offset = $(this).offset();
			
			$(this).css('display','none');
			$('#aero_arrivee_1').css('clear','both');
			$('.choix_dates_vols').css('clear','both');
			//$('.DestinationsAirAustral').css('margin-bottom','6px');
			
			var select_fake = '<a href="#" to="'+$(this).attr('id')+'" style="float:left;" class="select_fake">'+$(this).find('option:selected').html()+'</a>';

			$(this).after(select_fake);

		});

    	$('a.select_fake').click(function (e) {
    		e.preventDefault();

    		$('body').unbind('click');
    		var the_sel = $('select#'+$(this).attr('to'));
    		var the_a = $(this);
    		$('#route_tabs').remove();
    		var lcontinent = new Array();
    		var lpays = new Array();
    		var lvia = new Array();
    		var laero = {};
    		the_sel.find('optgroup').each(function (e, dome) {

    			var ct = $(dome).attr("class");
    			var pays = $(dome).attr('label');
    			//console.log($.inArray(ct, lcontinent));
    			if ($.inArray(ct, lcontinent)==-1)
    			lcontinent.push(ct);



    			$(this).find('option').each(function (r,rome) {
    				if (laero[ct]==undefined)
    				laero[ct]=new Array();
    				var via = $(rome).attr('title');

    				laero[ct].push({pays:pays, nom:$(rome).text(),value:$(rome).attr('value'), via: via});
    				if ($.inArray(via, lvia)==-1)
    				lvia.push(via);

    				if ($.inArray(pays, lpays)==-1)
    				lpays.push(pays);

    			});


    		});

    		var div_continent ='<div class="dmenu"><ul>';
    			for(i=0;i<lcontinent.length;i++)
    			div_continent+='<li><a href="#tab-'+i+'">'+lcontinent[i]+'</a></li>';
    		div_continent+='</ul></div>';


    		var div_aero = '';
    		var o =0;

    		for(lc in laero) {
    			var multicol =0;
    			div_aero+='<div id="tab-'+o+'" class="rtetab">';
    			var py = '';
    			var lp = laero[lc];
    			div_aero+="<div class='tpays'>";
	    			for(i=0;i<lp.length;i++) {
	    				if ((multicol/18)-Math.floor(multicol/18)==0) {
	    					//if (multicol!=0)
	    					div_aero+='</div>';
		    				div_aero+="<div class='tpays'>";

		    			}

		    				if (lp[i].pays!=py) {

		    					div_aero+='<h3>'+lp[i].pays+'</h3>';
		    					py = lp[i].pays;
		    					multicol+=2;
		    				}

		    				if (lp[i].via)
		    				via_class= stpchr(lp[i].via);
		    				else
		    				via_class= "";

		    				div_aero+='<a href="#'+lp[i].value+'" class="aero_choose '+via_class+'">'+lp[i].nom+'</a>';
		    				multicol++;
		    		}

		    		div_aero+='</div>';
		    	div_aero+='</div>';
	    		o++;
    		}


    		//via
    		var div_via = '';
    		if (lvia.length) {
    			div_via = '<div class="via">';
    			for(i=0;i<lvia.length;i++) {
    				div_via+='<div class="'+stpchr(lvia[i])+'">'+lvia[i]+'</div>';
    			}
    			div_via += '</div>';
    		}



    		the_sel.after('<div id="route_tabs">'+div_continent+div_aero+div_via+'</div>');
    		//the_sel.parent().css('position', 'relative');
    		var offset = $(this).offset();
    		 $('#route_tabs').css('top', offset.top+20);
    		  $('#route_tabs').css('left', offset.left);
    		$('#route_tabs #tab-0').css('display','block');
			$('#route_tabs ul a').eq(0).attr('class', 'selected');
    		$('#route_tabs ul a').click(function (e) {
    			e.preventDefault();
				var idt = $(this).attr('href').substr($(this).attr('href').length-6,6);

    			$('#route_tabs').find('.rtetab').css('display','none');
    			$('#route_tabs').find(idt).css('display','block');
    			$('#route_tabs ul a').attr('class', '')
    			$(this).attr('class', 'selected');
    		});

    		var sel = the_sel;
    		$('#route_tabs a.aero_choose').click(function (e) {
    			e.preventDefault();

				sel.val($(this).attr('href').substr($(this).attr('href').length-3,3));

				sel.change();

				$('select[id*="destination"]').each(function () {
					var aa = $('a[to="'+$(this).attr('id')+'"]');
					aa.text($(this).find('option:selected').text());
				})


    			/*sel.val($(this).attr('href').substr(1,20));*/

    			$('#route_tabs').remove();
    		});


    		$('#route_tabs').show('fast', function () {
    			$('body').one('click',function(e) {
				    $('#route_tabs').remove();
				 });
    		});



			$('#route_tabs').click(function (e) {
				e.stopPropagation();
			});



    	});
    }
    
    
    if (curl.indexOf('select_route=2')>0) {

		$('select[id*="destination"]').each(function () {
			var offset = $(this).offset();
			
			$(this).css('display','none');		
			//$('.DestinationsAirAustral').css('margin-bottom','6px');
			
			var select_fake = '<a href="#" to="'+$(this).attr('id')+'" style="float:left;" class="select_fake">'+$(this).find('option:selected').html()+'</a>';

			$(this).after(select_fake);

		});
		
			// gauche - defaut accueil
			$('#aero_arrivee_1').css('clear','both');
			$('#aero_arrivee_1').css('padding-top','5px');
			$('.choix_dates_vols').css('clear','both');
			
			// droite - guide horaire
			$('#moteur_resa_pg .pg_dates').css('clear','both');
			$('#moteur_resa_pg .pg_dates').css('margin-top','25px');
			$('#moteur_resa_pg #aero_arrivee_1').css('padding-top','5px');
			
			$('#moteur_resa_pg #aero_arrivee_1').css('clear','both');
			//$('#pgrcal #moteur_resa_pg #aero_arrivee_1').css('padding-top','5px');
		
			// centre - defaut resa
			$('#moteur_resa_mr #aero_arrivee_1').css('clear','both');
			$('#moteur_resa_mr #aero_arrivee_1').css('padding-top','5px');
			
			// pour ie7
			if(($.browser.msie) && ($.browser.version.slice(0,2) == '7.'))
			{
				$('#moteur_resa_mr .destination_grp_1 .aero_arrivee').css('clear','both');
				$('#moteur_resa_mr .destination_grp_1 .aero_arrivee').css('padding-top','5px');
				$('#moteur_resa_mr #aero_arrivee_2').css('margin-top','-17px');
				$('#moteur_resa_mr .date_grp_2').css('margin-top','-2px');
			}
			
			// moteur capricorne
			$('.tx-aaformulaireprime-pi1 .select_fake').css('float','none');
			
			
			
			
				
			// gauche - arrivee et depart
			$('#moteur_resa_hr h3').each(function () {
				$(this).css('clear','both');
				$(this).css('padding-top','5px');
			});
			
			$('#moteur_resa_hr #aero_arrivee_1').css('clear','both');
			$('#moteur_resa_hr #aero_arrivee_1').css('padding-top','5px');
			
			// centre - destination multi
			$('#moteur_resa_mr #aero_arrivee_2').css('clear','both');
			$('#moteur_resa_mr #aero_arrivee_2').css('padding-top','5px');
			$('#moteur_resa_mr .date_grp_2').css('clear','both');
			$('#moteur_resa_mr .date_grp_2').css('padding-top','1px');
			$('#moteur_resa_mr .date_grp_2').css('margin-left','33px');
			$('#moteur_resa_mr .destination_grp_1').css('width','275px');
			
			
			// centre - destination escale
			$('#moteur_resa_mr .mrd .destination_grp_1').css('width','207px');
			$('#moteur_resa_mr .mrd .destination_grp_2').css('width','207px');
			$('#moteur_resa_mr .mrd .destination_grp_3').css('width','207px');
			$('#moteur_resa_mr .mrd .destination_grp_4').css('width','207px');
			
			$('#moteur_resa_mr .mrd .date_grp_1').css('clear','none');
			$('#moteur_resa_mr .mrd .date_grp_2').css('clear','none');
			$('#moteur_resa_mr .mrd .date_grp_3').css('clear','none');
			$('#moteur_resa_mr .mrd .date_grp_4').css('clear','none');
			
			$('#moteur_resa_mr .mrd #aero_arrivee_1').css('padding-top','5px');
			$('#moteur_resa_mr .mrd #aero_arrivee_2').css('padding-top','5px');
			$('#moteur_resa_mr .mrd #aero_arrivee_3').css('padding-top','5px');
			$('#moteur_resa_mr .mrd #aero_arrivee_4').css('padding-top','5px');
			
			$('#moteur_resa_mr .mrd #aero_arrivee_1').css('clear','both');
			$('#moteur_resa_mr .mrd #aero_arrivee_2').css('clear','both');
			$('#moteur_resa_mr .mrd #aero_arrivee_3').css('clear','both');
			$('#moteur_resa_mr .mrd #aero_arrivee_4').css('clear','both');
			
			$('#moteur_resa_mr .mrd .date_grp_2').css('margin-left','242px');
			$('#moteur_resa_mr .mrd .date_grp_2').css('padding-top','0px');

    	$('a.select_fake').click(function (e) {
    		e.preventDefault();

    		$('body').unbind('click');
    		var the_sel = $('select#'+$(this).attr('to'));
    		var the_a = $(this);
    		$('#route_tabs').remove();
    		var lcontinent = new Array();
    		var lpays = new Array();
    		var lvia = new Array();
    		var laero = {};
    		the_sel.find('optgroup').each(function (e, dome) {

    			var ct = $(dome).attr("class");
    			var pays = $(dome).attr('label');
    			//console.log($.inArray(ct, lcontinent));
    			if ($.inArray(ct, lcontinent)==-1)
    			lcontinent.push(ct);



    			$(this).find('option').each(function (r,rome) {
    				if (laero[ct]==undefined)
    				laero[ct]=new Array();
    				var via = $(rome).attr('title');

    				laero[ct].push({pays:pays, nom:$(rome).text(),value:$(rome).attr('value'), via: via});
    				if ($.inArray(via, lvia)==-1)
    				lvia.push(via);

    				if ($.inArray(pays, lpays)==-1)
    				lpays.push(pays);

    			});


    		});

    		var div_continent ='<div class="dmenu"><ul>';
    			for(i=0;i<lcontinent.length;i++)
    			div_continent+='<li><a href="#tab-'+i+'">'+lcontinent[i]+'</a></li>';
    		div_continent+='</ul></div>';


    		var div_aero = '';
    		var o =0;

    		for(lc in laero) {
    			var multicol =0;
    			div_aero+='<div id="tab-'+o+'" class="rtetab">';
    			var py = '';
    			var lp = laero[lc];
    			div_aero+="<div class='tpays'>";
	    			for(i=0;i<lp.length;i++) {
	    				if ((multicol/15)-Math.floor(multicol/15)==0) {
	    					//if (multicol!=0)
	    					div_aero+='</div>';
		    				div_aero+="<div class='tpays'>";

		    			}

		    				if (lp[i].pays!=py) {

		    					div_aero+='<h3>'+lp[i].pays+'</h3>';
		    					py = lp[i].pays;
		    					multicol+=1;
		    				}

		    				if (lp[i].via)
		    				via_class= stpchr(lp[i].via);
		    				else
		    				via_class= "";

		    				div_aero+='<a href="#'+lp[i].value+'" class="aero_choose '+via_class+'">'+lp[i].nom+'</a>';
		    				multicol++;
		    		}

		    		div_aero+='</div>';
		    	div_aero+='</div>';
	    		o++;
    		}


    		//via
    		var div_via = '';
    		if (lvia.length) {
    			div_via = '<div class="via">';
    			for(i=0;i<lvia.length;i++) {
    				div_via+='<div class="'+stpchr(lvia[i])+'">'+lvia[i]+'</div>';
    			}
    			div_via += '</div>';
    		}



    		the_sel.after('<div id="route_tabs">'+div_continent+div_aero+div_via+'</div>');
    		//the_sel.parent().css('position', 'relative');
		$('#route_tabs #tab-0').css('display','block');
    		var offset = $(this).offset();
		
		var position_routetabs_left = offset.left;
		
		$('#route_tabs').css('left', '0px');
		
		 if(($(window).width()-offset.left) < ($('#route_tabs').width()+10))
		  {
			position_routetabs_left = offset.left-(($('#route_tabs').width()+10)-($(window).width()-offset.left));
		  }
		
    		 $('#route_tabs').css('top', offset.top+20);
    		  $('#route_tabs').css('left', position_routetabs_left);
		  //$('#route_tabs').css('left', offset.left);
		  
		  
    		//$('#route_tabs #tab-0').css('display','block');
		//alert($('#route_tabs').width());
			$('#route_tabs ul a').eq(0).attr('class', 'selected');
    		$('#route_tabs ul a').click(function (e) {
    			e.preventDefault();
				var idt = $(this).attr('href').substr($(this).attr('href').length-6,6);

    			$('#route_tabs').find('.rtetab').css('display','none');
    			$('#route_tabs').find(idt).css('display','block');
			
			$('#route_tabs').css('left', '0px');
			//alert($('#route_tabs').find(idt).width());
			if(($(window).width()-offset.left) < ($('#route_tabs').width()+10))
			{
			      position_routetabs_left = offset.left-(($('#route_tabs').width()+10)-($(window).width()-offset.left));
			}
			$('#route_tabs').css('left', position_routetabs_left);
			
			
				
    			$('#route_tabs ul a').attr('class', '')
    			$(this).attr('class', 'selected');
    		});

    		var sel = the_sel;
    		$('#route_tabs a.aero_choose').click(function (e) {
    			e.preventDefault();

				sel.val($(this).attr('href').substr($(this).attr('href').length-3,3));

				sel.change();

				$('select[id*="destination"]').each(function () {
					var aa = $('a[to="'+$(this).attr('id')+'"]');
					aa.text($(this).find('option:selected').text());
				})


    			/*sel.val($(this).attr('href').substr(1,20));*/

    			$('#route_tabs').remove();
    		});


    		$('#route_tabs').show('fast', function () {
    			$('body').one('click',function(e) {
				    $('#route_tabs').remove();
				 });
			
			var offset = $('#route_tabs').offset();
		
			var position_routetabs_left = offset.left;
			
			$('#route_tabs').css('left', '0px');
			
			 if(($(window).width()-offset.left) < ($('#route_tabs').width()+10))
			  {
				position_routetabs_left = offset.left-(($('#route_tabs').width()+10)-($(window).width()-offset.left));
			  }
			
			  $('#route_tabs').css('left', position_routetabs_left);
			});



			$('#route_tabs').click(function (e) {
				e.stopPropagation();
			});



    	});
    }
    
    if (curl.indexOf('infobulle=1')>0) {
	
	$(document).ready(function () {
		$('#centre [title]').each(function () {
		    if ($(this).attr('title') != ' ' && $(this).attr('title') != '')
		    {
			$(this).qtip({
			    attr:'title',
			    position: {
				my: 'top left',
				at: 'bottom right',
				target:'mouse',
				viewport: $(window)
			    }
			});
		    }
		    
		});
	});
    }
    
    /*** melanie ***/



});



function stpchr(s) {
	return s.replace(/[^a-zA-z]/g,'');
}














