var name = ".social_buttons";  
var menuYloc = null;  
VideoJS.setupAllWhenReady({scaling: 'fit'});


$(function() {
	// Tooltip Funktionen
	$('.tooltip').tooltip();
	$('.tooltip').css({"color" : "#666", "cursor" : "pointer", "border-bottom" : "1px dotted #666666"});
	
	// Kontaktslide
	$('.slideAnchor').click(function(){	
		$('.slide').slideToggle(800);
		$('.datenschutz').slideUp(800);
		return false;	
	});
	
	// Datenschutz Slide
	$('.regeln').click(function(){
		$('.datenschutz').slideToggle(800);
		return false;
	});
	
	// Social Buttons Hover Effekte
	$('.facebook_btn, .twitter_btn').hover(function(){
		$(this).stop().animate({"right": "0"}, { duration: 'slow', easing: 'easeOutBounce' });
	},function(){
		$(this).stop().animate({"right": "-71px"}, { duration: 'slow', easing: 'easeOutBounce' });
	});
	
	// Social Buttons Scroll Effekt
	menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))  
    $(window).scroll(function () {  
        var offset = menuYloc+$(document).scrollTop()+"px";  
        $(name).animate({top:offset},{duration:1000,queue:false, easing: 'easeOutBack'});  
    });
	
	// Fade Ins
	
	/*
	var left_col = $('.sub_left p').hide();
	var right_col = $('.sub_right p').hide();
	var counter_left = 0;
	var counter_right = 0;
	
	(function displayColLeft() {  
	 left_col.eq(counter_left++).fadeIn(400, displayColLeft);  
	})();

	(function displayColRight() {  
	 right_col.eq(counter_right++).delay(200).fadeIn(200, displayColRight);  
	})(); 
	*/
	
});

// this is a fix for the jQuery slide effects
function slideToggle(el, bShow){
  var $el = $(el), height = $el.data("originalHeight"), visible = $el.is(":visible");
  
  // if the bShow isn't present, get the current visibility and reverse it
  if( arguments.length == 1 ) bShow = !visible;
  
  // if the current visiblilty is the same as the requested state, cancel
  if( bShow == visible ) return false;
  
  // get the original height
  if( !height ){
    // get original height
    height = $el.show().height();
    // update the height
    $el.data("originalHeight", height);
    // if the element was hidden, hide it again
    if( !visible ) $el.hide().css({height: 0});
  }

  // expand the knowledge (instead of slideDown/Up, use custom animation which applies fix)
  if( bShow ){
    $el.show().animate({height: height}, {duration: 250});
  } else {
    $el.animate({height: 0}, {duration: 250, complete:function (){
        $el.hide();
      }
    });
  }
}

function swf(id,filename, width, height, flashvars, params, attributes)
{
	var arrayFlvars = new Array();
	for(var i in flashvars){ arrayFlvars.push(i+'='+flashvars[i]); }
	flashvars = arrayFlvars.join('&');
	
	var arrayAttrs = new Array();
	for(var i in attributes){ arrayAttrs.push(i + '="' + attributes[i] + '"'); }
	attributes = arrayAttrs.join(' ');
	
	var html = '<object id="'+id+'" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" data="'+filename+'"><param name="movie" value="'+filename+'?'+flashvars+'"></param>';
	var arrayParams = new Array();
	for(var i in params){
		html += '<param name="'+i+'" value="' + params[i] + '" />';
		arrayParams.push(i+'="'+params[i]+'"');
	}
	html += '<param name="flashvars" value="' + flashvars + '" />';
	params = arrayParams.join(' ');
	html += '</object>';
	return html;
}
