$(document).ready(function() {



	$(".navigation, #tools").superfish({ 
		hoverClass: "hover open", 
		delay: 500, 
		animation: {opacity:"show"}, 
		speed: 250,
		pathLevels: 1,
		autoArrows: false,
		dropShadows: false,
		disableHI: false,
		onShow:function() {
			Cufon.refresh();
		},
		onHide:function() {
			Cufon.refresh();
		}
	});


	$('.navigation').mouseenter(function() {
		$('#tools li > ul').hide();
		$('#tools li').removeClass('open hover');
	});
	
	$('#tools .button').mouseenter(function() {
		$('.navigation li').removeClass('open hover');
		$('#search-layer').show();
	});



	$(".one-col-img .col li a").hover(
		function () {
			var moodID = $(this).attr('rel');
		$(this).parent().parent().parent().find('.visual img').attr('src',moodID);
	 	}
	);

	$(".two-col-img .col li a").hover(
		function () {
			var moodID = $(this).attr('rel');
			$(this).parent().parent().parent().find('.visual img').attr('src',moodID);
	 	}
	);
	
	$(".three-col-img .col li a").hover(
		function () {
			var moodID = $(this).attr('rel');
			$(this).parent().parent().parent().find('.visual img').attr('src',moodID);
			
	 	}
	);
	
	// MODULE (EXPANDABLE)
 	expandItem = $('.expand', '#content');
	expandItem.find('.toggle').hide();
	expandItem.find('h2').click(function() {
		$(this).toggleClass('open');
		$(this).next().slideToggle(250);
		Cufon.refresh();
		scrollToTop();
	});
	
	// MODULE (PRODUCT-SET)
	$('.productset').each( function (index) {
		$(this).find('.set_wrapper').addClass('set-' + index);
		$(this).find('.set_wrapper.set-'+ index +' .set').hide();
		$(this).find('.set_wrapper.set-'+ index +' .set:nth-child(1)').show();
		
		var total = $('.set_wrapper.set-'+ index +' .set').length;
		var count = 1;

		$(this).find('.set_nav a').click( function (e) {
			e.preventDefault();
			$(this).parents().find('.set_wrapper.set-'+ index +' .set:nth-child('+ count +')').hide();
			$(this).attr('class') == 'next' ? count++ : count--;
			(count == total + 1) ? count = 1 : false;
			(count <= 0) ? count = total : false;
			$(this).parents().find('.set_wrapper.set-'+ index +' .set:nth-child('+ count +')').show();
			
			$('.product_stage .pager').html('[Seite '+ count +' von '+total+']');
		});
	
			$('.product_stage_item:last-child').addClass('last');
	});


	$('.press_release .more_text, .press_release .links').hide();
	$('.press_release .more').click(function(e) {
		e.preventDefault();
		$(this).prev().slideToggle('fast');
		$(this).children().text($(this).text() == 'Mehr lesen' ? 'Artikel schließen' : 'Mehr lesen');
		$(this).parent().prev().find('.links').toggle();
		$(this).parent().find('h3').toggleClass('active')
		Cufon.refresh();
	});

	$('.float_block:even').addClass('even');
	
	$('.module p:last-child').addClass('last');



	
	if (!$.browser.msie) {
	    /* STYLE INPUT[TYPE=FILE] */
		$(".module input[type=file]").filefield({ 
			width : 400,
			text: 'Durchsuchen…'
		});
	 }

	
	/* SEARCH RESULT FILTER */
	
	
	$('.search_result').hide();
	$('.search_result').eq(0).show();
	
	$('.search_result_filter a').click(function(e) {
		e.preventDefault();
		thisID = $(this).attr('id');
		$('.search_result_filter').find('a').removeClass('active');
		$(this).addClass('active');
		$('.search_result').hide();
		$('.'+thisID).show();
	});

 	$('.newsletter').cluetip({
		cluetipClass: 'newsletter',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'fixed',
		width: 642,
		height: 265,
		cluezIndex: 101,
		topOffset: -235,
		leftOffset: -318,
		sticky: true,
		onShow: function(){
			formData();
		}
	});
	
 	$('.newsletter_success').cluetip({
		cluetipClass: 'newsletter_success',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'fixed',
		width: 323,
		height: 85,
		cluezIndex: 101,
		topOffset: -83,
		leftOffset: -187,
		sticky: true,
		delayedClose: 3000,
		onShow: function(){
			formData();
		}
	});
	
	
	$('.newsletter_trendblog').cluetip({
		cluetipClass: 'newsletter newsletter-trendblog',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'fixed',
		width: 642,
		height: 265,
		cluezIndex: 101,
		topOffset: -190,
		leftOffset: -825,
		sticky: true,
		onShow: function(){
			formData();
		}
	});
	
 	$('.newsletter_trendblog_success').cluetip({
		cluetipClass: 'newsletter_success',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'fixed',
		width: 323,
		height: 85,
		cluezIndex: 101,
		topOffset: -190,
		leftOffset: -825,
		sticky: true,
		delayedClose: 3000,
		onShow: function(){
			formData();
		}
	});
	
	
	
	
	
 	$('.tellafriend').cluetip({
		cluetipClass: 'tellafriend',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'fixed',
		width: 410,
		height: 550,
		cluezIndex: 101,
		topOffset: -115,
		leftOffset: -85,
		sticky: true,
		onShow: function(cluetip, cluetipInner){
			formData(cluetip, cluetipInner);		
		},
		onActivate: function(e) {			
			$('a.tellafriend').each( function(index, element){
				$(element).attr("id","");
			});
			e.attr("id", "actu");		
			return true;
		}
	});
		
 	$('.tellafriend_success').cluetip({
		cluetipClass: 'tellafriend_success',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'fixed',
		width: 410,
		height: 350,
		cluezIndex: 101,
		topOffset: -82,
		leftOffset: -85,
		sticky: true,
		onShow: function(){
			formData();
		}
	});
	
 	$('.product_detail_layer').cluetip({
		cluetipClass: 'product_detail_layer',
		activation: 'click',
		dropShadow: true,
		dropShadowSteps: 6,
		arrows: false,
		showTitle: false,
		width: 630,
		cluezIndex: 101,
		topOffset: -320,
		leftOffset: 0,
		sticky: true,
		onShow: function(){
			formData();
		}
	});
	
 	$('.filialfinder').cluetip({
		cluetipClass: 'filialfinder',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'fixed',
		width: 800,
		height: 450,
		cluezIndex: 10001,
		topOffset: -115,
		leftOffset: 70,
		sticky: true
	});
 	$('.filialfinder2').cluetip({
		cluetipClass: 'filialfinder topp',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'bottomTop',
		width: 815,
		height: 520,
		cluezIndex: 1,
		topOffset: 50,
		sticky: true
	});
$('#topfinder').cluetip({
		cluetipClass: 'filialfinder topp',
		activation: 'click',
		dropShadow: false,
		arrows: false,
		showTitle: false,
		positionBy: 'bottomTop',
		width: 815,
		cluezIndex: 4,
		topOffset: 90,
		leftOffset: 20,
		sticky: true
});
	/* TRIGGER CLOSE EVENT */
	$('a.cluetip_close').live('click', function() {
		$(document).trigger('hideCluetip'); 
	});
	
	$('a.gallery').colorbox();

	/*IE*/
	$('.sitemap .col:last-child,.set .product_stage_item').addClass('last');


	$('.group_country').hide();

	$('.newsflash').delay(3000).animate({left: '-=390px'}, 250, function() {
	  $(this).removeClass('open');
	});

	
	$('.newsflash_trigger').toggle(
		function() {
			$('.newsflash').addClass('open').animate({left: '+=390px'}, 250);
		},
		function() {
			$('.newsflash').removeClass('open').animate({left: '-=390px'}, 250);
		}
	);	

		$('.button, button').live('click', function(event) {
			$('#myForm1, #myForm2, #myForm3, #myForm4, #sform').submit();
		});



		$('.bag').click(function() {
		 	window.location=$(this).parent().find("a").attr("href");
	     	return false;
		});

		$('.overlay').colorbox({
			iframe:'true',
			width:'70%',
			height:'70%'
			});

		$('.links .overlay').colorbox({
			iframe:'true',
			width:'1060px',
			height:'660px'
			});

		//Country select

		$('.change_country > a').click(function(e) {
			e.preventDefault();
		});
		$('.change_country a').click(function(e) {

				if ($(this).parent().hasClass('open')) {
					$('.change_country ul').hide();
					$('.change_country').removeClass('open');
				} else {

					$('.change_country').addClass('open');
					$('.change_country ul').show();
				};

		});

		if ($('.press_photos').html() != null) {
		        $.ajax({
		            type: 'GET',
		            url: '/DE/de/corp/js/tooltip.js',
		            success: function() {              

						$(".press_photos img[title]").tooltip({
							layout: '<div><span class="top"></span><span class="bottom"></span></div>',
							offset: [-15, 110]
						});

		              },
		            dataType: 'script',
		            cache: false
		        });
		    }

			$('.inputs input,.inputs textarea').focus(function() {
				$(this).parent().addClass('focus');
				Cufon.refresh();
			});
			$('.inputs input,.inputs textarea').blur(function() {
				$(this).parent().removeClass('focus');
				Cufon.refresh();
			});
			
			$('#info').toggle(function() {
				$('#layer-image').fadeOut('fast');
				$('#layer-image-info').fadeIn('fast');
			}, function() {
				$('#layer-image').fadeIn('fast');
				$('#layer-image-info').fadeOut('fast');
			});
			

		//SCROLL TO TOP
		scrollToTop();
		formTooltipHandling();


	});//DOCUMENT READY
