// JavaScript Document
function wideoNewWindow( $url ){
	
	var defaults = {
		width: 640+20,
		height: 392+20,
		titlebar: true,
		status: true,
		resizable: true,
		toolbar: true,
		scrollbars: true,
		menubar: true,
		windowURL: $url
	};
	var centeredY,centeredX;
	var windowFeatures =    'height=' + defaults.height +
							',width=' + defaults.width +
							',toolbar=' + defaults.toolbar +
							',scrollbars=' + defaults.scrollbars +
							',status=' + defaults.status + 
							',resizable=' + defaults.resizable +
							',location=' + defaults.location +
							',menuBar=' + defaults.menubar;	
	

	if ($.browser.msie) {//hacked together for IE browsers
		centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (defaults.height/2)));
		centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (defaults.width/2)));
	}else{
		centeredY = window.screenY + (((window.outerHeight/2) - (defaults.height/2)));
		centeredX = window.screenX + (((window.outerWidth/2) - (defaults.width/2)));
	}
	
	window.open(defaults.windowURL, defaults.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
	
	return false;
	
};

function wideoFuzz( $msg ){
	
	if ($("#fuzz")[0]){
		$("#fuzz").remove();
		$("object").show();
		return false;
	}
	
	$('body').append("<div id=\"fuzz\"></div>");
	$("#fuzz").css("height", $('body').height());
	$("object").hide();
	$(".mainWideo object").show();	
	
	
	$("#fuzz").click(function(){
									$(this).remove();
									$("object").show();
							  })
	
}

function wideoCreateBookmarkLink( $msg ) {

	title = document.title;
	url = location.protocol + "//" + location.host + location.pathname;
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
	
}

function wideoEmbed($rozmiar){
	
	var val = String();
	var w = String();
	var h = String();
	
	if($rozmiar==='304') {w='304';h='171';}
	else if($rozmiar==='448') {w='448';h='252';}
	else if($rozmiar==='608') {w='608';h='342';}
	else {w='640';h='360';}
	
	val = $('#wideoEmbedhidden').val();
	
	if(val==undefined) return;
	
	val = val.replace(/{%w}/g, w);
	val = val.replace(/{%h}/g, h);
	
	$('#wideoEmbed').val(val);
	
}

 
$(document).ready(function(){
						   
	wideoEmbed('608');
						   
	$('#osadzNaStronie').hide();
	$('.osadzClick').toggle(
											   
							function () {
								$('#osadzNaStronie').toggle();
								$(this).removeClass("osadzanie");
								$(this).addClass("osadzanie_open");
								},
							function () {
								$('#osadzNaStronie').toggle();
								$(this).removeClass("osadzanie_open");
								$(this).addClass("osadzanie");
								}										   
	);
	
});