//globals
var browserWidth	= 780
var global			= window.document
global.fo_shadows	= new Array

//function to get offset top of an element. Used to place popup windows
function getTotalOffSetTop(e) 
{ 
    var i = 0; 
    while (e.tagName != 'BODY') 
            {                       
            i = i + e.offsetTop;                     
            e = e.offsetParent; 
            }                                               
    return i;       
}

//function to accomodate large popups
function getTop(e,popHeight)
{
	fromTop = getTotalOffSetTop(e)
	if((fromTop - (popHeight/2)) > 0 ){return (fromTop-(popHeight/2));}
	else{return 20;}
}

//function to open new window
function popIframe(url,fromTop,popHeight,popWidth)
{
	
	//clear any already existing drop shadows
	//remove_flyout()
	
	//set position
	document.getElementById('popContainer').style.top = fromTop
	document.getElementById('popContainer').style.left = ((browserWidth/2)-(popWidth/2));
	//set size
	document.getElementById('popContainer').height = popHeight;
	document.getElementById('popContainer').width = popWidth;
	//set source and visibility
	document.getElementById('popContainer').src = "inner_popup_iframe.asp?"  + url;
	document.getElementById('popContainer').style.visibility = "visible";
	
	//draw drop shadow
	//makeRectangularDropShadow(document.getElementById('popContainer'), '#666666', 5)
	
}

//function to close the popUp iframe
function closeIframe(refresh)
{
	
	//remove_flyout()
	
	document.getElementById('popContainer').style.visibility = "hidden";
	document.getElementById('popContainer').src = "";
	if (refresh==1)
	{
//		alert('refresh')
		window.location.href = window.location.href
	}
}

//function to close the popUp iframe
function closeIframeNoReload()
{
	
	remove_flyout()
	
	document.getElementById('popContainer').style.visibility = "hidden";
	document.getElementById('popContainer').src = "";

}

//function for iframe popup to call back and resize itself
function resizeIframe(fromTop,popHeight,popWidth)
{
	//set position
	document.getElementById('popContainer').style.top = fromTop
	document.getElementById('popContainer').style.left = ((browserWidth/2)-(popWidth/2));
	//set size
	document.getElementById('popContainer').height = popHeight;
	document.getElementById('popContainer').width = popWidth;
}

//function to draw drop shadows
function makeRectangularDropShadow(el, color, size)
{
	var i;
	for (i=size; i>0; i--)
	{
		var rect = document.createElement('div');
		var rs = rect.style
		rs.position = 'absolute';
		rs.left = (el.style.posLeft + i) + 'px';
		rs.top = (el.style.posTop + i) + 'px';
		rs.width = el.offsetWidth + 'px';
		rs.height = el.offsetHeight + 'px';
		rs.zIndex = el.style.zIndex - i;
		rs.backgroundColor = color;
		var opacity = 1 - i / (i + 1);
		rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
		el.insertAdjacentElement('afterEnd', rect);
		global.fo_shadows[global.fo_shadows.length] = rect;
	}
}

//function to remove drop shadows
function remove_flyout()
{
	var i
	for (i=0; i<global.fo_shadows.length; i++)
		global.fo_shadows[i].removeNode(true);
	global.fo_shadows = new Array();
}

