function getKalendarz(offset){
	var connection = new AjaxConnection('kalendarz/kalendarz.php', 'POST');
	connection.setOption('offset', offset);
	//alert(connection.getOptions());
	connection.connect("getPanel(x,document.getElementById('kalendarz'))");			
}
function terytoriumChange(){
	var woj_id=document.getElementById('woj_id').value;
	var pow_id=document.getElementById('pow_id').value;
	var gmn_id=document.getElementById('gmn_id').value;
	var connection = new AjaxConnection('http://'+www_root+'/'+controller+'/ajaxTerytorium/', 'POST');
	connection.setOption('wojewodztwo_id', woj_id);
	connection.setOption('powiat_id', pow_id);
	connection.setOption('gmina_id', gmn_id);
	connection.connect("getPanel(x,document.getElementById('terytorium_ajax_box'))");
}

function getPanel(x,box){
	switch(x.readyState){
		case 0: break;
		case 1: showFog(box);break;
		case 2: break;
		case 3: break;
		case 4: removeFog(box);
		if(x.status==200 || window.location.href.indexOf("http")==-1){		 
      		if(x.responseText!=''){
        		box.innerHTML=x.responseText;
      		}
    	}
		else
			alert('error');
        break;
	}
}
function showFog(div){
  if(document.getElementById('fog')==null){
    var fog=document.createElement('div');
    fog.id="fog";
    var imgfog=document.createElement('div');
    imgfog.id="imgFog";
    fog.appendChild(imgfog);
    div.appendChild(fog);
  }
}
function removeFog(div){
	if(document.getElementById('fog')!=null){
    var fog=document.getElementById('fog');
		div.removeChild(fog);
	}
}
