// Image Preloader
// Copyright 2006 by Michal Gajek
// http://migajek.com/


var isIE = navigator.appName.search("Microsoft") == 0;

function $(id){
	return document.getElementById(id);
}

function setAlpha(obj, alpha){
	if (isIE){
		obj.style.filter = "alpha(opacity = "+alpha+")";
	} else {
		obj.style.opacity = alpha / 100;
	}
}


function promptWin(divname, imgname, imgsrc){
var obj = $(divname);
var img = $(imgname);

var  scrLeft = document.documentElement.scrollLeft;
var  scrTop =  document.documentElement.scrollTop ;

//utworz element z tekstem
if (document.getElementById('loadingd') == null ){
	var theNewDiv = document.createElement('div');
	theNewDiv.setAttribute('id','loadingd');
	theNewDiv.setAttribute('style', 'color: black; font-weight: bold;');	
	var txt = document.createTextNode('Loading ...');
	theNewDiv.appendChild(txt);
	obj.appendChild(theNewDiv);
}	

// pokaz status "ladowanie"
obj.style.top = scrTop + ( (Math.round(document.documentElement.clientHeight / 2) - 20 ) ) + 'px';
obj.style.left = scrLeft + ( (Math.round(document.documentElement.clientWidth / 2) - 200 ) ) + 'px';
obj.style.width = '400px';
obj.style.height = '60px';

obj.style.backgroundColor = '#C3BDBD';
obj.style.borderStyle = 'solid';
obj.style.borderWidth = '2px';
obj.style.borderColor = 'black';

setAlpha(obj, 70);
obj.style.display  = "block";				

	if (img){
		img.src = "./images/green_rot.gif";
		img.alt= 'Click to close';
		
		var iPr = new Image();
		
		iPr.onload = function (){
			obj.style.width = document.documentElement.clientWidth + 'px';
			obj.style.height = document.documentElement.clientHeight + 'px';
			obj.style.top = scrTop +'px';//+ ( (Math.round(document.documentElement.clientHeight / 2) - 20 ) ) + 'px';
			obj.style.left = scrLeft + 'px';// +( (Math.round(document.documentElement.clientWidth / 2) - 200 ) ) + 'px';			
			setAlpha(obj, 90);
			obj.removeChild(theNewDiv);
			obj.style.backgroundColor = '#000000';			
			img.src = imgsrc;			
		}		
		
		iPr.src = imgsrc; 		
	} 

}
