// JavaScript Document

function openPopup( id, cn )
{
	imageHolderClassName = cn;
	popupAnchorID = id;
	/*$('blackout').setStyle( { 'height': $('lContainer').offsetHeight + 'px', 'width' : $('lContainer').offsetWidth + 'px' } );*/
	$('blackout').setStyle( { 'height': $('lContainer').offsetHeight + 'px', 'width' : document.documentElement.clientWidth + 'px' } );
	
	$('blackout').appear( { 'duration': 1.0, 'from': 0.0, 'to': 0.3, 'afterFinish': ( function(){ showPopup();calcuateOffsetTop(); }) } );
	
	/*$('popupWindow').setStyle({ 'top' : $(id).offsetTop + 'px' });*/
}
function showPopup()
{
	$('popupWindow').show();
	
	addImage();
	
	new Draggable('popupWindow');
}
function addImage()
{
	$('imageholder').addClassName(imageHolderClassName); 
	
	var wv = $('popupcontent').offsetWidth - 386;
	$('popupfill').setStyle({width: wv + 'px'});
	
}
function calcuateOffsetTop()
{
	
	var offsetElement = $(popupAnchorID);
   	var offestEelementVal = offsetElement.cumulativeOffset();

	//var offset = $(popupAnchorID).offsetTop;
	var offset = offestEelementVal[1] - ($('popupWindow').clientHeight)/2;
	$('popupWindow').setStyle({ 'top' : offset + 'px' });
}
function closePopup()
{
	$('imageholder').removeClassName(imageHolderClassName); 
	$('popupWindow').hide();
	$('blackout').hide();
}

/*
var img_path = '/include/images/products/reports/';
	
	var id = document.getElementById( popup ).getElementsByTagName('img')[0];
	
	if( id != null )
	{
		id.src = img_path + image;
	}
	else
	{
		alert("ID is null");
	}
*/


/*
function loadajaxpage(page, containerid)
{
	var meth    = 'get';

	//Display loading image prior to loading content
	$(containerid).innerHTML = 'hello';

	new Ajax.Request(page,
    {
        method:     meth,
        //onSuccess:  function(transport){loadpage(transport, containerid);},
		onSuccess:  function(transport){$(containerid).update(transport.responseText);},
        onFailure:  function(){alert('AJAX page request (' + page + ') failed.');}
    });
} 
*/


