var curr_lb_div;
var is_modal = false;

function ShowLightBox(lb_div, isModal)
{
    //alert("div passed " + lb_div);
	document.getElementById(lb_div).style.display='block';
	//alert(lb_div);
    document.getElementById('fade').style.display='block';
    curr_lb_div = lb_div;
	//alert("showing lightbox");
    if (isModal)
        is_modal = true;
    else is_modal = false;
	
	//position window in the middle of the screen
	boxWidth = 200;
	boxHeight = 200;
	
	screenWidth=document.all?document.body.clinetWidth:window.innerWidth;
	screenHeight=document.all?document.body.clinetHeight:window.innerHeight;
	
	xPos = (screenWidth - boxWidth) * 0.5;
	yPos = (screenHeight - boxHeight) * 0.5;
	
	document.getElementById(lb_div).style.visibility = 'visible';
	document.getElementById('fade').style.visibility = 'visible';
	//alert("showing lightbox");
}

function updateContent(div, html)
{
	if (document.getElementById(div))
    {
         document.getElementById(div).innerHTML = "<p>haha</p>";
	}
}

function updatePrototype(div, url, pars)
{
	//alert(url + div + pars);
	var myVar = new Ajax.Updater( div, url, { onFailure: reportError, evalScripts: true, parameters: pars} );
	//alert("updatePrototype div " + div);
	ShowLightBox(div, true);
}

function closePrototype(div, url, pars)
{
	//alert(url + div + pars);
	var myVar = new Ajax.Updater( div, url, { onFailure: reportError, evalScripts: true, parameters: pars} );
	//alert("here2");
	  if (document.getElementById(div))
    {
         document.getElementById(div).style.display='none';
         document.getElementById('fade').style.display='none';
         curr_lb_div = '';
    }
}

function reportError()
{
	alert("there was an error");
}

function HideLightBox()
{
	closePrototype(div,url,pars);
    if (document.getElementById(curr_lb_div))
    {
         document.getElementById(curr_lb_div).style.display='none';
         document.getElementById('fade').style.display='none';
         curr_lb_div = '';
    }
}
