// JavaScript Document
 

		function kategoria(id) {
	  if (!id) return false;
		var i = 1;
		var nazwa ;
  		  while (el = document.getElementById('buton_' + i)) {
    			
          if(id==i)
    			{
           el.className='p_'+i+'_a';
    			}
    			else 
    			{
           el.className = 'p_'+i+'_i';
          }
          if (id=='1')
          {
          nazwa = '1';
          }
          else if (id=='2')
          {
          nazwa = '2';
          }
          else if (id=='3')
          {
          nazwa = '3';
          }
          else if (id=='4')
          {
          nazwa = '4';
          }
        i++;
  			}
		document.getElementById('kw').value = nazwa;	
		}
 
   function przenies(woj){
    var kat = document.getElementById('kw').value;
    if(kat==''){
     document.getElementById('error_cat').innerHTML = 'Brak kategorii!';
    }
    else{
     location.href=kat+','+woj+',najczesciej-oceniani,1,wiecej.html'; 
    }
   }
   
   
  function showDiv(pId) {
		if (!pId) return false;
		var i = 1;
		while (el = document.getElementById('div_' + i)) {
			i == pId ? el.style.display = 'block' : el.style.display = 'none';
			i++;
			}
		}
		
		function showHideBox(name, id)
       {
       if (!name) return false;
        	
       var box_1 = document.getElementById(name+'_'+id+'_radio');
       var box_2 = document.getElementById(name+'_'+id+'_radio');
      
       var i=1;
       while (el = document.getElementById(name+'_'+i)) { 
       
       var radio = document.getElementById(name+'_'+i+'_radio');
       var box = document.getElementById(name+'_'+i);
       if(i==id){
        box.style.display = ''; 
       }
       else
       {
        box.style.display = 'none';
        if(id!=2)
        radio.disabled = 'disabled';
       }
       i++;    
      }
      }
      
    function PrintContent()
      {
      var DocumentContainer = document.getElementById('druk');
      var WindowObject = window.open('', "TrackHistoryData",
      "width=760,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=yes"); 
      WindowObject.document.writeln(DocumentContainer.innerHTML);
      WindowObject.document.close();
      WindowObject.focus();
      WindowObject.print();
      WindowObject.close();
      } 
      
          function changeFont(fontSize)
        {
          $(".news_text").css("font-size", fontSize);
        }
        
        $().ready(function() {
 
	$("#lawyer_registration_form").validate({
		rules: {
			nick: {
				required: true,
				minlength: 2
			},
			password: {
				required: true,
				minlength: 5
			},
			confirm_password: {
				required: true,
				minlength: 5,
				equalTo: "#password"
			},
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			password: {
				required: "Proszę wprowadzić hasło",
				minlength: "Hasło musi zawierać minimum 5 znaków"
			},
			confirm_password: {
				required: "Proszę wprowadzić hasło",
				minlength: "Hasło musi zawierać minimum 5 znaków",
				equalTo: "Wprowadź takie samo hasło jak powyżej"
			},
			email: "Format email jest nieprawidłowy"
		}
	});
	
		$("#add_thread").validate({
		rules: {
			thread_nick: {
				required: true,
				minlength: 2
			},
      thread_title: {
				required: true,
				minlength: 2
			},
			thread_content: {
				required: true,
				minlength: 3
			}
		},
		messages: {
			thread_title: "Brak tytułu wątku",
			thread_nick: "Brak pseudonim użytkownika",
			thread_content: "Brak treści"
		}
	});
	
	$("#add_post").validate({
		rules: {
			post_nick: {
				required: true,
				minlength: 2
			},
			post_content: {
				required: true,
				minlength: 3
			}
		},
		messages: {
			post_nick: "Brak pseudonim użytkownika",
			post_content: "Brak treści posta"
		}
	});
	
	
});
      
   $(document).ready(
				function(){
 
					$('ul#lawyer_window').innerfade({
						speed: 1000,
						timeout: 5000,
						type: 'sequence',
						containerwidth: '220px',
						containerheight: '220px'
					});
 
			});    
			
					$(function(){
			$("#myselect").change(function(){
				$.getJSON("modules/select.php",{id: $(this).val()}, function(j){
					var options = '';
					options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].id + '">' + j[i].name + '</option>';
					}
					$("#city_sel").html(options);
					$('#city_sel option:first').attr('selected', 'selected');
				})
			})			
		})
