globalQuery=query=document.location.href.split(".pl");

if (globalQuery[1]=="/wizytownik.html") {
	globalQuery="datatype=5&query=&ptype=2";
} else if (globalQuery[1]=="/mapa.html") {
	globalQuery="datatype=7&query=";
} else if (globalQuery[1]=="/ogloszenia.html") {
	globalQuery="datatype=6&query=";
} else if (globalQuery[1]=="/galerie.html") {
	globalQuery="datatype=1&query=";
} else if (globalQuery[1]=="/grupy.html") {
	globalQuery="datatype=3&query=";
} else if (globalQuery[1]=="/uzytkownicy.html") {
	globalQuery="datatype=5&query=&ptype=1";
} else if (globalQuery[1]=="/wydarzenia.html") {
	globalQuery="datatype=4&query=";
} else if (globalQuery[1]=="/artykuly.html") {
	globalQuery="datatype=2&query=";
} else {
	globalQuery="";
}




/* #################  main js  ################# */
	function IncludeJavaScript(jsFile) { document.write('<script type="text/javascript" src="'+ jsFile + '"></script>'); }

	// hide error
	function handleError() { return true; }
	window.onerror = handleError;
	
    function showlayer(layer){ //digglike select
		var myLayer=document.getElementById(layer);
		if(myLayer.style.display=="none" || myLayer.style.display==""){
			myLayer.style.display="block";
		} else { 
			//myLayer.style.display="none";
			}
	}
    
    $(document).ready(
	    function()
	    {             
		    var browser=navigator.appName;
		    if (browser=="Microsoft Internet Explorer") { 
		    	 $("#small_society").css("position","relative");
		    	 $("#small_article").css("position","relative");
		    	 $("#small_event").css("position","relative");  
		    	 $("#small_gallery").css("position","relative");  
		    	 $("#small_advert").css("position","relative");  
		    	 $("#small_company").css("position","relative");  
		    } else { 
		        $("#small_society").css("position","absolute");
		        $("#small_article").css("position","absolute");
		         $("#small_event").css("position","absolute");
		         $("#small_gallery").css("position","absolute");
		         $("#small_advert").css("position","absolute");
		         $("#small_company").css("position","absolute");
		    }
		    $("#mainMenuSociety").bind("mouseenter",function(){
                  showlayer('small_society');
		        }).bind("mouseleave",function(){
		          hidelayer('small_society');
		        });
		
		    $("#mainMenuArticle").bind("mouseenter",function(){
		        }).bind("mouseleave",function(){
		          hidelayer('small_article');
		        });
		    $("#mainMenuEvent").bind("mouseenter",function(){
		        }).bind("mouseleave",function(){ 
		          hidelayer('small_event');
		        });	
		    $("#mainMenuGallery").bind("mouseenter",function(){
		        }).bind("mouseleave",function(){ 
		          hidelayer('small_gallery');
		        });	
		    $("#mainMenuAdvert").bind("mouseenter",function(){
		        }).bind("mouseleave",function(){ 
		          hidelayer('small_advert');
		        });	
		    $("#mainMenuCompany").bind("mouseenter",function(){
		        }).bind("mouseleave",function(){ 
		          hidelayer('small_company');
		        });	
            
            
	      $('textarea').keyup(function(){ 
		      if($(this).val().length > $(this).attr('maxl')){ 
		     	 $(this).val($(this).val().substr(0, $(this).attr('maxl'))); 
		      }
	      });  

	      if ($.browser.msie && $.browser.version<7) {
				fixPng(jQuery(this).find(".artt *"));
	      }
	      

		$('.handok').hover(function (e) {
			$(this).children('img').attr('src','images/ok2.png');
		},function (e) {
			$(this).children('img').attr('src','images/icon/ok.gif');			
		});	
		$('.handbad').hover(function (e) {
			$(this).children('img').attr('src','images/bad2.png');
		},function (e) {
			$(this).children('img').attr('src','images/icon/bad.gif');			
		});	      
	      
	    }
	);

	function fixPng(selector) {
      	selector.each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});		
	}
	
    function hidelayer(layer) {
        var myLayer=document.getElementById(layer);
        if(myLayer) myLayer.style.display="none";
    }
	function setSearchOption(optionId,optionValue) {
		document.getElementById(optionId).value=optionValue;
	}
	var varSetInterval;
	
	function invite(login,user_id,photo) {
		$('#getMessageBox').modal();
		changeData('getMessageBox','Message','getLiveMessageForm',login,user_id,photo);
	}
	
	function sendMessage(login,user_id) {
		$('#getMessageBox').modal();
		changeData('getMessageBox','Message','getLiveMessageFormSend',login,user_id,null);
	}	
	
	$(document).ready(function () {	
		var tooltipTime=0;
//		$('.sTab').click(function (e) {
//			$(this).parent().children(".sTab").removeClass("selected");
//			$(this).addClass("selected");
//		});	
//		$('.menuItem').hover(function (e) {
//			$(this).children(".leftcap").addClass("leftcapselected");
//			$(this).children(".rightcap").addClass("rightcapselected");
//			$(this).children(".mainMenu").addClass("mainMenuselected");
//		},function (e) {
//			$(this).children("span").removeClass("leftcapselected");
//			$(this).children("span").removeClass("rightcapselected");
//			$(this).children("span").removeClass("mainMenuselected");
//			$(this).children("a").removeClass("leftcapselected");
//			$(this).children("a").removeClass("rightcapselected");
//			$(this).children("a").removeClass("mainMenuselected");
//		});
//		
//		$('.menuItemSec').hover(function (e) {
//			$(this).children(".leftcap").addClass("leftcapselected");
//			$(this).children(".rightcap2").addClass("rightcapselected2");
//			$(this).children(".mainMenu").addClass("mainMenuselected");
//		},function (e) {
//			$(this).children("span").removeClass("leftcapselected");
//			$(this).children("span").removeClass("rightcapselected2");
//			$(this).children("span").removeClass("mainMenuselected");
//			$(this).children("a").removeClass("leftcapselected");
//			$(this).children("a").removeClass("rightcapselected");
//			$(this).children("a").removeClass("mainMenuselected");
//		});	
//		$('.area').hover(function (e) {
//			$(this).addClass("areaselected");
//		},function (e) {
//			$(this).removeClass("areaselected");
//		});		
//		
//		$('.indexing1').hover(function (e) { $(this).removeClass("nonS"); $(this).addClass("mouseS"); $(this).prev("div").removeClass("nonSL"); $(this).prev("div").addClass("mouseSL"); $(this).next("div").removeClass("nonSR"); $(this).next("div").addClass("mouseSR");
//		},function (e) { $(this).removeClass("mouseS"); $(this).addClass("nonS");$(this).prev("div").removeClass("mouseSL");$(this).prev("div").addClass("nonSL"); $(this).next("div").removeClass("mouseSR"); $(this).next("div").addClass("nonSR");	});		
//		
		$('.userTT').hover(function (e) {
			$(".userTT").parent('span').children('.userToolTip').hide();
			clearTimeout(tooltipTime);
			if ($(this).parent("span").children(".userToolTip").css("display")=="none") {
				$(this).parent("span").children(".userToolTip")
					.css("top",(e.pageY-40) + "px")
					.css("left",(e.pageX-5) + "px")
					.fadeIn("fast");	
//					alert(e.pageX);			
			}
		},function (e) {
			tooltip=this;
			tooltipTime=setTimeout("$(tooltip).parent('span').children('.userToolTip').hide();",3000);
		});		
		
		$('.helpTT').hover(function (e) {
			$(".helpTT").parent("span").children('.helpToolTip').hide();
			clearTimeout(tooltipTime);
			if ($(this).parent("span").children(".helpToolTip").css("display")=="none") {
				var height = $(this).parent("span").children(".helpToolTip").height();
				$(this).parent("span").children(".helpToolTip")
					.css("top",(e.pageY-height-25) + "px")
					.css("left",(e.pageX-5) + "px")
					.fadeIn("fast");				
			}
		},function (e) {
      tooltip=this;
			tooltipTime=setTimeout("$(tooltip).parent(\"span\").children('.helpToolTip').hide();",500);
		});				

//		var imgMenu = []; 
//			imgMenu[0] = new Image();
//	        imgMenu[0].src = "images/lCapS.jpg";
//	        imgMenu[1] = new Image();
//	        imgMenu[1].src = "images/rCapS.jpg";	
//	        imgMenu[2] = new Image();
//	        imgMenu[2].src = "images/rCapS2.jpg";
//	        imgMenu[3] = new Image();
//	        imgMenu[3].src = "images/areaBgS.gif";	
//	        imgMenu[4] = new Image();
//	        imgMenu[4].src = "images/thisweek1.gif";	
//	        imgMenu[5] = new Image();
//	        imgMenu[5].src = "images/thismonth1.gif";		
//
	}); 
	

function validateMessage(form, cont, noreceiver){
	var receiver_id = true;
    if(cont == '') receiver_id = false;
    //alert(form+" "+ cont+ " "+ noreceiver);
	//uzupelnic string z loginami odbiorcow
	if(form.elementFrom.value == 'MESSAGE') {
		 if(receiver_id) {
            form.receiver.value = cont;
         } else {
			form.receiver.value = '';
			
			var friendElement = document.getElementById('newMsgFriend');
			var Friends = friendElement.getElementsByTagName('div');
			var added = 0;
			for(i = 0; i < Friends.length; i++){
				if(Friends[i].className == 'SelectedFriend'){
					form.receiver.value += Friends[i].firstChild.firstChild.firstChild.firstChild.nodeValue+';';
					added++;
				}
			}
			if(added != 0)form.receiver.value = form.receiver.value.substring(0,form.receiver.value.length-1);
         }

		form.topic_text.style['background'] = '#FFFFFF';
		
		if(form.topic_text.value.length == 0){
			form.topic_text.style['background'] = '#7DFA0A';
			return false;
		}
		if(form.receiver.value.length == 0){
			alert(noreceiver);
			return false;
		}
		return true;
	}
	if(form.elementFrom.value == 'INDEX'){
		form.topic_text.style['background'] = '#FFFFFF';
		
		if(form.topic_text.value.length == 0 && form.kind[0].checked){
			form.topic_text.style['background'] = '#7DFA0A';
			return false;
		}
		if(form.kind[1].checked){
			form.topic_text.value = 'Zaproszenie';
		}
		return true;
	}
	return false;
}

IncludeJavaScript('javascript/login.js');
IncludeJavaScript('javascript/moreless.js');
//Dialog
IncludeJavaScript('javascript/jquery.simplemodal.js');
IncludeJavaScript('javascript/jquery.simplemodal.basic.js');

function clearEventTab(dwm,cat) {
  document.getElementById('eventTemp_'+cat).style.display='none';
  document.getElementById('eventType'+dwm+cat).style.display='block';
}
function changeEventTab(id,page,area) {
  el = document.getElementById('eventType'+id);
  obj = el.parentNode.lastChild;
  if(page == 0) { 
    el.style.display = 'block';
    obj.style.display = 'none';
    $(".eventload2").css("display","block");
    return true;
    }
  if(el.id != obj.id) {
    //el.style.display = 'none';
    //obj.style.display = 'block';
  }
  changeData(obj.id,'LastAdded','showEventTabs',id,page,area);
}


/* ################# end main js... ################# */
	
function markAsActive(optionId) {
	
	$('.sTab').removeClass('selected');
	$('#searchItem'+optionId).addClass('selected');
	/*for (i=0;i<8;i++) {
		alert('searchItem'+i);
		document.getElementById('searchItem'+i).style=background="white";
	}
	document.getElementById('searchItem'+optionId).style=background="red";*/
}

function checkPeriod(List) {
  if (List.options[List.selectedIndex].value == '0') {
    List.style.borderColor = '#cccccc';
    document.getElementById('period').style.display="none";
  }
  else document.getElementById('period').style.display="block";
}

function checkProfile(List) {
  if (List.options[List.selectedIndex].value == '3') {
    document.getElementById('sex').style.display="none";
    document.getElementById('companycategory').style.display="inline";
    document.getElementById('street').style.display="inline";
    document.getElementById('city').style.display="inline";
    document.getElementById('companyName').style.display="inline";
    document.getElementById('desc').style.display="inline";
	$("#name_fc").html("Nazwa Instutuacji:");
	$("#name_fc2").html("Nazwa twojej instytucji.");
	$("#category_fc").html("Wybierz kategorie do której należy instutucja.");
	$("#desc_fs").html("Krótko opisz swoją instutucje.");
  } else if (List.options[List.selectedIndex].value == '2') {
    document.getElementById('sex').style.display="none";
    document.getElementById('companycategory').style.display="inline";
    document.getElementById('street').style.display="inline";
    document.getElementById('city').style.display="inline";
    document.getElementById('companyName').style.display="inline";
    document.getElementById('desc').style.display="inline";
	$("#name_fc").html("Nazwa firmy:");
	$("#name_fc2").html("Nazwa twojej firmy.");
	$("#category_fc").html("Wybierz kategorie do której należy twoja firma.");
	$("#desc_fs").html("Krótko opisz swoją firmę.");
  }  else {
  	document.getElementById('sex').style.display="inline";
  	document.getElementById('companycategory').style.display="none";
  	document.getElementById('street').style.display="none";
  	document.getElementById('city').style.display="none";
    document.getElementById('companyName').style.display="none";
    document.getElementById('desc').style.display="none";
  }
}

function checkCity(List) {
  if (List.options[List.selectedIndex].value == '3') {
    document.getElementById('city').value="";
    document.getElementById('city').readOnly = false;
  }
  else {
    document.getElementById('city').value="Rzeszów";
    document.getElementById('city').readOnly = true;
  }
}

function checkCityy() {
  if (document.getElementById('city').value=="Rzeszów") {
    document.getElementById('area').selectedIndex="1";
  }
  else document.getElementById('area').selectedIndex="0";
}

var busy = false;
var sto; 
function locBarClickEvent() {
    clearTimeout(sto);
    sto = setTimeout("clearLocTimeout()",300);
    if( !busy ) { 
        busy = true;
        return true;
        }
    else return false;
}

function clearLocTimeout() {
  busy = false;
}

function checkDate() {
    var form = document.getElementsByTagName('form');
    for(var i = 0 ; i < form.length ; i++ ) {
        if(form[i].id == "addEventForm" || form[i].id == "addAdvertForm" || form[i].id == "editEventForm" || form[i].id == "editAdvertForm") {      
          var startdate;
          var period;
          var enddate;
          var expiredate;
          var ele;
          if(startdate = document.getElementById('startdate')) {
            period = document.getElementById('perioddate');
            enddate = document.getElementById('enddate');

            startdateValue = $("#startdateH").attr("value")+':'+$("#startdateM").attr("value");
            startdateValue = $("input[@name=startdate]").attr("value")+' '+startdateValue;
            
            periodValue = $("#eventPeriod").attr("value");

            enddateValue = $("#enddateH").attr("value")+':'+$("#enddateM").attr("value");
            enddateValue = $("input[@name=enddate]").attr("value")+' '+enddateValue;

            changeData('infoDate','Validator','eventDate',startdateValue,enddateValue,periodValue);
            
          }
          else if(expiredate = document.getElementById('expiredate')){
          
            expiredateValue = $("input[@name=expiredate]").attr("value");
            
            changeData('infoDate','Validator','advertDate',expiredateValue,null,null);
          }
      }
    }
}


function closeComm() {
  document.getElementById('communicateArea').style.display = 'none';
}

var timeVar;
function animateCloseComm() {
    $("#communicateArea").slideUp("slow",function(){
    });
}

//banner script

function showBanner(nr) {
    if(nr == 1) id = 'topBanner';
    else if(nr == 2) id = 'banner13nr1';
    else if(nr == 3) id = 'banner13nr2';
    else if(nr == 4) id = 'banner13nr3';
    else if(nr == 5) id = 'banner13nr4';
    else if(nr == 6) id = 'banner23nr1';
    else if(nr == 7) id = 'banner23nr2';
    else if(nr == 8) id = 'banner23nr3';
    else if(nr == 9) id = 'banner23nr4';
    else if(nr == 10) id = 'footBanner';
    else { return false;
    }
    if(document.getElementById(id)) {
        document.getElementById(id).style.display = 'block';
    } else {
        $(document).ready(function() {
            document.getElementById(id).style.display = 'block';
        });
    }
    
}

//textarea limit
function checkLength(a,max)
    {
    var MAXLENGTH=max
    var length=a.value.length;
    if (length>MAXLENGTH)
    { a.value=a.value.substring(0,MAXLENGTH);
      alert("Przekroczyłeś limit  "+MAXLENGTH+" znaków!");
      return false;}
    else return true;
}


//dla listingow
function changeViewIco(el,mode) {
    var parent = el.parentNode;
    var img1 = parent.firstChild.firstChild;
    var img2 = parent.lastChild.firstChild;
    if(mode == 1) {
//        img1.src = "images/list/view1b.png";
//        img2.src = "images/list/view2a.png";
    } else if(mode == 2) {
//        img1.src = "images/list/view1a.png";
//        img2.src = "images/list/view2b.png";
    }
}

// show and hide area box
function showHideArea() {
	if ($("#arealist").css("display")=="none") {
		$("#arealist").fadeIn("fast",function() {$("#arealist").next("div").hide(); });
		//$("#arealist").show("normal",function() {$("#arealist").next("div").css("margin-top","0px"); });
		//"normal",function() {$("#arealist").next("div").css("margin-top","0px"); }
	} else {
		$("#arealist").fadeOut("fast",function () { $("#arealist").next("div").show();});
		//$("#arealist").hide("normal",function () { $("#arealist").next("div").css("margin-top","29px");});
		//"normal",function () { $("#arealist").next("div").css("margin-top","29px");}
	}
}

function sendEmailAboutEvent(id) {
    disableSendButton('eventEmailSendButton');
    changeData('communicateArea','Event','sendEmail',document.getElementById('eventEmailSendInput').value,id,null);
}

function disableSendButton(id) {
    document.getElementById(id).className = 'submitButtonSend';
    document.getElementById(id).disabled = true;
}

function enableSendButton(id) {
   document.getElementById(id).className = 'submitButton';
   document.getElementById(id).disabled = false;
}

function confirmDel(link) {
    if(confirm("Czy na pewno chcesz to usunąć ?")) {
        window.location.href=link;
    }
}

function showPromotedDiv(el) {
    promotedDiv = $(el).siblings(".promotedDiv");
    if($(promotedDiv).css('display') == 'block') {
        $(promotedDiv).css('display','none');
    } else {
        $(promotedDiv).css('display','block');
        $(el).parent('span').bind("mouseenter",function(){
                }).bind("mouseleave",function(){ 
                  $(promotedDiv).css('display','none');
                });
    }
}

function addContentCheckLogin(datatype_id) {
	$('#divlogin').html('Zaloguj się.');
	showDialog('#divlogin');
	$("#p_addcontent").val(datatype_id);
}

function bannercheck() {
		$(".mt2_10 .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() > 0) {
				$(obj).parents(".mt2_10").show();
			}	
		});
		// center
		$(".middleunderwindow .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() > 0) {
				$(obj).parents(".middleunderwindow").show();
			}	
		});
		// top
		$(".pop_under .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() > 0) {
				$(obj).parents(".pop_under").show();
			}	
		});
		// bottom
		$(".pop_under3 .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() > 0) {
				$(obj).parents(".pop_under3").show();
			}	
		});
		// right
		$(".mb2_10 .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() > 0) {
				$(obj).parents(".mb2_10").show();
			}	
		});
}

$(document).ready(	function() 
	{  
		$("#sarticle").mouseover(function(){ showlayer('small_article');});
		$("#sevent").mouseover(function(){ showlayer('small_event');});
		$("#mainMenuSociety").click(function () { showlayer('small_society'); });

		$("#sgallery").mouseover(function(){ showlayer('small_gallery'); });
		$("#sadvert").mouseover(function(){ showlayer('small_advert'); });
		$("#scompany").mouseover(function(){ showlayer('small_company'); });
		
		
		
		// bannery
		// left
		$(".mt2_10 .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() == 0) {
				$(obj).parents(".mt2_10").hide();
			}	else {$(obj).parents(".mt2_10").show();}
		});
		// center
		$(".middleunderwindow .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() == 0) {
				$(obj).parents(".middleunderwindow").hide();
			}else {$(obj).parents(".middleunderwindow").show();}
		});
		// top
		$(".pop_under .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() == 0) {
				$(obj).parents(".pop_under").hide();
			}	else {$(obj).parents(".pop_under").show();}
		});
		// bottom
		$(".pop_under3 .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() == 0) {
				$(obj).parents(".pop_under3").hide();
			} else {$(obj).parents(".pop_under3").show();}
		});
		// right
		$(".mb2_10 .bannerclass").each(function (e,obj){
			if ($(obj).children("div").size() == 0) {
				$(obj).parents(".mb2_10").hide();
			} else {$(obj).parents(".mb2_10").show(); }
		});
	});
	
	
// hej.rzeszow.pl
function getCatalog(id) {
	
	$(".catalogBut"+id).addClass("catalogBut"+id+"sel");
	$(".catalogBut"+id).removeClass("catalogBut"+id);
	$("#list"+id).show();
	$("#catalogBut"+id).show();
	if (id!=1) {
		$(".catalogBut1sel").addClass("catalogBut1");
		$(".catalogBut1sel").removeClass("catalogBut1sel");
		$("#catalogBut1").hide();
		$("#list1").hide();
	}
	if (id!=2) {
		$(".catalogBut2sel").addClass("catalogBut2");
		$(".catalogBut2sel").removeClass("catalogBut2sel");
		$("#catalogBut2").hide();
		$("#list2").hide();
	}
	if (id!=3) {
		$(".catalogBut3sel").addClass("catalogBut3");
		$(".catalogBut3sel").removeClass("catalogBut3sel");
		$("#catalogBut3").hide();
		$("#list3").hide();
	}
}



		var current2=0;
		var maxcurrent2=6;
			function moveAnimate2(leftright) {
				if (leftright==1) {
					if (current2==maxcurrent2) return true;
					$(".foot_bazaar3").animate({left: "-="+918}, 500, "", function () {   }); 
					current2++;
				}
				if (leftright==0) {
					if (current2==0) return true;
					$(".foot_bazaar3").animate({left: "+="+918}, 500, "", function () {   }); 
					current2--;
				}
			}
