var timer= false;
var bg_obj= false;
var min_margin= -966;
var time_step= 25;
var margin_step= -1;
var action= true;
window.onload= function () {
	run_bg();
	recollectPNG();
}
function run_bg() {
	if ( !action ) { clearTimeout( timer ); return; }
	if ( !bg_obj ) { bg_obj= document.getElementById( "bg" ); if ( !bg_obj ) return; }
	
	//alert( parseFloat( bg_obj.style.marginLeft) );
	
	if ( parseFloat( bg_obj.style.marginLeft) <= min_margin ) {
		//alert( "stop" );
		action= false;
		clearTimeout( timer );
		return;
	}
	bg_obj.style.marginLeft= parseFloat( bg_obj.style.marginLeft)+margin_step+"px";
	clearTimeout( timer );
	timer= setTimeout( "run_bg()", time_step );
}

var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);

function fix_png ( img_obj ) {
		if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
				var imgID = ( img_obj.id ) ? "id='" + img_obj.id + "' " : "";
				var imgClass = ( img_obj.className ) ? "class='" + img_obj.className + "' " : "";
				var imgTitle = ( img_obj.title ) ? "title='" + img_obj.title + "' " : "title='" + img_obj.alt + "' ";
				var imgStyle = "display:inline-block;" + img_obj.style.cssText;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + 
									"width:" + img_obj.width + 
									"px; height:" + img_obj.height + "px;" + 
									imgStyle + ";" + 
									"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + 
									"(src=\'" + img_obj.src + "\', sizingMethod='scale');\"></span>";
				img_obj.outerHTML = strNewHTML;
		}
}

//window.addOnLoadListener( recollectPNG );
//window.onload= recollectPNG;
//jsEvent.addEvent(window, 'load', recollectPNG);
//alert( "" );

function recollectPNG () {
	//alert( "start"+version );
	//var statistic_container_obj= document.getElementById( "statistic_container" ); if ( !statistic_container_obj ) return;
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
		var stat_temp= "here";
		var collectedPng= new Array();
		var candidates= document.getElementsByTagName( "img" );
		
		//alert( candidates.length );
		
		for ( var c in candidates ) {
			if ( typeof( candidates[ c ].src ) == "undefined" || !candidates[ c ].src ) continue;
			//stat_temp+= "Looking src: "+candidates[ c ].src+"<br />";
			if ( candidates[c].src.indexOf( ".png" ) < 0 ) continue;
			//stat_temp+= "founded<br /><br /> ";
			collectedPng[ collectedPng.length ]= candidates[ c ];
			//fix_png( candidates[ c ] );
		} //end for
		//statistic_container_obj.innerHTML= stat_temp;
		if ( collectedPng.length > 0 ) {
			for ( var cP= 0; cP < collectedPng.length; cP++ ) {
				fix_png( collectedPng[ cP ] );
			} //end for
		}
	} //end if
}