function preloadimages(srclist, callback){
	var i;
	var imgTotal=n=srclist.length;
	var w=0;
	var step=(100/n);
	var loading = new Element('div', {'class': 'loading'});
	var border = new Element('div', {'class': 'loadingbar-border','style': 'width:100px;height:10px;'});
	var bar = new Element('div', {'class': 'loadingbar','style': 'width:'+w+'px;height:10px;'});
	Element.insert(border, bar);
	loading.innerHTML="loading";
	Element.insert(loading, border);
	Element.insert($$('body')[0], loading);
	for(i=0; i<n; i++){
		if(srclist[i].indexOf(".mp3")!=-1){
			
			new Ajax.Request("res/sound/"+srclist[i], {
			method: 'get',
			asynchronous:true,
			onSuccess: function(transport) {
				imgTotal--;
				w+=step;
				bar.style.width=w+'px';
				if(imgTotal==0){
					complete();
				}
			}
			});
		}
		else{
			var img=new Image();
			var ext=(srclist[i].indexOf(".")==-1)? '.gif':'';
			img.src='res/images/'+srclist[i]+ext;
			if (img.complete) {
				imgTotal--;
				w+=step;
				bar.style.width=w+'px';
				if(imgTotal==0){
					complete();
				}
			}
			else{
				img.onload=function(){
					imgTotal--;
					w+=step;
					bar.style.width=w+'px';
					if(imgTotal==0){
						complete();
					}
				};
			}
		}
	}
	function complete(){
		loading.remove();
		callback();
	}
}
