// JavaScript Document
/*
load anh 
*/
function onPreload(aImages, nImages,idimag,widthnew,heightnew)
{
   try{ 
     var oIdimag;
     oIdimag = document.getElementById(idimag);
      
            if ( nImages == 1 ){
                  aImages =  resizePicture(aImages.src,widthnew,heightnew);
                  oIdimag.style.width = aImages.width+"px";
                  oIdimag.style.height = aImages.height+"px";
                  oIdimag.src=aImages.src;
                  return ;
               }else{
                     oIdimag.style.width = width+"px";
                     oIdimag.style.height = height+"px";
                     oIdimag.src='images/no-image.gif';
                     }
    
  }catch(e){
	    
      return false;
      }
}
/*
    - Ham thuc hien viec resize hinh anh theo mot kich thuc khac
*/
function resizePicture(url,rong,cao)
{
	const_width = rong;
	const_height = cao;
	oImg = new Image();
	oImg.src =url;
	if((rong > oImg.width )&& (cao > oImg.height )){
	return oImg;
	}else{	
	scale = (const_width/oImg.width > const_height/oImg.height) ? const_height/oImg.height : const_width/oImg.width;
	oImg.width = oImg.width * scale;
	oImg.height = oImg.height * scale;
	}
	return oImg;
}
/*
the hien trang thai cua viec loading cua anh
*/


function loading(Image,Idimage,widthnew,heightnew)
{
      
	   try{
		 
     	   var urlsmall = [Image];
		  
          new ImagePreloader(urlsmall, onPreload,Idimage,widthnew,heightnew);
        }catch(e){
        
            return false;
}
}
function RandomImage(arr)
{
	var d= new Date();
	var sec = d.getSeconds();
	//if(sec%2==0)
		
}
function GetDate()
{
	var d=new Date();
	return "Ngày "+d.getDate()+" tháng "+(d.getMonth()+1)+" năm "+d.getFullYear();
}