// JavaScript Document
   $(document).ready(function(){
                  
            /* phần tử cuối cùng của mảng hình background */
            var lastEl = $("#body-bg > div").length-1;
          	var save_lastEl = lastEl; save_lastEl++;
            /* add css */
            $("#body-bg").css({"left":0,"top":0, "z-index":"-1"});
            $("#body-bg div").css({"width":$(document).width(), "height":$(document).height(), "height":"600px", "min-width":"800px","position":"absolute"});
           $("#body-bg > div").slice(1, save_lastEl).css("display","none"); // ẩn phan tu thu 2 tro di
					 					 
					 /* Cho phan tu dau tien cua mang la background mac dinh */
            var bgId = 0;   
            var preId = lastEl;
         		
						$('#body-bg').innerfade({ 
							speed: 8000, 
							timeout: 10000, 
							type: 'sequence', 
							containerheight: '220px'
						});
						
           // sau 8 giay goi lai ham thay doi background 1 lan
            /*setInterval(function()
                    {
                        if (bgId == lastEl)
                        {
                            bgId = 0;
                            preId = lastEl;
                        }
                        else
                        {
                            bgId++;
                            preId = bgId - 1;
                        }
                       
                       $("#body-bg > div").slice(preId).fadeOut('slow'); // hình hiện tại mờ dần trong 6 giây
											
                       $( "#body-bg > div ").slice(bgId).fadeIn('fast'); // hình tiếp theo hiện lên trong 6 giây
                    }, 8000 // 50 giây gọi lại hàm này
                );*/
        })
