
/**
 * popup #######################################################################
 */

(function($){
    var popup   = {};
    var options = '';
    var config  = {
        height:     -1,
        width:      -1,
        left:       -1,
        top:        -1,
        screenX:    -1,
        screenY:    -1,
        url:        '',
        name:       '',
        location:   false,
        menubar:    false,
        resizable:  true,
        status:     false,
        scrollbars: true,
        toolbar:    false
    };
    var integerItem = [
       'height',
       'width',
       'left',
       'top',
       'screenX',
       'screenY'
    ];
    var booleanItem = [
       'location',
       'menubar',
       'resizable',
       'status',
       'scrollbars',
       'toolbar'
    ];

    var init = function(params) {
        config = $.extend(config, params);

        if (config.name === '') {
            config.name = 'default';
        }

        buildOptions();
    };

    var buildOptions = function() {
        options = '';

        for(i=0;i<booleanItem.length;i++) {
            var name = booleanItem[i];
            if(options !== '') {
                options += ',';
            }
            if (config[name] === true) {
                options += name + '=yes';
                continue;
            }
            if (config[name] === false) {
                options += name + '=no';
            }
        }

        for(i=0;i<integerItem.length;i++) {
            var name = integerItem[i];
            if(options !== '') {
                options += ',';
            }
            if (config[name] === -1) {
                var value = config[name];
                switch(name) {
                    case 'left':
                    case 'screenX':
                        value = (screen.availWidth - config.width) / 2;
                        break;
                    case 'top':
                    case 'screenY':
                        value = (screen.availHeight - config.height) / 2;
                        break;
                    default:
                        value = 0;
                }

                options += name + '='+value+'';
                continue;
            }
            if (config[name] >= 0) {
                options += name + '='+config[name]+'';
            }
        }
    };

    var create = function(params) {
        init(params);
        popup[config.name] = window.open(config.url, config.name, options);
        popup[config.name].focus();
    };

    var close = function(name) {
        if (popup[name] === null) {
            return;
        }
        popup[name].close();
    };

    $.popup = {
        create : function(params) {
            create(params);
        },
        close : function(name) {
            close(name);
        }
    };
})(jQuery);

function popup(url, media, name) {
    var params = {};
    switch(media) {
        case "voucher":
            params = {width: 650, height: 550, scrollbars: false};
            break;
    }
    params.name = name || media;
    params.url  = url;
    jQuery.popup.create(params);
}

/**
 * menu ########################################################################
 */

(function($){

    $.fn.navmenu = function(params) {


        return this.each(function(){
            $t = $(this);
            $t.mouseenter(function(){
               $(this).addClass('hover');
               if ($.browser.msie && parseInt($.browser.version) == 6 && $(this).find('.submenu').length > 0) {

                   var submenu = $(this).find('.submenu');

                   $('#ieNav').attr('width',parseInt($(submenu).width()) + 'px');
                   $('#ieNav').attr('height', parseInt($(submenu).height() +5) + 'px');
                   $('#ieNav').css('left', $(submenu).offset().left + 'px');
                   $('#ieNav').css('top', parseInt($(submenu).offset().top +10) + 'px');
                   $('#ieNav').show();
               }
            });

            $t.mouseleave(function(){
                $(this).removeClass('hover');
                if ($.browser.msie && parseInt($.browser.version) == 6) {
                    $('#ieNav').hide();
                }
            });
            $t.find('.submenu li:not(.extra_short)').hover(function(){
                $(this).css('background-position', '0px -82px');
            },
            function(){
                $(this).css('background-position', '0px  -33px');
            });
        });
    };
})(jQuery);

jQuery(document).ready(function(){
    jQuery("#nav .nav").navmenu();
});

var infoOverlayElementIndex = 0;

function infoOverlay_close(){
    if(jQuery('#infoOverlayBody')) jQuery('#infoOverlayBody').remove();
}

function infoOverlayCustom(parent,msg,width,position,left,top) {
	infoOverlay(parent,msg,width,position);
	
	if (left) {
		var newLeft = jQuery(parent).children('#infoOverlayBody').position().left + left;
		jQuery(parent).children('#infoOverlayBody').css('left', newLeft);
	}
	
	if (top) {
		var newTop = jQuery(parent).children('#infoOverlayBody').position().top + top;
		jQuery(parent).children('#infoOverlayBody').css('top', newTop);
	}
}

function infoOverlay(parent,msg,width,position){
	var anchor = jQuery(parent).closest('div[id^="anchor"]');
	if (anchor) {
		jQuery(anchor).addClass('ontop');
	}
    jQuery(parent).append('<div id="infoOverlayBody">'+ msg +'</div>');
    if (width) {
        jQuery(parent).children('#infoOverlayBody').css('width', width);
    }
    var newLeft = jQuery(parent).position().left;
	var newTop = jQuery(parent).position().top;
	if (position == 'left') {
		newLeft = jQuery(parent).position().left - width;
		jQuery(parent).children('#infoOverlayBody').css('text-align', position);
	}
    jQuery(parent).mouseleave(function(){
    	if (anchor) {
    		jQuery(anchor).removeClass('ontop');
    	}
        jQuery(this).children('#infoOverlayBody').remove();
    });
    jQuery(parent).children('#infoOverlayBody').css('left', newLeft);
    jQuery(parent).children('#infoOverlayBody').css('top', newTop);
    jQuery(parent).children('#infoOverlayBody').css('z-index', 99);
}

function phoneOverlay(parent,number){
    var layerWidth = 330;
    if(number=="01805618000"){ //tel
        text = "0,14 €/Min. aus dem Festnetz, Mobilfunk max. 0,42 €/Min.\n 31.Dezember: 8:00 - 16:30 Uhr \n 01.Januar 10:00 - 23:00 Uhr  ";
    }
    else if(number=="01805618099"){ //fax
        text = "0,14 €/Min. aus dem Festnetz, Mobilfunk max. 0,42 €/Min.\n 31.Dezember: 8:00 - 16:30 Uhr \n 01.Januar 10:00 - 23:00 Uhr";
    }
    else if(number=="01805696369"){ //tel new
        text = "0,14 €/Min. aus dem Festnetz, Mobilfunk max. 0,42 €/Min.\n 31.Dezember: 8:00 - 16:30 Uhr \n 01.Januar 10:00 - 23:00 Uhr";
    }
    else if(number=="01805613300"){ //tel ultindi
        text = "0,14 €/Min. aus dem dt. Festnetz, aus Mobilfunknetzen bis zu 0,42 €/Min.\n 31.Dezember: 8:00 - 16:30 Uhr \n 01.Januar 10:00 - 23:00 Uhr";
        layerWidth = 400;
    }
    else if(number=="0180999445"){ //tel
        text = "0,14 €/Min. aus dem dt. Festnetz, aus Mobilfunknetzen bis zu 0,42 €/Min.\n 31.Dezember: 8:00 - 16:30 Uhr \n 01.Januar 10:00 - 23:00 Uhr";
        layerWidth = 400;
    }
    infoOverlay(parent,text,layerWidth);
}




