function tick() {}

function markerExtension() {
    
    var
        _this = this,
        infoWindow = null,
        text = {
            route       : 'Route berechnen: ',
            spacer      : ' - ',
            sumbmit     : 'Berechnen',
            fromHere    : 'Von hier',
            fromAddress : 'Ziel Adresse:',
            toHere      : 'Hierher',
            toAddress   : 'Start Adresse:',
            bigMapLink  : 'Größere Kartenansicht'
        },

        bigMapLinkUrl = 'http://maps.google.at/maps?f=q&source=s_q&hl=de&geocode=&q=Franz-Josefs-Kai+27%2F10&mrt=all&sll=48.21252,16.375551&sspn=0.014041,0.045447&ie=UTF8&hq=&hnear=Franz+Josefs+Kai+27,+Innere+Stadt+1010+Wien&z=16',
        
        fromHereLink =  $('<a/>')
            .attr('href','#')
            .text(text.fromHere)
            .click(function () {

                optionHTML.normal.detach();
                optionHTML.toHere.detach();
                optionHTML.fromHere.appendTo(infoWindow);

                try {
                    _this.map.getInfoWindow().reset(null,null, new GSize(300,230));
                }catch(e) {}

                $('#googleInput').focus();

                return false;
            }),

        fromHereForm = $('<form />')
            .attr('method','get')
            .attr('action','http://maps.google.de/maps')
            .attr('target','_blank')
            .submit(function () { 
                if($('#googleInput').val().length == 0) {
                    $('#googleInput').focus();
                    return false;
                }
            })
            .append(
                $('<input/>')
                    .attr('type','hidden')
                    .attr('name','saddr')
                    .attr('value',_this.marker.getLatLng().toUrlValue())
            )
            .append(
                $('<label/>')
                    .text(text.fromAddress)
            )
            .append(
                $('<input/>')
                    .attr('id','googleInput')
                    .attr('type','text')
                    .attr('name','daddr')
            )
            .append(
                $('<input/>')
                    .attr('type','submit')
                    .attr('value',text.sumbmit)
            ),
                
        toHereLink =  $('<a/>')
            .attr('href','#')
            .text(text.toHere)
            .click(function () {
                
                optionHTML.normal.detach();
                optionHTML.fromHere.detach();
                optionHTML.toHere.appendTo(infoWindow);

                try {
                    _this.map.getInfoWindow().reset(null,null, new GSize(300,230));
                }catch(e) {}

                $('#googleInput').focus();
                
                return false;
            }),

        toHereForm = $('<form />')
            .attr('method','get')
            .attr('action','http://maps.google.de/maps')
            .attr('target','_blank')
            .submit(function () {
                if($('#googleInput').val().length == 0) {
                    $('#googleInput').focus();
                    return false;
                }
            })
            .append(
                $('<input/>')
                    .attr('type','hidden')
                    .attr('name','daddr')
                    .attr('value',_this.marker.getLatLng().toUrlValue())
            )
            .append(
                $('<label/>')
                    .text(text.toAddress)
            )
            .append(
                $('<input/>')
                    .attr('id','googleInput')
                    .attr('type','text')
                    .attr('name','saddr')
            )
            .append(
                $('<input/>')
                    .attr('type','submit')
                    .attr('value',text.sumbmit)
            ),

        optionHTML = {
            normal : $('<p/>')
                        .text(text.route)
                        .append (toHereLink.clone(true))
                        .append (document.createTextNode(text.spacer))
                        .append (fromHereLink.clone(true)),
                        
            fromHere : $('<p/>')
                        .text(text.route)
                        .append (toHereLink.clone(true))
                        .append (document.createTextNode(text.spacer))
                        .append (
                            $('<b/>')
                                .text(text.fromHere)
                        )
                        .append (fromHereForm.clone(true)),
                        
            toHere : $('<p/>')
                        .text(text.route)
                        .append (
                            $('<b/>')
                                .text(text.toHere)
                        )
                        .append (document.createTextNode(text.spacer))
                        .append (fromHereLink.clone(true))
                        .append (toHereForm.clone(true))
        };

        GEvent.addListener(_this.marker,'infowindowopen',function () {
            infoWindow = $('#myInfowindow')
                .append(optionHTML.normal);
                
            _this.map.getInfoWindow().reset(null ,null, new GSize(300,210));
            GEvent.clearListener(_this.marker);
        });

        $('#map_canvas').after(
            $('<a/>')
                .attr('href',bigMapLinkUrl)
                .attr('target','_blank')
                .addClass('bigmap')
                .text(text.bigMapLink)
        );
}
