function resizeFlash() {
	var f=document.getElementById('flashcontent');
	if(document.body.clientHeight<600) {
		f.style.height='600px';
		document.getElementById('root').style.overflow='scroll';
	} else {
		f.style.height='100%';
	}
	if(document.body.clientWidth<860) {
		f.style.width='860px';
		document.getElementById('root').style.overflow='scroll';
	} else {
		f.style.width='100%';
	}
	if(document.body.clientWidth>=860 && document.body.clientHeight>=600) {	
		document.getElementById('root').style.overflow='visible';
	}

}

function init() {
	if(document.body.clientTop || navigator.userAgent.indexOf('Opera')!=-1 ) {
		window.onresize=resizeFlash;
		resizeFlash();
	}	
}

var winList = new Object();

function pop(file, width, height, scroll, unblock, wname) {
	var sc = 'no';
	if(scroll) sc = 'yes';

	if(!wname) var wn = 'win';
	else var wn = wname;

	var wo = wn;

	if(unblock && !wname) {
		var rnd = Math.random();
		rnd = rnd.toString();
		rnd = rnd.substring(2,rnd.length);
		wn += rnd;
		wo = 'freewin';
	}

	var xp = (screen.width - parseInt(width))/2;
	var yp = (screen.height - parseInt(height))/2;

	var opts = 'width=' + width;
	opts += ',height=' + height;
	opts += ',left=' + xp;
	opts += ',top=' + yp;
	opts += ',screenX=' + xp;
	opts += ',screenY=' + yp;
	opts += ',toolbar=no';
	opts += ',location=no';
	opts += ',directories=no';
	opts += ',status=no';
	opts += ',menubar=no';
	opts += ',scrollbars=' + sc;
	opts += ',resizable=no';

	if(typeof winList[wo] == 'object' && typeof winList[wo].document == 'object') {
		winList[wo].close();
		// Workaround: Opera potrzebuje troche czasu na uaktualnienie obiektu
		if (window.opera) while(typeof winList[wo].document == 'object') {void(null)}
	}

	var re = /.jpg$|.jpeg$|.gif$|.png$/;

	if(re.test(file)) {
		var htmlstring = '<html><head><title>' + document.title + '</title></head><body style="margin:0px; padding:0px"><img alt="" src=' + file + ' width=' + width + ' height=' + height + ' border="0" onclick="self.close()" style="cursor:pointer"></body></html>';
		winList[wo] = window.open('about:blank', wn, opts);
		winList[wo].document.open();
		winList[wo].document.clear();
		winList[wo].document.write(htmlstring);
		winList[wo].document.close();
	}
	else {
		winList[wo] = window.open(file, wn, opts);
	}

	if(winList[wo] && !winList[wo].closed) winList[wo].focus();
}

// Kompatybilnosc wywolan

function popup(file, width, height, scroll, unblock, wname) {
	pop(file, width, height, scroll, unblock, wname)
}

function winopen(file, width, height, scroll, unblock, wname) {
	pop(file, width, height, scroll, unblock, wname)
}