function submitLocator(){
    //document.getElementById("tx_locator_pi1_city").value = "Hatzfeld/Eder";
    //document.forms.locator.submit();    
    $('.tx-locator-pi1 form').submit();   
}

$(document).ready(function() {
    
    // automaticall submit locator form if it's displayed in content area
    if ($('#content .tx_locator_searchform').length > 1)
    {
        //~ $('#tx_locator_pi1_storename').val('');
        submitLocator();
    }
    
    /*
    $('#uid-5').click(function()
    {
        submitLocator();
    });    
    
    $('.navi-sub .a0').click(function()
    {
        submitLocator();
    });    
    */
    
    // Locator Navigation
    if ($("#mapAll").length > 0 ) 
    {
        // Bad Wildungen = Center of Germany
        var centerGermany = new google.maps.LatLng(51.151786,9.415039); 

        var centerEurope = new google.maps.LatLng(50.958427,8.349609); 

        // Irakleio = Center of the World on Zoom 1
        var centerWorld1 = new google.maps.LatLng(35.333123,25.137491);
        
        // Kamina, Kongo = Center of the World on Zoom 0
        var centerWorld0 = new google.maps.LatLng(-8.749366,25.009003);
         
        var centerHeadquarters = new google.maps.LatLng(50.961022,8.254852); 
        
        var centerOceania = new google.maps.LatLng(-16.130262,124.101563); 
        
        var centerAsia = new google.maps.LatLng(34.669359,123.75); 
        
        var centerMiddleEast = new google.maps.LatLng(25.799891,54.228516); 
        
        var centerNorthAmerica = new google.maps.LatLng(31.203405,-89.648437); 
       
        $('#world-view').click(function()
        {
            map.setZoom(1);
            map.setCenter(centerWorld1)
        });        
        
        $('#headquarters').click(function()
        {
            map.setZoom(9);
            map.setCenter(centerHeadquarters)
        });       
         
        $('#asia').click(function()
        {
            map.setZoom(3);
            map.setCenter(centerAsia)
        });        
        
        $('#oceania').click(function()
        {
            map.setZoom(3);
            map.setCenter(centerOceania)
        });     
           
        $('#middle-east').click(function()
        {
            map.setZoom(4);
            map.setCenter(centerMiddleEast)
        });     
           
        $('#north-america').click(function()
        {
            map.setZoom(3);
            map.setCenter(centerNorthAmerica)
        });        
        $('#europe').click(function()
        {
            map.setZoom(4);
            map.setCenter(centerEurope)
        });        
    }    
    // longDropdown for quickfinder
    // source: http://css-tricks.com/examples/LongDropdowns/

    $("#din-norm .trigger").attr('href','#');

    var maxHeight = 200;

    $(function(){

        $("#din-norm").hover(function() {

             var $container = $(this),
                 //$list = $container.find("#quickselect-dropdown > ul"),
                 $list = $container.find("ul"),
                 $anchor = $container.find("a"),
                 height = $list.height() * 1.1,       // make sure there is enough room at the bottom
                 multiplier = height / maxHeight;     // needs to move faster if list is taller

            // need to save height here so it can revert on mouseout
            $container.data("origHeight", $container.height());

            // so it can retain it's rollover color all the while the dropdown is open
            $anchor.addClass("hover");

            // for styling
            //$("#quickselect").addClass("hover");

            // make sure dropdown appears directly below parent list item
            $list
                .show()
                .css({
                    paddingTop: $container.data("origHeight"),
                    top: 0
                });

            // don't do any animation if list shorter than max
            if (multiplier > 1) {
                $container
                    .css({
                        height: maxHeight,
                        overflow: "hidden"
                    })
                    .mousemove(function(e) {
                        var offset = $container.offset();
                        var relativeY = ((e.pageY - offset.top) * multiplier) - ($container.data("origHeight") * multiplier);
                        if (relativeY > $container.data("origHeight")) {
                            $list.css("top", -relativeY + $container.data("origHeight"));
                        };
                    });
            }

        // mouseout
        }, function() {

            var $el = $(this);

            // put things back to normal
            //$("#quickselect").removeClass("hover").find(".js-bottom").remove();

            $el
                .height($(this).data("origHeight"))
                .find("ul")
                .css({ top: 0 })
                .hide()
                .end()
                .find("a")
                .removeClass("hover");

        });

        // Add down arrow only to menu items with submenus
        /*
        $(".dropdown > li:has('ul')").each(function() {
            $(this).find("a:first").append("<img src='images/down-arrow.png' />");
        });
        */

    });



/*
    $("#navi-main li a").hover(function () {
        $(this).show("drop", { direction: "up" }, 1000);
    });
    $("#navi-main li a").hover(function () {
        $(this).before('<div class="nav-' + myClass + '"></div>');
        $("div.nav-" + myClass).css({display:"none"}).fadeIn(200);
    }).mouseout(function() {
        $("div.nav-" + myClass).fadeOut(200, function() {
            $(this).remove();
        });
    }).mousedown(function() {
        $("div.nav-" + myClass).attr("class", "nav-" + myClass + "-click");
    }).mouseup(function() {
        $("div.nav-" + myClass + "-click").attr("class", "nav-" + myClass);
    });
    */


   /* var myClass = "test";

    $("#navi-main li a").hover(function () {
        $(this).before('<div class="nav-' + myClass + '"></div>');
    });
    */

    //$('#content-text ul li a.download').parents('#content-text').addClass('js-downloads');
    $('.be-downloads ul').each(function () {
         $(this).children('li:odd').addClass('js-odd');
         $(this).children('li:even').addClass('js-even');
         $(this).find('br').remove();
    });

    $('#head').cycle({ slideExpr: 'span.slideshowimage' });

    $('#search-input').focus(function () {
        $(this).attr('value','');
    });

    $('#quicklinks .loginlist').hide();

    if ( $("a.extranet").parent().next('li:hidden').hasClass('loginlist') ) {
        $("a.extranet").bind("click", function(ev){
                ev.preventDefault();
                $('#quicklinks .loginlist').slideToggle();
            }
        );
    };

    if ( $("#quicklinks .loginlist .foldout").get(0) ) {
        $("#quicklinks .loginlist").show();
    };
    
    $('a.top-rating-logo').click(function()
    {
        $.fancybox({
            'zoomSpeedIn'           :   300,
	        'zoomSpeedOut'          :  300,
	        'overlayShow'           :   true,
            'hideOnOverlayClick'    : false,
            'autoScale'		        : false,
			'transitionIn'	        : 'none',
			'transitionOut'	        : 'none',
			'width'		            : 542,
			'height'		        : 787,
			'href'			        : 'http://www.eew-group.com/fileadmin/layouts/main/public/gfx/EEW-Toprating.jpg',
			'type'			        : 'image'
            
        });
        return false;
    });

    $('a.fpal-logo').click(function()
    {
        $.fancybox({
            'zoomSpeedIn'           :   300,
	        'zoomSpeedOut'          :  300,
	        'overlayShow'           :   true,
            'hideOnOverlayClick'    : false,
            'autoScale'		        : false,
			'transitionIn'	        : 'none',
			'transitionOut'	        : 'none',
			'width'		            : 542,
			'height'		        : 787,
			'href'			        : 'http://www.eew-group.com/fileadmin/layouts/main/public/gfx/FPAL_accredited_stamp.jpg',
			'type'			        : 'image'
            
        });
        return false;
    });
    
    $('#startpage h2').each(function()
        {
            $(this).addClass('h2-accordion-down');
            $(this).parent().next('.csc-textpic').addClass('accordion');
        }
    );
    $('#startpage h2').bind({
        click: function()
        {
            $(this).toggleClass('h2-accordion-down');
            $(this).parent().next('.csc-textpic').toggleClass('accordion');    
        }

    });
    $('#startpage h2').first().parent().next('.csc-textpic').toggleClass('accordion');    
    $('#startpage h2').first().toggleClass('h2-accordion-down');
    
    
    $('#startpage a.thickbox img').each(function()
        {
            //$(this).after('<img class="start-plus" src="/fileadmin/layouts/main/public/gfx/red-plus.png" />');
            $(this).after('<span class="start-plus"></span>');
        }
    );
    
    $('#startpage .teaser-video-play a img').after('<span class="start-plus"></span>');
     
     
     $('ul.navi-main-dropdown li').hover(
        function()
        {
            var li_width = $(this).width();
            $(this).children('.navi-main-dropdown-second').css('left', '' + li_width + 'px');
            
        }
    ); 
      
      
    $('#startpage .teaser-video-play a').click(function(event) {
            event.preventDefault();
			$.fancybox({
			'width' : 640,
			'height' : 380,
			'href' : 'http://www.eew-group.com/index.php?id=548&type=99',
			'type' : 'iframe'
			});
			return false;
		});   
    
    
    if ($.browser.msie && $.browser.version.substring(0,1) === '6') 
    {
        $('#navi-main li').hover(
            function()
            {
                $(this).find('#navi-main-dropdown').css({
                    'display':'block'
                });
            },
            function()
            {
                $(this).find('#navi-main-dropdown').css({
                    'display' : 'none'
                });
            }
        ); 
        
        $('#navi-main-dropdown li').hover(
            function()
            {
                $(this).find('#navi-main-dropdown-second').css({
                    'display':'block',
                    'z-index':'200'
                });
            },
            function()
            {
                $(this).find('#navi-main-dropdown-second').css({
                    'display' : 'none'
                });
            }
        ); 
        
        
    }

    
});

