var last_leave;
var header_menu_timeout=15000;
koncnica = 'png';
extension = 'png';

function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}

if (vIE()==6) {
	koncnica = 'gif';
	extension = 'gif';
}

(function($) {
    $.fn.customFadeIn = function(speed, callback) {
        $(this).fadeIn(speed, function() {
            if (jQuery.browser.msie)
                $(this).get(0).style.filter = "";
            if (callback != undefined)
                callback();
        });
    };
    $.fn.customFadeOut = function(speed, callback) {
        $(this).fadeOut(speed, function() {
            if (jQuery.browser.msie)
                $(this).get(0).style.filter = "";
            if (callback != undefined)
                callback();
        });
    };
})(jQuery);

function try_hide_header_big()
{
//alert("[try_hide_header_big]");
	G_StopHeaderBanners=true;
	$('.bannerholder').hide();
	if(1>$('#closethisarea').length) $('.belowbanner').hide();
}

function try_hide_header()
{//pMode: -1: undefined; 0: small banner 1: big banner
	var i,pMode=-1,pTryN=1;
	for(i=0;i<arguments.length;i++)
		switch(i)
		{
		case 0: pMode = arguments[i]; break;
		case 1: pTryN = parseInt(arguments[i],0); break;
		}
	if(10<pTryN) return;

	if(-1==pMode)
	{
		if(0<$('.smallbannerholder').length) pMode=0;
		else
		{
			if(1>$('.bannerholder').length)
			{
				setTimeout(function(){try_hide_header(pMode,pTryN+1);}, 500);
				return;
			}
			
			//check if exists button "close area"
			if(0<$('#closethisarea').length) pMode=0;
			else pMode=1;
		}
	}
	
	if(1==pMode)
	{
		try_hide_header_big();
		return;
	}

    if ($('.bannerholderNoBorder').size()>0 || $('.bannerholder').size()>0 ){
		G_StopHeaderBanners=true;
		$('.bannerholderNoBorder').hide();
		$('.bannerholder').hide();
		$('#closethisarea').hide();
		$('#openthisarea').show(); 
		$(document).ready(function(e) {
			$("#openthisarea").css({ 'background-color': 'blue' });
			$("#openthisarea").fadeOut(800).fadeIn(800).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400);
			window.setTimeout(function() { $("#openthisarea").css({ 'background-color': 'transparent' }); }, 3500)
		});   	
    }
    else{setTimeout(function() {try_hide_header(pMode,pTryN+1);}, 500);return;} 
}

function hide_header()
{
	var i,pMode=-1,pTryN=1;
	for(i=0;i<arguments.length;i++)
		switch(i)
		{
		case 0: pMode = arguments[i]; break;
		case 1: pTryN = parseInt(arguments[i],0); break;
		}
	if(10<pTryN) return;

    if ($("#closethisarea").size() > 0) {
        if ($.cookie("full_headed") == "0") {
		   if ($('.bannerholderNoBorder').size()>0 || $('.bannerholder').size()>0 ){
		    G_StopHeaderBanners=true;
			$('.bannerholderNoBorder').hide();
			$('.bannerholder').hide();
			$('#closethisarea').hide();
			$('#openthisarea').show();   
			$(document).ready(function(e) {
				$("#openthisarea").css({ 'background-color': 'blue' });
				$("#openthisarea").fadeOut(800).fadeIn(800).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400);
				window.setTimeout(function() { $("#openthisarea").css({ 'background-color': 'transparent' }); }, 3500)
			});   			
			}
			else{setTimeout(function() {try_hide_header(pMode,pTryN+1);}, 500);return;} 
        }
    }
}

a = function(){}

$(document).ready(function() {
    $('#closethisarea').click(function() {
		G_StopHeaderBanners=true;
        $('.bannerholderNoBorder').slideUp('fast');
        $('.bannerholder').slideUp('fast');
        $(this).hide();
        $('#openthisarea').show();
        $.cookie("full_headed", "0", { path: '/' })
    });
    $('#openthisarea').click(function() {
		G_StopHeaderBanners=false;
        $('.bannerholderNoBorder').slideDown('fast');
        $('.bannerholder').slideDown('fast');
        $(this).hide();
        $('#closethisarea').show();
        $.cookie("full_headed", "1", { path: '/' })
//add by qaz
setTimeout(a,milisekund);
    });

    if (vIE() != 6) {
        $('#navigationcontrol').mouseleave(function() {
            last_leave = new Date();
            setTimeout(function() {
                var curdate = new Date();
                if (curdate - last_leave > header_menu_timeout - 2) {
                    $('#header .subnavigation').hide();
                    $('#header .subnavigation.selected').show();
                    $('#header .subnavigation.current').show();
                    $("div.navigation div.leftnaviactive").removeClass('leftnaviactive');
                    $("div.navigation div.rightnaviactive").removeClass('rightnaviactive');
                    $("div.navigation div.buttonactive").removeClass('buttonactive');
                    $("div.navigation div.leftnavi.static").addClass('leftnaviactive');
                    $("div.navigation div.rightnavi.static").addClass('rightnaviactive');
                    $("div.navigation div.button.static").addClass('buttonactive');
                }
            }, header_menu_timeout);
            $('.navibutton.current').children('.leftnavi').addClass('leftnaviactive');
            $('.navibutton.current').children('.rightnavi').addClass('rightnaviactive');
            $('.navibutton.current').children('.button').addClass('buttonactive');

        });
    }
    $('#language').click(function(pEvent) {
        $('#languageselect').slideToggle('fast');
        $('#fromselect').slideUp('fast');
        pEvent.stopPropagation();
    });
    $('#from').click(function(pEvent) {
        $('#fromselect').slideToggle('fast');
        $('#languageselect').slideUp('fast');
        pEvent.stopPropagation();
    });
    $('div.navigation div.navibutton').mouseenter(function() {
        $("div.navigation div.leftnaviactive").removeClass('leftnaviactive');
        $(this).find(".leftnavi").addClass('leftnaviactive');
        $("div.navigation div.rightnaviactive").removeClass('rightnaviactive');
        $(this).find(".rightnavi").addClass('rightnaviactive');
        $("div.navigation div.buttonactive").removeClass('buttonactive');
        $(this).find(".button").addClass('buttonactive');
        $('#header .subnavigation').hide();
        if ($('#' + $(this).attr('rel')).size() > 0)
            $('#' + $(this).attr('rel')).show();
        else
            $('#header .subnavigation.empty').show();
    });
    $('#header div.subnavigation div.navibutton').mouseenter(function() {
        $(this).find(".leftnavi").addClass('leftnaviactive');
        $(this).find(".rightnavi").addClass('rightnaviactive');
        $(this).find(".button").addClass('buttonactive');
    });
    $('#header div.subnavigation div.navibutton').mouseleave(function() {
        $(this).find(".leftnavi").removeClass('leftnaviactive');
        $(this).find(".rightnavi").removeClass('rightnaviactive');
        $(this).find(".button").removeClass('buttonactive');
    });
    $('#tdMainCenter div.spotlight div.choose a').click(function() {
        $("#tdMainCenter div.spotlight div.choose a").removeClass("active");
        $(this).addClass("active");
        $("div.spotLightContainer .article").not($(".type" + $(this).attr('rel'))).slideUp('slow');
        $("div.spotLightContainer .type" + $(this).attr('rel')).slideDown('slow');
    });
    $('#tdMainCenter div.column div.choose a').click(function() {
        $("#tdMainCenter div.column div.choose a").removeClass("active");
        $(this).addClass("active");
        $(".event").not($(".eventtype" + $(this).attr('rel'))).slideUp('slow');
        $(".eventtype" + $(this).attr('rel')).slideDown('slow');
    });

    $("#tdMainCenter div.column div.event").mouseenter(function() {
        $(this).addClass("hovered");
    });

    $("#tdMainCenter div.column div.event").mouseleave(function() {
        $(this).removeClass("hovered");
    });

    $("#tdMainCenter div.right div.event").mouseenter(function() {
        $(this).addClass("hovered");
    });

    $("#tdMainCenter div.right div.event").mouseleave(function() {
        $(this).removeClass("hovered");
    });

    $('#tdMainCenter div.right div.choose a').click(function() {
        $("#tdMainCenter div.right div.choose a").removeClass("active");
        $(this).addClass("active");
        $(".event").not($(".eventtype" + $(this).attr('rel'))).slideUp('slow');
        $(".eventtype" + $(this).attr('rel')).slideDown('slow');
    });



    $("#tdMainCenter div.column div.miss-out a.miss-out").mouseenter(function() {
        $("#tdMainCenter div.column div.miss-out a.miss-out").removeClass("active");
        $(this).addClass("active");
        $("#miss-out" + $(this).attr('rel')).show();
        $("#tdMainCenter div.column div.miss-out div.imgborder").not($("#miss-out" + $(this).attr('rel'))).hide();
    });

    $(".bubble").mouseenter(function() {
        $(this).children("div").show();
        $(".fields").css("position", "static");        
    });

    $(".bubble").mouseleave(function() {
        $(this).children("div").hide();
        $(".fields").css("position", "relative"); 
    });

    if (vIE() == 6) {
        $(".bubblebottom").addClass("bubblebottomie6");
        $(".bubbletop").addClass("bubbletopie6");
        $(".bubblemiddle").addClass("bubblemiddleie6");
    }

    $(".gotomap").mouseenter(function() {
        $(this).css('background-image', 'url(/img/gotomap-hover.png)');
    });

    $(".gotomap").mouseleave(function() {
        $(this).css('background-image', 'url(/img/gotomap.png)');
    });

    $(".blackdot").mouseenter(function() {
        $(this).children("div").show();
    });

    $(".blackdot").mouseleave(function() {
        $(this).children("div").hide();
    });

    $(".reddot").mouseenter(function() {
        $(this).children("div").show();
    });

    $(".reddot").mouseleave(function() {
        $(this).children("div").hide();
    });

    $("div.content-gray-box-top div.tab").click(function() {
        $(".tableftactive").removeClass("tableftactive");
        $(this).children(".tableft").addClass("tableftactive");
        $(".tabmiddleactive").removeClass("tabmiddleactive");
        $(this).children(".tabmiddle").addClass("tabmiddleactive");
        $(".tabrightactive").removeClass("tabrightactive");
        $(this).children(".tabright").addClass("tabrightactive");
        $("div.tab div.tabmiddle span.active").removeClass("active");
        $("div.tab div.tabmiddle span.activeblue").removeClass("activeblue");
        $(this).children(".tabmiddle").children("span").addClass("active");
        $(this).children(".tabmiddle").children("span").addClass("active" + $(this).children(".tabmiddle").children("span").attr('rel'));
        $(".box-content").hide();
        $(".box-content-control").hide();
        $("#" + $(this).attr("rel")).show();
        $("." + $(this).attr("rel")).show();
        $(".pagers").hide();
        $(".pager" + $(this).attr("relpager")).show();
    });
    $(".greenboxcontrol").click(function() {
        $(this).siblings(".greenbox").hide();
        $(this).siblings(".greenbox" + $(this).attr("rel")).show();
        $(this).siblings(".activetab").removeClass("activetab").addClass("tab");
        $(this).removeClass("tab").addClass("activetab");
        /*
        was replaced cause this code closes ALL elements on page
        $(".greenbox").hide();
        $(".greenbox"+$(this).attr("rel")).show();
        $(".activetab").removeClass("activetab").addClass("tab");
        $(this).removeClass("tab").addClass("activetab");
        */
    });

    $(".book-buy A.tab").click(function() {
        $(".book-buy .greenbox").hide();
        $(".book-buy .greenbox" + $(this).attr("rel")).show();
        $(".book-buy A.tab").removeClass("activetab");
        $(this).addClass("activetab");
    });
    
    $("#tdMainCenter h5.slideup").click(function() {
        $("#articles" + $(this).attr("rel")).slideToggle();
        $(this).toggleClass("slideup");
        $(this).toggleClass("slidedown");
        $(this).children(".right").toggle();
        $(this).children(".results").toggle();
    });

    $("#tdMainCenter h5.slidedown").click(function() {
        $("#articles" + $(this).attr("rel")).slideToggle();
        $(this).toggleClass("slideup");
        $(this).toggleClass("slidedown");
        $(this).children(".right").toggle();
        $(this).children(".results").toggle();
    });

    $("#tdMainCenter a.faqselect").click(function() {
        $(this).toggleClass("faqhide");
        $(this).parent().children("div.faqcontrol").slideToggle();
        if (jQuery.browser.msie) {
            $("#footer").slideUp(1000);
            $("#footer").slideDown(1);
        }
    });

    $("#header div.type3banner div.tabs").mouseenter(function() {

        $(this).addClass("tabhover");
        $(".smallbanner").hide();
        $(".smallbanner" + $(this).attr("rel")).show();

    });

    $("#header div.type3banner div.tabs").mouseleave(function() {

        $(this).removeClass("tabhover");
        $(".smallbanner").hide();
        $(".currentbanner").show();

    });

    $("div.travelplannergreen").click(function() {

        $(this).toggleClass("travelplannerslideup");
        $(this).parent().children(".travelplannerslidedown").slideToggle();
    });

    $("#content a.faqselect").click(function() {
        $(this).toggleClass("faqhide");
        $(this).parent().children("div.faqcontrol").slideToggle();
        if (jQuery.browser.msie) {
            $("#footer").slideUp(1000);
            $("#footer").slideDown(1);
        }
    });

});


/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
*       used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
*                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
*                             If set to null or omitted, the cookie will be a session cookie and will not be retained
*                             when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
*                        require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};