﻿

function addListener(element, type, expression, bubbling)
{
  bubbling = bubbling || false;
  if(window.addEventListener)	{ // Standard
    element.addEventListener(type, expression, bubbling);
    return true;
  } else if(window.attachEvent) { // IE
    element.attachEvent('on' + type, expression);
    return true;
  } else return false;
}

var ImageLoader = function(url){
  this.url = url;
  this.image = null;
  this.loadEvent = null;
};

ImageLoader.prototype = {
  load:function(){
    this.image = document.createElement('img');
    var url = this.url;
    var image = this.image;
    var loadEvent = this.loadEvent;
    addListener(this.image, 'load', function(e){
      if(loadEvent != null){
        loadEvent(url, image);
      }
    }, false);
    this.image.src = this.url;
  },
  getImage:function(){
    return this.image;
  }
};


function putImage(image){
  var h = document.getElementById('imageHolder');
  while(h.firstChild){
    h.removeChild(h.firstChild);
  }
  h.appendChild(image);
}

function setStatusText2(text, id){
  var t = document.getElementById(id);
  while(t.firstChild){
    t.removeChild(t.firstChild);
  }

  t.appendChild(document.createTextNode(text));
}

function setStatusText(text, id){
  var t = document.getElementById(id);
  //while(t.firstChild){
  //  t.removeChild(t.firstChild);
  //}
	t.innerHTML = text
  //t.appendChild(document.createTextNode(text));
}



function loadImage2(yer){
var loader = new ImageLoader('/resg.asp?kutu=700&res='+yer);
//setStatusText('loading image...', 'status');
setStatusText('<img src="/loading3.gif" border="0" > Yükleniyor...&nbsp;&nbsp;', 'status');
loader.loadEvent = function(url, image){
  setStatusText(' ', 'status');
  putImage(image);
}
loader.load();
}



