2
/*
 * -------------------------------------------------------------------------
 * @file 		dom.js
 * @version 	1.0.0
 * @date 		2010-08-24 12:39:52 +0200 (Tue, 24 Aug 2010)
 * @author 		Matthias Mertiens <mail@mertiens.biz>
 * --------------------------------------------------------------------------
 * Copyright (c) 2010 mertiens. ideas for communication <http://mertiens.biz>
 * -------------------------------------------------------------------------- 
 */
 

$(function() {

	vtip();


	$('li', 'menu').hover(
		function() { $(this).addClass('hover'); },
		function() { $(this).removeClass('hover'); }
		);
		
	$('.shk-del')
		.css({ opacity: 0.3 })
		.hover(
		function() { $(this).animate({ opacity: 0.5 }, 100); },
		function() { $(this).animate({ opacity: 0.3 }, 350); }
		);	
		
	
			$('.maximize').live('click', function() { 
		
				var self = this;
				self.max = $('.max_content', self);
		
				if( $(self).hasClass('open') ) {
				
				 	$(self.max).hide(300);
				 	$(self).removeClass('open');
				
				 } else {
					$(self.max).show(300);
					$(self).addClass('open');
				
				 }
			 
				 return false;
				 
			});
		
	
	$('.versandkosten').fancybox({
    
    			'opacity': true,
    			'transitionIn'	:	'elastic',
    			'transitionOut'	:	'fade',
    			'speedIn'		:	300, 
    			'speedOut'		:	100, 
    			'overlayColor'	:	'#000',
    			'overlayOpacity':	'0.2',
    			'titleShow'		:	false
    
    			});


    $('.fancybox').fancybox({
    
    			'opacity': true,
    			'transitionIn'	:	'elastic',
    			'transitionOut'	:	'elastic',
    			'speedIn'		:	500, 
    			'speedOut'		:	300, 
    			'overlayColor'	:	'#000',
    			'overlayOpacity':	'0.2',
    			'titleShow'		:	false
    
    			});	
    			
    			
   $('.fotoshow').innerfade({   
        speed: 2000,   
        timeout: 4500,   
        type: 'sequence' ,
        containerheight: '300px'   
    });

    

	$('.external_link').attr('target','_blank');
						
						
/* 	Easy Form Validation   -------------------------------------------------------------					 */
$('#shopOrderForm').bind('submit', function(event) {
	 
	 			//alert("submitted");
	 			var stopSubmit = true;
	 			
	 			
	 			
	 			var cf = this;
	 			
	 			$('.required',cf).each(function(){
	 				 						 			
	 				if( $(this).val()=="" || ( $(this).attr('type')=='checkbox' && !$(this).is(':checked')  )  ) {
	 					
	 					$(this).addClass("error")
	 							.change(function() { 
	 					
	 										$(this).removeClass("error").parent().find('label').removeClass("error");
	 								 })
	 							.parent().find('label')
	 							.addClass("error");
	 				
	 					stopSubmit = false;
	 					
	 					event.preventDefault();
	 					
	 					}
	 				
	 				
	 				});
	 			
	 			
				if( stopSubmit===false ) {
	 				
	 					if( $('#errormessage').length==0) {
	 						$('<p class="errors" id="errormessage">Bitte füllen Sie alle rot markierten Felder aus!</p>').
	 							prependTo(this).css("display","none").slideDown(100);
	 						}
	 				
	 				}
				
	 			
	 			
	 			});
/* 	--------------------------------------------------------------------------------------					 */			
		
		
		
var msie6 = $.browser == 'msie' && $.browser.version < 7;
  
  if (!msie6 && $('#warenkorb_small').length > 0 && $('#content').height() > $('#warenkorb_small').height() + 200 ) {
    var top = $('#warenkorb_small').offset().top - parseFloat( $('#warenkorb_small').css('margin-top').replace(/auto/, 0) );
    $(window).scroll(function (event) {
      // what the y position of the scroll is
      var y = $(this).scrollTop();

        //$('body').append( y + "<br />");
      
      // whether that's below the form
      if( y >= ( $('#content').offset().top + parseFloat($('#content').height() - $('#warenkorb_small').height()) )  ) {
      	
      	var newtop = parseFloat($('#content').height() - $('#warenkorb_small').height() );
      	
      	if (newtop >= 0 ) {
      	$('#warenkorb_small').css('top', newtop  );
      	$('#warenkorb_small').removeClass('fixed').addClass('absolute');
      	} else {
      	$('#warenkorb_small').removeClass('fixed');
      	}

     
      } else if (y >= top - 0) {
        // if so, ad the fixed class
        //$('body').append("fix - " + ( $('#content').offset().top + parseFloat($('#content').height() - $('#warenkorb_small').height()) ) + "<br />");
        $('#warenkorb_small').addClass('fixed').css("top","0");

        

      } else {
        // otherwise remove it
        $('#warenkorb_small').removeClass('fixed');
      }
    });
  } 		
	
	
});
