
var current_tab_top_teaser = 1,
    num_tabs_top_teaser = 0,
    current_tab_media_teaser = 1,
    num_tabs_media_teaser = 0;

function switch_top_teaser_pane( element, animate, hovered )
{
    var tab_id = element.attr('rel').replace( /item_/, '' ),
        teaser_item = $('#header_teaser_item_' + tab_id ),
        pos = teaser_item.position();

    if( animate ) {
        $('#header-teaser-content').animate({'left': -pos.left + 'px' }, 300);
    } else if( !animate  ) {
        $('#header-teaser-content').css({'left': -pos.left + 'px' });
    }
    current_tab_top_teaser = tab_id;
    /**
     * Reset tab titles to numbers
     */
    $('#header-teaser-navigation ul.navigation-tabs li>a').each( function() {
        var tab_title = $(this).attr('rel').replace(/item_/,'');
        $(this).html(tab_title).removeClass('active');
    });

    element.html(header_teaser_items[tab_id].title).toggleClass('active');
    /**
     * Fade color of navigation and teaser content
     */
    $('#header-teaser .navigation-tabs li > a').css({
        'background-color'  : header_teaser_items[tab_id].col_bg,
        'color'             : header_teaser_items[tab_id].tab_inact
    });

    if( hovered ) {
        element.css( 'color', header_teaser_items[tab_id].tab_act );
    }

    $('#header-teaser .header-teaser-content').css({
        'background-color'  : header_teaser_items[tab_id].col_bg,
        'color'             : header_teaser_items[tab_id].col_fg
    });

    $('#header-teaser .header-teaser-content h3').css( 'color', header_teaser_items[tab_id].col_hl );

    /**
     * Set content
     */
    /** headline and content */

    /** tags */
    var teaser_tags = '';
    $.each( header_teaser_items[tab_id].type, function( index, data ){
        teaser_tags += '<li><a href="' + data.href + '">' + data.name + '</a></li>';
    });

    $.each( header_teaser_items[tab_id].tags, function( index, data ){
        teaser_tags += '<li><a href="' + data.href + '">' + data.name + '</a></li>';
    });

    $('#header-teaser .header-teaser-content ul.tags').html( teaser_tags );

    var headline_content = '';
    var article_teaser_content = '';
    headline_content += '<a href="' + header_teaser_items[tab_id].href + '">' + header_teaser_items[tab_id].headline + '</a>';
    $('#header-teaser .header-teaser-content h3').html( headline_content );
    $('#header-teaser .header-teaser-content h3 a').css( 'color', header_teaser_items[tab_id].col_hl );
    $('#header-teaser .header-teaser-content h3 a').hover(function(){$(this).css({'color':'#a36973'});},function(){$(this).css({'color':header_teaser_items[tab_id].col_hl});});

    article_teaser_content += header_teaser_items[tab_id].content + ' ' + '<a href="' + header_teaser_items[tab_id].href + '" class="teaser-more-link">mehr...</a>';
    $('#header-teaser .header-teaser-content div.article-teaser').html( article_teaser_content );
}

function switch_media_teaser_panel( element, animate )
{
    var pane_id = element.attr('rel').replace( /item_/, '' ),
        media_item = $('#media_data_item_' + pane_id ),
        pos = media_item.position();

    if( animate === true ) {
        $('#media-data-teaser-content').animate({'left': -pos.left + 'px' }, 300);
    } else if( animate === false ) {
        $('#media-data-teaser-content').css({'left': -pos.left + 'px' });
    }

    current_tab_media_teaser = pane_id;
    /**
     * Reset tab titles to numbers
     */
    $('#media-data-teaser-navigation ul.navigation-tabs li>a').each( function() {
        var tab_title = $(this).attr('rel').replace(/item_/,'');
        $(this).html(tab_title).removeClass('active');
    });

    element.html(media_data_teaser_items[pane_id].title).toggleClass('active');
    /**
     * Fade color of navigation and teaser content
     */
    $('#media-data-teaser .navigation-tabs li > a').css({
        'background-color'  : media_data_teaser_items[pane_id].col_bg,
        'color'             : media_data_teaser_items[pane_id].col_fg
    });

    $('#media-data-teaser .header-teaser-content').css({
        'background-color'  : media_data_teaser_items[pane_id].col_bg,
        'color'             : media_data_teaser_items[pane_id].col_fg
    });

    $('#media-data-teaser .header-teaser-content h3').css( 'color', media_data_teaser_items[pane_id].col_hl );

    /**
     * Set content
     */
    /** headline and content */
    $('#media-data-teaser .header-teaser-content h3').html( media_data_teaser_items[pane_id].headline );
    $('#media-data-teaser .header-teaser-content div.article-teaser').html( media_data_teaser_items[pane_id].content );
    $('#media-data-teaser .header-teaser-content a.link-cta').css( 'color', media_data_teaser_items[pane_id].col_ln );
}

function top_teaser_auto_switch()
{
    current_tab_top_teaser++;
    if( current_tab_top_teaser > num_tabs_top_teaser ) {
        current_tab_top_teaser = 1;
    }

    var element = $('#header-teaser ul.navigation-tabs li').find( 'a[rel=item_' + current_tab_top_teaser + ']' );
    switch_top_teaser_pane( element, true, true );
}

function media_teaser_auto_switch()
{
    current_tab_media_teaser++;
    if( current_tab_media_teaser > num_tabs_media_teaser ) {
        current_tab_media_teaser = 1;
    }

    var element = $('#media-data-teaser ul.navigation-tabs li').find( 'a[rel=item_' + current_tab_media_teaser + ']' );
    switch_media_teaser_panel( element, true );
}

$(document).ready( function() {

    /****************************************************************************************************
     *
     * BLOG TOP TEASER
     *
     ****************************************************************************************************/
  if(typeof(header_teaser_items) != "undefined"){
    var teaser_content = '',
        teaser_content_width = 960,
        navigation_html = '';

    $.each( header_teaser_items, function( index, data ) {
        teaser_content += '<img id="header_teaser_item_' + index + '" src="' + data.img + '" alt="' + data.headline + '" />';
        teaser_content_width += 960;

        if( index == "1" ) {
            navigation_html += '<li><a rel="item_' + index + '" class="active" href="javascript:void(0)">' + data.title;
        } else {
            navigation_html += '<li><a rel="item_' + index + '" href="javascript:void(0)">' + index;
        }
        navigation_html += '</a></li>';
        num_tabs_top_teaser++;
    });

    $('#header-teaser-content').css( 'width', teaser_content_width + 'px' );
    $('#header-teaser-content').html( teaser_content );
    $('#header-teaser-navigation .navigation-tabs').html( navigation_html );

    /**
     * init teaser and navigation
     */
    $('#header-teaser-navigation .navigation-tabs li > a').css({
        'background-color'  : header_teaser_items["1"].col_bg,
        'color'             : header_teaser_items["1"].tab_inact
    });

    $('#header-teaser-navigation .navigation-tabs li a:first').css({
        'color'             : header_teaser_items["1"].tab_act
    });

    $('#header-teaser .header-teaser-content').css({
        'background-color'  : header_teaser_items["1"].col_bg,
        'color'             : header_teaser_items["1"].col_fg
    });

    $('#header-teaser .header-teaser-content h3').css( 'color', header_teaser_items["1"].col_hl );


    /** tags */
    var teaser_tags = '';
    $.each( header_teaser_items["1"].type, function( index, data ){
        teaser_tags += '<li><a href="' + data.href + '">' + data.name + '</a></li>';
    });
    $('#header-teaser .header-teaser-content ul.tags').html( teaser_tags );

    /** headline and content */
    var headline_content = '';
    var article_teaser_content = '';
    headline_content += '<a href="' + header_teaser_items["1"].href + '">' + header_teaser_items["1"].headline + '</a>';
    $('#header-teaser .header-teaser-content h3').html( headline_content );
    $('#header-teaser .header-teaser-content h3 a').css( 'color', header_teaser_items["1"].col_hl );
    $('#header-teaser .header-teaser-content h3 a').hover(function(){$(this).css({'color':'#a36973'});},function(){$(this).css({'color':header_teaser_items["1"].col_hl});});

    article_teaser_content += header_teaser_items["1"].content + ' ' + '<a href="' + header_teaser_items["1"].href + '" class="teaser-more-link">mehr...</a>'
    $('#header-teaser .header-teaser-content div.article-teaser').html( article_teaser_content );

    /**
     * set opacity
     */
    $('#header-teaser-navigation ul.navigation-tabs li > a,#header-teaser-navigation .header-teaser-content').css('opacity', 0.85);

    /***
     * switch panes & navigation menu hover
     */
    var element = null,
        switchPanel = null;

    if( $('#header-teaser-navigation ul.navigation-tabs').length > 0 ) {
        var auto_switcher = window.setInterval( 'top_teaser_auto_switch()', 9000 );

        $('#header-teaser-navigation .navigation-tabs a').live({
            mouseover : function() {
                window.clearTimeout( switchPanel );
                element = $(this);
                switchPanel = window.setTimeout( function() {
                    switch_top_teaser_pane( element, false, true );
                }, 50 );
                //clearInterval( auto_switcher );
            },
            mouseout : function() {
                //auto_switcher = window.setInterval( 'top_teaser_auto_switch()', 3000 );
            }
        });

        $('#header-teaser').live({
            mouseover : function() {
                clearInterval( auto_switcher );
            },
            mouseout : function() {
                auto_switcher = window.setInterval( 'top_teaser_auto_switch()', 9000 );
            }
        });
    }
	}
    /****************************************************************************************************
     *
     * MEDIA DATA TEASER
     *
     ****************************************************************************************************/
  if(typeof(media_data_teaser_items) != "undefined"){
    var media_data_content = '',
        media_content_width = 0,
        media_navigation_html = '';

    $.each( media_data_teaser_items, function( index, data ) {
        media_data_content += '<img id="media_data_item_' + index + '" src="' + data.img + '" alt="' + data.headline + '" />';
        media_content_width += 635;

        if( index == "1" ) {
            media_navigation_html += '<li><a rel="item_' + index + '" class="active" href="javascript:void(0)">' + data.title;
        } else {
            media_navigation_html += '<li><a rel="item_' + index + '" href="javascript:void(0)">' + index;
        }
        media_navigation_html += '</a></li>';
        num_tabs_media_teaser++;
    });
    $('#media-data-teaser-content').css( 'width', media_content_width + 'px' );
    $('#media-data-teaser-content').html( media_data_content );
    $('#media-data-teaser-navigation .navigation-tabs').html( media_navigation_html );

    /**
     * init teaser and navigation
     */
    $('#media-data-teaser-navigation .navigation-tabs li > a').css({
        'background-color'  : media_data_teaser_items["1"].col_bg,
        'color'             : media_data_teaser_items["1"].col_fg
    });

    $('#media-data-teaser .header-teaser-content').css({
        'background-color'  : media_data_teaser_items["1"].col_bg,
        'color'             : media_data_teaser_items["1"].col_fg
    });

    $('#media-data-teaser .header-teaser-content h3').css( 'color', media_data_teaser_items["1"].col_hl );
    $('#media-data-teaser .header-teaser-content a.link-cta').css( 'color', media_data_teaser_items["1"].col_ln );

    /** headline and content */
    $('#media-data-teaser .header-teaser-content h3').html( media_data_teaser_items["1"].headline );
    $('#media-data-teaser .header-teaser-content div.article-teaser').html( media_data_teaser_items["1"].content );

    /**
     * set opacity
     */
    $('#media-data-teaser-navigation ul.navigation-tabs li > a,#media-data-teaser-navigation .header-teaser-content').css('opacity', 0.8);

    /***
     * switch panes
     */
    var media_switchPanel = null;


    if( $('#media-data-teaser-navigation').length > 0 ) {
        var auto_switcher_media = window.setInterval( 'media_teaser_auto_switch()', 3000 );
        $('#media-data-teaser-navigation .navigation-tabs a').live({
            mouseover : function() {
                window.clearTimeout( media_switchPanel );
                element = $(this);
                media_switchPanel = window.setTimeout( function() {
                    switch_media_teaser_panel( element, false );
                }, 80);
                //clearInterval( auto_switcher_media );
            },
            mouseout: function() {
                //auto_switcher_media = window.setInterval( 'media_teaser_auto_switch()', 3000 );
            }
        });

        $('#media-data-teaser').live({
            mouseover : function() {
                clearInterval( auto_switcher_media );
            },
            mouseout : function() {
                auto_switcher_media = window.setInterval( 'media_teaser_auto_switch()', 3000 );
            }
        });
    }
  }
    /****************************************************************************************************
     *
     * FOOTER ICON HOVER
     *
     ****************************************************************************************************/

    $('a.icon').hover( function() {
        $(this).find('span').addClass('hover');
    }, function() {
        $(this).find('span').removeClass('hover');
    });

    /****************************************************************************************************
     *
     * CLICK IN SEARCH FIELD
     *
     ****************************************************************************************************/

    $('#search-string').focus( function() {
        if( $(this).val() == "Suchbegriff eingeben" ) {
            $(this).val( '' );
        }
    });

    /****************************************************************************************************
     *
     * SWITCH FORM DELIVERY ADDRESS
     *
     ****************************************************************************************************/

    $('.form input[type="radio"][name="billing_address"]').click(function() {
        if( $(this).val() == 1 ) {
            $('tr.delivery-address').fadeOut();
        } else if( $(this).val() == 2 ) {
            $('tr.delivery-address').fadeIn();
        }
    });

    /****************************************************************************************************
     *
     * CONFIGURE DATE PICKER
     *
     ****************************************************************************************************/

	$.datepicker.regional['de'] = {
		closeText: 'schließen',
		prevText: '&#x3c;zurück',
		nextText: 'Vor&#x3e;',
		currentText: 'heute',
		monthNames: ['Januar','Februar','März','April','Mai','Juni',
		'Juli','August','September','Oktober','November','Dezember'],
		monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
		'Jul','Aug','Sep','Okt','Nov','Dez'],
		dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
		dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		weekHeader: 'Wo',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['de']);

    $('.date-picker').datepicker({
        prevText    : '&laquo;',
        nextText    : '&raquo;',
        showOn      : ''
    });

    $('.date-picker-icon').click( function() {
        var alt_field = $(this).parent().attr('rel');
        $('#' + alt_field ).datepicker('option', 'altField', alt_field );
        $('#' + alt_field ).datepicker('show');
    });

    /****************************************************************************************************
     *
     * CONFIGURE COUNTRIES FOR COUNTRY SELECTOR IN FORMS
     *
     ****************************************************************************************************/

    $('.country-selector').each( function() {
        var country_options = '';
        $.each( country_codes, function( short_code, description ) {
            if( short_code == "DE" ) {
                country_options += '<option value="' + short_code + '" selected="selected">' + description + '</option>';
            } else {
                country_options += '<option value="' + short_code + '">' + description + '</option>';
            }

        });
        $(this).append(country_options);
    });

    /****************************************************************************************************
     *
     * TW-ACCORDION
     *
     * accordion effect is applied to all div elements on the current page
     * take care of the element structure of tw-accordion:
     *
     * <div class="tw-accordion">     - main container
     *     <ul>                       - unordered list of items
     *         <li>                   - accordion item (add class="open" to open item on load
     *              <h3>...</h3>      - main headline
     *              <h4>...</h4>      - sub headline
     *              <div>
     *                  ....          - item content (can be any HTML)
     *              </div>
     *         </li>
     *     </ul>
     * </div>
     *
     ****************************************************************************************************/
    $('div.tw-accordion').each( function() {
        $(this).find('ul li').each( function() {
            var headline = $(this).find('h3');

            $(this).find('h3,h4').hover( function() {
                $(this).parent().find('h3,h4,h3>span').each( function() {
                    if( $(this).parents('div.form').length <= 0 ) {
                        $(this).removeClass('closed');
                    }
                });
            }, function() {
                $(this).parent().find('h3,h4,h3>span').each( function() {
                    if( !$(this).parent().hasClass('open') && $(this).parents('div.form').length <= 0 ) {
                        $(this).addClass('closed');
                    }
                });
            });

            if( $(this).hasClass('open') ) {
                $(this).find('h3').append( '<span class="arrow-open"></span>').nextAll('div').show();
            } else {
                $(this).find('h3,h4').each( function() {
                    $(this).parent().find('h3,h4,h3>span').each( function() {
                        $(this).addClass('closed');
                    });
                });
                $(this).find('h3').append( '<span class="arrow-closed closed"></span>');
            }

            $(this).find('h3,h4').click( function() {
                /*$(this).parent().find('h3,h4').toggleClass('closed');*/

                if( $(this).parent().hasClass('open') ) {
                    $(this).parent().removeClass('open');
                    headline.nextAll('div').slideUp(250, "linear", function() {
                        headline.find('span').removeClass('arrow-open').addClass('arrow-closed');
                        $(this).parent().find('h3,h4').addClass('closed');
                    });
                } else {
                    $(this).parent().find('h3,h4').removeClass('closed');
                    $(this).parent().addClass('open');
                    headline.nextAll('div').slideDown(250, "linear", function() {
                        headline.find('span').removeClass('arrow-closed').addClass('arrow-open');
                    });
                }
            });

        });
    });

    /****************************************************************************************************
     *
     * TW-ACCORDION-SMALL
     *
     ****************************************************************************************************/
    $('div.tw-accordion-small').each( function() {
        $(this).find('ul li').each( function() {
            var headline = $(this).find('h3');

            $(this).find('h3,h4,h5,h6').hover( function() {
                $(this).parent().find('h3,h4,h5,h5>span.arrow,h6').removeClass('closed');
            }, function() {
                $(this).parent().find('h3,h4,h5,h5>span.arrow,h6').each( function() {
                    if( !$(this).parent().hasClass('open') && !$(this).hasClass('no-hover') ) {
                        $(this).addClass('closed');
                    }
                });
            });

            if( $(this).hasClass('open') ) {
                $(this).find('h5').append( '<span class="arrow a-down"></span>').nextAll('div').show();
            } else {
                $(this).find('h5').append( '<span class="arrow a-left closed"></span>');
                $(this).find('h3,h4,h5,h6').each( function() {
                    if( !$(this).hasClass('no-hover') ) {
                        $(this).addClass('closed');
                    }
                })
            }

            $(this).find('h3,h4,h5,h6').click( function() {
                if( !$(this).hasClass('no-hover')) {
                    var trigger_id = $(this).parent().attr('id').replace(/accordion_trigger_/, '');
                    /**
                     * first close all open items
                     */
                    if( !$(this).parent().hasClass('open') ) {
                        headline.parentsUntil('ul').parent().find('li').removeClass('open');
                        headline.parentsUntil('ul').parent().find('li h3').nextAll('div').slideUp( 250, "linear", function() {
                            $(this).parent().find('h5>span.arrow').removeClass('a-down').addClass('a-left');
                            $(this).parent().find('h3,h4,h5,h6').addClass('closed');
                        });

                        /**
                         * open current clicked item
                         */
                        $(this).parent().find('h5>span.arrow').removeClass('a-left').addClass('a-down');
                        $(this).parent().find('h3,h4,h5,h6').removeClass('closed');
                        $(this).parent().addClass('open');
                        headline.nextAll('div').slideDown(250, "linear" );

                        /**
                         * change teaser image and text
                         */
                        var image_position = $('#subscription_conditions_teaser_' + trigger_id ).position();
                        $('.subscription-conditions-teaser .teaser-content, .subscription-conditions-teaser .info-box').fadeOut( 250, function() {
                            $('.subscription-conditions-teaser .teaser-content').css('top', -image_position.top + 'px' );
                            $('.subscription-conditions-teaser .info-box').css('background-color', subscription_conditions_teaser[ trigger_id ].col_bg );
                            $('.subscription-conditions-teaser .info-box h3').html( subscription_conditions_teaser[ trigger_id ].headline ).css( 'color', subscription_conditions_teaser[ trigger_id ].col_hl );
                            $('.subscription-conditions-teaser .info-box .teaser-text').html( subscription_conditions_teaser[ trigger_id ].content ).css( 'color', subscription_conditions_teaser[ trigger_id ].col_fg );
                            $('.subscription-conditions-teaser .teaser-content, .subscription-conditions-teaser .info-box').fadeIn();
                        });
                    } else {
                        headline.parentsUntil('ul').parent().find('li').removeClass('open');
                        headline.parentsUntil('ul').parent().find('li h3').nextAll('div').slideUp( 250, "linear", function() {
                            $(this).parent().find('h5>span.arrow').removeClass('a-down').addClass('a-left');
                            $(this).parent().find('h3,h4,h5,h6').addClass('closed');
                        });
                    }
                }
            });

        });
    });

    /****************************************************************************************************
     *
     * TW-TABS / multiple tab containers are possible
     *
     * take care of the element structure of tw-tabs:
     *
     * <div class="tw-tabs">                - main tabs container
     *      <ul class="tab-switcher">       - list container for tabs description
     *          <li>
     *              <a rel="tab-1">         - serial number for tabs start at "1"
     *                  description
     *              </a>
     *          </li>
     *      </ul>
     *
     *      <ul class="tab-contents">       - list container for tab contents
     *          <li>                        - create as many items as you wish
     *              ...
     *          </li>
     *      </ul>
     * </div>
     *
     * Please note:
     *
     * 1. The number of items in "tab-switcher" must be equal to the items in "tab-contents"
     *
     ****************************************************************************************************/

    $('div.tw-tabs').each( function() {

        /**
         * get tab-switcher and content lists
         */
        var switcher_list = $(this).find('ul.tab-switcher');
        var content_list = $(this).find('ul.tab-contents');

        /**
         * first hide all content
         */
        content_list.children().hide();

		if (switcher_list.attr('id')) {
		  var tab_index = parseInt( switcher_list.attr('id').replace( /tab-/, '' ), 10 ) - 1;
		  if (isNaN(tab_index)) {
			content_list.children().first().show();
			switcher_list.children().first().find('a').addClass('selected');
		  } else {
			content_list.children().eq( tab_index ).show();
			switcher_list.children().eq( tab_index ).find('a').addClass('selected');
		  }
		} else {
		  /**
           * open first tab automatically
           */
		  content_list.children().first().show();
          switcher_list.children().first().find('a').addClass('selected');
		}

        $(this).find('ul.tab-switcher > li > a').live( 'click', function() {
            /**
             * remove all visible content and reset CSS class of current tab
             */
            content_list.children().hide();
            switcher_list.children().find('a').removeClass('selected');

            var tab_index = parseInt( $(this).attr('rel').replace( /tab-/, '' ), 10 ) - 1;
            $(this).addClass('selected');

            content_list.children().eq( tab_index ).show();
            return false;
        });
    });

    /****************************************************************************************************
     *
     * SUBSCRIPTION TEASER
     *
     ****************************************************************************************************/
  if(typeof(subscription_teaser) != "undefined"){
    var subscription_teaser_html = '',
        teaser_content_height = 0;
    $('.subscription-teaser .info-box').css('opacity', 0.6);
    $.each( subscription_teaser, function( index, data ) {
        subscription_teaser_html += '<img id="subscription_teaser_' + index + '" src="' + data.img + '" alt="' + data.headline + '" />';
        teaser_content_height += 430;
    });
    $('.subscription-teaser .teaser-content').html( subscription_teaser_html ).css( 'height', teaser_content_height + 'px' );

    $('.subscription-teaser .info-box').css('background-color', subscription_teaser["1"].col_bg );
    $('.subscription-teaser .info-box h3').html( subscription_teaser["1"].headline ).css('color', subscription_teaser["1"].col_hl );
    $('.subscription-teaser .info-box .teaser-text').html( subscription_teaser["1"].content ).css('color', subscription_teaser["1"].col_fg );
  }
    /****************************************************************************************************
     *
     * SUBSCRIPTION CONDITIONS TEASER
     *
     ****************************************************************************************************/
 if(typeof(subscription_conditions_teaser) != "undefined"){
    var subscription_conditions_teaser_html = '',
        conditions_teaser_content_height = 0;
    $('.subscription-conditions-teaser .info-box').css('opacity', 0.6);
    $.each( subscription_conditions_teaser, function( index, data ) {
        subscription_conditions_teaser_html += '<img id="subscription_conditions_teaser_' + index + '" src="' + data.img + '" alt="' + data.headline + '" />';
        conditions_teaser_content_height += 430;
    });
    $('.subscription-conditions-teaser .teaser-content').html( subscription_conditions_teaser_html ).css( 'height', conditions_teaser_content_height + 'px' );

    $('.subscription-conditions-teaser .info-box').css('background-color', subscription_conditions_teaser["1"].col_bg );
    $('.subscription-conditions-teaser .info-box h3').html( subscription_conditions_teaser["1"].headline ).css('color', subscription_conditions_teaser["1"].col_hl );
    $('.subscription-conditions-teaser .info-box .teaser-text').html( subscription_conditions_teaser["1"].content ).css('color', subscription_conditions_teaser["1"].col_fg );
 }
    /****************************************************************************************************
     *
     * SIDEBAR ELEMENT HOVER
     *
     ****************************************************************************************************/
    $('.sidebar-element.hover-element').hover( function() {
        var teaser_id = $(this).attr('id').replace( /abo_/, '' );
        $('.sidebar-element.hover-element').removeClass('active');
        $(this).addClass('active');

        /**
         * set info-box and teaser image
         */
        var image_position = $('#subscription_teaser_' + teaser_id ).position();
        $('.subscription-teaser .teaser-content').css('top', -image_position.top + 'px' );
        $('.subscription-teaser .info-box').css('background-color', subscription_teaser[ teaser_id ].col_bg );
        $('.subscription-teaser .info-box h3').html( subscription_teaser[ teaser_id ].headline ).css( 'color', subscription_teaser[ teaser_id ].col_hl );
        $('.subscription-teaser .info-box .teaser-text').html( subscription_teaser[ teaser_id ].content ).css( 'color', subscription_teaser[ teaser_id ].col_fg );
    });

    /**
     * set some element opacity
     */
    $('.personal-information-name').css('opacity', 0.7 );
    $('.personal-information-position, .personal-information-title').css('opacity', 0.35 );

    /****************************************************************************************************
     *
     * MORE-LINK IN SEARCH SITE
     *
     ****************************************************************************************************/
    $('a.more-link').click( function() {
        var list_id = $(this).attr('rel'),
            position = $(this).position(),
            list_obj = $( '#' + list_id );

        if( $(this).hasClass( 'open' ) ) {
            $(this).removeClass('open');
            $(this).children( 'span' ).removeClass( 'arrow-open' ).addClass( 'arrow-closed' );

            if( list_obj.length > 0 ) {
                list_obj.fadeOut( 250 );
            }
        } else {
            $(this).addClass('open');
            $(this).children( 'span' ).removeClass( 'arrow-closed' ).addClass( 'arrow-open' );

            if( list_obj.length > 0 ) {
                list_obj.css({
                    'top'   : position.top + 25,
                    'left'  : position.left
                }).fadeIn( 250 );
            }
        }
    });

    /**
     * open additional input fields in form
     */
    if( $('input.open-add-field').length > 0 ) {
        $('input.open-add-field').click( function() {
            if( $(this).attr('checked') ) {
                $('#' + $(this).attr('alt') ).fadeIn();
            } else {
                $('#' + $(this).attr('alt') ).fadeOut();
            }
        });
    }

    /**
     * form submits
     */
    $('a.form-submit').click( function() {
        $('#' + $(this).attr('rel') ).submit();
    });

    /**
     * form error message
     */
    $('.error-trigger').hover( function() {
        if($(this).attr('for')){
          var error_dialog = $('#error_' + $(this).attr('for') ), pos = $(this).position();
        }
        else{
          var error_dialog = $('#error_' + $(this).attr('id') ), pos = $(this).position();
        }

        error_dialog.css({
            'left': pos.left + 190,
            'top' : pos.top
        }).fadeIn();
    }, function() {
        if($(this).attr('for')){
          var error_dialog = $('#error_' + $(this).attr('for') );
        }
        else{
          var error_dialog = $('#error_' + $(this).attr('id') );
        }
        error_dialog.fadeOut();
    })



  $('#business-menu-link').mouseover(function() {
    $('#business-menu').show(200);
  }).mouseout(function(){
   $('#business-menu').css('display','none');
  });
  $('#business-menu').mouseenter(function() {
    $('#business-menu').css('display','block');
  }).mouseleave(function() {
    $('#business-menu').hide(200);
  });

  $('#fashion-menu-link').mouseover(function() {
    $('#fashion-menu').show(200);
  }).mouseout(function(){
    $('#fashion-menu').css('display','none');
  });
  $('#fashion-menu').mouseenter(function() {
    $('#fashion-menu').css('display','block');
  }).mouseleave(function() {
    $('#fashion-menu').hide(200);
  });



});

function issue_pager (end, idpref, img) {
  var s = 0;
  return function (that) {
	var n1 = document.getElementById(idpref + s);
	n1.className = n1.className + ' hidden';
	if (img) {
	  var n2 = document.getElementById(idpref + s + img);
	  n2.className = n2.className + ' hidden';
	}
	if (that.rel == 'prev') {
	  s--;
	} else if (that.rel == 'next') {
	  s++;
	}
	if (s == -1) {
	  s = end;
	} else if (s > end)
	  s = 0;

	n1 = document.getElementById(idpref + s);
	n1.className = n1.className.replace(/ hidden/, "");
	if (img) {
	  n2 = document.getElementById(idpref + s + img);
	  n2.className = n2.className.replace(/ hidden/, "");
	}
	$('#' + idpref + '-ct').text(s + 1);
	return false;
  };
}


