var Clock_Days = new Array("Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota");
var Clock_Months = new Array("stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia");

function Clock_StepIt(clockID){
	window.setTimeout("Clock('"+clockID+"');", 1000);
}

function Clock(clockID){
	var tDate = new Date();
	wd = tDate.getDay();
	d = tDate.getDate();
	m = tDate.getMonth();
	y = tDate.getFullYear();
	h = tDate.getHours(); if (h<10) {h = "0"+h;}
	i = tDate.getMinutes(); if (i<10) {i = "0"+i;}
	s = tDate.getSeconds(); if (s<10) {s = "0"+s;}
	
	outp = Clock_Days[wd]+', '+d+' '+Clock_Months[m]+' '+y+' &nbsp; '+h+':'+i+'.'+s;
	document.getElementById(clockID).innerHTML = outp;
	
	Clock_StepIt(clockID);
}

function Sys_stripURL(url){
	url = url.split('?');
	url = url[0];
	return url;
}


function Sys_add2Favorites(){
	var location = document.location.href;
	location = Sys_stripURL(location);
	window.external.AddFavorite(location, document.title);
}


function Sys_setHomePage(obj){
	var location = document.location.href;
	location = Sys_stripURL(location);
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage(location);
}

function PopupImage(url){
	window.open('images.php?mode=show&url='+url,'_blank',"menubar=no,location=no,resizeable=no,scrollbars=auto,status=no,width=400,height=200");
}

function OpenClearWnd(url,w,h,scroll){
	window.open(url, "_blank", "menubar=no,location=no,resizeable=no,scrollbars="+scroll+",status=no,width="+w+", height="+h);
}


function StartNewsBar()
{
	$(document).ready(function()
	{
		newsbar_current = -1;
		newsbar_max = $("#newsBar .article_preview").length-1;
		$("#newsBar .article_preview").hide();
		
		StartNewsBarCycle();
	});
}

function StartNewsBarCycle()
{
	$("#newsBar .article_preview:eq("+newsbar_current+")").hide('slow');
	newsbar_current++;
	if (newsbar_current>newsbar_max){ newsbar_current = 0; }
	$("#newsBar .article_preview:eq("+newsbar_current+")").show('slow');
	
	window.setTimeout(function(){ StartNewsBarCycle(); }, 5000);
}


function JQPopupImage(src)
{
	$.fn.colorbox({href: src, photo: true, scalePhotos: true, maxWidth: '950px', maxHeight: '100%', close: 'Zamknij'});
	return false;
}


$(document).ready(function()
{
	$("#tiles .images").ScrollBox({orientation: 'h', speed: 25, nextLnk: '#tiles .navigation a.prev', prevLnk: '#tiles .navigation a.next', container: '#tiles .images .group', box: '#tiles .images .group .gallery_tile'});
	$("#tiles .images .group img").click(function()
	{
		t = $(this).attr('title');
		d = $(this).attr('alt');
		s = $(this).attr('rel');

		$(".gallery_thumb_infodiv").fadeOut(600, function()
		{
			$(".gallery_thumb_title").text(t);
			$(".gallery_thumb_description").text(d);
			$(".gallery_thumb_infodiv").fadeIn(600);
		});
		
		
		$(".gallery_thumb img").fadeOut(600, function()
		{
			$(".gallery_thumb img").load(function(){ $(".gallery_thumb img").fadeIn(600); });
			$(".gallery_thumb img").click(function(){ JQPopupImage(s); return false; });
			$(".gallery_thumb img").attr('src',"images.php?mode=scaled&mw=425&mh=283&url="+s);
		});
		return false;
	}
	); 
});
