
/**
 * custom.js
 * General JavaScripts and custom webtrekk integration
 * 
 * @requires jQuery
 *
 */
var $j = jQuery.noConflict();
       
$j(document).ready(function() {

  
  $j( "#slider_1" ).accessNews({
	        headline : "",
	        speed : "normal",
			    slideBy : 2
	    });
  
  $j( "#slider_2" ).accessNews({
	        headline : "",
	        speed : "normal",
			    slideBy : 1
	    });
	    
	  $j( ".slider" ).accessNews({
	        headline : "",
	        speed : "normal",
			    slideBy : 1
	    });
  
  
  $j('.tabs').accessibleTabs({
    // Der Name der Klasse die dem Div zugewiesen
    // welche um das Markup herumgeschrieben wird
    wrapperClass: 'content',
    // Der Name der Klasse die das aktuelle Tab markiert
    currentClass: 'current',
    // Tag oder valider Query Selector der Elemente 
    // aus denen die Tabs Navigation erzeugt wird
    // (die Originale werden entfernt)
    tabhead: 'h2',
    // Tag oder valider Query Selector der Elemente die
    // als Inhalte der Tabs genutzt werden sollen
    tabbody: '.tabbody',
    // Anzeigeeffekte:  'fadeIn', 'slideDown' oder 'show'
    fx:'fadeIn',
    // Geschwindigkeit (String|Number): 'slow', 'normal', oder 'fast')
    // oder die Milisekunden die die Anzeigeeffekte dauern sollen
    fxspeed: 'fast',
    // Text um Screenreadern anzuzeigen welches der ausgewählte Tab ist
    currentInfoText: '',
    // Definition wo der Text eingefügt wird
    // Entwender 'prepend' oder 'append'
    currentInfoPosition: 'prepend',
    // Klasse des span mit dem Infotext
    currentInfoClass: 'current-info'
	
});  
     
     switchHometabsBackground();
     $j('#hometabs ul li:first').addClass('first');
     $j('#hometabs ul li a').click(function()
     {
          switchHometabsBackground();
     });
     

     
     function switchHometabsBackground()
     {
       if ($j('#hometabs ul li:first').hasClass('current') )
       {
        $j('#hometabs ul.tab_ul').removeClass('active2');
        $j('#hometabs ul.tab_ul').addClass('active1');
       }
       else
       {
        $j('#hometabs ul.tab_ul').removeClass('active1');
        $j('#hometabs ul.tab_ul').addClass('active2');
       }
     }
    
     
     // change class of first li links from .left_navigation for another background 
     $j('ul#main_navigation li a:first, ul#product_navigation li a:first, ul#product_navigation2 li a:first').addClass('first');
     $j('ul#main_navigation li a:last, ul#product_navigation li a:last, ul#product_navigation2 li a:last').addClass('last');
     
     $j('ul#product_navigation li.active a').removeClass('last');
     
     $j().piroBox({
      my_speed: 300, //animation speed
      bg_alpha: 0.5, //background opacity
      radius: 4, //caption rounded corner
      scrollImage : false, // true == image follows the page _|_ false == image remains in the same open position
                           // in some cases of very large images or long description could be useful.
      slideShow : 'true', // true == slideshow on, false == slideshow off
      slideSpeed : 3, //slideshow
      pirobox_next : 'piro_next', // Nav buttons -> piro_next == inside piroBox , piro_next_out == outside piroBox
      pirobox_prev : 'piro_prev', // Nav buttons -> piro_prev == inside piroBox , piro_prev_out == outside piroBox
      close_all : '.piro_close' // add class .piro_overlay(with comma)if you want overlay click close piroBox
      });

      
      var $jj = jQuery;
      $jj.fn.extend({
     	  toggleValue : function (defaultText) {
          return this.each(function() {

        		if ($jj.trim($jj(this).val()) == '') {
      				$jj(this).val(defaultText);
      			}
      		
      	    $jj(this).focus(function() {
      	     if ($jj(this).val() == defaultText) {
      					$jj(this).val('');
      				}
      				$jj(this).blur(function () {
      					if ($jj.trim($jj(this).val()) == '') {
      						$jj(this).val(defaultText);
      					}
      				});
      			});
      		});
      	}
      });

      //$j('.search').toggleValue('Search');
      $j('.search').toggleValue($j('.searchLabel').text());
      $j('#newsletter_input').toggleValue('enter email address');
      
      $j('.faq').accordion({ 
        active: false, 
        autoheight: false,
        header: '.accordion_headline',  
        animated: '' 
      });
      
       $j('.product_accordion').accordion({ 
        active: 0, 
        autoheight: false,
        header: '.accordion_headline',  
        animated: 'easeslide' 
      });
      
      // activate first item
      
	  
	  $j("table.sort:not(.notablesort):not(#datetable)").tablesorter(
        { widgets: ['zebra']}        
      );

	$j("#datetable").tablesorter(
	{        
		headers: 
		{
			0: { 
				sorter:'shortDate' 
				}
		},
		widgets: ['zebra'],
		dateFormat: 'de'
	});

      $j("#prod_a-h").click(
        function () {
            $j('#products_i_z').hide();
            $j('#products_a_h').show();
            return false;
        }
      );

      $j("#prod_i-z").click(
        function () {
            $j('#products_a_h').hide();
            $j('#products_i_z').show();
            return false;
        }
      );  
      
      
      $j("#close_iz").click(
        function () {
            $j('#products_i_z').hide();
        }
      );  
      
      $j("#close_ah").click(
        function () {
            $j('#products_a_h').hide();
        }
      ); 
      
      $j('.product_accordion .accordion_headline:first').addClass('accordion_headline_first');   
      $j('.product_accordion .accordion_headline:last').addClass('accordion_headline_last');
      
      $j(function(){$j('.jNice').jNice();	});
      
      
      
      
      $j("#login").hover(
        function () {
            $j('#login_dropdown').fadeIn();
            $j('#shop').fadeOut();
        },
        function () {
            $j('#login_dropdown').fadeOut();
            $j('#shop').fadeIn();
        }
      );  
      
      $j("#language_selector").hover(
        function () {
            $j('#language_dropdown').fadeIn();
        },
        function () {
            $j('#language_dropdown').fadeOut();
        }
      );  
      
     // watchscreenshots watchvideos
    
     $j('#productimages').hide();
     $j('#watchvideos, #watchscreenshots').click(function()
     {
       $j('#productimages').toggle();
       $j('#productvideos').toggle();
       return false;
     });
	 $j('#home_flash').focus();
});

function openCountryLink() {
				location.href = document.mainform.country_selector_options.options[document.mainform.country_selector_options.selectedIndex].value;
			}

function openPopUp(url){
	args = 'width=500,height=345,resizable';
  window.open(url,'',args);
}