var IE=navigator.appName=="Microsoft Internet Explorer";
var Opera=navigator.appName.toLowerCase()=="opera";
var FF=!IE && !Opera;
function loaderFunction(style,num,iframe_width,iframe_height) {
this._preImages = new Array();
this._imageUrlBuffer = new Array();
this._currentID = 0;
this._loaded = new Array();
this._loadedNum = 0;
this._currentLoading = "";
this._timeOut = 2 * 1000;
this._timeElapsed = 0;
this._checkInterval = 50;
this._style = style;
this._num = num;
this._iframe_height = iframe_height;
this._iframe_width = iframe_width;
this._loadok = new Array();
}
loaderFunction.prototype.add = function() {
for (var i = this._currentID; i < arguments.length; this._currentID++,i++) {
if (arguments[i] != null || arguments[i] != "") {
this._imageUrlBuffer[i] = arguments[i];
}
}
}
loaderFunction.prototype.getResourceCount = function() {
return this._imageUrlBuffer.length;
}
loaderFunction.prototype.getLoadedCount = function() {
return this._loadedNum;
}
loaderFunction.prototype.getCurrentLoading = function() {
return this._currentLoading;
}
loaderFunction.prototype.setTimeOut = function(ts) {
this._timeOut = ts;
}
loaderFunction.prototype.getTimeOut = function() {
return this._timeOut;
}
loaderFunction.prototype.startLoad = function() {
for (var i = 0; i < this._imageUrlBuffer.length; i++) {
this._preImages[i] = new Image();
var test = new Image();
if(FF)
{
this._preImages[i].onload = this.loading(i);
}
this._preImages[i].src = this._imageUrlBuffer[i];
this._loaded[i] = false;
}
this.checkLoad();
}
if(FF)
{
loaderFunction.prototype.loading = function(k)
{
this._loadok[k] = 1;
}
}
loaderFunction.prototype.checkLoad = function() {
if (this._loadedNum == this._preImages.length) {
this.onLoadFinish();
return;
}
if (this._timeElapsed >= this._timeOut) {
this.onTimeOut();
return;
}
for (i = 0; i < this._preImages.length; i++) {
if(FF)
{
if (this._loaded[i] == false && this._loadok[i] == 1 && this._preImages[i].height == 50) {
this._loaded[i] = true;
this._currentLoading = this._imageUrlBuffer[i];
this._loadedNum++;
this.onProgressChange();
}
}
else
{
if (this._loaded[i] == false && this._preImages[i].complete) {
this._loaded[i] = true;
this._currentLoading = this._imageUrlBuffer[i];
this._loadedNum++;
this.onProgressChange();
}
}
}
this._timeElapsed += this._checkInterval;
setTimeout("a"+this._style+".checkLoad()",this._checkInterval);
}
loaderFunction.prototype.onProgressChange = function() {
;
}
loaderFunction.prototype.onLoadFinish = function() {
document.getElementById("d"+this._style).innerHTML=DilinglingShowad(this._style,this._num,this._iframe_width,this._iframe_height);
}
loaderFunction.prototype.onTimeOut = function() {
//alert("timeout!");
}