/*
var startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("pojFlashMenu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
				this.className+=" over";
				}
				node.onmouseout=function() {
				this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
*/



/* funckaja pomocnicza */
	function $$(sIdName){
			return document.getElementById(sIdName);
	}


/* sterowanie menu we flashu */
	$('#pojMenu').css('overflow','hidden');
	function FflashHideDiv(){
			$('#topSocialNetworksIcon').css('z-index','4000');	
			$('#pojTopRight').css('z-index','4000');
			$('#pojTresc').css('z-index','4000');
			$('#pojMenu').css('height','52px');
			$('#pojFlashMenu').css('height','52px');
	}

	function FflashShowDiv(){
			$('#topSocialNetworksIcon').css('z-index','-1');	
			$('#pojTopRight').css('z-index','-1');
			$('#pojTresc').css('z-index','-1');
			$('#pojMenu').css('height','190px');	
			$('#pojFlashMenu').css('height','400px');
	}
	
	function onBTmenuOutRollOutJs(){
			if($$('flashMenu'))
					$$('flashMenu').onBTmenuOutRollOut();
	}

	
/* rozwijanie / zwijanie boksow */
	function fShowHideBox(sElementId){
			$('#'+sElementId).toggle();
	}
	
/* zaladowanie klasy popupu */
	$(document).ready(function() {
			$('#pojFotoMax')
					.jqm({
							overlay: 50,
							onShow: function(h) {
								h.w.slideDown(); 
								},
							onHide: function(h) {
								h.w.slideUp("slow",function() { if(h.o) h.o.remove(); }); } 
					});
/*
			var sSwfMenu = 'swf/menu.swf';

			if( sLangPrefix == 'cz,' || sLangPrefix == 'hu,' || sLangPrefix == 'ro,' || sLangPrefix == 'sk,' ){
					sSwfMenu = 'swf/menu_condensed.swf';
			}
			if( sLangPrefix == 'ru,' || sLangPrefix == 'ua,'  ){
					sSwfMenu = 'swf/menu_cyrylica.swf';
			}
		
			var swf01 = new SWFObject( sSwfMenu+"?flashVersion=4", "flashMenu", "520", "100%", "8", "#ffffff");
			swf01.addParam("quality", "high");
			swf01.addParam("wmode", "transparent");
			swf01.addParam("menu", "false");
			swf01.addParam("FlashVars","&szId={$aContent.IdPath}&szXmlFile=menu.xml&szXmlFilesVersion=?2");
			swf01.write("pojFlashMenu");
*/			
			$('#LangSwitcher').change( function() {
				if ( $(this).val() ){
					location.href = $(this).val();
				}
			});

			// obsluga zewnatrznych linkow
			$('a.external').click( function(){	window.open(this.href,'_blank'); return false;})
			
			// LIGHTBOX
			
			if($('a.lightbox').length || $('a.lightboxArrangements').length || $('a.lightboxMaterials').length){
			
				var oLightBoxSettings = {
						imageBtnNext: 				'images/lightbox_next.gif',
						imageBtnPrev: 				'images/lightbox_prev.gif',
						txtBtnClose:				sLBCloseText,
						txtBtnSave:					sLBSaveText
				};
				
			}
			
			if($('a.lightbox').length){			
					$('a.lightbox').lightBox(oLightBoxSettings);		
			}
			
			if($('a.lightboxArrangements').length){				
					$('a.lightboxArrangements').lightBox(oLightBoxSettings);			
			}
			
			if($('a.lightboxMaterials').length){				
					$('a.lightboxMaterials').lightBox(oLightBoxSettings);			
			}
			
			//galeria
			/*
			$('.boxGallery  a').lightBox({
				fixedNavigation: true,
				overlayBgColor: '#FFF'
			});
			*/
			
			// base64 dla linkow z rozszerzeniem pdf (wymuszanie plikow do pobrania)
			$("a").each(function(){
				
					var sLinkHref = $(this).attr('href');
					
					if(undefined != sLinkHref){
						
							if(sLinkHref.match(/^files\/(.+)\.pdf$/g)){
									var sBase64LinkHref = base64.encode(sLinkHref);
									$(this).attr('href','download_file_'+sBase64LinkHref);
							}
					
					}
					
			});// $("a").each(function()
			
			
			
	});


/* pokazanie popupu ze zdjeciem */
	function fShowMax(sFoto,sDescription){
		
			if(!sDescription)
					sDescription = '';
		
			tb_show( '', 'index.php?xml=true&sXmlElement=Content&height=560&width=650&sModul=mpopupfoto&sFoto='+sFoto+'&sDescription='+sDescription);
		
		
		
		
			/*$('#pojLoading').show();
			$('#pojF').hide();
			$('#pojF').html('<img src="_libs/phpThumb/phpThumb.php?src=../../'+sFoto+'&wl=650&hp=650&amp;q=80&amp;f=jpg" alt="" />');
			$('#pp_save').attr({ href: sFoto });
			$('#pojFotoMax').jqmShow();
			
			$('#pojF img').load(function(){ $('#pojLoading').hide();$('#pojF').show();})*/
			
	}
	
/* wyslanie formularza kontaktowego */
	function sendKontakt(){
			document.forms['formKontakt'].submit();
	}

/* wyslanie formularza */
	function fSendForm(sFormName){
			document.forms[sFormName].submit();
	}
	
/* pokazanie formularza przypominania hasla */
	function showFormRemind(){
			$('#pojRemindPass').show();
			
			// wyrenderowanie sifra
			//fSifrRender();
	}		
	
/* wyslanie formularza przypominania hasla */
	function sendFormRemind(){		
			var options = {
	    		dataType: 'xml',
	    		success: function(oXml) {
	       			$("#pojRemindPassContent").html($(oXml).find('Content').text());
		   		}
			};
			$('#formPrzypomnij').ajaxSubmit(options);		
	}
	
$(document).ready(
	function()
	{
		// fix for target="_blank"
		$("a[@rel~='external']").click(function(){
			window.open($(this).attr("href"));
			return false;
		});

		// fix for too long email address 
        $(".pojAddressOne a[@href~='mailto']").each(function(){
            if ( $(this).width() > 160 )
            {
                var aItems = $(this).html().split('@');
                $(this).html( aItems[0] + '<br/>@' + aItems[1] );
            }
        });
	}
);
