$(document).ready(function() {
	$('#searchterm').focus(function() {
			sTerm = $(this).val();
			$(this).val('');
	});

	$('#searchterm').blur(function() {
		 verVal = $(this).val();
		 if(verVal == "") {
			$(this).val(sTerm);
		}
	});
	

	var baseHeight = 365; // Stage height
	var addHeight = 78; // Vertical paddings from #productHead and #productText
	
	if(jQuery.browser.msie && jQuery.browser.version == '7.0') {
		addHeight = 72;
	}

	$('#sidebar, #sidebar .container, #sidebar .content').height(baseHeight + addHeight + $('#productHead').height() + $('#productText').height());

	$('#sidebar .content').animate({width: '1'}, 2100);

  $('#sidebar .opener .arrow').toggle(
      function() {
          $('#sidebar .content').animate({width: '200'}, 750);
          if($(this).attr('src').indexOf('_r') == -1) {
            $(this).attr('src', $(this).attr('src').replace(/.jpg/, '_r.jpg'));
          }
      },
      function() {
          $('#sidebar .content').animate({width: '1'}, 750);
          $(this).attr('src', $(this).attr('src').replace(/_r.jpg/, '.jpg'));
      }
  );

    $('#sidebar .content .item ul li:last').css('border', 'none');
    
   //$('#bandsaege ul li ul > li:last').css('border', 'none');
    //$('#besaeum ul li ul > li:last').css('border', 'none');
    //$('#kreissaege-profilier ul li ul > li:last').css('border', 'none');
    //$('#gatter ul li ul > li:last').css('border', 'none');
    
    $('#nav').droppy({speed: 400});

    $('#nav > li:not(".active")').mouseenter(function() {
        
        var img = $('img', this);
                
        if($(img).attr('src').indexOf('_hl.gif') == -1) {

            $(img).attr('src', $(img).attr('src').replace(/.gif/g, '_hl.gif'));
			
        }
    });
    
    $('#nav > li:not(".active")').mouseleave(function() {
        var img = $('img', this);
        
        if($(img).attr('src').indexOf('_hl.gif') > 0) {

            $(img).attr('src', $(img).attr('src').replace(/_hl.gif/g, '.gif'));
			
        }
    });
	
	/**/
	 $('#nav.id_36 > li:not(".active")').mouseenter(function() {
        
        var img = $('img', this);
                
        if($(img).attr('src').indexOf('_hl.png') == -1) {

            $(img).attr('src', $(img).attr('src').replace(/.png/g, '_hl.png'));
			
        }
    });
    
    $('#nav.id_36 > li:not(".active")').mouseleave(function() {
        var img = $('img', this);
        
        if($(img).attr('src').indexOf('_hl.png') > 0) {

            $(img).attr('src', $(img).attr('src').replace(/_hl.png/g, '.png'));
			
        }
    });
	

	 
	 
	
	
	
        
//    $('#nav li:not(".active") a img, #subnav li:not(".active") a img').hover(
//        function() {
//            if($(this).attr('src').indexOf('_hl.gif') == -1) {
//                $(this).attr('src', $(this).attr('src').replace(/.gif/g, '_hl.gif'));
//            } 
//        },
//
//        function() {
//            if($(this).attr('src').indexOf('_hl.gif') > 0) {
//                $(this).attr('src', $(this).attr('src').replace(/_hl.gif/g, '.gif'));
//            }
//        }
//    );

 $('#news .item:even').addClass('grey');
  $('#productlist .row:even').addClass('grey');  
/* 
    $('#productlist .row .product .pic').mouseover(function(){
    if($(this).parent('.product').children('.teaser').html().length > 0) {
        $(this).parent('.product').children('.teaser').fadeIn("slow");
    }
  }).mouseout(function(){
        if($('#productlist .row .product .teaser').html().length > 0) {
            $('#productlist .row .product .teaser').fadeOut("slow");
        }
  });
*/
    //Weltkarte
    
    $('#contactMap area').hover(
        function() {
            var id = $(this).attr('class');
            $('#welt .hover').css('background', 'url(images/worldmap/ww_' + id + '.gif) no-repeat left top');
        },
        function() {
            $('#welt .hover').css('background', 'url(images/worldmap/map.gif) no-repeat left top');
        }
    );
 
    $('#contactMap.europe area').hover(
        function() {
            var id = $(this).attr('class');
            $('#welt .hover').css('background', 'url(images/euromap/eu_' + id + '.gif) no-repeat left top');
        },
        function() {
            $('#welt .hover').css('background', 'url(images/euromap/map.gif) no-repeat left top');
        }
    );
  
    $('#contactMap area').click(function() {
        var id = $(this).attr('class');
        if(id == 'europa') {
            return true;
        } else {
            $('#welt .click').css('background', 'url(images/worldmap/ww_' + id + '.gif) no-repeat left top');
            $('#welt .data .country').hide();
            $('#' + id).show();
            
            return false;
        }
    });

    $('#contactMap.europe area').click(function() {
        var id = $(this).attr('class');
        
        $('#welt .click').css('background', 'url(images/euromap/eu_' + id + '.gif) no-repeat left top');
        $('#welt .data .country').hide();
        $('#' + id).show();
    });
    
    
    
    
    //Eurpopakarte


    $('#contactMap area').hover(
        function() {
            var id = $(this).attr('class');
            $('#europe .hover').css('background', 'url(images/worldmap/ww_' + id + '.gif) no-repeat left top');
        },
        function() {
            $('#europe .hover').css('background', 'url(images/worldmap/map.gif) no-repeat left top');
        }
    );
 
    $('#contactMap.europe area').hover(
        function() {
            var id = $(this).attr('class');
            $('#europe .hover').css('background', 'url(images/euromap/eu_' + id + '.gif) no-repeat left top');
        },
        function() {
            $('#europe .hover').css('background', 'url(images/euromap/map.gif) no-repeat left top');
        }
    );
  
    $('#contactMap area').click(function() {
        var id = $(this).attr('class');
        if(id == 'europa') {
            return true;
        } else {
            $('#europe .click').css('background', 'url(images/worldmap/ww_' + id + '.gif) no-repeat left top');
            $('#europe .data .country').hide();
            $('#' + id).show();
            
            return false;
        }
    });

    $('#contactMap.europe area').click(function() {
        var id = $(this).attr('class');
        
        $('#europe .click').css('background', 'url(images/euromap/eu_' + id + '.gif) no-repeat left top');
        $('#europe .data .country').hide();
        $('#' + id).show();
    }); 
    
    
    $('#first_lvl_nav img.searchIcon').mouseenter(function() {
        $('#search').addClass('act');
            $('#search').show();
    });
    $('#search').mouseleave(function() {
    $('#search').removeClass('act');
            $('#search').hide();
    });
        
            

    
    
    $('.stageCont').mouseenter(function(){
        $('.stageCont .container').show();
    });

    $('.stageCont').mouseleave(function(){
        $('.stageCont .container').hide();
    });

});


function setSubNavWidth() {
    /*
  $('#nav ul.subMenu').each(function() {
        $(this).width($(this).parents('#nav li').width() + 1);
  });
  */
  $('#nav ul.subMenu ul.subSubMenu').each(function() {
      $(this).css('left', ($(this).parents('ul.subMenu').width() - 0) + 'px');
      $(this).children('li:last').addClass('last');
  });   
}


function showVideo(file) {
    var playerMarginLeft = (($(document).width() - 650) / 2) + 'px';
    var playerMarginTop = (($(window).height() - 420) / 2) + 'px';

    $('#dark').width($('html').width()).height($('html').height()).css('opacity', 0.5).fadeIn('slow');
    $('#player').css({ left: playerMarginLeft, top: playerMarginTop}).attr('src', 'swf/player.php?file=' + file);
    $('#video').show();
}

function hideVideo() {    
    $('#video').hide();
    $('#player').css({ left: 0, top: 0}).attr('src', '');
    $('#dark').width(0).height(0).fadeOut('slow');
}



function editSlideshow() {
    $('.anythingControls').hide();
    
    
    $('.anythingSlider').mouseenter(function() {
        $('.anythingControls').show();
        $('span.arrow').show();
    });
    
    $('.anythingSlider').mouseleave(function() {
        $('.anythingControls').hide();
        $('span.arrow').hide();
    });
}
