var IE = document.all?true:false

function live() {

  noweOkno = window.open('live.html', 'Relacja na żywo', 'menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=no, status=no,width=800, height=600');
   
}

function changeFilmClass(id) {
  var li=document.getElementsByTagName('li');
  for(i=0;i<li.length;i++) { 
    if (li[i].className=="playing" || li[i].className=="notplaying") {
      li[i].className="notplaying";
    }
  }
  var obj=document.getElementById('filmId_'+id);
  if (obj) {
    obj.className='playing';
  }
}

function showCommentBox(id) {
  document.getElementById('commentId').value=id;
  InitPageFade(1);
  AddComment(1);
}

function InitLightbox() {
		$("a[rel='lightbox']").lightBox({
			overlayBgColor: '#223345',
			overlayOpacity: 0.8,
			imageLoading: _templates_dir+'images/loading.gif',
			imageBtnClose: _templates_dir+'images/close.gif',
			imageBtnPrev: _templates_dir+'images/prev.gif',
			imageBtnNext: _templates_dir+'images/next.gif',
			containerResizeSpeed: 350,
			txtImage: 'Obrazek',
			txtOf: 'z'

	}); 	
	
}


$(document).ready(function(){
	
	
	$("#menu").hover(
      function () {
        $('#menu-flash').css("height","180px");
      }, 
      function () {
        $('#menu-flash').css("height","26px");
      }
    );

	
	$(document).pngFix();
	$('.commercial').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});		
	$('.commercial').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	
    $("#default-usage-select").selectbox();
	InitLightbox();
	$("ul.aktualnosci li").hover(
		function(){
			$(this).css('background-position','left top');
			$(this).find(".header .data").css('color','#b4c3d0');
			$(this).find(".cont span.comments").css('color','#b4c3d0');
			$(this).find(".cont .txt").css('color','#d6dbe0');
		},
		function(){
			$(this).css('background-position','left 1000px');
			$(this).find(".header .data").css('color','#999999');
			//$("ul.aktualnosci li .cont span.comments").css('color','#b4c3d0');
			$(this).find(".cont .txt").css('color','#666666');
		}
	)
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
	if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}


	$(".comments span.toggle").toggle(
	function(){
		$(this).html("zwiń<img src=\""+_templates_dir+"gfx/blue-arrow.png \" />");
		$(".comments ul").slideDown();
	},
	function(){
		$(this).html("rozwiń<img src=\""+_templates_dir+"gfx/blue-arrow-down.png \" />");
		$(".comments ul").slideUp();
	}	
	)

	$(".comments a.add-comment").click(function() {
		InitPageFade(1);
		AddComment(1);
	})
	$("div#AddComment input.reset").click(function() {
		InitPageFade(0);
		AddComment(0);
	})
	$("#PollBox .submit a").click(function() {
		InitPageFade(0);
		document.getElementById('PollBox').style.display = "none";
	})
$('#Trophies a').tooltip({     
track: true,     
delay: 0,     
showURL: false,     
showBody: " - ",     
fade: 250 });

});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};



function Live(){
	
	window.open("live.html","Relacja",'menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=no,status=no,width=800,height=600'); 
	
}


function ShowPollResults(){
	InitPageFade(1);
		pageS = new Array();
		pages = getPageSize();
		CommentBox = (pages[0]/2)-200+'px';
		document.getElementById('PollBox').style.left = CommentBox;
		if(IE)
		document.getElementById('PollBox').style.top = document.documentElement.scrollTop + 10 + 'px';
		else 
		document.getElementById('PollBox').style.top = window.pageYOffset + 10 + 'px';					
		document.getElementById('PollBox').style.display = "block";	
}


function InitPageFade(c) {
	if (c) {
		pageS = new Array();
		pages = getPageSize();
		document.getElementById('mediaPlayer').style.visibility = "hidden";
		document.getElementById('PageFade').style.height = pages[1] + 'px';
		document.getElementById('PageFade').style.display = "block";
	}
	else {
		document.getElementById('PageFade').style.display = "none";
		document.getElementById('mediaPlayer').style.visibility = "visible";
	}
}
function AddComment(action) {
	if (action) {
		pageS = new Array();
		pages = getPageSize();
		CommentBox = (pages[0]/2)-200+'px';
		document.getElementById('AddComment').style.left = CommentBox;
		if(IE)
		document.getElementById('AddComment').style.top = document.documentElement.scrollTop + 100 + 'px';
		else 
		document.getElementById('AddComment').style.top = window.pageYOffset + 100 + 'px';					
		document.getElementById('AddComment').style.display = "block";
	}
	else {
		document.getElementById('AddComment').style.display = "none";
	}
}
function getPageSize(){
  var xScroll, yScroll;
  if (window.innerHeight && window.scrollMaxY) {
     xScroll = document.body.scrollWidth;
     yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
     xScroll = document.body.scrollWidth;
     yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
     xScroll = document.body.offsetWidth;
     yScroll = document.body.offsetHeight;
  }
  var windowWidth, windowHeight;
  if (self.innerHeight) {   // all except Explorer
     windowWidth = self.innerWidth;
     windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
     windowWidth = document.documentElement.clientWidth;
     windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
     windowWidth = document.body.clientWidth;
     windowHeight = document.body.clientHeight;
  }
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
     pageHeight = windowHeight;
  } else {
     pageHeight = yScroll;
  }
  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth){
     pageWidth = windowWidth;
  } else {
     pageWidth = xScroll;
  }
  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
  return arrayPageSize;
}