﻿var pat = window.location.href.match((/((.+)?\/([^\/\\]+))?\.(html|php)([\?](.+)?(id=([0-9]{1,2})))?/));

$=jQuery.noConflict();
$(document).ready(function() {
  $("#image_rotate").innerfade( {
  	speed: "medium",
  	timeout: 4000,
  	type: "sequence"
  	});
  //Pause the slidershow with clearInterval
  $("#btn-pause").click(function () {
    clearInterval(run);
    return false;
  	});
  //Continue the slideshow with setInterval
  $("#btn-play").click(function () {
    run = setInterval("newsscoller(0)", speed);
    return false;
  	});
  //Next Slide by calling the function
  $("#btn-next").click(function () {
  	newsscoller(0);
  	return false;
  	});
  //Previous slide by passing prev=1
  $("#btn-prev").click(function () {
  	newsscoller(1);
  	return false;
  	});

	run = setInterval("newsscoller(0)", speed);

  //Mouse over, pause it, on mouse out, resume the slider show
  $("#news").hover(
  function() {
      clearInterval(run);
      $('#buttons').stop(false,true).animate({bottom:0},{duration:200, easing: style});
		},
		function() {
			run = setInterval("newsscoller(0)", speed);
			$('#buttons').stop(false,true).animate({bottom:-50},{duration:200, easing: style});
		}
	);
  spr();
});

function spr()
{

//	C_LEFT
if(16*screen.height/screen.width>9)
	proc=0.3;
else
	proc=0.23;
szer_rob=(($("#c_left").width()+$("#c_right").width())*proc);


if(2*(szer_rob*(254/388)+34)>$(window).height()-$("#head").height()-$("#foot").height()-$("#nagl").height() )
	szer_dod=((2*(szer_rob*(254/388))+34)-($(window).height()-$("#head").height()-$("#foot").height()-$("#nagl").height()))*(388/254);

spr_tabs();

if($(window).height()<$(window).width()*(254/388))
	wys_rob=($("#tabs").height())/2+$(".podpis").height();
else
	wys_rob=$(window).width()*proc;
$("#c_left").css("width",wys_rob);
$("#c_left").css("height",wys_rob*(254/388));

$("#c_left").css("width",wys_rob);
$("#c_left").css("height",wys_rob*(254/388));

$(".podpis, #nagl").css("font-size",wys_rob*(254/388)/8);

win_h=$("#win_left img").height();
win_w=$("#win_left img").width();
$("#t_tresc").html("w_h="+($(window).height())+"\nw_w="+($(window).width()));

	$("#win_left img").width($(window).width()*.3);
	$("#win_left img").height((($(window).width()*.3)*win_h)/win_w);

$("#foot").css("font-size",wys_rob*(254/388)/16);
$("#imieniny").css("font-size",wys_rob*(254/388)/13);
//	TLO IMIENINY
$(".tlo").css("height",$(".tlo").next().height());

$("#radioset, #win_left").css("height",($("#win_left img").height())+"px");
$("#radioset input").css("font-size",($(window).width()*.014)+"px");
$("#radioset input").css("padding",($(window).height()*.001)+"px "+($(window).height()*.0036)+"px");
$("#radioset p").css("top",($("#radioset").height()-$("#radioset p").height())+"px");
$("#win_left").width("100%");//$(window).width()-$("#radioset").width());

$("#image_rotate").css("height",wys_rob*(254/388));
$(".slider").css("width",wys_rob);
$(".slider").css("height",wys_rob*(254/388));
$(".slider").css("background-size","100% 100%");

$("#news, #gallery, #mask-gallery").width(wys_rob);
$("#news, #gallery, #mask-gallery").height(wys_rob*(254/388));
$("#mask-excerpt, #excerpt li").width(wys_rob);

$("#mask-excerpt, #excerpt li").css("height",(70*($(window).height()/867))+"px");
$("#mask-excerpt, #excerpt li").css("font-size",(11*($(window).height()/867))+"px");
$("#mask-excerpt, #excerpt li").css("top",wys_rob*(254/388)-70*($(window).height()/867));

$("#mask-gallery, #gallery li").width(wys_rob);
$("#gallery").width(wys_rob * $("#gallery li").length);
$("#mask-gallery, #gallery li").height(wys_rob*(254/388));

$("#buttons").css("height",($("#news").height()*(70/282))+"px");
$("#buttons").css("top",(-50*($(window).height()/867)-$("#buttons").height())+"0px");

//spr_tabs();
$(".tlo").css("width",($("#radioset").width()));

if(pat==5)
	{
	$("#mapka").width("100%");
	$("#mapka").height($("#tresc").height()-100);
	}
$("#tresc font").css("font-size",wys_rob*(254/388)/12);
}

function spr_tabs()
{
//	C_RIGHT
if($("#tresc :first-child").height()>$(window).height()-$("#head").height()-$("#foot").height()-$("#nagl").height() || (pat!=null && pat[8]==3))
	$("#tresc").css("overflow-y","scroll");
else
	$("#tresc").css("overflow","hidden");

//*
if($(".editableToolbar").is(":visible"))
	$("#tresc").height($(window).height()-$("#head").height()-$("#foot").height()-$("#nagl").height()-$(".editableToolbar").height()-65).css("padding","10px");
else
	$("#tresc").height($(window).height()-$("#head").height()-$("#foot").height()-$("#nagl").height()-65).css("padding","10px");
//*/

$("#tabs").addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").css("padding","3px").children(":first-child").addClass("ui-widget-header ui-corner-all").css("padding","0px").css("text-align","center");
}


