jQuery(document).ready(function(){

	// SUCHBEGRIFF BEI KLICK LEEREN
	/*jQuery('.search_keyword input').click(function(){
		jQuery(this).attr('value','');
	});*/
	
	// SUCHBEGRIFF BEI KLICK MARKIEREN
	jQuery('.search_keyword input').focus(function(){
		
		var that = this;
    	setTimeout(function(){$(that).select();},10);
    	
	});
	
	jQuery('#blockffFocus').focus();
	
	// SLIDESHOW STARTSEITE
	
	if( jQuery('#start-slider-inner').size() > 0){
	
		jQuery('#start-slider-inner').cycle({ 
			    fx: 'scrollHorz', 
			    speed: 1000, 
				timeout: 15000, 
	    		next:   '#slider-next a', 
	   			prev:   '#slider-prev a'
		});
		
		jQuery('#slider-next a').click(function(){
			jQuery(this).trigger('blur');
		});
		
		jQuery('#slider-prev a').click(function(){
			jQuery(this).trigger('blur');
		});
		
	}

	// FORMULAR INFO POPUP
	
	jQuery('#formRegister input#phone, #order input#test_usr_phone, #formRegister input#vatid, #order input#test_usr_vatid').focus(function(){
		
		jQuery(this).parent().find('.form-notice-container .form-notice').fadeIn(200);
		
		if( jQuery(this).hasClass('validationError') ){
			jQuery(this).parent().find('.errorLabel .validationError').fadeOut(200);
		}
		
	});
	
	jQuery('#formRegister input#phone, #order input#test_usr_phone, #formRegister input#vatid, #order input#test_usr_vatid').blur(function(){
		
		jQuery(this).parent().find('.form-notice-container .form-notice').fadeOut(200);
		
		if( jQuery(this).hasClass('validationError') ){
			jQuery(this).parent().find('.errorLabel .validationError').fadeIn(200);
		}
		
	});
	
	
	/*
	jQuery('a').click(function(){
		
		var href = jQuery(this).attr('href');

		if( href == '#delivery_link' ){
		
			alert("Deutschland: 19% MwSt \nAusland innerhalb der EU mit UID: MwSt-frei \nAusland außerhalb der EU: MwSt-frei ");
			return false;
		
		}
		
	});
	*/
	
	
	jQuery('a').click(function(){
		
		var href = jQuery(this).attr('href');

		if( href == '#delivery_link' ){
			fenster = window.open('http://pur-led.de/mwst.html', "Popupfenster", "width=320,height=150,resizable=yes");
			fenster.focus();
			return false;
		}
		
	});
	
		
	$("table.basket input.changeAmount").keypress(function(e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            $('input#test_basketUpdate').click();
            return false;
        } else {
            return true;
        }
    });
		
	//$("#body select").msDropDown();
	//$(".ffselect select").msDropDown();

	
	/* ZAHLUNGSARTEN */
	$('#choosePayment tr.paymentRow').hover(function(){
		
		$('#choosePayment .paymentDescPopup').hide();
		$(this).find('.paymentDescPopup').show();
		
		$('#choosePayment tr.paymentRow').removeClass('hover');
		$(this).addClass('hover');
		
	}, function(){
	
		$('#choosePayment .paymentDescPopup').hide();
		$('#choosePayment tr.paymentRow').removeClass('hover');
	});
	
	/* Bei klick, fahre zusatzbox aus */
	$('#choosePayment tr.paymentRow').click(function(){
		
		if( !( $(this).hasClass('active')) ){	
			$('#choosePayment tr').removeClass('active');
			$(this).addClass('active');
			
			$('.paymentFlyout').slideUp(750);
			
			if( $(this).find('.paymentFlyout').size() > 0 && $(this).find('.paymentFlyout').is(':hidden') ){
				$(this).find('.paymentFlyout').slideDown(750);	
			}
		}
			
	});
	
	/* Beim Laden aktives auslesen und evtl. ausklappen */
		
	$('.paymentRadio input').each(function(){
	
		if($(this).attr('checked')){
			$(this).parent().parent().addClass('active');
			$(this).parent().parent().find('.paymentFlyout').show();
		}
	
	});
	
	
	/* Sortierungs-Dropdown Weiterleitung */
	$('#sortSelector').change(function(){

		$(this).find('option').each(function(){
						
			if($(this).attr('selected')){
				
				var optionValue = $(this).attr('value');
				window.location = optionValue;
			}
			
		});
	});
	
	
	// FANCYBOX KUNDENGALERIE
	$('a.galleryImage').fancybox();
	
});
