function removePromo1() {
	stopvideo();
}

function showPromo1() {
	playvideo('zIiOupEBHUM');
}

function showBg() {
	$('#popup-bg').show();
}

function hideBg() {
	$('#popup-bg').hide();
}

$(function() {
	$('body').append('<div id="popup-bg"></div>');
	$('body').append('<div id="popup-center"><div id="popup"><div class="content"></div></div></div>');
	$('body').append('<div id="popup-all"></div>');
	$('body').append('<div id="popup-center2"><div id="popup-login"></div></div>');
	$.ajax({
		url: login_form_url,
		success: function(html) {
			$('#popup-login').html(html);
		}
	});
});


function getFlashMovie(div) {
	div = div || "player" ;
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[div] : document[div];
}


function toas_load(file, sbool) {
	getFlashMovie().toas_load(file,sbool);
}

function toas_stop() {
	getFlashMovie().toas_stop();
}

function toas_play(file, abool) {
	getFlashMovie().toas_play();
}


function playvideo(id) {
	var c = '<div style="padding-top:100px;" class="center"><div class="center video"><a href="javascript:stopvideo()" id="close-popup">&nbsp;</a><div id="ytapiplayer"></div></div></div>';
	showBg();
	$('#popup-all').html(c).show();
	var params = { allowScriptAccess: "always", bgcolor: "#cccccc" };
    swfobject.embedSWF("http://www.youtube.com/v/"+id+"&enablejsapi=1&playerapiid=ytplayer&hl=pl&fs=1&rel=0", 
            "ytapiplayer", "400", "300", "8", null, null, params, {id: "myytplayer"});
}
var ytplayer;
function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById('myytplayer');
	ytplayer.playVideo();
}

function stopvideo() {
	ytplayer.stopVideo();
	hideBg();
	$('#myytubeplayer').remove();
	$('#popup-all').hide();
}



$(function() {
	$('#top-links a').click(function() {
		playvideo($(this).attr("rel"));
		return false;
	});
	$('body').append('<div id="thumb-win" style="display: none"><img src="" alt="zdjęcie" /></div>');
	$('.tooltip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - "
	});
	
	$('#open-login-popup').click(function() {
		showBg();
		$('#popup-center2').show();
		return false;
	});
	
});

function close_login_popup() {
	hideBg();
	$('#popup-center2').hide();
}

function showThumb(el, file) {
	$('#thumb-win img').attr("src", file);
	$('#thumb-win').css({
		top: ($(el).position().top + 20)+ 'px', 
		left: $(el).position().left + 'px'
	}).show();
}

function hideThumb() {
	$('#thumb-win').hide();
}

function externallinks()
{
    var c=document.getElementById('all-page');
    if(c)
    {
        var ls=c.getElementsByTagName('a');
        for(var i=0;i<ls.length;i++){
            if(ls[i].getAttribute('rel')=='external' || ls[i].getAttribute('href').match(/^\:\/\/(.*)/i))
            {
	            ls[i].className+=ls[i].className?' extlink':'extlink';
	            ls[i].onclick=function(){window.open(this.href);return false;}
        	}
   		}
	}
}
$(document).ready(function(){
   // if(!document.getElementById && !document.createTextNode){return;}
    externallinks();
});

/*
 * Progress Bar Plugin for jQuery
 * Version: Alpha 2
 * Release: 2007-02-26
 */ 
(function($) {	
	//Main Method
	$.fn.reportprogress = function(val,maxVal) {			
		var max=100;
		if(maxVal)
			max=maxVal;
		return this.each(
			function(){		
				var div=$(this);
				var innerdiv=div.find(".progress");
				
				if(innerdiv.length!=1){						
					innerdiv=$("<div class='progress'></div>");					
					div.append("<div class='text'>&nbsp;</div>");
					$("<span class='text'>&nbsp;</span>").css("width",div.width()).appendTo(innerdiv);					
					div.append(innerdiv);					
				}
				var width=Math.round(val/max*100);
				innerdiv.css("width",width+"%");	
				//div.find(".text").html(width+" %");
			}
		);
	};
})(jQuery);