$(document).ready(function() {   

	// $(function () {
	//         setTimeout(function () {
	//             if (typeof __flash__removeCallback != "undefined") {
	//                 __flash__removeCallback = __flash__removeCallback__replace;
	//             } else {
	//                 setTimeout(arguments.callee, 50);
	//             }
	//         }, 50);
	//     });
	// 
	//     function __flash__removeCallback__replace(instance, name) {
	//         if(instance != null)
	//             instance[name] = null;
	//     }  
	
	

$('.b2c a[href$=".m4v"],.b2c a[href$=".flv"],.b2b a[href$=".m4v"]').each(function(){
 var a_href = $(this).attr('href');
 $(this).parent().parent().addClass('video');   
 $(this).attr('href', '/fileadmin/videos/player.php?file='+a_href); 
//this.href = this.href.replace(/^http:\/\/beta\.stackoverflow\.com/, "http://b2c.qualitaetskliniken.de");

});	
   

$(".krankheitsbilder #content ul.csc-menu-3").prependTo("#sidebar_1");        
	
	
if (!($('#page_66').length > 0)){	
	$('.krankheitsbilder #page_title h1').clone().prependTo('#sidebar_1 ul.csc-menu-3');  
}  

$('.b2b #nav_main ul.nav_1,.b2b #nav_main ul.nav_2').superfish({
      delay:       100,                            // 100 miliseconds delay on mouseout
      animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
      speed:       'fast',                          // faster animation speed
      autoArrows:  false,                           // disable generation of arrow mark-up
      dropShadows: false                            // disable drop shadows
  });
        
//	$(".slideshow").appendTo('<div class="prev"></div><div class="slide_nav"></div><div class="next"></div>');  
	
onAfter = function(curr,next,opts) {
      var caption = (opts.currSlide + 1) ;
      $('#slide_nav .nav').html(caption +" von "+opts.slideCount);
}
   
 $('.slideshow').after('<div class="nav_thumb"><ul></ul></div><div id="slide_nav"><div class="prev"></div><div class="nav"></div><div class="next"></div></div>').cycle({ 
	    fx:     'scrollLeft', 
	    speed:  'fast', 
		slideExpr: '.slideshow_element ',
		timeout:  8000,
		delay: 3000,
		next:   '.next', 
		prev:   '.prev',
		pager:  '.nav_thumb ul',
		after: function(curr,next,opts) {
		              onAfter(curr,next,opts);
		            },
		pagerAnchorBuilder: function(idx, slide) {
						var src = $('img',slide).attr('src');
			            return '<li><a href="#"><img src="' + src + '"  width="94" /></a></li>';
			        }
	});

//$('.content-element .csc-header').nextAll().wrapAll('<div class="expandable_content" />');
$('.expandable .csc-header').nextAll().hide();	

$('.expandable .csc-header').live('click', function() { 
	if($(this).hasClass('expanded')){
		$(this).removeClass('expanded');
	}else{
		$(this).addClass('expanded');
	}
	$(this).nextAll().slideToggle("slow");
	
	});  

$('a.popupimage').fancybox({
	titlePosition: 'over'
});  

$(".video a,.video a.video").fancybox({
	'width'				: 720,
	'height'			: 396,
	'autoScale'     	: false,
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'scrolling'   		: 'no'
	
});   

$(".video .csc-textpic-single-image img").bind('mouseover',function(){ 
	var hoehe = $(this).css('height');  
	var hoehe_num = parseFloat(hoehe, 0);
	var hoehe_num = hoehe_num / 2 - 13;   
	var breite = $(this).css('width');  
	var breite_num = parseFloat(breite, 0);
	var breite_num = breite_num / 2 - 18;
	
	$(this).after('<div class="play_pic" style="width:'+breite+';height:'+hoehe+'"><img src="/fileadmin/qualitaetskliniken.de/css/img/b2b_play_button.png"></div>').fadeIn("slow");  
	$(this).parent().find('.play_pic img').css('top',hoehe_num); 
	$(this).parent().find('.play_pic img').css('left',breite_num);
});   

// $(".video .csc-textpic-single-image .play_pic").mouseleave(function(){
// 	$(this).parent().find('.play_pic').remove();
// }); 

$(".video .csc-textpic-single-image a .play_pic").live('mouseout',function(event){
	if(event.type == 'mouseout'){
		$(this).parent().parent().find('.play_pic').remove();
	} 
}); 

	
	
var contentarea = jQuery('body');
var num_ee = contentarea.css('font-size');
var num_e = parseFloat(num_ee, 10);
jQuery("#zoom a").click(function() {
	var currentSize = contentarea.css('font-size');
	var num = parseFloat(currentSize, 10);
	var unit = currentSize.slice(-2);
	if (this.id == 'enlarge'){
		num = num * 1.2;
	} else if (this.id == 'reduce') {
		num = num / 1.2;
	} else if (this.id == 'normal') {
		num = num_e;
	}
	contentarea.css('font-size', num + unit);
  		return false;
}); 



   
	 
	
});
