hasui = false;

function showUI() {
	var fl = document.getElementById('flobj'),
		wra = document.getElementById('wrap'),
		o = 0,
		fade = function() {
			if(o < 10) {
				o += 1;
				wra.style.opacity = o/10;
				//fl.style.opacity = 1-(o/10);
				if(navigator.userAgent.indexOf('MSIE') !== -1) {
					fadeChildren(wra, (o*10));
				}
				setTimeout(fade, 100);
			} else {
				wra.style.opacity = 1;
				if(navigator.userAgent.indexOf('MSIE') !== -1) {
					fadeChildren(wra, false);
				}
				fl.parentNode.removeChild(fl);
			}
			return;
		};
	if(!hasui) {
		hasui = true;
		wra.style.visibility='visible';
		fade();
	}
}

function fadeChildren(el, amnt) {
	var cnt = 0;
	try {
		if(el.id !== 'inlinelogo') {
			if(amnt === false) {
				el.style.filter = '';
			} else {
				el.style.filter = 'alpha(opacity='+amnt+')';
			}
		}
		if(el.id && el.id == 'refill') {
			if(amnt === false) {
				el.style.filter = '';
				el.style.background = 'url(images/refill.png)';
			} else {
				el.style.background = 'none';
				el.style.filter = 'alpha(opacity='+amnt+') progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/refill.png)';
			}
		}
	} catch(err) {}
	if(el.childNodes.length > 0 && el.id != 'nav') {
		for(cnt = 0; cnt < el.childNodes.length; cnt++) {
			fadeChildren(el.childNodes[cnt], amnt);
		}
	}
}

var flashit = function() {
	var start = function() {
		var wrap, fl, i=0;
		if(document.getElementById('wrap')) {
			if(hasflash && document.body.id == 'home' && document.referrer.indexOf('milostea.com') === -1) {
				wrap = document.getElementById('wrap');
				wrap.style.opacity = 0;
				if(navigator.userAgent.indexOf('MSIE') !== -1) {
					fadeChildren(wrap, 0);
				}
				wrap.style.visibility='hidden';
				wrap.style.background = 'url(images/final.jpg)';
				fl = document.createElement('div');
				fl.id = 'flobj';
				fl.style.position = 'absolute';
				fl.style.height = '657px';
				fl.style.width = '790px';
//				fl.style.clip = 'auto';
//				fl.style.overflow = 'hidden';
				//fl.style.background='url(images/home_no_light.jpg)';
				fl.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="790" height="657" id="milos_intro" align="middle"><param name="allowScriptAccess" value="sameDomain"><param name="allowFullScreen" value="false"><param name="movie" value="flash/milos_intro.swf"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="bgcolor" value="#ffffff">	<embed src="flash/milos_intro.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="790" height="657" name="milos_intro" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></object>';
				wrap.parentNode.insertBefore(fl, wrap);
			}
		} else {
			setTimeout(start, 1);
		}
	}
	start();
}();
