$(document).ready(
	function()
	{
			$(".aktWiad").click(function(){				
				$(this).next("ul").slideToggle(100)
			});
			
			$("#navZakladki li").click(function(){
			
				$("ul#navZakladki li.aktyw").removeClass("aktyw");
				$(this).addClass("aktyw");		
				
				var idname = $(this).attr("id");              
        var doc_id = $(this).attr("value");
								
				$("#zakladki").html("<div class='loader' style='height: 200px;'>&#160;</div>");
				$("#zakladki .loader").css("background-image", "url(/gallery/serwis/load.gif)");
				$("#zakladki .loader").css("background-position", "50%");
				$("#zakladki .loader").css("background-repeat", "no-repeat");
				
	      $.ajax({
	        type: "GET",
	        url: "http://www.poland.gov.pl/cache/tab/"+doc_id+".html",
	        //data: "main_template=main/blank&ajax=2&doc_id="+doc_id+"&portlet=WEBZakladki/show_content",
	        //data: "cache/tab/"+doc_id+".html",
	        success: function(msg){  
	          $("#zakladki").html(msg);    
	          zakladkiSlide(); 
	        }  	
			  });		
		  });
		  
		  
		  function zakladkiSlide(){
				$(".zakladka .box").jCarouselLite({				
					btnNext: ".nav_box_zak .next",
					btnPrev: ".nav_box_zak .prev",
					btnPause: "",
					flagi: "",
					speed: 300,
					auto: 0,
					visible: 4,
					circular: false
				});  
			}
			
			zakladkiSlide();
				
			$("#select_miesiac").selectbox();
			$("#select_rok").selectbox();
			$("#select_miejsce").selectbox();
			
  
	});		
	
  function winPopUpInter(name, url, width, height) {
    var x = Math.floor((screen.availWidth-width) / 2);
    var y = Math.floor((screen.availHeight-height) / 2);
    var config = ", left=" + x;
    config += ", top=" + y;
    config += ", scrollbars=yes,resizable=yes,status=yes";

    var popup=window.open(url,name,'width='+width+', height='+height+config);
    return false;
  } /*winPopUp*/	
  
  
  
  
  
  
  function publicationListAdd(id, parentG) {
		 $('#sda_'+id).html('')
		 $('#dda_'+id).html('<img src="gallery/serwis/load.gif"  class="animSectionLoader"  />');
		 $.get("index.php", { portlet: "publication/manageA" , main_template: "main/blank", ajax: 2, parent_graph: parentG, parent_doc: id, dVersion: 'C'},
				  function(data){
			 		$('#dda_'+id).html(data);
			 		$('#sda_'+id).html('<a href="javascript:publicationListDel(\''+id+'\', \''+parentG+'\');"><img src="gallery/system/p_minus.gif" style="margin: 0;" ></a>')
			 		//$('#tda_'+id).append(data);
				  });
  }
  
  function publicationListDel(id, parentG) {
	  $('#dda_'+id).html('');
	  $('#sda_'+id).html(' <a href="javascript:publicationListAdd(\''+id+'\', \''+parentG+'\');"><img src="gallery/system/p_plus.gif" style="margin: 0;" ></a>')
	  $.get("index.php", { portlet: "publication/manageAD" , main_template: "main/blank", ajax: 2, parent_doc: id, dVersion: 'C'});
	
  }
	
  function publicationListDelV(id, parentG) {
	  $('#dvda_'+id).html('');
	  $('#spda_'+id).html(' <a href="javascript:publicationListAddV(\''+id+'\', \''+parentG+'\');" class="redA">pokaż</a>')
	  $.get("index.php", { portlet: "publication/manageAD" , main_template: "main/blank", ajax: 2, parent_doc: id, dVersion: 'V'});
  }
  
  function publicationListAddV(id, parentG) {
		 $('#spda_'+id).html('')
		 $('#dvda_'+id).html('<img src="gallery/serwis/load.gif"  class="animSectionLoader"  />');
		 $.get("index.php", { portlet: "publication/manageA" , main_template: "main/blank", ajax: 2, parent_graph: parentG, parent_doc: id, dVersion: 'V'},
				  function(data){
			 		$('#dvda_'+id).html(data);
			 		$('#spda_'+id).html('<a href="javascript:publicationListDelV(\''+id+'\', \''+parentG+'\');" class="redA">ukryj</a>')
			 		//$('#tda_'+id).append(data);
				  });
} 
  
  
  