function DrawImage(ImgD, iwidth, iheight){ //resize image(name)
    var image=new Image();
    image.src=ImgD.src;
	var a=image.width/image.height;
	var b=iwidth/iheight;
        if( a>= b){
            if(image.width>iwidth){
                ImgD.width=iwidth;
                ImgD.height=(image.height*iwidth)/image.width;
				//document.writeln('1ImgD.width='+ImgD.width+'<br>');
				//document.writeln('ImgD.height='+ImgD.height);
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
        }
        else{
            if(image.height>iheight){
                ImgD.height=iheight;
                ImgD.width=(image.width*iheight)/image.height;
				//document.writeln('3ImgD.width='+ImgD.width+'<br>');
				//document.writeln('ImgD.height='+ImgD.height);
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
				//document.writeln('4ImgD.width='+ImgD.width+'<br>');
				//document.writeln('ImgD.height='+ImgD.height);
            }
        }
}



function preloadAlbums(AlbumType, PageNo){ 
//alert('AlbumType:'+AlbumType+'&&PageNo:'+PageNo)
var preloadAlbumsPic=new Array();
for (i=1;i<5;i++){
preloadAlbumsPic[i]=new Image();
//alert(researchpic.length-4*(PageNo-1)-i);
if (AlbumType=='research'){	if((researchpic.length-4*(PageNo-1)-i)>0){
preloadAlbumsPic[i].src='albums/research'+(researchpic.length-4*(PageNo-1)-i)+".jpg";
//alert(preloadAlbumsPic[i].src)
}
}
if (AlbumType=='activity'){	if((activitypic.length-4*(PageNo-1)-i)>0){
preloadAlbumsPic[i].src='albums/activity'+(activitypic.length-4*(PageNo-1)-i)+".jpg";
//alert(preloadAlbumsPic[i].src)
}
}
if (AlbumType=='visitor'){if((visitorpic.length-4*(PageNo-1)-i)>0){
preloadAlbumsPic[i].src='albums/visitor'+(visitorpic.length-4*(PageNo-1)-i)+".jpg";
//alert(preloadAlbumsPic[i].src)
}
}
if (AlbumType=='conference'){if((conferencepic.length-4*(PageNo-1)-i)>0){
preloadAlbumsPic[i].src='albums/conference'+(conferencepic.length-4*(PageNo-1)-i)+".jpg";
//alert(preloadAlbumsPic[i].src)
}
}
}


}