 $(window).load(function(){
	resize_contents()
	 })

function resize_contents(){
		   // set height of right to center id (box)
		  if ($("#right").length > 0) {
			 
			var centerHight = $("#center").outerHeight();
			var rightHight = $("#right > .box:first").innerHeight();
			var margin = 30;
		
			if (rightHight < centerHight) {
			 $("#right > .box:first").height(centerHight-margin);
			}
		
		  }
		  }
$(document).ready(function(){

  $(".box-product").hover(
  	function (event) {
  		$(".pr-action", this).addClass("activ");
  	},
  	function (event) {
  		$(".pr-action", this).removeClass("activ");
  	}
  );

resize_contents()
  
    // set height of right to center id (box)
	
  if ($("#sShipSetTable").length > 0) {
	 
   $("#sShipSetTable .oShippingSetTitle").each(function(){
	  var $this= $(this)
	  
	  var $this_text= $this.text()
	   
	  if(typeof($this_text.split("[")[1])!="undefined")
	   
	   $this.text($this_text.split("[")[0])
	   $this.append("<b>"+$this_text.split("[")[1].split("]")[0]+"</b>")
	   })

  }

  // same for center vs. right
 /* var centerHight = $("#center").outerHeight();
  var rightHight = $("#right > .box:first").innerHeight();

  if (centerHight < rightHight) {
    var center = $("#center > .box:last-child");
    center.height(center.height() + (rightHight - centerHight) + 10);
  }
*/
  $("#jquery-notifications div > a").click(function (event) {
   $(this).parent().fadeOut(500, function(){
     $(this).remove();
   });
  });

  $("#togle-login-form").click(function(){
   $("#loginform").toggle();
   $("#test_RightLogin_Email").focus();
   $(this).toggleClass("active"); return false;
   return false;
	});

   $('.success').animate({top:"30px", opacity: 1.0}, 1000);
   $('.success').animate({opacity: 1.0}, 8000);
   $('.success').fadeOut('slow');

   /*
   makebg();

   $(window).resize(function() {
     makebg();
   });
   */

   $('#aid').change(function() {
     active_variant = $(this).attr("value");
     var stock = variants_stock[active_variant];
     var html = '';

     $('#pr-price span').html("&euro;&nbsp;" + floatToGermanNumberFormat(variants_price[$(this).attr("value")]));

     if (stock <= 0) {
       $('#pr-addtocart').fadeOut();
       $('#pr-out').show();
       $('#pr-quantity').hide();

     } else {
       for (i=1; i<=stock; i++) {
         html += '<option value="'+i+'">'+i+'</option>';
       }

       $('#pr-addtocart').fadeIn();
       $('#pr-out').hide();
       $('#pr-quantity').show();
     }

     $('#amount').html(html);
	 
   })


      
	  
	  
	     $('#amount').change(function() {
     if ($('#aid').length > 0) {
       $('#pr-price span').html("&euro;&nbsp;" + floatToGermanNumberFormat(variants_price[$('#aid').attr("value")] * $(this).attr("value")));

     } else {
       $('#pr-price span').html("&euro;&nbsp;" + floatToGermanNumberFormat(product_price * $(this).attr("value")));

     }
   });

});

function makebg() {
  var h = $(document).height();
   if ($(window).height() > h) h = $(window).height();
   $("body").height(h);
}

function floatToGermanNumberFormat(nStr) {
  nStr = nStr.toFixed(2);

  nStr += '';
  x = nStr.split('.');

  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ' ' + '$2');
  }
  newString = (x1 + x2).replace(/\./, ',').replace(/\s/, '.');
  return newString;
}


//MINDUP
$(document).ready(function(){
	$(".youtube_player").each(function(){
		
		var $this=$(this);
		var yt_prop=425/344;
		var width=$this.parent().width()
		var height=width/yt_prop
		var video_no_cut=$this.parent().hasClass("video_no_cut");
		if($("#frontpage").size()==0)video_no_cut=true
		if(video_no_cut && height>$this.parent().height() && $this.parent().height()>0){
			
			height=$this.parent().height();
			width=height*yt_prop
			}
		
		if(video_no_cut){$this.width(width).css("margin","auto")}
		var video_id=$this.attr("data").split("/v/")[1].split("&")[0]
		$this.html('<object type="application/x-shockwave-flash" wmode="transparent" data="'+$this.attr("data")+'&controls=0&autoplay=0&rel=0&showinfo=0&showsearch=0&color=white&version=3&modestbranding=1&loop=1&playlist='+video_id+'" width="'+width+'" height="'+height+'"><param name="movie" value="'+$this.attr("value")+'&controls=0&autoplay=0&rel=0&showinfo=0&showsearch=0&color=white&version=3&modestbranding=1&loop=1&playlist='+video_id+'"><param name="wmode" value="transparent"></object>');
		//$this.html('<iframe id="player" type="text/html" src="http://www.youtube.com/embed/'+video_id+'&controls=0&autoplay=0&rel=0&showinfo=0&showsearch=0&color=white&modestbranding=1&loop=1"  width="'+width+'" height="'+height+'"></iframe>');
		if(!video_no_cut){
			var delta=($this.parent().height()-height)/2
			$this.parent().css("position","relative").css("overflow","hidden")
			$this.css("top",delta+"px").css("left","0").css("position","absolute")
		}
		
		});
		
})
