﻿//Flyout.js
function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 'px';
    top.style.left = location.x + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}

var openfly;

function zipfly() {
	var flyboxstyle;
	var comma = openfly.indexOf(',');
	var id = openfly.substring(0, comma);
	var width = openfly.substring(comma+1);
	var closeparent = id.replace(/_content/, 'CloseParent');
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (!document.getElementById(id))
			return; //element gone...
		flyboxstyle = document.getElementById(id).style;
	}
	else {
		if (document.layers) { // NS4
			if (!document.id)
				return; //element gone...
			flyboxstyle = document.id;
		}
		else { // IE4
			if (!document.all.id.style)
				return; //element gone...
			flyboxstyle = document.all.id.style;
		}
	}
	
	flyboxstyle.display = 'none';
	flyboxstyle.height = '';
	flyboxstyle.width = width + 'px';
	document.getElementById(closeparent).style.opacity = '0';
	openfly = '';
}

function killFlyOuts(fly) {
	if (openfly != null)
		if (openfly != '')
			zipfly();
	
	openfly = fly;
}

