/**
 * @author BitArtis.pl
 */

function get_podkategorie(id) {	
	var splited=id.split("_");	
	if($('#'+id).val() != "") {
		$.get("/", { ajax: 1, module: "ogloszenia", akcja: "get_podkategorie", row: $('#'+id).val(), level: splited[1] },
	  	function(data2){    	
			$('select').each(function(i){			
				if($(this).attr("id") != id && $(this).attr("id").split("_")[1] >= id.split("_")[1] ) $(this).remove();
			});
			
			$('#lista_kategorii_ogloszen').append(data2);
	  	});
	}
	else {
		$('select').each(function(i){			
			if($(this).attr("id") != id && $(this).attr("id").split("_")[1] >= id.split("_")[1] ) $(this).remove();
		});
	}
}


function dodaj_koment() {
	otworz_komentarze();
	$('.dod_kom').click( function(){ return false; });
	$('#komentarz_add').show(500);
	$('#komentarz_add_text').hide(500);
}

function otworz_komentarze() {
	$('.otw_kom').click(function(){ return false; });
	$('.komentarze').show(500,function() {
		var targetOffset = $('.komentarze').offset().top;
		$('html').animate({scrollTop: targetOffset}, 1000);
	});
}

function ajax_zaloguj(id_formy, redirect) {
	if (validacja_formy(id_formy,false)) {
		$('#button_logujacy').html('<div style="height:25px;">Ładowanie... <img class="vm" alt="ładowanie" src="/css/images/ajax.gif" /></div>');
		var login=$('#forma_zaloguj input[name=login]').attr('value');
		var haslo=$('#forma_zaloguj input[name=haslo]').attr('value');
		
		$.ajax({
			type: "GET",
			url: "/zaloguj/?ajax=1&login="+encodeURIComponent(login)+'&haslo='+encodeURIComponent(haslo),
			cache: false,
			success: function(info) {
				if (info) {
					if (info!="BLEDNE") {
						text='<big class="bold">Zostałeś pomyślnie zalogowany. Teraz możesz dodawać komentarze.</big>';
						
						$('#button_logujacy').html('<div style="min-height:25px;">'+text+'</div>');
						$('#pse').html('<input title="Wpisz pseudonim" class="c req_text" name="nick" value="'+info+'" id="nick11" disabled/>');
						
						
						
						
						$('input#nick11').value = "<big class=bold></big>";
						//$('input#nick11').attr('disabled') = 'disabled'
						var xSeconds = 2; // 2 seconds
						setTimeout(function() {
							$('#zalo').hide(1500);
						}, xSeconds * 1000);
					}
					else  {
						text='<big class="bold">Przepraszamy, błędne dane logowania.</big>';
						$('#button_logujacy').html('<div style="min-height:25px;">'+text+'</div>');
					}
				} else {
					text='<big class="bold">Przepraszamy, wystąpił błąd.</big>';
					$('#button_logujacy').html('<div style="min-height:25px;">'+text+'</div>');
				}
	         } // success
		});// ajax
	}
	else {
		
	}
}

function ajax_zaloguj_bezkoment(id_formy) {
	if (validacja_formy(id_formy,false)) {
		$('#button_logujacy').html('<div style="height:25px;">Ładowanie... <img class="vm" alt="ładowanie" src="/css/images/ajax.gif" /></div>');
		var login=$('#forma_zaloguj_login input[name=login]').attr('value');
		var haslo=$('#forma_zaloguj_login input[name=haslo]').attr('value');
		
		$.ajax({
			type: "GET",
			url: "/zaloguj/?ajax=1&login="+encodeURIComponent(login)+'&haslo='+encodeURIComponent(haslo),
			cache: false,
			success: function(info) {
				if (info) {
					if (info!="BLEDNE") {
						text='<big class="bold">Zostałeś pomyślnie zalogowany.</big>';
						
						$('#button_logujacy').html('<div style="min-height:25px;">'+text+'</div>');
						
						$('input#nick11').value = "<big class=bold></big>";
						//$('input#nick11').attr('disabled') = 'disabled'
						var xSeconds = 2; // 2 seconds
						setTimeout(function() {
							$('#zalo').hide(1500);
							window.location.reload();
						}, xSeconds * 1000);
					}
					else  {
						text='<big class="bold">Przepraszamy, błędne dane logowania.</big>';
						$('#button_logujacy').html('<div style="min-height:25px;">'+text+'</div>');
					}
				} else {
					text='<big class="bold">Przepraszamy, wystąpił błąd.</big>';
					$('#button_logujacy').html('<div style="min-height:25px;">'+text+'</div>');
				}
	         } // success
		});// ajax
	}
	else {
		
	}
}

function ajax_dodaj_komentarz(typ, id_o, id_formy) {
	if (validacja_formy(id_formy,false)) {
		$('#button_dodajacy1').html('<div style="height:25px;">Ładowanie... <img class="vm" alt="ładowanie" src="/css/images/ajax.gif" /></div>');
		var nick=$('#forma_komentarze input[name=nick]').attr('value');
		var tresc=$('#forma_komentarze textarea[name=tresc]').attr('value');
		
		$.ajax({
			type: "GET",
			url: "/dodaj_komentarz/?ajax=1&nick="+encodeURIComponent(nick)+'&tresc='+encodeURIComponent(tresc)+'&id_o='+id_o+'&typ='+typ,
			cache: false,
			success: function(info) {
				if (info) {
					if (info=='OK') {
						text='<big class="bold">Dziękujemy. Komentarz został zapisany.</big>';
						$('#button_dodajacy1').html('<div style="min-height:25px;">'+text+'</div>');

						var xSeconds = 2; // 2 seconds
						setTimeout(function() {
							$('#komentarz_add').hide(1500);
						}, xSeconds * 1000);
					}
					else if (info=='BAD-WORDS') {
						text = 'Ze względu na użyte słownictwo, naruszające zasady współżycia społecznego, Twój komentarz nie może zostać zamieszczony.';
						alert(text);
						text = '<big class="bold">'+text+'</big>';
						$('#button_dodajacy1').html('<div style="min-height:25px;">'+text+'</div>');
					}
					else {
						text='<big class="bold">Przepraszamy, wystąpił nieznany błąd.</big>';
						$('#button_dodajacy1').html('<div style="min-height:25px;">'+text+'</div>');
					}
				} else {
					text='<big class="bold">Przepraszamy, wystąpił błąd.</big>';
					$('#button_dodajacy1').html('<div style="min-height:25px;">'+text+'</div>');
				}
	         } // success
		});// ajax
	}
	else {
		
	}
}

function ajax_wyslij_link(id) {
	if (validacja_formy(id,false)) {
		$('#'+id+' #dis').attr('disabled','disabled');
		var link=$('#'+id).attr('title');
		var od_mail=$('#'+id+' input[name=mail2]').attr('value');
		var do_mail=$('#'+id+' input[name=mail]').attr('value');
		var od_imie=$('#'+id+' input[name=imie2]').attr('value');
		var do_imie=$('#'+id+' input[name=imie]').attr('value');
		text='<div class="ac"><br /><br /><br /><br /><br /><br /><br />Wysyłanie wiadomości. Proszę poczekaj.</div>';
		$('#main_div').html(text);
		$.ajax({
			type: "GET",
			url: '/wyslij_link/?ajax=1&od_mail='+od_mail+'&do_mail='+do_mail+'&od_imie='+od_imie+'&do_imie='+do_imie+'&link='+encodeURIComponent(link),
			cache: false,
			success: function(info) {
				if (info) {
					if (info=='OK') {
						text='<div class="ac"><br /><br /><br /><br /><br /><br /><br />Dziękujemy. Link został wysłany.</div>';
						$('#main_div').html(text);
						return false;
					}
					else if (info=='ALREADY-IN-DATABASE') {
						text='Wysłałeś już tego linka wcześniej.';
					}
					else {
						text='Przepraszamy, wystąpił nieznany błąd.';
					}
					alert(text);
					window.parent.$.prettyPhoto.close();
					return false;
				} else {
					text='Przepraszamy, wystąpił błąd.';
					alert(text);
					window.parent.$.prettyPhoto.close();
					return false;
				}
	         }
		});// ajax
	}
	else {
		return false;
	}
}



function ajax_napisz_do_nas(id) {
	if (validacja_formy(id,false)) {
		$('#'+id+' #dis').attr('disabled','disabled');
		var link=$('#'+id).attr('title');
		var od_mail=$('#'+id+' input[name=mail2]').attr('value');
		var od_imie=$('#'+id+' input[name=imie2]').attr('value');
		var tresc=$('#'+id+' textarea[name=tresc]').attr('value');
		$.ajax({
			type: "GET",
			url: '/napisz_do_nas/?ajax=1&od_mail='+od_mail+'&od_imie='+od_imie+'&link='+encodeURIComponent(link)+'&tresc='+encodeURIComponent(tresc),
			cache: false,
			success: function(info) {
				if (info) {
					alert(info);
					if (info=='OK') {
						text='Dziękujemy. Wiadomość została wysłana.';
					}
					else if (info=='ALREADY-IN-DATABASE') {
						text='Wysłałeś już tą wiadomość.';
					}
					else {
						text='Przepraszamy, wystąpił nieznany błąd.';
					}
					alert(text);
					window.parent.$.prettyPhoto.close();
					return false;
				} else {
					text='Przepraszamy, wystąpił błąd.';
					alert(text);
					window.parent.$.prettyPhoto.close();
					return false;
				}
	        }
		});// ajax
	}
	else {
		return false;
	}
}

 
$(document).ready(function() {
	// "Lightbox" dla <a /> z klasą LB
	//$("a.LB").prettyPhoto({theme:'dark_rounded'});
	// "Lightbox" dla <a /> z klasą powieksz
	//$("a.powieksz").prettyPhoto({theme:'dark_rounded'});

	$("a.LB").attr('rel','prettyPhoto[gal1]');
	$("a.powieksz").attr('rel','prettyPhoto[gal1]');	
	$("a.LB2").prettyPhoto({theme:'dark_rounded'});
	
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded', hideflash:true});
	
	
	$('a.LB').click(function(){
		var href=$(this).attr('href');
		if (/http:\/\/youtube.com/.test(href)) {
			var br=href.split('?v=');
			var id_YT=br[1];
			if (id_YT) {
				$.ajax({
					type: "GET",
					url: "/ogladano/?ajax=1&type=film&id_YT="+id_YT,
					cache: false,
					success: function(info) {}
				});// ajax
			}
		}
		else if (/content\/galeria\/[0-9]+\/[0-9]+\/(.+)/.test(href)){
			var br=href.split('/');
			var ida=br[3];
			var nr=br[4];
			var foto=br[5];
			$.ajax({
				type: "GET",
				url: "/ogladano/?ajax=1&type=zdj&ida="+ida+"&nr="+nr+"&foto="+foto,
				cache: false,
				success: function(info) {}
			});// ajax
		}
	});
	
	
	// wybieracz daty
	$("#data_waznosci").datepicker({dateFormat: 'yy-mm-dd'});
	$(".datepicker").datepicker({dateFormat: 'yy-mm-dd'});

	// Podswietlanie menu
	$('#menu a:regex(rel,^m[0-9][0-9]$)').each(function() {
		$(this).hover(
		
			function() {
				var rel=($(this).attr('rel'));
				
				
					$('.podmenu').hide();
					$('ul#'+rel).show();
				
			},
			function() {
				var rel=($(this).attr('rel'));
				 $('div#'+rel).hide();
			}
		);
	});
	
	// Wyświetlanie podmenu
	$('div:regex(id,^m[0-9][0-9]$)').each(function() {
		$(this).hover(
				function() {
					$(this).show();
				},
				function() {
					// $(this).hide();
				}
			);
	});

	// Własny PNGFIX - TODO ew kiedys zmienic mozna na dd bealted czy jakos tak
	supported=false; test1=false;
	if (navigator.platform=="Win32") test1=true;
	if (test1 && /MSIE 6/.test(navigator.userAgent)) supported=true;
	if (supported) {
		$('img:regex(src,^.*\.png$)').each (function() {
			h_ = $(this).css('height');
			w_ = $(this).css('width');
			sciezka="/css/images/";
			stara=$(this).attr("src");
			stara=stara.split('/');
			link=stara[(stara.length)-1];
			$(this).attr("src","/css/images/transp.gif");
			$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+sciezka+link+"', sizingMethod='scale')");
			$(this).css("height",h_);
			$(this).css("width",w_);
		});	
	}
	
	// Tip`sy dla kalendarza (klasa .bTips, tresc w Title)
	$('.bTips').bt({
		  spikeLength: 4,
		  spikeGirth: 5,
		  padding: 5,
		  width: 300,
		  positions: ['right', 'top', 'left', 'bottom'],
		  cornerRadius: 0,
		  fill: 'rgba(0, 0, 0, .60)',
		  strokeWidth: 1,
		  align: 'left',
		  strokeStyle: 'rgba(255,0,0,.0)',
		  cssStyles: {color: '#FFF', fontWeight: 'bold', lineHeight: '20px', textAlign: 'left', paddingLeft: '20px'}
	});
	
	// wielkosci czcionek
	
	$('img.font_small').click(function(){
		$('p').css('font-size','11px');
	});
	$('img.font_medium').click(function(){
		$('p').css('font-size','13px');
	});
	$('img.font_large').click(function(){
		$('p').css('font-size','15px');
	});
	
});


function dodaj_do_newslettera(obiekt) {
	var mail=$('#newsletter_mail').attr('value');
	
	$('.newsletter_zapisz_sie').html('<br /><span class="red bold">Proszę czekaj..</span><br />');

	$.ajax({
		type: "GET",
		url: "/newsletter/?ajax=1&mail="+mail,
		cache: false,
		success: function(info) {
			if (info) {
				if (info=='OK') {
					var text='<br /><span class="red bold">Dziękujemy.</span><br />';
				}
				else if (info=='ALREADY-IN-DATABASE') {
					var text='<br /><span class="red bold">Podany e-mail jest już w naszej bazie.</span><br />';
				}
				else {
					var text='<br /><span class="red bold">Podano niepoprawny adres e-mail...</span><br />';
					alert(info);
				}
				$('.newsletter_zapisz_sie').html(text);
			} else {
				$('.newsletter_zapisz_sie').html('<br /><span class="red bold">Błąd przetwarzania żądania. Spróbuj ponownie później.</span><br />');
			}
         }
	});// ajax
}


/**
 * Dodaje link do ulubionych (onclick="addAsFav", rel="sidebar" dla Opery, FF)
 * 
 * @return nothing
 */
function addAsFav() {
    var tytul = 'Nowy Łowiczanin';
    var adres = 'http://127.0.0.1/';

    // FireFox
    if (window.sidebar) { 
    	// brak akcji, ponieważ powinno być ustawione rel="sidebar"
    } // IE
    else if (window.external) {
    	window.external.AddFavorite(adres, tytul); 
    } // Opera
    else if (window.opera && window.print) {
    	// brak akcji, powinno być ustawione rel="sidebar"
    }
    else {
    	// coś dla przeglądarek nie umozliwiajacych dodania ?
    }
}

/**
 * Walidacja formularzy (bez pól textarea), można było lepiej zrobic bo textarea
 * nie może miec atrybutu alt
 * 
 * @return bool - jezeli wszystko ok to true
 */

var blokowany=false;
function validacja_formy(id, blokuj) {
	var blad='';
	$('#'+id+' [alt=req_text]').each (function () {
		if ($(this).attr('value')=='') {
			blad += "- " + $(this).attr('title') + "\n";
		}
	});
	$('#'+id+' .req_code').each (function () {
		if ($(this).attr('value')=='') {
			blad += "- " + $(this).attr('title') + "\n";
		}
		else {
			var tmp = $(this).attr('value');
			var regCode = /^[0-9A-Z]{8}$/;
			if (!regCode.test(tmp)) {
				blad += "- Niepoprawny format kodu. Kod składa się z 8 DUŻYCH liter i cyfr.\n";
			}
		}
	});
	
	
	
	$('#'+id+' [alt=req_mail]').each (function () {
		if (!isEmail($(this).attr('value'))) {
			blad += "- " + $(this).attr('title') + "\n";
		}
	});

	$('#'+id+' .req_text').each (function () {
		if ($(this).attr('value')=='') {
			blad += "- " + $(this).attr('title') + ".\n";
		}
	});
	$('#'+id+' .req_text100').each (function () {
		if ($(this).attr('value')=='') {
			blad += "- Wpisz " + $(this).attr('title') + ".\n";
		}
		if ($(this).attr('value').length>100) {
			blad += "- " + $(this).attr('title').substr(0, 1).toUpperCase() + $(this).attr('title').substr(1) + " może mieć maksymalnie 100 znaków.\n";
		}
	});
	$('#'+id+' .req_text120').each (function () {
		if ($(this).attr('value')=='') {
			blad += "- Wpisz " + $(this).attr('title') + ".\n";
		}
		if ($(this).attr('value').length>120) {
			blad += "- " + $(this).attr('title').substr(0, 1).toUpperCase() + $(this).attr('title').substr(1) + " może mieć maksymalnie 120 znaków.\n";
		}
	});
	$('#'+id+' .req_text241').each (function () {
		if ($(this).attr('value')=='') {
			blad += "- Wpisz " + $(this).attr('title') + ".\n";
		}
		if ($(this).attr('value').length>241) {
			blad += "- " + $(this).attr('title').substr(0, 1).toUpperCase() + $(this).attr('title').substr(1) + " może mieć maksymalnie 241 znaków.\n";
		}
	});
	$('#'+id+' .req_mail').each (function () {
		if (!isEmail($(this).attr('value'))) {
			blad += "- " + $(this).attr('title') + "\n";
		}
	});
	$('#'+id+' .req_check').each (function () {
		if (!$(this).attr('checked')) {
			blad += "- " + $(this).attr('title') + "\n";
		}
	});

	
	if (blad != '') {
		alert(blad);
		return false;
	}
	else {
		if (blokuj==true) {
			if (blokowany == true) {
				alert("Przycisk już kliknięty, proszę poczekać..");
				return false;
			}
			else {
				blokowany=true;
				return true;
			}
		}
		else {
			return true;
		}
	}
}


function isEmail(email) {
	email = email.replace(/[ ]/g, '');
	var regEmail = /^([a-zA-Z0-9._-]{1,})@([a-zA-Z0-9._-]{1,})\.([a-zA-Z]{2,4})$/;
	if (!regEmail.test(email))
		return false;
	else
		return email;
}



/*
$(document).ready(function() {
	var sek=10;
	var czas=sek*1000;
	$('#REKLAMA_TOP').everyTime(czas,function(){
	   var m3_u = (location.protocol=='https:'?'https://openx.lowiczanin.info/www/delivery/ajs.php':'http://openx.lowiczanin.info/www/delivery/ajs.php');
	   var m3_r = Math.floor(Math.random()*99999999999);
	   if (!document.MAX_used) document.MAX_used = ',';
	   var text = '';
	   text += m3_u;
	   text +=  ("?zoneid=5");
	   text +=  ('&amp;cb=' + m3_r);
	   if (document.MAX_used != ',') text +=  ("&amp;exclude=" + document.MAX_used);
	   text +=  (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
	   text +=  ("&amp;loc=" + escape(window.location));
	   if (document.referrer) text +=  ("&amp;referer=" + escape(document.referrer));
	   if (document.context) text +=  ("&context=" + escape(document.context));
	   if (document.mmm_fo) text +=  ("&amp;mmm_fo=1");
	   
	   var url = '/wybierzurl.php?url='+encodeURIComponent(text)+'&id=REKLAMA_TOP';
	   
	   $.ajax({
			type: "GET",
			url: url,
			cache: false,
			success: function(info) {
				if (info) {
					if (info!='ERROR') {
						var test = info.split('|');
						if (test[0]=="FLASH") {
							var info2=info.replace('FLASH|','');
							eval(info2);
						}
						else if (test[0]=="IMG") {
							var info2=info.replace('IMG|','');
							$('#REKLAMA_TOP').html(info2);
						}
					}
				}
	   		}
		});
	});
	
	
	$('#REKLAMA_BOTTOM').everyTime(czas,function(){
	   var m3_u = (location.protocol=='https:'?'https://openx.lowiczanin.info/www/delivery/ajs.php':'http://openx.lowiczanin.info/www/delivery/ajs.php');
	   var m3_r = Math.floor(Math.random()*99999999999);
	   if (!document.MAX_used) document.MAX_used = ',';
	   var text = '';
	   text += m3_u;
	   text += ("?zoneid=4");
	   text += ('&amp;cb=' + m3_r);
	   if (document.MAX_used != ',') text += ("&amp;exclude=" + document.MAX_used);
	   text += (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
	   text += ("&amp;loc=" + escape(window.location));
	   if (document.referrer) text += ("&amp;referer=" + escape(document.referrer));
	   if (document.context) text += ("&context=" + escape(document.context));
	   if (document.mmm_fo) text += ("&amp;mmm_fo=1");
	   
	   var url = '/wybierzurl.php?url='+encodeURIComponent(text)+'&id=REKLAMA_BOTTOM';
	   
	   $.ajax({
			type: "GET",
			url: url,
			cache: false,
			success: function(info) {
				if (info) {
					if (info!='ERROR') {
						var test = info.split('|');
						if (test[0]=="FLASH") {
							var info2=info.replace('FLASH|','');
							eval(info2);
						}
						else if (test[0]=="IMG") {
							var info2=info.replace('IMG|','');
							$('#REKLAMA_BOTTOM').html(info2);
						}
					}
				}
	   		}
		});
	});
	
	$('#REKLAMA_BOTTOM2').everyTime(czas,function(){
		var m3_u = (location.protocol=='https:'?'https://openx.lowiczanin.info/www/delivery/ajs.php':'http://openx.lowiczanin.info/www/delivery/ajs.php');
		var m3_r = Math.floor(Math.random()*99999999999);
		if (!document.MAX_used) document.MAX_used = ',';
		var text = '';
		text += m3_u;
		text += ("?zoneid=6");
		text += ('&amp;cb=' + m3_r);
		if (document.MAX_used != ',') text += ("&amp;exclude=" + document.MAX_used);
		text += (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
		text += ("&amp;loc=" + escape(window.location));
		if (document.referrer) text += ("&amp;referer=" + escape(document.referrer));
		if (document.context) text += ("&context=" + escape(document.context));
		if (document.mmm_fo) text += ("&amp;mmm_fo=1");
	   
		var url = '/wybierzurl.php?url='+encodeURIComponent(text)+'&id=REKLAMA_BOTTOM2';
		   
	   $.ajax({
			type: "GET",
			url: url,
			cache: false,
			success: function(info) {
				if (info) {
					if (info!='ERROR') {
						var test = info.split('|');
						if (test[0]=="FLASH") {
							var info2=info.replace('FLASH|','');
							eval(info2);
						}
						else if (test[0]=="IMG") {
							var info2=info.replace('IMG|','');
							$('#REKLAMA_BOTTOM2').html(info2);
						}
					}
				}
	   		}
		});
	});

	
	
	$('#REKLAMA_PRAWA1').everyTime(czas,function(){
		
	   var m3_u = (location.protocol=='https:'?'https://openx.lowiczanin.info/www/delivery/ajs.php':'http://openx.lowiczanin.info/www/delivery/ajs.php');
	   var m3_r = Math.floor(Math.random()*99999999999);
	   if (!document.MAX_used) document.MAX_used = ',';
	   var text = '';
	   text += m3_u;
	   text += ("?zoneid=1");
	   text += ('&amp;cb=' + m3_r);
	   if (document.MAX_used != ',') text += ("&amp;exclude=" + document.MAX_used);
	   text += (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
	   text += ("&amp;loc=" + escape(window.location));
	   if (document.referrer) text += ("&amp;referer=" + escape(document.referrer));
	   if (document.context) text += ("&context=" + escape(document.context));
	   if (document.mmm_fo) text += ("&amp;mmm_fo=1");
	   
	   var url = '/wybierzurl.php?url='+encodeURIComponent(text)+'&id=REKLAMA_PRAWA1';
	   
	   $.ajax({
			type: "GET",
			url: url,
			cache: false,
			success: function(info) {
				if (info) {
					if (info!='ERROR') {
						var test = info.split('|');
						if (test[0]=="FLASH") {
							var info2=info.replace('FLASH|','');
							eval(info2);
						}
						else if (test[0]=="IMG") {
							var info2=info.replace('IMG|','');
							$('#REKLAMA_PRAWA1').html(info2);
						}
					}
				}
	   		}
		});
	});
	
	
	$('#REKLAMA_PRAWA2').everyTime(czas,function(){	
	   var m3_u = (location.protocol=='https:'?'https://openx.lowiczanin.info/www/delivery/ajs.php':'http://openx.lowiczanin.info/www/delivery/ajs.php');
	   var m3_r = Math.floor(Math.random()*99999999999);
	   if (!document.MAX_used) document.MAX_used = ',';
	   var text = '';
	   text += m3_u;
	   text += ("?zoneid=2");
	   text += ('&amp;cb=' + m3_r);
	   if (document.MAX_used != ',') text += ("&amp;exclude=" + document.MAX_used);
	   text += (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
	   text += ("&amp;loc=" + escape(window.location));
	   if (document.referrer) text += ("&amp;referer=" + escape(document.referrer));
	   if (document.context) text += ("&context=" + escape(document.context));
	   if (document.mmm_fo) text += ("&amp;mmm_fo=1");
	   
	   var url = '/wybierzurl.php?url='+encodeURIComponent(text)+'&id=REKLAMA_PRAWA2';
	   
	   $.ajax({
			type: "GET",
			url: url,
			cache: false,
			success: function(info) {
				if (info) {
					if (info!='ERROR') {
						var test = info.split('|');
						if (test[0]=="FLASH") {
							var info2=info.replace('FLASH|','');
							eval(info2);
						}
						else if (test[0]=="IMG") {
							var info2=info.replace('IMG|','');
							$('#REKLAMA_PRAWA2').html(info2);
						}
					}
				}
	   		}
		});
	});
	
	$('#REKLAMA_PRAWA3').everyTime(czas,function(){
		
	   var m3_u = (location.protocol=='https:'?'https://openx.lowiczanin.info/www/delivery/ajs.php':'http://openx.lowiczanin.info/www/delivery/ajs.php');
	   var m3_r = Math.floor(Math.random()*99999999999);
	   if (!document.MAX_used) document.MAX_used = ',';
	   var text = '';
	   text += m3_u;
	   text += ("?zoneid=3");
	   text += ('&amp;cb=' + m3_r);
	   if (document.MAX_used != ',') text += ("&amp;exclude=" + document.MAX_used);
	   text += (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
	   text += ("&amp;loc=" + escape(window.location));
	   if (document.referrer) text += ("&amp;referer=" + escape(document.referrer));
	   if (document.context) text += ("&context=" + escape(document.context));
	   if (document.mmm_fo) text += ("&amp;mmm_fo=1");
	   
	   var url = '/wybierzurl.php?url='+encodeURIComponent(text)+'&id=REKLAMA_PRAWA3';
	   
	   $.ajax({
			type: "GET",
			url: url,
			cache: false,
			success: function(info) {
				if (info) {
					if (info!='ERROR') {
						var test = info.split('|');
						if (test[0]=="FLASH") {
							var info2=info.replace('FLASH|','');
							eval(info2);
						}
						else if (test[0]=="IMG") {
							var info2=info.replace('IMG|','');
							$('#REKLAMA_PRAWA3').html(info2);
						}
					}
				}
	   		}
		});
	});
	
});

*/


/*******************************************************************************
 * 
 * CZĘŚĆ DO WYSZUKIWARKI
 * 
 */

$(document).ready(function() {

	$('input[name="firma"]').change(function() { 
		if ($(this).val()=='1') {
			$('input[name="nazwa_firmy"]').attr('disabled', false);
			$('input[name="NIP"]').attr('disabled', false);
			$('input[name="ulica"]').attr('disabled', false);
			$('input[name="numer"]').attr('disabled', false);
			$('input[name="miasto"]').attr('disabled', false);
			$('input[name="kod"]').attr('disabled', false);
		} else {
			$('input[name="nazwa_firmy"]').attr('disabled', true);
			$('input[name="NIP"]').attr('disabled', true);
			$('input[name="ulica"]').attr('disabled', true);
			$('input[name="numer"]').attr('disabled', true);
			$('input[name="miasto"]').attr('disabled', true);
			$('input[name="kod"]').attr('disabled', true);

		}
		
	});
	
	var currentTime = new Date()

	kalendarz(currentTime.getFullYear(),currentTime.getMonth()+1,76,"kalendarz_sport");
	kalendarz(currentTime.getFullYear(),currentTime.getMonth()+1,77,"kalendarz_turystyka");
	kalendarz(currentTime.getFullYear(),currentTime.getMonth()+1,75,"kalendarz_kultura");

	var czas=500;
	$('.szukajka input#cb1').click(function() {
		$('.szukajka .cb1').show(
				czas,
				function() {
					$('.szukajka .cb2').hide(czas);
					$('.szukajka .cb3').hide(czas);
					$('.szukajka .cb4').hide(czas);
					$('#cb3').attr('checked','');
					$('#cb4').attr('checked','');
					$('.szukajka .cb8').hide(czas);
				}
		);
	});
	$('.szukajka input#cb2').click(function() {
		$('.szukajka .cb2').show(
				czas,
				function() {
					$('.szukajka .cb1').hide(czas);
					$('.szukajka .cb8').hide(czas);
				}
		);
	});
	$('.szukajka input#cb8').click(function() {
		$('.szukajka .cb8').show(
				czas,
				function() {
					$('.szukajka .cb1').hide(czas);
					$('.szukajka .cb2').hide(czas);
					$('.szukajka .cb3').hide(czas);
					$('.szukajka .cb4').hide(czas);
					$('#cb3').attr('checked','');
					$('#cb4').attr('checked','');
				}
		);
	});

	$('.szukajka input#cb3').click(function() {
		$('.szukajka .cb3').show(
				czas,
				function() {
					$('.szukajka .cb4').hide(czas);
				}
		);
	});
	$('.szukajka input#cb4').click(function() {
		$('.szukajka .cb4').show(
				czas,
				function() {
					$('.szukajka .cb3').hide(czas);
				}
		);
	});

});


// Google MAPS
/*
 * function load() { var zoom=11; var xx=50.0; var yy=22.0; var point = new
 * GLatLng(xx,yy); var marker = new GMarker(point);
 * 
 * if (GBrowserIsCompatible()) { var mapa = new
 * GMap2(document.getElementById("mapka")); mapa.addControl(new
 * GSmallZoomControl()); mapa.setCenter(new GLatLng(xx,yy), zoom);
 * mapa.addOverlay(marker); } }
 */
 
 
 
 function check_max(limit, obj) {
	var dlugosc = obj.value.length;
	if (dlugosc>120) {
		var str=obj.value;
		str = str.substr(0, 120);
		obj.value=str;
	}
	dlugosc = obj.value.length;
	$('#zmiana').html(dlugosc);
}
