function changeHeight()
{
	  /*var infoboxHeight;
	  infoboxHeight = jQuery("#infobox_content").height()-10;
	  jQuery("#infobox_right_table").height(infoboxHeight);*/
}


function przelacz(id)
{
	document.getElementById("infobox_right_table").style.height = '180px';
	for ( i=1 ; i<6 ; i++ ) {
		var div_name = 'wiadomosc_'+i;
		var page_name = 'page_'+i;
		document.getElementById(div_name).style.display = 'none';
		document.getElementById(page_name).style.color = '#777777';
		document.getElementById(page_name).style.fontWeight = 'normal';  
		document.getElementById(page_name).style.background = 'url(images/pager_bg.gif)';
	}
	document.getElementById('wiadomosc_'+id).style.display = 'block';
	document.getElementById('page_'+id).style.color = '#285F9F';
	document.getElementById('page_'+id).style.fontWeight = 'bold';
	document.getElementById('page_'+id).style.background = 'url(images/pager_bg_on.gif)';
	changeHeight();
	setTimeout("changeHeight();", 150);
	setTimeout("changeHeight();", 250);
	setTimeout("changeHeight();", 350);
	setTimeout("changeHeight();", 500);
	setTimeout("changeHeight();", 1000);
	setTimeout("changeHeight();", 2000);
}


function setMenuGwarek()
{
	jQuery("#infobox_removable").remove();
	jQuery("div#infobox_buttons").append('<div id="infobox_removable"><a href="#" id="z1" class="infobox_button_on" onclick="Pobierz_z(\'1\',\'z1\');return false;">Informacje</a> <a href="#" id="z2" class="infobox_button" onclick="Pobierz_z(\'6\',\'z2\');return false;">Sport</a> <a href="#" id="z3" class="infobox_button" onclick="Pobierz_z(\'2\',\'z3\');return false;">Kultura</a> <a href="#" id="z4" class="infobox_button" onclick="Pobierz_z(\'4\',\'z4\');return false;">Historia</a></div>');
	document.getElementById("rightButtonTd").innerHTML = '<img src="images/ibDziennik.gif" alt="Dziennik Zachodni" style="margin: 0px 0px 0px 0px; width: 18px;" onclick="setMenuDZ();"/>';
	document.getElementById("infobox_right_table").style.height = '180px';
	pobierz_dane(1);
	changeHeight();
	setTimeout("changeHeight();", 150);
	setTimeout("changeHeight();", 250);
	setTimeout("changeHeight();", 350);
	setTimeout("changeHeight();", 500);
	setTimeout("changeHeight();", 1000);
	setTimeout("changeHeight();", 2000);
}

function setMenuDZ()
{
	jQuery("#infobox_removable").remove();
	jQuery("#infobox_buttons").append('<div id="infobox_removable"><a href="#" id="d1" class="infobox_button_dz" >Dziennik Zachodni</a></div>');
	document.getElementById("rightButtonTd").innerHTML = '<img src="images/ibGwarek.gif" alt="Gwarek" style="margin: 30px 0px 0px 0px; width: 18px;" onclick="setMenuGwarek();"/>';
	pobierz_rss('rss_php.php?url=http://polskatimes.pl/rss/dziennikzachodni.xml');
	changeHeight();
	setTimeout("changeHeight();", 150);
	setTimeout("changeHeight();", 250);
	setTimeout("changeHeight();", 350);
	setTimeout("changeHeight();", 500);
	setTimeout("changeHeight();", 1000);
	setTimeout("changeHeight();", 2000);
}

function pobierz_rss(url) {
	var zrodlo = url;
    advAJAX.get({
     url : zrodlo,
      onLoading : function(obj) { 
    	  document.getElementById("infobox_right_table").style.height = '180px';
		  document.getElementById("infobox_1").innerHTML = '<p class=\'loader\'>Wczytywanie...</p>'; 
		  changeHeight();
      },
      onSuccess : function(obj) {
    	  document.getElementById("infobox_right_table").style.height = '180px';
		  document.getElementById("infobox_1").innerHTML = obj.responseText;
		  changeHeight();
	  },
      onError : function(obj) {
		  document.getElementById("infobox_right_table").style.height = '180px';
		  document.getElementById("infobox_1").innerHTML = 'Wystąpił błąd podczas ładowania newsa!';	  
		  changeHeight();
	  }
    });
}



function pobierz_dane(url) {
       var zrodlo = 'gwarek.php?dzial=' +url;
        advAJAX.get({
         url : zrodlo,
          onLoading : function(obj) { 
        	  document.getElementById("infobox_right_table").style.height = '180px';
			  document.getElementById("infobox_1").innerHTML = '<p class=\'loader\'>Wczytywanie...</p>'; 
			  changeHeight();
          },
          onSuccess : function(obj) {
        	  document.getElementById("infobox_right_table").style.height = '180px';
			  document.getElementById("infobox_1").innerHTML = obj.responseText;
			  changeHeight();
		  },
          onError : function(obj) {
			  document.getElementById("infobox_right_table").style.height = '180px';
			  document.getElementById("infobox_1").innerHTML = 'Wystąpił błąd podczas ładowania newsa!';	  
			  changeHeight();
		  }
        });
   }

function Pobierz_z(url, id) {
	document.getElementById('z1').style.background = 'url(images/infobox_button.jpg)'; document.getElementById('z1').style.color = '#0D4195';
	document.getElementById('z2').style.background = 'url(images/infobox_button.jpg)'; document.getElementById('z2').style.color = '#0D4195';
	document.getElementById('z3').style.background = 'url(images/infobox_button.jpg)'; document.getElementById('z3').style.color = '#0D4195';
	document.getElementById('z4').style.background = 'url(images/infobox_button.jpg)'; document.getElementById('z4').style.color = '#0D4195';
	document.getElementById(id).style.background = 'url(images/infobox_button_on.jpg)';  document.getElementById(id).style.color = '#FFF';
	pobierz_dane(url);
	changeHeight();
	setTimeout("changeHeight();", 150);
	setTimeout("changeHeight();", 250);
	setTimeout("changeHeight();", 350);
	setTimeout("changeHeight();", 500);
	setTimeout("changeHeight();", 1000);
	setTimeout("changeHeight();", 2000);
}

function przelaczTemat(wId,id) {
	var expand = true;
	if(document.getElementById('temat_'+wId+'_'+id).style.display == 'block'){
		expand = false;
	}
	for(var i = 0; i<4; i++) {
		document.getElementById('temat_'+wId+'_'+i).style.display = 'none';
	}
	if(expand){
		document.getElementById('temat_'+wId+'_'+id).style.display = 'block';
	}
	changeHeight();
	setTimeout("changeHeight();", 150);
	setTimeout("changeHeight();", 250);
	setTimeout("changeHeight();", 350);
	setTimeout("changeHeight();", 500);
	setTimeout("changeHeight();", 1000);
	setTimeout("changeHeight();", 2000);
}

function Przejdz_d() {
	document.getElementById('infobox_1').innerHTML = '<p style="margin: 50px 0px 80px 50px;">Narazie puste</p>';
}