// khi trang web vua load xong lan dau 

$( function(){
       query = 'type=anouncement'; 
       $.get("modules/anouncement/anouncement.php",query,refreshData);
       
       
});

// khi click cac link cua menu ben trai
function menuleft(type,id_parent){
   query = "type="+type+"&idparent="+id_parent;
      switch(type){
            case 'about' :
                $.get("modules/about/about.php",query,refreshData);
            break;
            case 'organization' :
                $.get("modules/organization/organization.php",query,refreshData);
            break;
            case 'infrastructure' :
                 $.get("modules/infrastructure/infrastructure.php",query,refreshData);
            break;
            case 'form' :
                 $.get("modules/form/form.php",query,refreshData);
            break;
            case 'process' :
                $.get("modules/process/process.php",query,refreshData);
            break;
            case 'anouncement' :
                $.get("modules/anouncement/anouncement.php",query,refreshData);
            break;
            case 'job' :
                 $.get("modules/job/job.php",query,refreshData);
            break;
            case 'download' :
                 $.get("modules/download/download.php",query,refreshData);
            break;
            case 'contact':
                 $.get("modules/contact/contact.php",query,refreshData);
            default:
                  $.get("modules/about/about.php",query,refreshData);       
            break;
      }
}
function refreshData(data, statusText){
    $("#content").empty().append(data);
    
    $("#contentborder  a").click(
            function(event){
                url = $(this).attr("href");
                
                $.get(url,refreshDataDetail);
                event.preventDefault();  
            }        
     );
     $("#paging a").click(
        function(event){
             url = $(this).attr("href");
                
             $.get(url,refreshDataDetail);
             event.preventDefault(); 
        }
     );
      $("#contact").click(
        function(event){
             url = $(this).attr("href");
            // console.debug('contact');   
             $.get(url,refreshDataDetail);
             event.preventDefault(); 
        }
     );
     $("#detail_back > a").click(
            function(event){
                url = $(this).attr("href");
                //console.debug(url);
                $.get(url,refreshData);
                event.preventDefault();  
            }        
     );
         
}

function refreshDataDetail(data, statusText){
//console.debug(data);
     $("#content").empty().append(data);
     $("#detail_back > a").click(
            function(event){
                url = $(this).attr("href");
                //console.debug(url);
                $.get(url,refreshData);
                event.preventDefault();  
            }        
     );
      $("#paging a").click(
        function(event){
             url = $(this).attr("href");
                
             $.get(url,refreshDataDetail);
             event.preventDefault(); 
        }
     );
}