function get_documente_fiscale(containerID,iAn,iCategorie,sCalledBy){jQuery("#"+containerID).html(display_loading());jQuery.ajax({type:"POST",url:"ajax/get_documente_fiscale.php",async:true,data:{an:iAn,categorie:iCategorie,called_by:sCalledBy},success:function(data){a_data=data.split("[%VALUE_SEPARATOR%]");if(a_data[0]=='OK'){jQuery("#year-"+iCategorie).val(a_data[1]);jQuery("#"+containerID).html(a_data[2]);}else{jQuery("#"+containerID).html(display_error("Nu exista documente pentru anul "+iAn+"."));}}});}
function get_rapoarte_evaluari(containerID,iAn,sCalledBy){jQuery("#"+containerID).html(display_loading());jQuery.ajax({type:"POST",url:"ajax/get_rapoarte_evaluari.php",async:true,data:{an:iAn,called_by:sCalledBy},success:function(data){a_data=data.split("[%VALUE_SEPARATOR%]");if(a_data[0]=='OK'){jQuery("#year").val(a_data[1]);jQuery("#"+containerID).html(a_data[2]);}else{jQuery("#"+containerID).html(display_error("Nu exista documente pentru anul "+iAn+"."));}}});}
function get_declaratii_avere(containerID,iCategorie,iPersoana,iAn,sCalledBy){jQuery("#"+containerID).html(display_loading());jQuery.ajax({type:"POST",url:"ajax/get_declaratii_avere.php",async:true,data:{an:iAn,categorie:iCategorie,persoana:iPersoana,called_by:sCalledBy},success:function(data){a_data=data.split("[%VALUE_SEPARATOR%]");if(a_data[0]=='OK'){jQuery("#year-"+iCategorie+"-"+iPersoana).val(a_data[1]);jQuery("#"+containerID).html(a_data[2]);}else{jQuery("#"+containerID).html(display_error("Nu exista declaratii pentru anul "+iAn+"."));}}});}
function change_page(oCaller,sContainerId,iPage,iScript,sParams,iArchive){jQuery("#"+sContainerId).html(display_loading());jQuery("#"+sContainerId).css('border','1px solid red !important');a_id=jQuery(oCaller).attr('id').split('-');if(!iArchive){if(iPage=='next'){jQuery("a[id^=pagNr"+"-"+a_id[1]+"-]").each(function(){if(jQuery(this).hasClass('active')){a_active_id=jQuery(this).attr('id').split('-');var next_page=jQuery(this).next('a');try{if(next_page.attr('id').indexOf('pagNr')==0){oCaller=next_page;iPage=parseInt(a_active_id[2])+1;}}catch(e){oCaller=jQuery(this);iPage=a_active_id[2];}}});}
if(iPage=='prev'){jQuery("a[id^=pagNr"+"-"+a_id[1]+"-]").each(function(){if(jQuery(this).hasClass('active')){a_active_id=jQuery(this).attr('id').split('-');var prev_page=jQuery(this).prev('a');try{if(prev_page.attr('id').indexOf('pagNr')==0){oCaller=prev_page;iPage=parseInt(a_active_id[2])-1;}}catch(e){oCaller=jQuery(this);iPage=a_active_id[2];}}});}
var max=0;jQuery("a[id^=pagNr"+"-"+a_id[1]+"-]").each(function(){var a_pag_id=jQuery(this).attr('id').split('-');if(a_pag_id[2]>max)max=a_pag_id[2];});if(max==iPage){jQuery("#nextPage-"+a_id[1]).hide();}else{jQuery("#nextPage-"+a_id[1]).show();}
if(iPage==1){jQuery("#prevPage-"+a_id[1]).hide();}else{jQuery("#prevPage-"+a_id[1]).show();}}else{}
jQuery.ajax({type:"POST",url:"ajax/"+iScript,async:true,data:{page:iPage,params:sParams,archive:iArchive},success:function(data){a_data=data.split("[%VALUE_SEPARATOR%]");if(a_data[0]=='OK'){jQuery("#"+sContainerId).html(a_data[1]);a_id=jQuery(oCaller).attr('ID').split('-');if(a_data[2]==''){jQuery("a[id^="+a_id[0]+"-"+a_id[1]+"-]").removeClass('active');jQuery(oCaller).addClass('active');}else{jQuery("#pagContainer-"+a_id[1]).html(a_data[2]);jQuery("#pagContainer-"+a_id[1]).show();}}else{jQuery("#"+sContainerId).html(display_error('Nu exista nici o informatie disponibila.'));a_id=jQuery(oCaller).attr('ID').split('-');jQuery("#pagContainer-"+a_id[1]).hide();}}});}
function display_loading(){var loaderImgContainer=jQuery(document.createElement('div'));loaderImgContainer.css("text-align","center");var loaderImg=jQuery(document.createElement('img'));loaderImg.attr("src","imgs/ajax-loader.gif");loaderImg.css({"width":"220px","height":"19px"});loaderImgContainer.html(loaderImg);return loaderImgContainer;}
function display_error(sError){var errorMsgContainer=jQuery(document.createElement('div'));errorMsgContainer.addClass("noResults");errorMsgContainer.html(sError);return errorMsgContainer;}
