function f(x) {
	var test = x.toString();
	var test2 = test.split(',');
	
	for (i=0;i<test2.length;i++) {
		$("#kom_"+test2[i]).show();
	}
}

var player;

function playerReady(obj) {
	//alert('the video player '+obj['id']+' has been instantiated');
	player = document.getElementById(obj['id']);
};

function showAndHide(what) {
	//var player = document.getElementById('flashfile');
	var obiekt = document.getElementById(what);
	//player.sendEvent("STOP","true");
	
	if (what == "videoPlayer")  {
		player.sendEvent("STOP","true");
		document.getElementById('mp3Player').style.display = 'none';
		document.getElementById('swfPlayer').style.display = 'none';
		/*document.getElementById('img').style.display = 'none';*/
	 }
	 if (what == "swfPlayer") {
	 	player.sendEvent("STOP","true");
		document.getElementById('mp3Player').style.display = 'none';
		document.getElementById('videoPlayer').style.display = 'none';
		/*document.getElementById('img').style.display = 'none';*/
	 }
	 if (what == "mp3Player") {
	 	player.sendEvent("STOP","true");
		document.getElementById('swfPlayer').style.display = 'none';
		document.getElementById('videoPlayer').style.display = 'none';
		/*document.getElementById('img').style.display = 'none';*/
	}	 
     if (obiekt.style.display == 'block') { 
          obiekt.style.display = 'none';
     } else {
          obiekt.style.display = 'block';
     }
}


// JavaScript Document
function resize(width,height){
	
	var obj={
		'width':Math.round(width),
		'height':Math.round(height),
		'margin':'auto'
	}
	console.log(obj);
	$('#videoPlayer').css(obj);
}

function vcenter(cont,itm,test,h_max){
	var cont_h=cont.height();
	var itm_h=itm.height();
	if(itm_h>cont_h){
		return false;	
	}
	var top=Math.round((cont_h-itm_h)/2);
	var cssObj={
		display:"none",
		position:"relative",
		top:top
	}
	$(itm).css(cssObj);
	$(itm).show();
	
	if(test==true) {
		alert(cont_h+' , '+itm_h);
	}
}

function ajaxPager(href, pager_tag) {
	var showAnim = {}, hideAnim = {}, showSpeed = 'normal', hideSpeed = 'normal';
	
	showAnim['opacity'] = 'show';
	hideAnim['opacity'] = 'hide';
                
	$("#"+pager_tag).ajaxStart(function(){
		var height = $("#"+pager_tag).height();
		
		$(this).empty();
		$(this).html('<div style="text-align: center; position:relative; padding:50px;"><img id="ajax-loader" src="_images/ajax-loader.gif"></div>');
		$('.simpletip').hide(0);
			//$("#"+pager_tag).css('visibility','hidden');
			$("#tresc").css('height',height);
			//$("#"+pager_tag).hide('fast');
			//$("#"+pager_tag).slideUp('fast');
			//$("#"+pager_tag).empty();
		
	});
	
	$.ajax({
		url: href,
		cache: false,
		success: function(html) {
			//$("#"+pager_tag).animate({width:'toggle'},1000);slideDown
			//$("#"+pager_tag).html(html).show(1000);
			//$("#"+pager_tag).empty();
			$("#"+pager_tag).html(html);
			//$("#"+pager_tag).animate(hideAnim, hideSpeed);
			$("#"+pager_tag).animate(showAnim, showSpeed);
			//$("#"+pager_tag).slideDown(1000);
		}
	});
}

$(document).ready(function() {
	$('*[rel=tooltip_pager]').each(function(i){
		var tool_id = $(this).attr('id');
		$(this).simpletip($("#"+tool_id+"_tip").html(), {
			hook: { target: 'topMiddle', tooltip: 'bottomMiddle' } ,
			offset: [0, 0],
			stem: 'bottomMiddle',
			showEffect: 'fade', 
			hideEffect: 'slide'
		});
	});
	
	$(".iframe_comment").colorbox({transition:'elastic', width:"60%", height:"100%", overlayClose:false, iframe:true});
	$(".iframe_test").colorbox({transition:'elastic', width:"960", height:"100%", overlayClose:false, iframe:true});
	$("#program").colorbox({transition:'elastic', speed:400, width:"960", height:"100%", inline:true, href:"#program_szkolenia"});
	$(".single_foto").colorbox();

	$().bind('cbox_open', function(){
        embeds = document.getElementsByTagName('embed');
		for(i = 0; i < embeds.length; i++) {
			embeds[i].style.visibility = 'hidden';
		}
		
		objects = document.getElementsByTagName('object');
		for(i = 0; i < objects.length; i++) {
			objects[i].style.visibility = 'hidden';
		}
	});

	$().bind('cbox_closed', function(){
        embeds = document.getElementsByTagName('embed');
		for(i = 0; i < embeds.length; i++) {
			embeds[i].style.visibility = 'visible';
		}
		
		objects = document.getElementsByTagName('object');
		for(i = 0; i < objects.length; i++) {
			objects[i].style.visibility = 'visible';
		}
	});
	
	$("#all").toggle(
		function() {
		 	$(".dropdown").slideDown("normal");
	 	},
	 	function() {
	 		$(".dropdown").slideUp("normal");
 		}
 	);
 	
 	/*$("#actual_list h3").toggle(
		 function(){$(this).next().next().slideDown("fast");},
		 function(){$(this).next().next().slideUp("fast");}
	);*/
	$("#messages_users").toggle(
		function() {
			$(".messages_users_form").slideDown("normal");
		},
		function() {
			$(".messages_users_form").slideUp("normal");
		}
	);

$("#messages_moderator").toggle(
		function() {
			$(".messages_moderator_form").slideDown("normal");
	 	},
	 	function() {
	 		$(".messages_moderator_form").slideUp("normal");
 		}
	);
	
	$("#messages_techs").toggle(
		function() {
			$(".messages_techs_form").slideDown("normal");
	 	},
	 	function() {
	 		$(".messages_techs_form").slideUp("normal");
 		}
	);
	
	$("#all_prog").toggle(
		function() {
			$(".section").slideDown("normal");
			$("#all_prog").text('zwiń');
	 	},
	 	function() {
	 		$(".section").slideUp("normal");
	 		$("#all_prog").text('rozwiń');
 		}
	);
	$("#actual_list h3").toggle(
		function() {
		 	$(".dropdown").slideDown("normal");
	 	},
	 	function() {
	 		$(".dropdown").slideUp("normal");
 		}
	);	
	$("#mycourses h3").toggle(
		function() {
			$(this).next().slideDown("fast");
	 	},
	 	function() {
	 		$(this).next().slideUp("fast");
 		}
	);
	$(".open").toggle(
		function() {
		 	var empty = $(this).next().children().length;
		 	if(empty!=0) {
		 		$(this).next().slideDown("fast")
	 		};
 		},
 		function() {
 			$(this).next().slideUp("fast");
		}
	);
	var modul = $('#modul').text();
	$('#toggle_'+modul).next().slideDown("fast");

	$("#info_close").toggle(
		 function(){$(this).parent().slideUp("fast");},
		 function(){$(this).parent().slideDown("fast");}
	);
	$(".hover").hover(
		function() {
		 	$(this).fadeTo("normal", 0.7);
	 	},
	 	function() {
	 		$(this).fadeTo("normal", 1);
 		}
 	);
	
	/*$(".matsy img, .hover").hover(
		  function(){$(this).fadeTo("fast", 0.5);},
		  function(){$(this).fadeTo("fast", 1);}
		  );
	*/
	$(".szkolenia").find(".rozwin").toggle(
		 function(){
			 $(".klikniety_szczeg").remove()
			 $(this).after("<div class=\"klikniety_szczeg\"></div>");
	         var id=$(this).parent().find(".rozwin").attr("id");
			 $(".klikniety_szczeg").load("_main/calendar.php?id="+id);
			},
		 function(){$(this).next().remove()}
		 );
	/*$(".szkolenia").hover(
			function(){$(this).fadeTo("fast",0.7)},
			function(){$(this).fadeTo("fast",1)
			}
			
		);	*/	
		
		$(".highlight").hover(
			function(){$(this).addClass("grey")},
			function(){$(this).removeClass("grey")
		}
	);	
	$("#f_closeedi").toggle(
		function(){
			$("#f_new_post_form").slideUp("normal");
			$("#textbox").animate({ 
				top:"-60px",
				right:"-500px"
			}, "fast" );
			$("#f_new_post").animate({ 
				height:"64px"
			}, 600 );
			$("#f_closeedi").text("rozwin edytor");
		},
		function(){
			$("#textbox").animate({ 
				top:"0px",
				right:"0px"
			}, "fast" );
			
			$("#f_new_post").animate({ 
				height:"100%"
			}, 600 );
			
			$("#f_new_post_form").slideDown("fast");
			$("#f_closeedi").text("zwin edytor");
		}
	);
	
	vcenter($("#fla"),$("#fla #img"),false,240);
	
	function menuLeft(){
		var togglers =  $('#art_left li');
		var items = $('#art_left p');
		
		$('#art_left p:first').show();
		$('#art_left p:first').attr('class','show');
		
		togglers.mouseover(function(){
			var section = $(this).find('p');
			items.not(section).slideUp(200);
			items.not(section).fadeOut(200);
			items.not(section).removeClass('show');
			
			if(section.is(':hidden') ) {
				section.slideDown(200);
				section.fadeIn(200);
				section.addClass('show');
			}
		});
	}
	
	$('.matsy img').mouseover(function() {
		$('.matsy dt span').text($(this).attr('alt'));
	});
	
	/* menu_top*/
	$("#menu_top li a img").mouseover(
		function(){
			$(this).next().addClass("mnu_bar_act");
			$(this).next("span.mnu_bar_act").not(".top_act").show(200);
		}
	);
	
	$("#menu_top li a img").mouseout(
		function(){
			$(this).next("span").removeClass("mnu_bar_act");
			$(this).next("span").not(".mnu_bar_act, .top_act").hide(200);
		}
	);
	menuLeft();
	
	//$("#logo").blend({reverse:true});
	

});
