/***
	dLoader v 1.0.1 
	Copyright by Daken, 2008
	mailto: me@daken.ru
	www.daken.ru
***/

var dLoader = new Object;
dLoader.imagesToLoad;
dLoader.progbarWidth = 333;
dLoader.progbarId = 'mainprogbarfg';
dLoader.gId = function(i){ return document.getElementById(i); }
dLoader.getScript =  function(src, size){
	this.jsCount++;
   var script = document.createElement('script');
   script.type = 'text/javascript';
   script.onreadystatechange= function (){ 
	if (this.readyState == 'complete' || this.readyState == 'loaded') 
       dLoader.jsLoaded(size);
   }
   script.onload = function () { dLoader.jsLoaded(size); }
   script.src = src;
   document.getElementsByTagName('head')[0].appendChild(script);
}
dLoader.jsLoaded = function(size){
	dLoader.itemLoaded(size);
	this.jsLoadedCnt++;
	if(this.jsCount==this.jsLoadedCnt)
		setTimeout("dLoader.beginInvokes();", 250);
}
dLoader.beginInvokes = function(){
	var inv = this.loadData.invoke;
	for(var i=0;i<inv.length;i++){
	    try{
		    eval(inv[i].action + '("dLoader.itemLoaded(' + inv[i].size + ')");');
		}catch(exc){}
	}
}
dLoader.progress = function(){
    for(key in this.imagesToLoad){
        if(this.imagesToLoad[key]!=null && this.imagesToLoad[key].complete){
            this.itemLoaded(this.imagesToLoad[key].size);
            this.iLoaded++;
			this.imagesToLoad[key] = null;
        }
    }
}

dLoader.itemLoaded = function(size) {
    this.bytesLoaded += size;
	if(this.userProgress)
		this.userProgress(this.bytesLoaded, this.totalBytes);
	else{
		var pos = this.progbarWidth * this.bytesLoaded / this.totalBytes;
		this.gId(this.progbarId).style.width = Math.floor(pos)+'px';
	}
    if(this.bytesLoaded == this.totalBytes){
       clearInterval(this.progressTimer);
	   if(this.onLoad)
		setTimeout("dLoader.onLoad();", 250);
    }
}
dLoader.calcImages = function() {
    this.imagesToLoad = Array();
    var di = document.images;
    for(var i=0;i<di.length;i++){
        if(!di[i].completed)
            di[i].size = 1;
            this.imagesToLoad[i] = di[i];
            this.totalBytes++;
    }
}
dLoader.start2 = function(pbId, pbWidth, mode, callBack){
    ld = this.loadData;
	this.progbarId = pbId;
	this.progbarWidth = pbWidth;
	this.onLoad = callBack;
    this.bytesLoaded = 0;
    this.iLoaded = 0;
	this.jsCount = this.jsLoadedCnt = 0;
    if(mode=='count'){
        var fj = ld.js;
        this.totalBytes = fj.length;
        for(var i=0;i<fj.length;i++)
            this.getScript(fj[i].path, 1);
        this.calcImages();
    }
    else if(mode=='size'){
        this.totalBytes = 0;
        var a = ld.js;
        for(var i=0;i<a.length;i++){
            this.getScript(ld.jspath + a[i].path, a[i].size);
            this.totalBytes+=a[i].size;
        }
        a = ld.im;
        this.imagesToLoad = Array();
        for(var i=0;i<a.length;i++){
            var im = new Image();
            im.src = ld.impath +a[i].path;
            im.size = a[i].size;
            this.imagesToLoad[i] = im;
            this.totalBytes+=im.size;
        }
		a = ld.invoke;
        for(var i=0;i<a.length;i++){
            this.totalBytes+=a[i].size;
        }
    }
    this.progressTimer = setInterval("dLoader.progress();", 25);
}
dLoader.start = function(pbId, pbWidth, mode, callBack){
    window.onload = document.body.onload = function(){
        dLoader.start2(pbId, pbWidth, mode, callBack);
    }
}



dLoader.loadData = {"js":[{"path":"jquery.js","size":89084},{"path":"loader.js","size":10456}],"im":[{"path":"\/1.gif","size":43},{"path":"\/bookmarks\/chrome.png","size":2196},{"path":"\/bookmarks\/chrome_glow.png","size":2203},{"path":"\/bookmarks\/delicious.png","size":2220},{"path":"\/bookmarks\/delicious_glow.png","size":2220},{"path":"\/bookmarks\/firefox.png","size":2194},{"path":"\/bookmarks\/firefox_glow.png","size":2217},{"path":"\/bookmarks\/google.png","size":2204},{"path":"\/bookmarks\/google_glow.png","size":2220},{"path":"\/bookmarks\/ie.png","size":2209},{"path":"\/bookmarks\/ie_glow.png","size":2220},{"path":"\/bookmarks\/konqueror.png","size":2190},{"path":"\/bookmarks\/konqueror_glow.png","size":2220},{"path":"\/bookmarks\/opera.png","size":2190},{"path":"\/bookmarks\/opera_glow.png","size":2220},{"path":"\/bookmarks\/safari.png","size":2210},{"path":"\/bookmarks\/safari_glow.png","size":2220},{"path":"\/bookmarks\/yandex.png","size":2193},{"path":"\/bookmarks\/yandex_glow.png","size":2220},{"path":"\/css.png","size":6022},{"path":"\/css_glow.png","size":6210},{"path":"\/fonts\/yellow\/0.png","size":1349},{"path":"\/fonts\/yellow\/0A.png","size":1260},{"path":"\/fonts\/yellow\/1.png","size":1237},{"path":"\/fonts\/yellow\/2.png","size":1374},{"path":"\/fonts\/yellow\/3.png","size":1379},{"path":"\/fonts\/yellow\/4.png","size":1318},{"path":"\/fonts\/yellow\/5.png","size":1378},{"path":"\/fonts\/yellow\/6.png","size":1373},{"path":"\/fonts\/yellow\/7.png","size":1323},{"path":"\/fonts\/yellow\/8.png","size":1385},{"path":"\/fonts\/yellow\/9.png","size":1356},{"path":"\/h1.png","size":1071},{"path":"\/hands.png","size":6043},{"path":"\/hands_glow.png","size":6269},{"path":"\/l.png","size":1109},{"path":"\/loading.png","size":11732},{"path":"\/logo.png","size":30088},{"path":"\/logo2.png","size":30126},{"path":"\/menu\/about.png","size":2776},{"path":"\/menu\/about_glow.png","size":2831},{"path":"\/menu\/articles.ajax-preloaders.png","size":3900},{"path":"\/menu\/articles.ajax-preloaders_glow.png","size":3978},{"path":"\/menu\/articles.delete-files-from-svn.png","size":5059},{"path":"\/menu\/articles.delete-files-from-svn_glow.png","size":5157},{"path":"\/menu\/articles.gimp_can_everything.png","size":3572},{"path":"\/menu\/articles.gimp_can_everything_glow.png","size":3604},{"path":"\/menu\/articles.png","size":2333},{"path":"\/menu\/articles_glow.png","size":2354},{"path":"\/menu\/index.png","size":3740},{"path":"\/menu\/index_glow.png","size":3794},{"path":"\/menu\/projects.html_stripper.png","size":5359},{"path":"\/menu\/projects.html_stripper_glow.png","size":5444},{"path":"\/menu\/projects.png","size":3822},{"path":"\/menu\/projects.veapon.png","size":3001},{"path":"\/menu\/projects.veapon_glow.png","size":3027},{"path":"\/menu\/projects_glow.png","size":3867},{"path":"\/menu_arrow.png","size":878},{"path":"\/progbar-ie.png","size":13306},{"path":"\/progbar.png","size":14165},{"path":"\/progbar_glow-ie.png","size":12894},{"path":"\/progbar_glow.png","size":23486},{"path":"\/progbar_ph.gif","size":57},{"path":"\/texture1.jpg","size":21144},{"path":"\/texture2.jpg","size":17301},{"path":"\/xhtml.png","size":5987},{"path":"\/xhtml_glow.png","size":6150},{"path":"\/z1-ie.png","size":3034},{"path":"\/z1.png","size":4909},{"path":"\/z2-ie.png","size":3164},{"path":"\/z2.png","size":5062},{"path":"\/z3-ie.png","size":3162},{"path":"\/z3.png","size":5264}],"invoke":[{"action":"dLoader.LoadTemplates","size":2201}],"jspath":"\/design\/js\/","impath":"\/design\/im"}