

var mouseIsInsideSearch = false;
var stuffWrittenInSearchBox = false;

jQuery.noConflict();
jQuery(document).ready(function() {

	// F R O N T P A G E   S L I D E R  
	if(jQuery("#headerRegionSelector").length > 0)
	{
		jQuery("#headerRegionSelector").scrollable({
			circular: true, 
			/*mousewheel: true,*/
			easing: 'swing',
			speed: 600
		}).navigator().autoscroll({
			interval: 5000		
		});
	}

	
	// HOTPICKS
	jQuery('.htmlRahmen').hover(function(){
		jQuery(this).find('.bannerImage').stop().animate({top: '84px'},600);
		jQuery(this).find('.htmlContent').stop(true,true).hide().fadeIn(250);
	},function(){
		jQuery(this).find('.bannerImage').stop().animate({top: '-1px'},250);
	});
	
	
	//FANCYBOX Magento
	if(jQuery('#zoom a,a#zoom').length > 0)
	{
		jQuery('#zoom a,a#zoom').fancybox({
			'titlePosition' : 'inside',
			'titleShow' : true,
			'overlayOpacity': 0.7,
			'overlayColor':'#000'
		});
	}
	
	// FANCYBOX Typo3
	if(jQuery('a.fancyboxImage').length > 0)
	jQuery("a.fancyboxImage").fancybox();
	
	if(jQuery('a[rel=group]').length > 0)
	jQuery("a[rel=group]").fancybox();
	
	// TOOLTIPS KEYWORD DESCRIPTIONS
	jQuery('.produktNaviOuter').parent('li').hover(
		function(){
			jQuery(this).children('.produktNaviOuter').hide();
		},
		function(){
			jQuery(this).children('.produktNaviOuter').show();
		}
	);
	
	// REGION SELECTOR DROP DOWN
	jQuery('#regionSelector').mouseenter(function(){
		jQuery("#regionSelector ul").stop(true,true).slideDown('slow');
	});	
	jQuery('#regionSelector').mouseleave(function(){
		jQuery("#regionSelector ul").slideUp('fast');
	});	
	
	// PRODUKT SUPER NAVI DROP DOWN 	
	jQuery('.produktNaviOuter').parent('li').hover(
		function(){
			jQuery(this).children('.produktNaviOuter').stop(true,true).slideDown();
		},
		function(){
			jQuery(this).children('.produktNaviOuter').slideUp('fast');
		}
	);
	
	/** SEARCHBOX **/
	// beim submit des forms
	jQuery('#productSearchBox form').submit(function(event){
		if(jQuery('#switchToContentSearch:checked').val())  //content suche
		{
			event.preventDefault();
			searchControl.execute(jQuery('#productSearchString').val());
			jQuery('html,body').animate({scrollTop: jQuery('#contentSearchResultBox').offset().top},'slow'); //zum suchergebnis scrollen
		}
		else
		{
			jQuery('#productSearchBox form').attr('action',jQuery('#productSearchBox form').attr('action')+'#q='+jQuery('#productSearchString').val()); //action attribut umschreiben fuer exorbyte suche
		}
	});
  
    // beim klick auf submitbutton
	jQuery('#submitbutton').click(function()
	{
		if(jQuery('#switchToContentSearch:checked').val())  //content suche
		{
			searchControl.execute(jQuery('#productSearchString').val());
			jQuery('html,body').animate({scrollTop: jQuery('#contentSearchResultBox').offset().top},'slow'); //zum suchergebnis scrollen
		}
		else
		{
			jQuery('#productSearchBox form').attr('action',jQuery('#productSearchBox form').attr('action')+'#q='+jQuery('#productSearchString').val()); //action attribut umschreiben fuer exorbyte suche
			jQuery('#productSearchBox form').submit();  //form absenden
		}

	});
	
	//wechsel auf content suche
	jQuery('#switchToContentSearch').click(function(){
		jQuery('#productSearchString').unexautocomplete();
		searchFieldFocus();
	});
	
	//wechsel auf Produktsuche
	jQuery('#switchToProductSearch').click(function(){
		jQuery('#productSearchString').unexautocomplete();
		searchFieldFocus();
		addAutoComplete();
	});
	
	//Standards herstellen beim seitenaufruf
	searchFieldFocus();
	addAutoComplete();
  
	
	jQuery('#searchwrap').hover(function(){ 
		mouseIsInsideSearch=true; 
	}, function(){ 
		mouseIsInsideSearch=false; 
	});
	
	//beim tippen suchergebnissfeld einblenden (bei Produktsuche)
	jQuery('#productSearchString').keypress(function(){
		if(!jQuery('#switchSearchBox').is(':visible')){
			jQuery('#switchSearchBox').fadeIn('fast');
		}
		stuffWrittenInSearchBox = true;
	}).click(function(){
		if(stuffWrittenInSearchBox) //wenn Text in Suchfeld eingegeben wurde
		{
			jQuery('#switchSearchBox').fadeIn('fast');
		}
	});
	
	
	//klick in body blendet Suchergebnissfeld aus
    jQuery('body').mouseup(function(){ 
        if(!mouseIsInsideSearch) 
			jQuery('#switchSearchBox').stop(true,true).fadeOut('slow');
    });
	
	/** SEARCHBOX ENDE **/
	
	// FILTER NAVIGATION
  	if (jQuery('.layered-nav').length > 0){
  		jQuery('#narrow-by-list').hide();
		jQuery('.narrow-by h4').click(function(){
			jQuery('#narrow-by-list').slideToggle();
			jQuery(this).parent('div.narrow-by').toggleClass('active');
		});	

  	} else {
		jQuery('div.narrow-by').addClass('active');
  	}
	
	jQuery('#xmasBanner').animate({top:'+=141px'},2000,'easeOutBounce');
	
	
	jQuery('.quintaemail').focus(function() {
	//alert('tesT');
		if(jQuery(this).val() == 'EMAIL ADDRESS')
		jQuery(this).val('');
	});
	
	jQuery('.quintaemail').blur(function() {
		if(jQuery(this).val() == '')
		jQuery(this).val('EMAIL ADDRESS');
	});
	
	var gesendet = false;
	jQuery('.quintasubmit').click(function(){
		if(gesendet != true)
		{
			//jQuery('#handheld .quintaemail').val()
			var emailobj  = jQuery(this).parent('form').find('.quintaemail');
			jQuery(this).attr('src','fileadmin/images/landingQuinta/thankyou.png');
			jQuery.get('/fileadmin/quinta-registration/sendnewsletteremail.php', { email: emailobj.val() ,m: 'se'}, function(datax) {
				if(datax == 'true')
				{
					gesendet = true;
					emailobj.delay(500).fadeOut('slow');
				}
			});

		}
	});
	
	
	
});
