jQuery.noConflict();
jQuery(document).ready(function() {


//Seitennavi
var subnav = Math.ceil(jQuery(".ul_2").children().length / 3);
jQuery(".contentnavigation").addClass("ul_2_background"+subnav);

//Externe Url's im neuem Fenster
jQuery(".link-url").attr('target', '_blank');
jQuery(".link-img").attr('target', '_blank');

//PDF
jQuery('a[href$=".pdf"]').attr('target','_blank');

//Gallery
jQuery(".galleryZoomPic").fancybox({ 
	'hideOnContentClick': true, 
	'zoomSpeedIn': 800, 
	'zoomSpeedOut': 800, 
	'overlayShow': true
});

//Headerbildwechsel
jQuery('#headerwechsel').innerfade({
						animationtype: 'fade',
						speed: 2000,
						timeout: 4000,
						type: 'sequence',
						containerheight: 'auto'
					});


//Sprungnavigation
  jQuery('#jumpbox li:not(.first)').css('display','none');	
	jQuery('#jumpbox').mouseover(function() {
		jQuery('#jumpbox li').css('display','block');
		jQuery('#jumpbox').css('height','150px');  // IE Hack
	});
	jQuery('#jumpbox').mouseout(function() {
		jQuery('#jumpbox li:not(.first)').css('display','none');
		jQuery('#jumpbox').css('height','auto'); // IE Hack
	});

//Locationsuche
  jQuery('#header-locationsearchers-link').css('display','none');
	jQuery('#header-locationsearchers').click(function(){
		jQuery('#header-locationsearchers-link').slideToggle("slow");
	});
	
//Unternehmer
  jQuery('#header-employers-link').css('display','none');
	jQuery('#header-employers').click(function(){
		jQuery('#header-employers-link').slideToggle("slow");
	});
	
	//Kreisprofile
	jQuery('#Stadprofile_Menu').css('display','none');
	jQuery('#showStadtprofile').click(function(){
      jQuery('#Stadprofile_Menu').slideToggle("slow");
			changeText();
			return false;
	});
		 
function changeText() {
    if(jQuery('#showStadtprofile').text() == 'Alle Profile anzeigen') {
        jQuery('#showStadtprofile').text('Alle Profile ausblenden');
    } else if (jQuery('#showStadtprofile').text() == 'Alle Profile ausblenden') {
       jQuery('#showStadtprofile').text('Alle Profile anzeigen');
    } else if (jQuery('#showStadtprofile').text() == 'Show Profiles ') {
       jQuery('#showStadtprofile').text('Hide Profiles ');
    } else if (jQuery('#showStadtprofile').text() == 'Hide Profiles ') {
       jQuery('#showStadtprofile').text('Show Profiles ');
    }
  }
  
  //Selectlisten Sprungmenu
    jQuery('.Selectjump_nojs').css('display','none');
    jQuery('#Selectjump').css('display','block');
  	jQuery('#Selectjump').change(function(){
       document.location.href = this.options[this.selectedIndex].value;
	});

  //Spezialitaeten Kommentar
  jQuery(".spezialitaeten_kommentar_container").hide();  

      jQuery(".spezialitaeten_kommentar").click(function(event){
      jQuery('.spezialitaeten_kommentar_container').toggle('slow');
      });

  /** ------------------------- Autocomplete -------------------------**/
  function formatItem(row) {
      return row[0];
    }
    function formatResult(row) {
      return row[1].replace(/(<.+?>)/gi, '');
    }
	
  for (i = 5643; i <= 5650; i++){
    jQuery(".spt_"+i).autocomplete("fileadmin/templates/wmr/scripts/general/autocomplete.php?id="+i, {
        minChars: 1,
        width: 117,
        highlight: false,
        selectFirst: false,
        formatItem: formatItem,
        formatResult: formatResult
      }).result(function() {
        $('.sp_'+i).submit();
      });
  }
/** ------------------------- Autocomplete -------------------------**/ 
});

