//**********************************+
// stromag.js - Peter Scheffler
// V1 - 16.02.2010

jQuery.noConflict();

jQuery(document).ready(function() {


//jQuery('#popup').hide();
//jQuery('#navicounty ul').hide();
// .noscript => JS-Fallback mit pure "CSS-Dropdown"
jQuery('#navitop').removeClass('noscript');


// ====================
  // Tooltip begin
  jQuery('#popup').hide();
  
  jQuery('#navitop').each(function () {
  	var distance = -25;
      var time = 600;
      var hideDelay = 1000;
      var hideDelayTimer = null;
      var beingShown = false;
      var shown = false;
      var trigger = jQuery('#iconkontakt', this);
      var info = jQuery('#popup', this).css('opacity', 0);
  
      jQuery([trigger.get(0), info.get(0)]).mouseover(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
          if (beingShown || shown) {
              // don't trigger the animation again
              return;
          } else {
              // reset position of info box
              beingShown = true;
              info.css({
                  top: 0,
                  right: 0,
                  display: 'block'
              }).animate({
                  top: '-=' + distance + 'px',
  						right: 0,
                  opacity: 1
              }, time, 'swing', function() {
                  beingShown = false;
                  shown = true;
              });
          }
  
          return false;
      }).mouseout(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
          hideDelayTimer = setTimeout(function () {
              hideDelayTimer = null;
              info.animate({
                  top: '-=' + distance + 'px',
                  opacity: 0
              }, time, 'swing', function () {
                  shown = false;
                  info.css('display', 'none');
              });
  
          }, hideDelay);
  
          return false;
      });
  });
  
  // Tooltip end
	// ====================
	// Leanderauswahl
 //jQuery('#navicounty ul:first').hide();
 jQuery('#navicounty').click(function(){
 		//jQuery(this).next().slideToggle('fast');
		jQuery('#navicounty h1').toggleClass('open').next().slideToggle('fast');
 		//return false; //Prevent the browser jump to the link anchor
		jQuery('#navicounty-trigger').find('#navicounty h1').toggleClass('open').find('#navicountry ul:first').slideToggle('fast');
 	});

	
    jQuery("#navitop li").hover(function(){
        jQuery('ul:first',this).filter(':not(:animated)').css('top' ,'26px').slideDown('fast');
        }, function(){
		jQuery('ul:first',this).slideUp('fast');
    });
    jQuery("#navitop li.last").hover(function(){
        jQuery('ul:first',this).hide();
        }, function(){
		jQuery('ul:first',this).hide();
    });    

// Tabs                                                                                                                                          
jQuery('.standortkarte > .standortkarte-item').each(
function(i) {
    this.id = 'tab' + (i + 1);
});

//jQuery('.standortkarte-item:first').css('display', 'block');

	//Default Action
	jQuery(".standortkarte-item").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".standortkarte-item:first").show(); //Show first tab content
	
	//On Click Event
	jQuery("ul.tabs li").click(function() {
		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".standortkarte-item").hide(); //Hide all tab content
		//var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		//jQuery(activeTab).fadeIn(); //Fade in the active content
		//jQuery(activeTab).
		//alert(activeTab);
		var activeTab_href = jQuery(this).find("a").attr("href"); // Get the current href attribute
		var activeTab = activeTab_href.split('#'); // get the current Tab-ID
		var activeTab_id = activeTab[1];   
		jQuery("#"+activeTab_id).show(); //show the active content
		return false;
	});
	

// Tabs end
// ===		

  // ====================
	// Lightbox - Fancybox
	jQuery('.clickenlarge').fancybox({
		'zoomSpeedIn'	: 600,
		'zoomSpeedOut'	: 500,
		'padding'	: 10,
		'titlePosition'	: 'inside'
	}); // Lightbox end
// ==============

	// ====================
	// Slider Kernmärkte Menü
	jQuery('div#cycle').cycle({});
}); //document.ready end
