/**
 *
 * jQuery plugins + page functions
 *
 * @date $Date: 2012-02-18 10:54:06 +0100 (Sa, 18 Feb 2012) $
 * @revision $Rev: 692 $
 *
 * Version 2.0
 *
 */

(function ( $ ) {

  $( document ).ready( function() {
	  
	 var items;
	 var subitems;
	
	/*********************************************************************************************
     * Profile-Layer
     * =============
     *********************************************************************************************/
    //Logout-Link
    $('a.logoutLink').click(function() {
        $(this).parents('form').submit();
        return false;
    });
	// Detect Cookies:17.08.2011 (eas)
    
     var cookies = navigator.cookieEnabled;
        if (typeof navigator.cookieEnabled === "undefined" && !cookieEnabled) { 
            document.cookie="testcookie";
            cookieEnabled = document.cookie.indexOf("testcookie") != -1;
        }
	
	/*********************************************************************************************
     * ReDesign Mini-Layer
     * ====================
     * - tooltip open/close 
     *********************************************************************************************/
	 $('a.help').click( function() {
		  $('#wizard-contact-layer').css('display', 'none');
          $(this).parent().find('div.wizard-tooltip').css('display', 'block');
      });

	 $('#wizard-contact-link').click( function() {
		 $('#wizard-help-layer').css('display', 'none');
         $('#wizard-contact-layer').css('display', 'block');
     });
	 
      $('a.close').click( function() {
        $(this).parents('div.wizard-tooltip').css('display','none');
      });

      
      items = $( 'div.formRow .item, div.formRow .item input' );
      items.focus( function() {
          $( 'div.formRow' ).removeClass( 'active' );
          $( this ).parents('div.formRow').addClass( 'active' );
      } );

      items.blur( function() {
          $( 'div.formRow' ).removeClass( 'active' );
      } );
	 
	 
	 /* LEGACY: BEGIN */
      $('#Layer a.help').click( function() {
        $(this).parent().find('.tooltipbox').css('display', 'block');
      });

      $('#Layer a.close').click( function() {
        $(this).parents('.tooltipbox').css('display','none');
      });

      $('a.help').click( function() {
        $(this).parents('h1').find('.tooltipbox').css('display', 'block');
      });

      $('a.close').click( function() {
        $(this).parents('.tooltipbox').css('display','none');
      });
      /* LEGACY: END */
	  
      /*********************************************************************************************
       * application layers
       ********************************************************************************************/
      var closeHandler = function() {
    	  var currentURL = window.location.href;
    	  if (currentURL.indexOf("?open=") != -1) {
    		  // do not reload the deep link layer one more time
    		  currentURL = currentURL.substring(0, currentURL.indexOf("?open="));
    	  }
    	  window.location.replace(currentURL);
      };
      // layerProfile, layerSmall and layerSmallWithRefresh MUST be global variables.
      // they are used in openOverlay.xhtml
      layerProfile = {iframe:true, innerWidth:"960px", innerHeight:"650px", additionalStyleClass: "profileLayer", onClosed:closeHandler, additionalCloseButton: true, imageNavigation:false};
      layerSmall = {iframe:true, scrolling:false, innerWidth:541, innerHeight:787, additionalStyleClass: "miniLayer", additionalCloseButton: true, imageNavigation:false };
      layerSmallWithRefresh = {iframe:true, scrolling:false, innerWidth:541, innerHeight:787, additionalStyleClass: "miniLayer", additionalCloseButton: true, imageNavigation:false, onClosed:closeHandler };
      layerPhotoSeries = {iframe:true, innerWidth:"960px", innerHeight:"650px", additionalStyleClass: "photoSeriesLayer", additionalCloseButton: true };
      layerVideoPlayer = {iframe:true, innerWidth:"960px", innerHeight:"650px", additionalStyleClass: "profileLayer", additionalCloseButton: true, imageNavigation:false };
      layerDelete = {iframe:true, innerWidth:"580px", innerHeight:"300px", additionalStyleClass: "profileLayer", onClosed:closeHandler, additionalCloseButton: true, imageNavigation:false};
      layerEvent = {iframe:true, scrolling:false, innerWidth:"660px", innerHeight:"590px", additionalStyleClass: "profileLayer", additionalCloseButton: true, imageNavigation:false};

      var layerLaufplan = {iframe:true, scrolling:false, innerWidth:"960px", innerHeight:"530px", additionalStyleClass: "laufplanLayer", onClosed:closeHandler, additionalCloseButton: true, imageNavigation:false};

      $("a[target='layer-profile']").colorbox(layerProfile);
      $("a[target='layer-photo-series']").colorbox(layerPhotoSeries);
      $("a[target='layer-video-player']").colorbox(layerVideoPlayer);
      $("a[target='layer-small']").colorbox(layerSmall);
      $("a[target='layer-small-refresh']").colorbox(layerSmallWithRefresh);
      $("a[target='layer-delete']").colorbox(layerDelete);
      $("a[target='layer-event']").colorbox(layerEvent);
      $("a[target='layer-laufplan']").colorbox(layerLaufplan);


		/*********************************************************************************************
	     * Image Layer for one Image -- ProductDetails etc.
	     *********************************************************************************************/
     $("a[rel='imageLayer']").colorbox({ imageNavigation:false, additionalStyleClass: 'imageGallery' });
     
	
    /*********************************************************************************************
     * SSL-Check
     * =========
     * SSl-Check == LEGACY (before wizard/miniLayer refactoring)
     *********************************************************************************************/
    if( document.location.protocol === 'https:' ) {
        $('#SSL-Check, #SSL-Icon').css({display: 'block'});
        var sslText = $('#SSL-Check span, #SSL-Icon span');
        // animation is not possible here, because alpha in IE7 will break the scrolllayer
        window.setTimeout(function() {sslText.hide();}, 5000);
        $('#SSL-Check img, #SSL-Icon img').mouseover( function() {
            sslText.show();
        }).mouseout(function() {
            sslText.hide();
        });
    }
	
    $( "#accordion" ).accordion( {
      autoHeight: false,
      navigation: true
    } );

    $( "div.accordion" ).accordion( { event: 'mouseover'  } );
    $( "#tabs" ).tabs();
	
	/*********************************************************************************************
     * gemerkte aussteller, produkte, etc.
     *********************************************************************************************/

    $('div.additional.on a.more').click( function() {
      var $link = $(this),
          $addtional = $link.parents('div.additional');
      $addtional.toggleClass('open');
    });

    /*
     * Interests
     */
    // init: set default status
    $( 'table.interests-check input:enabled' ).attr('disabled','disabled');
    
    $( 'input.newsletter-check' ).click( function() {
      var $elements = $( 'table.interests-check input' ),
          disabled = $elements.is( ':disabled' );
      if( disabled ) {
        $elements.removeAttr( 'disabled' );
        disabled = false;
      } else {
        $elements.attr( 'disabled', 'disabled' );
        disabled = true;
      }
    } );
	
	/*********************************************************************************************
     * CGC - Konferenzprogramm
     *********************************************************************************************/
    $('input.cgc_input').click( function() {
        var cgcType = $(this).attr('name');
        if( $(this).is(':checked') ) {
            $('div.tabberlive .' + cgcType ).css('display', 'table-cell');
			$("div.tabberlive input[name=" + cgcType + "]").attr('checked',true);
        } else {
            $('div.tabberlive .' + cgcType ).css('display', 'none');
			$("div.tabberlive input[name=" + cgcType + "]").attr('checked',false);
        }
    });
	
	
    $('a.cgc_close').click( function() {
        var cgcType = $(this).parents('th').attr('class');
        $('div.tabberlive .' + cgcType ).css('display', 'none');
        $("div.tabberlive input[name=" + cgcType + "]").attr('checked',false);
        return false;
    });
	
	/*********************************************************************************************
     * Button-Wrapper
     *   - DropDown behavior
     *********************************************************************************************/
	 $('div.button-wrapper ul.drop-down').each( function() {
         var $dropDown = $(this),
             $buttonWrapper = $dropDown.parent('div.button-wrapper');
         $($buttonWrapper).mouseenter( function() {
             $dropDown.stop(true,true).show();
         }).mouseleave( function() {
             $dropDown.stop(true,true).hide();
         });
     });	
	
	/*********************************************************************************************
     * Newsletter-Service Tooltip
     *********************************************************************************************/

      items = $('div.newsletter-item');
      items.hover( function() {
          var item = $(this),
              parentHeight = item.parent().outerHeight(),
              itemHeight = item.outerHeight(),
              leftPosition = item.position().left,
              topPosition = item.position().top,
              bottomPosition = parentHeight - topPosition,
              tooltip = $(this).find('div.tooltip');

          if( leftPosition > 100 ) {
            tooltip.addClass('right');
          }
          tooltip.css( { bottom: bottomPosition, 'z-index': 99999 } ).show();
      }, function() {
          $(this).find('div.tooltip').hide();
      });

      items.find('div.tooltip').mouseenter( function() {
         $(this).hide(); 
      });
	
	/*********************************************************************************************
     * Max length for textarea's with class limitLength
     * default max length == 2000
     *********************************************************************************************/
     $( 'textarea.limitLength' ).limitMaxlength();
	
	/*********************************************************************************************
      * display 'merken und teilen' module after page is loaded
      * hide ajax loading image
      * ie7 fix
      *********************************************************************************************/
    $( '#merken_teilen' ).css( 'display', 'block' );
    $( '#mt-loader' ).hide();
	
    /*********************************************************************************************
     *
     * js_controls.js
     *
     *********************************************************************************************/
    // Collapsible-Message-Panels
    //hide message_body after the first one
	jQuery("ol.message_list .message_body:gt(0)").hide(); // element optimized
	
	// Set body class to disable non-JS css
	jQuery('body').removeClass('noscript');
			
	items = jQuery('#mycarousel.jcarousel-object li'); // element optimized
	items.live('mouseenter', function(){
				
				// POSITIONIERUNG
				var len = jQuery('#mycarousel').css('left').length-2;
				var temp1 = jQuery('.jcarousel-object').offset().left;
				var temp2 = jQuery(this).find('img').offset().left;
				var temp3 = jQuery('#mycarousel').css('left').substr(0,len);
				var temp = temp1 - temp2 - temp3 + 20;
				var left = (temp * -1);
		
				var current = jQuery(this).parent().children().index(this)+1;
				jQuery('.jcarousel-tooltip span').addClass("active");
				jQuery('.jcarousel-tooltip span').html( jQuery(this).find('a span').html());
				jQuery('.jcarousel-tooltip span').css('left',left);
			});
	items.live('mouseleave', function(){
		jQuery('.jcarousel-tooltip').children().removeClass("active");
	});			
			
    // General tooltips
    items = jQuery('div.jcarousel-tooltips li > div'); // element optimized
    items.live('mouseenter', function (ev) { 
        var pos = jQuery(this).offset();
        pos.top += (jQuery(this).height() - 10);
        pos.left -= (jQuery(this).width() - 30) / 2;
        var content = jQuery(this).find('.tooltip').html();

        if(!content) return;

        jQuery('body').append('<div id="tooltip-container"><div class="content"></div></div>');
        jQuery('#tooltip-container div.content').html(content);
        jQuery('#tooltip-container').css({top: pos.top, left: pos.left}).show();
    });
    items.live('mouseleave', function (ev) {
        jQuery('#tooltip-container').remove();
    });
    
	//toggle message_body open
	jQuery("h3.message_head, h4.message_head").click(function(event){ // element optimized
	// Ändeung 23.08.11 für den Sitestat-Zähler Akkordeon
	    index=event.target.id;
		var label = "position=" + index;
		if (window.triggerSitestat) {
			triggerSitestat(label);
		}
    
    if (window.triggerAgof) {
      //triggerAgof(label);
    }
		if( jQuery(this).parent().parent().hasClass('message_list-single')) {
			jQuery(this).parent().parent().find(".message_body:visible").slideToggle(50);
			if( jQuery(this).next(".message_body").css('display')!='block') {
				jQuery(this).next(".message_body").slideToggle(50);
			}
		} else {
			jQuery(this).next(".message_body").slideToggle(50);
		}
		return false;
	});

	 /* adesso (MaFa) DMAGIPAR-658:
		aufklappen ging, aber einklappen (minus) fehlte
	 */	
		//toggle message_body closed
	jQuery("div.message_body .icon-message-open").click(function(){ // element optimized
		jQuery(this).parent().parent().find(".message_body:visible").toggle();
		return false;
	});
	
	/* Author: Michael Mayer */
	    // Tabs fuer Suche (5.10.2011; Update am 2.11.2011)    
	    items = jQuery('ul.tabs'); // IE7 optimized
	    items.find('a').live('click', function (ev) {
	        ev.preventDefault();

	        var alreadyActive = jQuery(this).parents('li').hasClass('active');
	        
	        if(alreadyActive && jQuery(this).parents('.tab-container').length) return;
	        
	        var matchingClass = '.' + jQuery(this).attr('href').substr(1);
            var parent = jQuery(this).parents('.tab-container').length == 1 ? jQuery(this).parents('.tab-container') : jQuery(this).parents('.cont-searchform');
            
	        parent.find('.tab.active').removeClass('active');
	        parent.find('.tabs li.active').removeClass('active');

	        if(!alreadyActive) {
	            parent.find('.tab' + matchingClass).addClass('active');
	            jQuery(this).parents('li').addClass('active');
	        }
	    });
	
	    // Expander fuer Gruppen in .block Containern
	    jQuery('div.block .expander').live('click', function (ev) {
	        ev.preventDefault();
	        var el = jQuery(this);

	        var alreadyActive = el.hasClass('expanded');
            var node = jQuery(this).parent('.padding').length == 1 ? jQuery(this).parent('.padding') : el;
            
	        if(alreadyActive) {
	            node.siblings('.subblock').hide();
	            el.removeClass('expanded');
	        } else {
	            node.siblings('.subblock').show();
	            el.addClass('expanded');
	        }
	    });	    	
	    
	    jQuery('#mymesse-dashboard .closed').live('mouseover', function (ev) {
	        jQuery('#mymesse-dashboard > div').attr('class', 'navigation');
	    });	    
	    
	    jQuery('#mymesse-dashboard').live('mouseleave', function (ev) {
    	    ev.preventDefault();
    	    if(ev.relatedTarget.className != '') return;
	        if(jQuery(this).children('div.register, div.help, div.login').length) {
    	        jQuery('#mymesse-dashboard > div').attr('class', 'default');
    	    } else if(jQuery(this).children('div.navigation').length && jQuery('#mymesse-dashboard div.closed').length) {
    	        jQuery('#mymesse-dashboard > div').attr('class', 'closed');
    	    }
	    });
	    
	    jQuery('#mymesse-dashboard a').live('click', function (ev) {
	        var href = jQuery(this).attr('href'); // Use href to configure the page that should be displayed
	        if(href == '#' || href.substr(0,1) != '#') return;
	        ev.preventDefault();
	        $('#mymesse-dashboard > div').attr('class', href.substr(1));
	    });	    
	    
	    jQuery('.buttons a.note').live('click', function (ev) {
	        ev.preventDefault();
	        jQuery(this).parents('td').find('.cont-note-inlist').show();
	    });
	    
	    jQuery('.cont-note-inlist a.close').live('click', function (ev) {
	        ev.preventDefault();
	        jQuery(this).parent().hide();
	    });
	    
	    // Edit-Form mit Toggle-Funktion (edit on/off)
	    items = jQuery('form.editable'); // IE7 optimized
	    items.find('.edit-toggle').live('click', function (ev) {
	        ev.preventDefault();
	        jQuery(this).parents('form.editable').toggleClass('editable-active');
	    });
	    
	    // Tooltip fuer Index-Seiten-Header 
	    
	    jQuery('#cont-map .messen-box').live('mouseenter', function (ev) {
    	    var el = jQuery(this);
	        el.stop().css({'height': '79px'}).css({width: '59px'}).show().animate({'width': '255px'}, function () { 
	            // el.find('.messe-box-text').show(); 
	            });
	    });
	    
	    jQuery('#cont-map .messen-box').live('mouseleave', function (ev) {
	        var el = jQuery(this);
	        el.stop().css({'height': '59px'}).animate({'width': '59px'}, function () { 
	        // el.find('.messe-box-text').hide(); 
	        });
	    });
	    
	    /* Code fuer CeBIT Global Conferences Schedule Table - 11.01.2012 */
	    
	    jQuery('#cont-content .conference-schedule .container input').bind('change', function (ev) {
	        var checked = jQuery(this).attr('checked');
	        var name = jQuery(this).attr('name');
	        var parent = jQuery(this).parents('div.tab');
	        
	        var hideEmptyRows = function () {
    	        jQuery.each(parent.find('.event-' + name), function () {
                    if(!jQuery(this).siblings('td:not(.hidden)').length) {
                        jQuery(this).parent('tr').hide().addClass('hidden');
                    }
                });
	        }
	        
	        if(!parent.find('.event-' + name).length) return; // No such event available
	        
	        if(checked) {
    	        jQuery.each(parent.find('.event-' + name).parent('tr.hidden'), function () {
        	        jQuery(this).show().removeClass('hidden');
    	        });
    	        
	            parent.find('.event-' + name).show().removeClass('hidden');
	        } else {
                parent.find('.event-' + name).hide().addClass('hidden');

                hideEmptyRows();
	        }

	        var rows = parent.find('table tr:not(.hidden)');
	        var rowspanElement = parent.find('td.vertical');
	        var newRow;

            if(!rowspanElement.length) return; // Nothing to do
            
            var tableParts = parent.find('table').attr('class').split('-');
            var colspan = tableParts[1];            

	        if(rowspanElement.prev('td.hidden').length > 0) { // There is a td in the current row, but it's hidden (need to find a new row)
	            rowspanElement.parent('tr').hide().addClass('hidden');
	            
	            newRow = parent.find('table tr:not(.hidden):not(.placeholder):not(.bottom)').find('td:not(.hidden)').first();
	            
	            if(newRow.length == 0) {
           	        parent.find('table tr:not(.hidden)').first().after('<tr class="placeholder"><td class="empty" colspan="' + (colspan - 1) + '"></td></tr>');
           	        newRow = parent.find('table tr.placeholder:first td');
	            }
	            
	            newRow.after(rowspanElement);
	        } else { // There is no hidden td in the current row, but we need to make sure we're in the top most row
    	        newRow = parent.find('table tr:not(.hidden):not(.placeholder):not(.bottom)').find('td:not(.hidden):not(.vertical):not(.empty)').first();
    	        
    	        if(newRow.length) {
        	        parent.find('table tr.placeholder').remove();
       	            newRow.after(rowspanElement);
        	    }
	        }	  	           
	        	        
	        // Does not work with IE7
	        // jQuery('#cont-content .conference-schedule td.vertical').attr('rowspan', rows.length - 1);
	    });

	    // Newsletter form submit handler (12.10.2011)
		/* Die  Methode wird auskommentiert, weil wir für Newsletter keine Bestätigungs-Layer benötigen.(EAS 07.11.2011) 
        var showNewsletterConfirmBox = function (ev) {
	        if(ev) ev.preventDefault();
    	    $.colorbox({html: $('#newsletter-confirm-box').html()});
        };
        
        jQuery('form.mymesse-newsletter').live('submit', showNewsletterConfirmBox);        
	    jQuery('form.mymesse-newsletter input.edit-save').live('click', showNewsletterConfirmBox);
	    
    	/* --- */
    	
	    jQuery('a.map-button, a.layer-button').live('click', function (ev) {
	        ev.preventDefault();
	        var href = $(this).attr('href');
	        var selector = href.length > 1 ? href : '#map-box';
	        
	        $.colorbox({html: $(selector).html()});
	    });       
	    
	
	    		// AUSWAHLDIALOG used on 
	    		// Veranstaltungsprogramm (h3) with div.item.hasChilds, (h4, h5) handled on page 
	    		// detail pages (h3) with div.content and 
	    		// speaker_overview (h3) with div.item.hasChilds 

                jQuery("div.auswahldialog-list h3").click(function(){
                	
                    var $this = $(this);
                    
                	$this.find("strong").toggleClass("expandOpen");
                	
                	if( !$this.hasClass('first') && $this.hasClass('mainOpen') ) {
                		$this.removeClass('mainOpen');
                    } else {
                        if( !$this.hasClass('first') ) {
                        	$this.addClass('mainOpen');
                        }
                    }

                    if( $this.next().hasClass('mainOpen') ) {
                    	$this.next().removeClass('mainOpen');
                    } else {
                    	$this.next().addClass('mainOpen');
                    }
                    
                    if ( $this.hasClass('hasChilds') ) {
                    	$this.next().slideToggle(50);
                    }
                });
                
                // new Veranstaltungsprogramm - toggle all
                jQuery("a.auswahldialog-open-all").live('click', 
                    function (ev) {
                        ev.preventDefault();
                        jQuery("div.auswahldialog-list h3:not(.mainOpen)").click();
                    }
                );
                jQuery("a.auswahldialog-close-all").live('click', 
                    function (ev) {
                        ev.preventDefault();
                        jQuery("div.auswahldialog-list h3.mainOpen").click();
                    }
                );
                

                // STARRATING
                /* currently unused
                items = jQuery(".starrating a");
                items.mouseover(function(){
                    jQuery(this).addClass('hover');
                    jQuery(this).parent().prevAll().find('a').addClass('hover');
                });

                items.mouseout(function(){
                    jQuery('.starrating .hover').removeClass('hover');
                });
                */

                // SLIDER
                if ( jQuery("div.content-scroller").length > 0 ) { // element optimized
                    jQuery("div.content-scroller").jFancyscroller({});
                }

                // MERKEN / TEILEN
                if ( jQuery("#merken_teilen").length > 0 ) {

                     jQuery("#merken_teilen .mt-right").append('<a href="#" class="mt_openclose">&nbsp;</a>');
                     

                     jQuery("#merken_teilen div.mt-title").mouseover(function(){
                         jQuery(this).find(".mt_openclose").css('background-position', '0px -18px');
                     });

                     jQuery("#merken_teilen div.mt-title").mouseout(function(){
                         if( jQuery(this).find('div.mt-details').css('display') != 'block' ) {
                            jQuery(this).find(".mt_openclose").css('background-position', '0px 0px');
                         }
                     });

                     jQuery("#merken_teilen div.mt-title .mt-left").click(function(){
                        var mt_details = jQuery(this).parent();
                        if( mt_details.find('div.mt-details').css('display') != 'block' ) {
                            mt_details.find(".mt_openclose").css('background-position', '0px -18px');
                        }
                        mt_details.find('div.mt-details').slideToggle(50);
						mt_details.toggleClass('mt-details-open');
                        return false;
                     });

                }


    // Suchbox im Header
    items = jQuery( "ol.message_list2" ); // element optimized
    items.find( ".message_body2:gt(0)" ).hide();
    items.find( ".message_head2" ).click( function() {
      jQuery( this ).next( ".message_body2" ).slideToggle( 50 );
      return false;
    } );


    // Extended Search
    //Extended Search - Form einblenden
    items = jQuery( "#extended-search" );
    items.mouseenter( function() {
      $( "#extended-search2" ).show();
      $( "#extsearchbutton-on" ).show();
    } );
    
    //Extended Search - Form ausblenden
    items.mouseout( function() {
      //jQuery( "#extended-search2" ).show();
      //jQuery( "#extsearchbutton-on" ).hide();
    } );

    //Extended Search - Form eingeblendet lassen
    items = jQuery( "#extended-search2" );
    items.mouseover( function() {
      //jQuery( "#extended-search2" ).show();
      //jQuery( "#extsearchbutton-on" ).show();
    } );
    //Extended Search - Form ausblenden
    items.mouseleave( function() {
      jQuery( "#extended-search2" ).hide();
      jQuery( "#extsearchbutton-on" ).hide();
    } );


	  jQuery(".csc-mailform-field input").click(function() {
    	jQuery('#searchformInput').focus();
    });
    
	// Detect Cookies, 17.08.2011 (eas)
	
		$('#mymesse-dashboard > div').click(function(){
		if(!cookies){
			jQuery.fn.dialog("#cookies_error", {
				  autoClose : 5000
		    });
		    return false;
		}
	});
	
	$('#extsearchbutton-on').click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
				autoClose : 7000
		     });
			return false;
		}
	});
	
	$('#extsearchbutton2-on').click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			  autoClose : 7000
			});
			return false;
		}
	});
	
	$('#searchformInput').click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			  autoClose : 7000
			});
			return false;
		}
	});
	$("#list\\:selectRestriction").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchKE\\:searchKE-button").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchKE\\:searchKE-ext-button").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchKE\\:searchWord").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchZB\\:searchZB-button").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchZB\\:searchWord").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}

	
	});

	
	$("#searchPG\\:searchPG-button").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchPG\\:searchWord").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000

			});
			return false;
		}
	
	});

	$("#searchAP\\:searchWord").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchAP\\:searchAP-button").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	$("#searchAP\\:searchAP-ext-button").click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});
	
	/*$("#contactForm\\:contact-button").click(function() {
		if (!navigator.cookieEnabled) {
			jQuery.fn.dialog("#cookies_error", {
			autoClose : 5000
			});
			return false;
		}
	
	});*/
	$('#selectRestriction').click(function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
			  autoClose : 5000
			});
			return false;
		}
	});
	
	//Mediapartner
	$('#switch_to_shortlist_mediapartner').click(function() {
		 $('.mediapartner_shortlist_view').hide();
		 $('#mediapartner_shortlist_mode').show();
		 $('#mediapartner_normal_mode').hide();
	});
	
	$('#switch_to_normallist_mediapartner').click(function() {
		$('.mediapartner_shortlist_view').show();
		$('#mediapartner_shortlist_mode').hide();
		$('#mediapartner_normal_mode').show();
	});

    // Noticebar Printbutton Demo
    //Printlayer einblenden
	
    items = jQuery( ".print-menu" );
    items.mouseover( function() {
      jQuery( this ).find('.print-menu-layer').show();
    } );
    //Printlayer schliessen
    items.mouseout( function() {
      jQuery( this ).find('.print-menu-layer').hide();
    } );
    
	items = jQuery(".print-menu-layer");
	items.mouseover(function(){
		jQuery(this).show();
	});
	items.mouseout(function(){
		jQuery(this).hide();
	});
	// Noticebar Printbutton Demo
	//Printlayer einblenden
    items = jQuery( "#cont-noticebar .print-menu-icon" );
    items.mouseover( function() {
      jQuery( "#cont-noticebar .print-menu-layer" ).show();
    } );
    //Printlayer schliessen
    items.mouseout( function() {
      jQuery( "#cont-noticebar .print-menu-layer" ).hide();
    } );
    
    //Printlayer eingeblendet lassen
    items = jQuery( "#cont-noticebar .print-menu-layer" );
    items.mouseover( function() {
      jQuery( "#cont-noticebar .print-menu-layer" ).show();
    } );
    //Printlayer schliessen
    items.mouseout( function() {
      jQuery( "#cont-noticebar .print-menu-layer" ).hide();
    } );


    // Noticebar Sortinglist Sorting-Button (element and code optimized)
    items = jQuery( "span.sortinglist-menu");
    subitems = items.find( ".sortinglist-menu-icon" );
    subitems.mouseover( function() {
      jQuery(this).addClass('hover');
      jQuery(this).parent().find( ".sortinglist-menu-layer" ).show();
    } );
    subitems.mouseout( function() {
      jQuery(this).removeClass('hover');
      jQuery(this).parent().find( ".sortinglist-menu-layer" ).hide();
    } );   
    // layer eingeblendet lassen
    subitems = items.find( ".sortinglist-menu-layer" );
    subitems.mouseover( function() {
      jQuery(this).prev().addClass('hover');
      jQuery(this).show();
    } );
    subitems.mouseout( function() {
      jQuery(this).prev().removeClass('hover');
      jQuery(this).hide();
    } );
    
    // Noticebar Sortinglist Print-Button Demo
    //Printlayer einblenden
    items = jQuery( "#cont-noticebar-event .print-menu-icon" );
    items.mouseover( function() {
      jQuery( "#cont-noticebar-event .print-menu-layer" ).show();
    } );
    //Printlayer schliessen
    items.mouseout( function() {
      jQuery( "#cont-noticebar-event .print-menu-layer" ).hide();
    } );
    
    //Printlayer eingeblendet lassen
    items = jQuery( "#cont-noticebar-event .print-menu-layer" );
    items.mouseover( function() {
      jQuery( "#cont-noticebar-event .print-menu-layer" ).show();
    } );
    //Printlayer schliessen
    items.mouseout( function() {
      jQuery( "#cont-noticebar-event .print-menu-layer" ).hide();
    } );

    /* adesso (YaSi) DMAGIPAR-387: blendet Druck-Button aus
	jQuery('.notice-button').mouseover(function(){
		jQuery(this).next().show();
	});*/
    
    /* adesso (YaSi) DMAGIPAR-387: blendet Druck-Button aus
	jQuery('.notice-button').mouseout(function(){
		jQuery(this).next().hide();
	});*/

    items = jQuery('.wrapper');
    items.mouseover(function(){
		jQuery(this).prev().addClass('hover');
	});
	items.mouseout(function(){
		jQuery(this).prev().removeClass('hover');
	});

	/* currently unused
	items = jQuery('.notice-menu-layer');
	items.mouseover(function(){
		jQuery(this).show();
	});
	items.mouseout(function(){
		jQuery(this).hide();
	});
	*/


    // Noticebar Sortinglist list-in-list Subevent-Button Demo
    //Unter-Liste einblenden
	/* currently unused
    jQuery( ".but-list-in-list-on" ).click( function() {
      jQuery( "#subevent-1" ).slideToggle( "fast" );
      jQuery( ".but-list-in-list-on" ).hide();
      jQuery( ".but-list-in-list-off" ).show();
      jQuery( ".first" ).css( "background-color", "#EFEFEF" );
    } );
    //Unter-Liste ausblenden
    jQuery( ".but-list-in-list-off" ).click( function() {
      jQuery( "#subevent-1" ).slideToggle( "fast" );
      jQuery( ".but-list-in-list-off" ).hide();
      jQuery( ".but-list-in-list-on" ).show();
      jQuery( ".first" ).css( "background-color", "transparent" );
    } );
    */


	// Extended Search Button Ebene 1
    //Erweiterte Suche einblenden
    items = jQuery( "div.cont-extended-but" );
    subitems = items.find( ".icon-message-close" );
    subitems.click( function() {
      jQuery(".cont-searchform.extended").slideToggle("fast");
      jQuery( ".cont-extended-but .icon-message-close" ).hide();
      jQuery( ".cont-extended-but .icon-message-open" ).show();
      jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").val("open");
      jQuery("#searchResult\\:restrictions\\:extendedSearchRestrictsHiddenInputTwo").val('open');
    } );
    
    // Suchfilter einblenden
	//Erweiterte Suche einblenden
    subitems.click(function(){
		jQuery( ".cont-searchform.searchfilter" ).slideToggle( "fast" );
		jQuery( ".cont-extended-but .icon-message-close" ).hide();
		jQuery( ".cont-extended-but .icon-message-open" ).show();
		jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").val("open");
		jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").val('open');
	});
    
    //Erweiterte Suche ausblenden
    subitems = items.find( ".icon-message-open" );
    subitems.click( function() {
      jQuery(".cont-searchform.extended").slideToggle("fast");
      jQuery( ".cont-extended-but .icon-message-open" ).hide();
      jQuery( ".cont-extended-but .icon-message-close" ).show();
      jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").val("closed");
      jQuery("#searchResult\\:restrictions\\:extendedSearchRestrictsHiddenInputTwo").val('closed');
    } );
    
	
	//Erweiterte Suche ausblenden
    subitems.click(function(){
		jQuery(".cont-searchform.searchfilter").slideToggle("fast");
		jQuery(".cont-extended-but .icon-message-open").hide();
		jQuery( ".cont-extended-but .icon-message-close" ).show();
		jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").val("closed");
		jQuery("#searchResult\\:restrictions\\:extendedSearchRestrictsHiddenInputTwo").val('closed');
	});
	
    items.find("a.extended-but-type").click( function() {
		if (!cookies) {
			jQuery.fn.dialog("#cookies_error", {
				autoClose : 7000
		     });
			return false;
		}
		jQuery(".cont-searchform.searchfilter").slideToggle("fast");
		jQuery( ".cont-extended-but .icon-message-open" ).toggle();
		jQuery( ".cont-extended-but .icon-message-close" ).toggle();
		jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").toggle( function() {
			if( $(this).val() === 'closed' ) {
				jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").val('open');
				jQuery("#searchResult\\:restrictions\\:extendedSearchRestrictsHiddenInputTwo").val('open');
			} else {
				jQuery("#searchResult\\:extendedSearchRestrictsHiddenInput").val('closed');
				jQuery("#searchResult\\:restrictions\\:extendedSearchRestrictsHiddenInputTwo").val('closed');
			}
		} );
	});

			// Normal Search Layer: Suche speichern
				//Layer der normalen Suche einblenden
    			/* currently unused
    			items = jQuery(".save-search-but-arrow");
    			items.mouseover(function(){
				jQuery(".cont-noticebar-search .notice-menu-layer").show();
				});
				//Layer der normalen Suche schliessen
				items.mouseout(function(){
				jQuery(".cont-noticebar-search .notice-menu-layer").hide();
				});
						
				//Layer der normalen Suche eingeblendet lassen
				items = jQuery(".cont-noticebar-search .notice-menu-layer");
				items.mouseover(function(){
				jQuery(".cont-noticebar-search .notice-menu-layer").show();
				});
				//Layer der normalen Suche schliessen
				items.mouseout(function(){
				jQuery(".cont-noticebar-search .notice-menu-layer").hide();
				});
				*/

			// Suchfilter Ebene 1 Demo1
    //Weitere Inhalte einblenden (angepasst von T-Systems am 6.10.2011) (element optimized)
    jQuery('div.cont-but-filtervalues-all').live('click', 
        function(ev) {
            $(this).toggleClass('cont-but-filtervalues-all-open').next('.filtervalues-all').slideToggle('fast');        
        } 
    );

    // Navigation - WICHTIG: von adesso angepasst
    jQuery( "a.level-1-no" ).mouseover( function() {
      jQuery( "a.level-1-no" ).next().addClass( "invisible" );
      jQuery( "a.level-1-mar" ).next().addClass( "invisible" );
      jQuery( this ).next().removeClass( "invisible" );
    } );

    jQuery( "a.level-1-mar" ).mouseover( function() {
      jQuery( "a.level-1-no" ).next().addClass( "invisible" );
      jQuery( "a.level-1-mar" ).next().addClass( "invisible" );
      jQuery( this ).next().removeClass( "invisible" );
    } );

    jQuery( "#nav" ).bind( "mouseleave", function() {
      jQuery( "a.level-1-no" ).next().addClass( "invisible" );
      jQuery( "a.level-1-mar" ).next().addClass( "invisible" );
    } );
    

    /*********************************************************************************************
     *
     * js_controls_registration.js
     *
     *********************************************************************************************/

    // Navigation
    items = jQuery( "a.level-1" );
    items.mouseover( function() {
      jQuery( "a.level-1" ).parent().removeClass( "active" );
      jQuery( this ).parent().addClass( "active" );
    } );

    items.next().bind( "mouseleave", function() {
      jQuery( "a.level-1" ).parent().removeClass( "active" );
    } );
    jQuery( "#navi" ).bind( "mouseleave", function() {
      jQuery( "a.level-1" ).parent().removeClass( "active" );
    } );


    // Default Value (toggle) in Eingabefeld
    jQuery( 'input.defaultValue' ).each( function() {
      var default_value = this.value;
      jQuery( this ).focus( function() {
        if( this.value == default_value ) {
          this.value = '';
          jQuery( this ).removeClass( "defaultFont" );
        }
      } );
      jQuery( this ).blur( function() {
        if( this.value == '' ) {
          this.value = default_value;
          jQuery( this ).addClass( "defaultFont" );
        }
      } );
    } );

    // box help icon (open tooltip)
    $( 'div.box a.help' ).click( function() {
      //attributes
      var $box = $( this ).parents( 'div.box' ),
          boxWidth = $box.width() - 1; // scrollbar 

      //init: set default values
      $('div.tooltipbox').css( { display : 'none' } );

      // set clicked tooltip visible
      $box.find( 'div.tooltipbox' ).css( { display : 'block', width: boxWidth } );
      return false;
    } );

    // tooltip close icon
    jQuery( 'div.tooltipbox a.close' ).click( function() {
      jQuery( this ).parents( 'div.box' ).find( 'div.tooltipbox' ).css( { display : 'none' } );
      return false;
    } );
	
    /*********************************************************************************************
     *
     * js_controls-form.js
     *
     *********************************************************************************************/

    // fieldset.contentForm onFocus Function
	// @deprecated since 18.01.2011 by PaDa - reDesign wizards
    items = $( '.contentForm input[type="text"], .contentForm input[type="password"], .contentForm select, .contentForm textarea' );
    items.focus( function() {
      $( '.formRow' ).removeClass( 'active' );
      $( this ).parent().addClass( 'active' );
    } );

    // fieldset.contentForm onBlur Function
	// @deprecated since 18.01.2011 by PaDa - reDesign wizards
    items.blur( function() {
      $( '.formRow' ).removeClass( 'active' );
    } );

  } );

  /**
   * DIALOG PLUGIN
   *
   * how to use:
   * ===========
   * Open dialog on document ready (page loaded):
   * $.fn.dialog( '#dialogId' );
   *
   * Open dialog on link/button click:
   * $('a').dialog( '#dialogId' );
   */
  $.fn.extend( {
    dialog: function( dialogSelector, options ) {

      // preCon: dialogSelector must set
      if( !dialogSelector ) {
        return this;
      }

      // jQuery instance
      var $this = this;

      // default options
      var defaults = {
        automatePosition: true,
        calcNewPositionByResize: true,
        autoClose: false,
        onOpenComplete: false,
        appendToBody: true
      };

      // initialize options and new dialog instance for given id
      var settings = $.extend( defaults, options ),
          $dialog = new DialogClass( dialogSelector, settings.automatePosition, settings.calcNewPositionByResize, settings.appendToBody );

      // open dialog for: jQuery.fn.dialog();
      if( !$this.selector ) {
        $dialog.open( settings.onOpenComplete );
      } else {
        // bind click events to every element in jQuery('elements').dialog();
        this.each( function() {
          var $link = $( this );

          $link.click( function() {
            $dialog.open( settings.onOpenComplete );
            return false;
          } );

        } );
      }
      // set time in ms (if set) for automatic dialog close
      if( settings.autoClose ) {
        var timer = 0;
        clearTimeout( timer );
        timer = setTimeout( function() {
          $dialog.close();
        }, settings.autoClose );
      }

      // return the instance of the dialog - with helper functions
      return $dialog;
    }
  } );


  /**
   * creates a new Dialog object for given id. Handles all functionality of one dialog instance
   * @param id dialog id (UNIQUE)
   * @param automatePosition if true, the dialog is positioned in the middle of the browser window
   * @param calcNewPositionByResize if true, dialog will calculate the new position by resize the browser window
   */
  var DialogClass = function( id, automatePosition, calcNewPositionByResize, appendToBody ) {
    // attributes
    var INSTANCE = this,
        $dialog = $( id ),
		$body = $( "body" ),

		positionCalculator = {
			getCalculatedTopPosition : function() {
				var windowHeight = $( window ).height(),
						dialogHeight = $dialog.height();
				return ( windowHeight - dialogHeight ) / 2;
			},

			getCalculatedLeftPosition : function() {
				var windowWidth = $( window ).width(),
						dialogWidth = $dialog.width();
				return ( windowWidth - dialogWidth ) / 2;
			}
		};

    // bind events
    $( $dialog ).find( '.closeDialog' ).click( function() {
      INSTANCE.close();
    } );

    if( calcNewPositionByResize ) {
      $( window ).resize( function() {
        INSTANCE.setAutomatedPosition();
      } );
    }

    // public api
    this.open = function( callback ) {
      $dialog.fadeIn();
      if( appendToBody ) {
    	  $dialog.prependTo( $body );    	  
      }
      $dialog.fadeIn();
      if( callback ) {
        callback();
      }
      return false;
    };

    this.close = function() {
      $dialog.fadeOut();
      return false;
    };

    this.setAutomatedPosition = function() {
		INSTANCE.setPosition( positionCalculator.getCalculatedLeftPosition(), positionCalculator.getCalculatedTopPosition() );
    };

    this.setPosition = function( leftPosition, topPosition ) {
		var positions = { left: null, top: null };

		if( leftPosition === 'auto' ) {
			positions.left = positionCalculator.getCalculatedLeftPosition();
		} else {
			positions.left = leftPosition;
		}

		if( topPosition === 'auto' ) {
			positions.top = positionCalculator.getCalculatedTopPosition();
		} else {
			positions.top = topPosition;
		}

		$dialog.css( positions );
    };

	this.fixZIndex = function() {
    	$dialog.parent().css('z-index', 1);
    };
	
    // construct dialog
    if( automatePosition ) {
      this.setAutomatedPosition();
    } else {
      this.setPosition( 0, 0 );
    }
    
  };
	
	
    /**
     * max length script for textarea's 
     * 
     * script found here: http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/

     * edit by PaDa, 21.02.2011
     * 
     * @param options optional values
     */
    jQuery.fn.limitMaxlength = function( options ) {

        var settings = jQuery.extend( {
            maxlength: 2001,
            onLimit: function() {},
            onEdit: function() {}
        }, options );

        // Event handler to limit the textarea
        var onEdit = function() {
            var textarea = jQuery( this );
            if( textarea.val().length > settings.maxlength ) {
                textarea.val( textarea.val().substr( 0, settings.maxlength ) );

                // Call the onlimit handler within the scope of the textarea
                jQuery.proxy( settings.onLimit, this )();
            }

            // Call the onEdit handler within the scope of the textarea
            jQuery.proxy( settings.onEdit, this )( settings.maxlength - textarea.val().length );
        };

        this.each( onEdit );

        return this.keyup( onEdit )
                .keydown( onEdit )
                .focus( onEdit )
                .live( 'input paste', onEdit );
    };
	
}( window.jQuery ));


/**
 * Berechnet die Passwortstaerke
 */
function setPasswordStrength( id, password ) {
  if( !password ) {
    updatePasswordStrength( id, 0 );
    return;
  }

  var passwordComplexity = 0;
  if( password.match( /[a-z]/ ) )  passwordComplexity++;
  if( password.match( /[A-Z]/ ) )  passwordComplexity++;
  if( password.match( /\d/ ) )     passwordComplexity++;
  if( password.match( /(\W|_)/ ) ) passwordComplexity++;

  var passwordLength = Math.floor( (password.length - 4) / 2 );

  var passwordStrength = Math.min( passwordComplexity, passwordLength );
  if( passwordStrength < 0 ) passwordStrength = 0;
  if( passwordStrength > 4 ) passwordStrength = 4;

  updatePasswordStrength( id, passwordStrength );
}


/**
 * Zeigt die Passwort-Staerke als Balkengrafik
 */
function updatePasswordStrength( id, level ) {
  jQuery( '#' + id ).css( { width : level * 25 + '%' } );
}

function addBookmark(){
    if(window.sidebar)
	    window.sidebar.addPanel(document.title || location.href, location.href,"");
    else if(window.external) 
	    window.external.AddFavorite(window.location.href, document.title);
    else
	    alert("Leider konnte kein Lesezeichen gesetzt werden.");
    return false;
}
/**
 *
 * @param feld
 * @param next
 * @param anzahl
 */
function focuswechsel(feld, next, anzahl) {
    if (next != 'none') {
        nextid = document.getElementById(next);
    }

    if (anzahl == 1) {
        if (feld.value.search(/[^rp]/ig) >= 0) {
            feld.value = feld.value.replace(/[^rp]/ig, '');
        }
        feld.value = feld.value.toUpperCase();
    } else {
        if (feld.value.search(/[^abcdefghkmnopqrstuvwxyz23456789]/ig) >= 0) {
            temp = feld.value.replace(/0/ig, 'o');
            temp = temp.replace(/[^abcdefghkmnopqrstuvwxyz23456789]/ig, '');
            feld.value = temp;
        }
        feld.value = feld.value.toLowerCase();
    }
    if (next != 'none' && feld.value.length >= anzahl) {
        nextid.focus();
    }
    return true;
}

function disableInputs() {
    // jira-69, deactivate input fields depending on the users input
    var ticketCode = $('input.first, input.second, input.third, input.fourth, input.fifth');
    var ticketCodeVal = "";
    ticketCode.each(function(i, field) {
        ticketCodeVal += field.value;
    });
    var actionCode = $('input.actionCode');
    var actionCodeVal = actionCode.val();

    if (ticketCodeVal == "" && actionCodeVal == "") {
        // enable all input fields
        ticketCode.removeAttr('disabled');
        actionCode.removeAttr('disabled');

    } else if (ticketCodeVal != "") {
        actionCode.attr('disabled', 'disabled');

    } else if (actionCodeVal != "") {
        ticketCode.attr('disabled', 'disabled');

    }
}

function loescheCode() {
  document.getElementById( 'code1' ).value = '';
  document.getElementById( 'code2' ).value = '';
  document.getElementById( 'code3' ).value = '';
  document.getElementById( 'code4' ).value = '';
  document.getElementById( 'code5' ).value = '';
}


function printCurrentWindow() {
	var location = window.location.href;
    // remove last '#' if exist
	if (location.indexOf('#') == location.length - 1) {
		location = location.substring(0, location.length - 1);
	}
	if (location.indexOf("?") == -1) {
		location += "?print=true";
	} else {
		location += "&print=true";
	}
	var newWin = openWinCentered(location, "print", 980, 600);
	newWin.location = location;
	newWin.onload = function() {
	    newWin.focus();
	    newWin.print();
	};
	return false;
}

function printCurrentDocument() {
	var printWin = openWinCentered("", "print", 980, 600);
	var printCss = jQuery("link[media='print']");
	printCss.attr("media", "all"); // switch to print view
	
	var doc = jQuery(window.document.documentElement).html(); // dump html code

	printCss.attr("media", "print"); // switch back to screen view
	
	// remove script tags from content (cause errors in IE within a popup)
	var re = new RegExp("<script.*?>(.|\n)*?<\/script>", "gi");
	doc = doc.replace(re, "");

	// write popup document
	printWin.document.open();
	printWin.document.write("<html>");
	printWin.document.write(doc);
	printWin.document.write(
		"<script type='text/javascript'>" + 
			"window.onload = function() { " + 
				"window.focus();" + 
				"window.print();" +
			"};" +
		"<\/script>"
	);
	printWin.document.write("</html>");
	printWin.document.close();
	return false;
}

function openWindow(url, name, width, height){
	win = openWinCentered(url, name, width, height);
	win.focus();	
}

function openWinCentered(url, name, width, height) {
	width += 32;
	height += 96;
	var wleft = (screen.width - width) / 2;
	var wtop = (screen.height - height) / 2;
	var win = window.open(url, name, 'width=' + width + ', height=' + height + ', ' + 'left=' + wleft + ', top=' + wtop + ', location=no, menubar=yes, status=no, toolbar=no, scrollbars=yes, resizable=yes');
	return win;
}

function openWin( sourceFile, winWidth, winHeight ) {
  if( document.all ) {
    window.open( sourceFile, "PopUp", "height=" + (winHeight) + ",width=" + (winWidth) + ",innerWidth=" + winWidth + ",innerHeight=" + winHeight + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no" );
  }
  else {
    window.open( sourceFile, "PopUp", "innerWidth=" + (winWidth) + ",innerHeight=" + (winHeight) + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no" );
  }
  return false;
}

function openWin( sourceFile, winWidth, winHeight, xPos, yPos ) {
  if( document.all ) {
    window.open( sourceFile, "PopUp", "height=" + (winHeight) + ",width=" + (winWidth) + ",innerWidth=" + winWidth + ",innerHeight=" + winHeight + ",left=" + xPos + ",top=" + yPos + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no" );
  }
  else {
    window.open( sourceFile, "PopUp", "innerWidth=" + (winWidth) + ",innerHeight=" + (winHeight) + ",left=" + (xPos) + ",top=" + (yPos) + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no" );
  }
  return false;
}

function openNamedPopUp( popupName, sourceFile, xPos, yPos, winWidth, winHeight, scrollbars ) {
  if( document.all ) {
    window.open( sourceFile, popupName, "height=" + (winHeight) + ",width=" + (winWidth) + ",scrollbars=" + scrollbars + ",innerWidth=" + winWidth + ",innerHeight=" + winHeight + ",left=" + xPos + ",top=" + yPos + ",toolbar=no,location=no,status=no,menubar=no,resizable=no" );
  }
  else {
    window.open( sourceFile, popupName, "innerWidth=" + (winWidth) + ",innerHeight=" + (winHeight) + ",left=" + (xPos) + ",top=" + (yPos) + ",scrollbars=" + scrollbars + ",toolbar=no,location=no,status=no,menubar=no,resizable=no" );
  }
  return false;
}

/**
 * Function to call when a tab is clicked on the minidashboard.
 * This is used for lazy loading detail content.
 * 
 * It will search for a hidden command link to execute an
 * ajax refresh (loading detail data) inside the tab.

 * 
 * @param onClickArgs
 * @returns {Boolean}
 */
function minidashTabLazyLoad(onClickArgs) {
	var tabber = onClickArgs.tabber;
	var tabberIndex = onClickArgs.index;
	var event = onClickArgs.event;
	
	var div = tabber.tabs[tabberIndex].div;
	jQuery(div).find(".ajaxLazyLoading").trigger("click");
	return true;
}

// nedstat - page statistics
// FromURL v1.5 Copyright (c) 2001-2007 Nedstat B.V.
// All rights reserved.
function sitestat(ns_l) {
							
	var ns_type = ''; // leave empty for normal/ppc measurement, fill in for clickin, clickout or pdf
	var r = ''; // yes=only parse url when there is a real document.referrer, no=only parse url when there is no real document.referrer, empty=always
	// parse url
	var t = '?'; // tag in url where parameters follow; default '?' could be
					// replaced by "#"
	var p = new Array();
	var w = '';
	var l = '';
	var d = document;
	var n = navigator;
	var ns_0 = '';
	if (top != self) {
		if ('\u0041' == 'A') {
			var u = n.userAgent;
			if (u.indexOf('Safari') == -1) {
				var b = u.indexOf('Opera');
				if (b == -1 || (u.charAt(b + 6) + 0) > 5) {
					b = u.indexOf('Mozilla');
					var xb = b != -1 ? u.charAt(b + 8) > 4 : 1;
					if (u.indexOf('compatible') != -1 || xb) {
						var c = 'try{ns_0=top.document.referrer}catch(e){}';
						eval(c);
						c = 'try{l=top.document.location.href}catch(e){}';
						eval(c);
					}
				}
			}
		}
	} else {
		ns_0 = d.referrer;
		l = d.location.href;
	}
	if (ns_0.lastIndexOf('/') == ns_0.length - 1) {
		ns_0 = ns_0.substring(ns_0.lastIndexOf('/'), 0);
	}
	var f = ns_l.indexOf('?');
	if (f != -1) {
		var q = ns_l.substring(f + 1);
		ns_l = ns_l.substring(0, f);
		if (q) {
			var m = q.indexOf('&');
			w = q.substring(0, m == -1 ? q.length : m);
			if (w.indexOf('=') != -1) {
				w = '';
			}
			if (w) {
				q = q.substring(m == -1 ? q.length : m + 1);
				q += (q ? '&' : '') + 'ns_name=' + w;
			}
			if (ns_0.length > 0) {
				q += (q ? '&' : '') + 'ns_referrer=' + escape(ns_0);
			}
			var s = 0;
			var e = 0;
			while (q.length) {
				e = q.indexOf('&');
				if (e == -1) {
					e = q.length;
				}
				var o = q.substring(s, e);
				if (o.substring(0, 4) == 'amp;') {
					o = o.substring(4);
				}
				if (o)
					p[p.length] = o;
				q = q.substring(e + 1);
			}
		}
	}
	var a = l.indexOf(t);
	a = a == -1 ? 0 : l.substring(a + 1);
	var j;
	if (r == 'yes')
		j = ns_0.length;
	else if (r == 'no')
		j = !ns_0.length;
	else if (r == '')
		j = 1;
	if (a && j) {
		while (a.length) {
			var e = a.indexOf('&');
			if (e == -1) {
				e = a.length;
			}
			var k = a.substring(0, a.substring(0, e).indexOf('='));
			var v = a.substring(a.substring(0, e).indexOf('=') + 1, e);
			if (k.substring(0, 4) == 'amp;') {
				k = k.substring(4);
			}
			while (v.substring(0, 1) == '=') {
				v = v.substring(1);
			}
			if (k == 'ns_name') {
				w = v;
			} else if (k == 'ns_or') {
				var g = 'ns_referrer=';
				for ( var z = 0; z < p.length; z++) {
					if (p[z].substring(0, g.length) == g) {
						p[z] = 'ns_referrer=' + v;
					}
				}
			} else {
				if (k.substring(0, 3) == 'ns_' && v && k) {
					var h = 0;
					for ( var x = 0; x < p.length; x++) {
						if (p[x].substring(0, p[x].indexOf('=')) == k) {
							p[x] = k + "=" + v;
							h = 1
						}
					}
					if (!h) {
						p[p.length] = k + "=" + v;
					}
				}
			}
			a = a.substring(e + 1);
		}
	}
	if (!w) {
		return;
	}
	var s = '';
	var y = '';
	for ( var i = 0; i < p.length; i++)
		if (p[i].substring(0, 8) != 'ns_name=') {
			if (p[i].substring(0, 12) != 'ns_referrer=') {
				s += '&' + p[i];
			} else {
				y = '&' + p[i];
			}
		}
	s += ns_type ? '&ns_type=' + ns_type + '&ns_action=view' : '';
	ns_pixelUrl = ns_l + '?' + w + "&ns__t=" + (new Date()).getTime();
	ns_l = ns_pixelUrl + s + y;
	if (d.images) {
		ns_1 = new Image();
		ns_1.src = ns_l;
	} else {
		d.write('<img src=' + ns_l + ' width="1" height="1">');
	}
}

//nedstat - download statistics
function ns_onclick (ns_url, a, url, name, type, winopt){
	var ns_l = "http://" + ns_url // e.g. "http://ländercode.sitestat.com/kundenname/websitename/s?";
	ns_l += name;
	ns_l += '&ns_type=' + type + '&ns_action=view';
	ns_l += '&ns__t=' + (new Date()).getTime();
	if (!url)
		url = a.href;
	var ns_0 = document.referrer;
	if (ns_0.lastIndexOf('/') == ns_0.length - 1)
		ns_0 = ns_0.substring(ns_0.lastIndexOf('/'), 0);
	if (ns_0.length > 0)
		ns_l += '&amp;ns_referrer=' + escape(ns_0);
	winopt = winopt || "";
	var target = (a && a.target && a.target != "") ? (a.target.substring(0, 1) == "_") ? a.target
			.substring(1)
			: a.target
			: "self";
	var ns_i = new Image();
	if (target && url) {
		if (window[target]) {
			window.ns_softclick_timer = function(target, url) {
				return function() {
					ns_i.onload = ns_i.onerror = function() {
						return;
					};
					window[((window[target]) ? target : "self")].location.href = url;
				}
			}(target, url);
			window.setTimeout('ns_softclick_timer()', 5000);
			ns_i.onload = ns_i.onerror = window.ns_softclick_time
			r;
		} else {
			window.open(url, target, winopt);
		}
	}
	ns_i.src = ns_l;
	return false;
}

function displayAd(zoneid, withtext) {
   var m3_u = (location.protocol=='https:'?'https://balder.messe.de/werbung/www/delivery/ajs.php':'http://balder.messe.de/werbung/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=" + zoneid);
   if (withtext) {
      document.write ("&amp;withtext=1");
   }
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
}

