if(typeof(help_hostname) == "undefined") {
    	var help_hostname = "help.switch.ch"	
    } 

$(document).ready(function(){
	
	//search btn hover for ie6
	$('#search_btn').hover(
      function () {
        $(this).css('background-image', 'url(<cms:link>../images/suche_button_hover.gif</cms:link>)');
      }, 
      function () {
        $(this).removeAttr('style');
      }
    );

    // Falls die URL keine Sprungmarke zu einem Anker enthaelt
    // (Workaround wegen Firefox, der sonst den Sprung nicht ausfuehrt,
    // sondern beim Suchfeld haengenbleibt.)
    if (location.hash.length == 0) {
	    // Setze Fokus in das Suchfeld
        $('input#searchfield').focus();
    }
    
    hoverContentContainerImg();
	formatHelpPopup();

});

function hoverContentContainerImg() {
	/* Verhalten für Bilder mit Hover */
	$('.hoverimg').each(function() {
		if($(this).children('img').length == 2) {
			var $img;
			var $img_hover;
			
			$(this).children('img').each(function() {
				if($(this).hasClass('hidden')) {
					$img_hover = $(this);
				} else {
					$img = $(this);
				}
			});
			
			$(this).hover(
				function() {
					$img.hide();
					$img_hover.css('display', 'inline');
				}, function() {
					$img.show();
					$img_hover.removeAttr('style');
				}
			);
		}
	});
}

/*
 * entfernt bereits gesetzte onclick Attribute und definiert selber wie der HelpBrowser geöffnet wird
 */
function formatHelpPopup() {

	/* SWITCH_parents Methode, damit Icon nicht angezeigt wird, wenn in einem Parent-Element class .noicon angezeigt wird*/
jQuery.expr[':'].SWITCH_parents = function(a,i,m){
	    return jQuery(a).parents(m[3]).length < 1;
};	
	
	$('#linkbox_dots a[href*=' + help_hostname + '], #col3 a[href*=' + help_hostname + '], #col2 a[href*=' + help_hostname + ']')
	  .filter(':SWITCH_parents(.noicon)') // Kein Icon wenn ein Parent Node Klasse "noicon" hat
	  .not('.noicon')
      .removeAttr('onclick')
	  .addClass("fileicon_popup") // Icon hinzufügen
	  .click(function(ev){
		window.open(
				this.href,
				'',
				'width=850,height=700,top=100,left=100,status=yes,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes'
				);
				ev.preventDefault();
				return false;
		})	
	}
