/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function filterTravelsByCountryId(countryId) {
	/*
    var intId = countryId.replace('travel-flow-', '');
    $('.no-travels-available').remove();
    $('.travel-list li').hide();
    $('.travel-list li div.travel-parent-'+intId).parent().show();
    $('.travel-list li>div').each(function(){
        if($(this).attr('rel').indexOf(intId) != -1) {
            $(this).parent().show()
        }
    });
    var itemCount = $('.travel-list li:visible').length;
    if(itemCount <= 0) {
        $('.travel-list').append('<li class="no-travels-available"><img border="0" width="160" height="110" alt="" src="fileadmin/templates/images/content/reisen-thumbnails/160x110_accept.jpg"><h2>Keine Daten verfügbar</h2><p>Hierzu liegen uns momentan leider keine Daten vor. Wenn Sie dennoch hier hin reisen wollen, nehmen Sie <a href="/kontakt.html">Kontakt</a> zu uns auf.</p><div class="clear"></div></li>');
    }
    */
    
    var intId = countryId.replace('travel-flow-', '');
    $('.no-travels-available').remove();
    $('.travel-list li').hide();
    $('.travel-list li div.travel-parent-'+intId).parent().show();
}

function oeffnefenster (url) {
   fenster = window.open(url, "Druckansicht", "width=800,height=500,status=yes,scrollbars=yes,resizable=yes");
   fenster.focus();
}

function activeSitemapLink(linkToFind) {
    $('.sitemap li a').removeClass('active');
    $('.sitemap li a').each(function() {
        if($(this).attr('href') == linkToFind) {
            $(this).addClass('active');
        }
    });
}

function blurLink() {
}

$(document).ready(function(){
	
	$('a._blank, a.external-link').click(function(){
		var href = $(this).attr('href');
		window.open(href);
		return false;
	});
    
    $('.sitemap-wrap').parent().find('h1').addClass('sitemap-title');    

    var stepmapWidth = $('#stepmap-stage div').eq(4).find('img').width();
    $('#stepmap-stage').width(stepmapWidth);

    /**
     * Hovereffekt fuer Hauptmenu
     *
    $('#main-menu>li').hover(
        function(){
            $(this).addClass('hover');
            $(this).find('.submenu').show();
        },
        function(){
            $(this).removeClass('hover');
            $(this).find('.submenu').hide();
        }
    );
 */

$('#main-menu li.item>a').click(function(){
    $('#main-menu .submenu').fadeOut();
    if($(this).text()=='Startseite') {
        var gotoUrl = $(this).find('a').attr('href');
        location.href = gotoUrl;
    }
    else {
        $(this).parent().find('.submenu').fadeIn();
        return false;
    }
});

$('body').click(function(){
    $('#main-menu .submenu').fadeOut();
});

$('.places, .info').tipsy({
    gravity: 'w'
});
$('.categoryicon, .tipsy').tipsy();
$('.captcha-help').tipsy({
    gravity: 'sw'
});

$('.comment').autogrow();

    $('.stepmap>img').click(function(){
        $('.stepmap-wrap').fadeIn();
    });
    
    $('.stepmap-wrap').click(function(){
    	
        });
    
    /**
     * Slider auf Link prüfen
     **/
    $('.panel').has('a').addClass('has-link');

    /**
     * Footer-Menu Breite anpassen
     */
    $('ul#footer-menu>li:eq(0)').width('110px');
    $('ul#footer-menu>li:eq(1)').width('420px');
    $('ul#footer-menu>li:eq(2)').width('185px');
    $('ul#footer-menu>li:eq(3)').width('85px');

    /**
     * Headerslider
     */
    $('.header-slider').codaSlider({
        dynamicTabs: false,
        dynamicArrowRightText: '',
        dynamicArrowLeftText: '',
        autoSlide: true,
        autoSlideInterval: 8000,
        autoSlideStopWhenClicked: true
    });

    /**
     * Accordion
     */
    //    $('#travel-routing li:first').addClass('open');
    $('#travel-routing li').each(function(){
        $(this).find('.travel-item').wrapAll('<div class="travel-item-container"></div>');
    })
    // $('.travel-item-container').hide();
    //    $('.travel-item-container:first').show();
    $('.travel-headline').click(function(){
        $('.travel-item-container').slideUp();
        if($(this).parent().hasClass('open')) {
            $('#travel-routing li').removeClass('open');  
        } else {
            $(this).next('.travel-item-container').slideDown();
            $('#travel-routing li').removeClass('open');  
            $(this).parent().addClass('open');
        }
    });

    /**
     * Coverflow
     */
    $('ul.flow').roundabout({
        tilt: 0,
        reflect: false,
        btnNext: '.flow-left',
        btnPrev: '.flow-right'
    });

    $('.roundabout-in-focus').live('click', function(){
        var gotoUrl = $(this).find('a').attr('href');
        location.href = gotoUrl;
    });
    
    $('.facebook').click(function(){
    	window.open('http://www.facebook.com/pages/ACCEPT-Reisen/157419157631852');	
    });
    
    $('.twitter').click(function(){
    	window.open('http://twitter.com/acceptreisen');	
    });

    /**
     * Pagination
     */
    $('.country-list').pagination();

    $('#stepmap-stage').append('<div id="stepmap-close"></div>');

    $('#stepmap-close').click(function(){
        $('.stepmap-wrap').fadeOut();
    });
});

