 var IE = document.all?true:false

function print() {
  var content = document.getElementById('printContent').innerHTML;
  var p = window.open('print.html', 'Drukowanie', "width=720, height=600, status=no, scrollbars=yes, resizable=no");
  p.document.open();
  
  var htmlContent = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"+
"<html>"+
	"<head>"+
		"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"+
		"<title>Drukowanie</title>"+
    
		"<script type=\"text/javascript\">var _templates_dir = \"templates/default/\";</script>"+
		
		"<link rel=\"shortcut icon\" href=\"templates/default/gfx/favicon.ico\">"+

		"<script type=\"text/javascript\" src=\"templates/default/js/jquery.js\"></script>"+
  	"<script type=\"text/javascript\" src=\"templates/default/js/swfobject.js\"></script>	"+
		"<script type=\"text/javascript\" src=\"templates/default/js/jquery.swfobject.js\"></script>"+
		"<script type=\"text/javascript\" src=\"templates/default/js/jquery.sifr.js\"></script>"+

	  "<script src=\"templates/default/js/js.js\" type=\"text/javascript\"></script> "+
		"<link type=\"text/css\" href=\"templates/default/style.css\" rel=\"stylesheet\" /> "+
   	"<link rel=\"stylesheet\" href=\"templates/default/sIFR-screen.css\" type=\"text/css\" />"+
		"<script type=\"text/javascript\" src=\"templates/default/js/jquery.rating.js\"></script>"+
		"<link href=\"templates/default/jquery.rating.css\" rel=\"stylesheet\" type=\"text/css\" />"+
		"<script type=\"text/javascript\" src=\"templates/default/js/jquery.filestyle.js\"></script>"+
		"<link href=\"templates/default/shadowbox.css\" rel=\"stylesheet\" type=\"text/css\" />"+
		"<script type=\"text/javascript\" src=\"templates/default/js/shadowbox/shadowbox.js\"></script>"+
        
		"</head>"+
	"<body style=\"background-image:none\"><div class=\"mainWide\" style=\"padding: 0px;width: 700px;\">"+
	  "<div id=\"printContent\" class=\"rightCol\" style=\"padding-left: 0px;\">"+ content + "</div>"+
	"</div></body>"+
"</html>";
  p.document.write(htmlContent);
  p.document.close();
  p.focus();
  p.print();

  //p.getElementById('printContent').innerHTML = content;
}
 
   function SWFDelegate(url,width,height,caption) 
  {
     var objLink = document.createElement('a');
     objLink.setAttribute('href',url);
     objLink.setAttribute('rel','lightbox');
     objLink.setAttribute('title',caption);
     if(typeof width != 'undefined') 
     {
        objLink.setAttribute('width',width);
     }
     if(typeof height != 'undefined') 
     {
        objLink.setAttribute('height',height);
     }
     Shadowbox.open(objLink);
}
function GroupDelegate(id) {
   var objLink = document.getElementById(id);
   Shadowbox.open(objLink);
}

 $(document).ready(function(){
   
	$customCheck = $("input.customC:checkbox");
	$customCheck.wrap('<div class="customCheck customCheckOn"></div>');
	//$customCheck.parent().addClass("customCheckOn");
	
	$customCheck.not(':checked').parent().removeClass("customCheckOn");;
	$customCheck.parent().next().filter("label").click(function(){
		if($(this).prev().hasClass("customCheckOn")) {
			$(this).prev().removeClass("customCheckOn");
			$(this).prev().children().attr("checked","");
		}
		
		else {
			$(this).prev().addClass("customCheckOn");
			$(this).prev().children().attr("checked","checked");
		}
		
	})
	
	
	
	$customCheck.parent().click(function(){
		if($(this).hasClass("customCheckOn")) {
			$(this).removeClass("customCheckOn");
			$(this).children().attr("checked","");
		}
		
		else {
			$(this).addClass("customCheckOn");
			$(this).children().attr("checked","checked");
		}
	}
	)
	$customRadio = $("input.customR:radio");
	$customRadio.wrap('<div class="customRadio"></div>');
	$customRadio.parent().click(function(){
		var atrybut = $(this).children().attr("name");
		$customRadio.filter("input[name='"+atrybut+"']").parent().removeClass("customRadioOn");
		$(this).addClass("customRadioOn");
		$(this).children().attr("checked","checked");
	})	
	
	
	//$(".error").after('<div class="errSign">&nbsp;</div>');
	showErrors();
	
	 $("input[type=file]").filestyle({ 
     image: _templates_dir+"gfx/fileSubmit.png",
     imageheight : 20,
     imagewidth : 101,
     width : 250
 });

	$('#siedziba').flash({ 
		// test.swf is the flash document 
		swf: _templates_dir+'swf/galeria_fr.swf?gateway=/templates/default/amfphp/gateway.php&site_id='+_page_id, 
		height: 200, 
		width: 700 
	});


	
			$('.bTopTitle h2').sifr({ font: _templates_dir+'swf/zapf.swf', version: '3', height: '25',width: '198',fontSize : '16', fontWeight : 'normal', 'color' : '#ffffff', fitExactly : 'true', textTransform : 'uppercase', cursor : 'pointer' });
			$('.bBotTitle h2').sifr({ font: _templates_dir+'swf/zapf.swf', version: '3', height: '25',width: '198',fontSize : '16', fontWeight : 'normal', 'color' : '#333333', fitExactly : 'true', textTransform : 'uppercase', cursor : 'pointer' });			
			
			
			$('h1').sifr({ font: _templates_dir+'swf/zapf.swf', version: '3', height: '25',width: '410',fontSize : '20', fontWeight : 'normal', 'color' : '#ac186c', fitExactly : 'false', textTransform : 'uppercase', cursor : 'pointer' });
			
			$('#bulletin h5').sifr({ font: _templates_dir+'swf/zapf.swf', version: '3', height: '50',fontSize : '20', fontWeight : 'normal', 'color' : '#ac186c', fitExactly : 'false', textTransform : 'uppercase', cursor : 'pointer' });			
			
			
			$('.leftMenuHeader h2').sifr({ font: _templates_dir+'swf/zapf.swf', version: '3', height: '23',fontSize : '17', fontWeight : 'normal', 'color' : '#ffffff', fitExactly : 'true', textTransform : 'uppercase', cursor : 'pointer' });			
		


			$("#index-baner .bTopTitle .clickable").mouseenter(bBotTitleClick);



			
			$("#index-baner .bBotTitle .clickable").mouseenter(bTopTitleClick);			

	
	 });
	 
function showErrors(){$(".errSign").remove();$(".error").after('<div class="errSign">&nbsp;</div>');}  

function showBulletin() {
	pageS = new Array();
	pages = getPageSize();
	pollX = (pages[0]/2)-210+'px';
	$("div#bulletin").css({'left' : pollX});
	$("div#bulletin").css({'top' : document.documentElement.scrollTop + 50 + 'px'});
}
function hideBulletin(){
	$("div#bulletin").css({'top' : '-5000px'});
}














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;
}









function bTopTitleClick(){
		if ($(this).parent().parent().data("pozycja") != "top") {
			
			$(this).parent().parent().children(".botBox").css({
				'position': 'relative',
				'top': '0px'
			});
			$(this).parent().parent().children(".topBox").slideDown("normal", function(){
				$(this).parent().children(".bBotTitle").attr("class", "bTopTitle");
				$(this).parent().children(".bTopTitle:last").attr("class", "bBotTitle");
				var zamianka1 = $(this).parent().children(".bTopTitle").children(".sIFR-replaced").children(".sIFR-alternate").text();
				var zamianka = $(this).parent().children(".bBotTitle").children(".sIFR-replaced").children(".sIFR-alternate").text();
				
				
				
				$(this).parent().children(".bTopTitle").children(".sIFR-replaced").remove();
				$(this).parent().children(".bBotTitle").children(".sIFR-replaced").remove();
				
				$(this).parent().children(".bTopTitle").children(".clickable").before("<h2></h2>");
				$(this).parent().children(".bBotTitle").children(".clickable").before("<h2></h2>");
				
				
				$(this).parent().children(".bTopTitle").children("h2").sifr({
					font: _templates_dir + 'swf/zapf.swf',
					version: '3',
					height: '25',
					fontSize: '16',
					width: '198',
					fontWeight: 'normal',
					'color': '#ffffff',
					fitExactly: 'false',
					textTransform: 'uppercase',
					cursor: 'pointer',
					content: zamianka1
				});
				$(this).parent().children(".bBotTitle").children("h2").sifr({
					font: _templates_dir + 'swf/zapf.swf',
					version: '3',
					height: '25',
					fontSize: '16',
					width: '198',
					fontWeight: 'normal',
					'color': '#333333',
					fitExactly: 'false',
					textTransform: 'uppercase',
					cursor: 'pointer',
					content: zamianka
				});
				
				
				$(this).parent().children(".bTopTitle").children(".sIFR-replaced").children(".sIFR-alternate").text(zamianka);
				$(this).parent().children(".bBotTitle").children(".sIFR-replaced").children(".sIFR-alternate").text(zamianka1);
				
			$(this).parent().data("pozycja", "top");
			});
			
		}
}



function bBotTitleClick() {
	if ($(this).parent().parent().data("pozycja") != "bot"  && $(this).parent().parent().data("pozycja")!=null) {
		$(this).parent().parent().children(".topBox").slideUp("normal", function(){
			var zamianka1 = $(this).parent().children(".bTopTitle").children(".sIFR-replaced").children(".sIFR-alternate").text();
			var zamianka = $(this).parent().children(".bBotTitle").children(".sIFR-replaced").children(".sIFR-alternate").text();
			$(this).parent().children(".bBotTitle").attr("class", "bTopTitle");
			$(this).parent().children(".bTopTitle:first").attr("class", "bBotTitle");
			
			
			
			
			$(this).parent().children(".bTopTitle").children(".sIFR-replaced").remove();
			$(this).parent().children(".bBotTitle").children(".sIFR-replaced").remove();
			
			$(this).parent().children(".bTopTitle").children(".clickable").before("<h2></h2>");
			$(this).parent().children(".bBotTitle").children(".clickable").before("<h2></h2>");
			
			$(this).parent().children(".bTopTitle").children("h2").sifr({
				font: _templates_dir + 'swf/zapf.swf',
				version: '3',
				height: '25',
				fontSize: '16',
				width: '198',
				fontWeight: 'normal',
				'color': '#ffffff',
				fitExactly: 'false',
				textTransform: 'uppercase',
				cursor: 'pointer',
				content: zamianka1
			});
			$(this).parent().children(".bBotTitle").children("h2").sifr({
				font: _templates_dir + 'swf/zapf.swf',
				version: '3',
				height: '25',
				fontSize: '16',
				width: '198',
				fontWeight: 'normal',
				'color': '#333333',
				fitExactly: 'false',
				textTransform: 'uppercase',
				cursor: 'pointer',
				content: zamianka
			});
			
			
			$(this).parent().children(".bTopTitle").children(".sIFR-replaced").children(".sIFR-alternate").text(zamianka1);
			$(this).parent().children(".bBotTitle").children(".sIFR-replaced").children(".sIFR-alternate").text(zamianka);
			$(this).parent().children(".botBox").css({
				'position': 'absolute',
				'top': '80px',
				'left': '0px'
			});
			
		$(this).parent().data("pozycja", "bot");
		});
		
	}
}
function toggle(div_id) {
    var el = document.getElementById(div_id);
    if ( el.style.display == 'none' ) {    el.style.display = 'block';}
    else {el.style.display = 'none';}
}
function closePopup(div_id) {
    var el = document.getElementById(div_id);
    el.style.display = 'none';
}
function blanket_size(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportheight = window.innerHeight;
    } else {
        viewportheight = document.documentElement.clientHeight;
    }
    if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
        blanket_height = viewportheight;
    } else {
        if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
            blanket_height = document.body.parentNode.clientHeight;
        } else {
            blanket_height = document.body.parentNode.scrollHeight;
        }
    }
    var blanket = document.getElementById('blanket');
    blanket.style.height = blanket_height + 'px';
    var popUpDiv = document.getElementById(popUpDivVar);
    popUpDiv_height=blanket_height/2-150;//150 is half popup's height
    popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportwidth = window.innerHeight;
    } else {
        viewportwidth = document.documentElement.clientHeight;
    }
    if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
        window_width = viewportwidth;
    } else {
        if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
            window_width = document.body.parentNode.clientWidth;
        } else {
            window_width = document.body.parentNode.scrollWidth;
        }
    }
    var popUpDiv = document.getElementById(popUpDivVar);
    window_width=window_width/2-309;//430;//150 is half popup's width
    popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
    blanket_size(windowname);
    window_pos(windowname);
    toggle('blanket');
    toggle(windowname);
    setTimeout("closePopup('popUpDiv');closePopup('blanket');",5000);
     
    //setTimeout("closePopup('blanket');",5000); 
    
}