var shadow_nextInnerHTML = "";
setTimeout("shadow_CreateBox()", 100);


function shadow_CreateBox()
{
	if (!document || !document.body)
	{
		setTimeout("shadow_CreateBox()", 100);
		return;
	}
	
	var shadowBox          = document.createElement("DIV");	shadowBox.id = "shadowBox";
	var shadowWindowHolder = document.createElement("DIV");	shadowWindowHolder.id = "shadowWindowHolder";
	
	shadowBox.style.position = "absolute";
	shadowBox.style.top = "0px";
	shadowBox.style.left = "0px";
	shadowBox.style.width  = "100%";
	try {
		shadowBox.style.height = parseInt(document.body.offsetHeight)+'px';
	} catch (e) {}
	
	shadowBox.style.zIndex = 998;
	try { shadowBox.style.filter  = "alpha(opacity=0)"; } catch (e) {}
	try { shadowBox.style.opacity = 0; } catch (e) {}
	shadowBox.style.background = "#000000";
	shadowBox.style.display = "none";
	shadowBox.onclick = shadow_HideAll;
	
	shadowWindowHolder.style.position = 'fixed';
	shadowWindowHolder.style.top    = "0px";
	shadowWindowHolder.style.left   = "0px";
	shadowWindowHolder.style.width  = "100%";
	shadowWindowHolder.style.display = "none";
	shadowWindowHolder.style.color   = "#FFFFFF";
	shadowWindowHolder.style.zIndex  = 999;
	
	shadowWindowHolder.innerHTML = "<center><div id='shadowWindow' style='width: 60px; padding-top: 30px'>"+
		"<div id='shadowWindowBody' style='border: 2px solid #888888; background: black; text-align: left; height: 60px;'></div>"+
		"<div style='text-align: right; cursor: pointer' onclick='shadow_HideAll()'>x Close</div>"+
	"</div></center>";
	
	document.body.appendChild(shadowWindowHolder);
	document.body.appendChild(shadowBox);

	var arr = document.body.getElementsByTagName("A");
	for (i=0; i<arr.length; i++)
		if (arr[i].target.toLowerCase().indexOf("_shadow") != -1)
			arr[i].onclick = shadow_Click
}

function shadow_Click(ev)
{
	var shadowBox          = document.getElementById("shadowBox");
	var shadowWindowHolder = document.getElementById("shadowWindowHolder");
	var shadowWindow       = document.getElementById("shadowWindow");
	var shadowWindowBody   = document.getElementById("shadowWindowBody");

	if (typeof this.href == "string")
	{
		var W = 700, H = 480;
		if (this.target.length > 7)
		{
			W = parseInt(this.target.substr(7));
			if (this.target.indexOf('x') > 7)
				H = parseInt(this.target.substr(this.target.indexOf('x')+1));
		}
		
		shadowBox.style.display = "block";
		shadowBox.style.height = parseInt(document.body.offsetHeight)+'px';
		try { shadowBox.style.filter  = "alpha(opacity=0)"; } catch (e) {}
		try { shadowBox.style.opacity = 0; } catch (e) {}
		
		shadowWindow.style.width = "0px";
		shadowWindowBody.style.height = "0px";
		shadowWindowBody.innerHTML = "";
		shadowWindowHolder.style.display = "block";
		
		
		setTimeout("shadow_animate('shadowBox'       , 1, 1, 0, 0.85)", 30);
		setTimeout("shadow_animate('shadowWindow'    , 1, 1, 1, "+(W+4)+")" , 200);
		setTimeout("shadow_animate('shadowWindowBody', 1, 1, 2, "+H+")" , 300);
		
		shadow_nextInnerHTML = "<iframe frameborder='0' src='"+this.href+"' style='width: "+W+"px; height: "+H+"px; overflow:hidden' scrolling='no'></iframe>";
		
		return false;
	}
}

function shadow_animate(elID, cur_pos, pos_add, anim_type, dest_value)
{
	var obj = document.getElementById(elID);
	
	if (anim_type == 0)
	{
		try { obj.style.filter  = "alpha(opacity=" + (cur_pos * dest_value * 10) + ")"; } catch (e) {}
		try { obj.style.opacity = cur_pos * dest_value / 10; } catch (e) {}
	}
	if (anim_type == 1) obj.style.width   = (cur_pos * dest_value / 10)+"px";
	if (anim_type == 2) obj.style.height  = (cur_pos * dest_value / 10)+"px";
	cur_pos = cur_pos + pos_add;
	
	if (cur_pos > 0 && cur_pos <= 10)
		setTimeout("shadow_animate('"+obj.id+"', "+cur_pos+", "+pos_add+", "+anim_type+", "+dest_value+")", 30);
	else {
		if (elID == 'shadowBox'        && cur_pos ==  0) obj.style.display = "none";
		if (elID == 'shadowWindowBody' && cur_pos >= 10) obj.innerHTML = shadow_nextInnerHTML;
	}
}

function shadow_HideAll()
{
	var shadowBox          = document.getElementById("shadowBox");
	var shadowWindowHolder = document.getElementById("shadowWindowHolder");
	var shadowWindowBody   = document.getElementById("shadowWindowBody");
	
	shadowBox.style.display = "none";
	shadowWindowHolder.style.display = "none";
	shadowWindowBody.innerHTML = "";
}

