
// firefox doesn't always put the box in the right place when using async calls
// need to track this down

var pv_evt, pv_head, pv_path, req, pv_x, pv_y, pv_ok = false, pv_async = true;

function showPreview(event, headline, path)
{
	pv_evt = event;
    pv_head = headline;
    pv_path = path;
    pv_ok   = true;

    pv_x = tt_EvX(event);
    pv_y = tt_EvY(event);

    //alert("event at " + pv_x + ", " + pv_y);

    if (!pv_async)
    {
      tt_go(event, pv_head, req.responseText);
    }
    else
    {
      window.setTimeout('getOOTB()', 700);
    }  
}

function getOOTB()
{
   if (!pv_ok)
	return true;
   
   path = pv_path;

//    url = "/pages/homepage/ootb.php?u=" + path;
    url = path;

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = onPreviewLoaded;
        req.open("GET", url, pv_async);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = onPreviewLoaded;
            req.open("GET", url, pv_async);
            req.send();
        }
    }
}

function onPreviewLoaded()
{
    if (pv_async && req.readyState == 4 && req.status == 200 && pv_ok)
    {
       tt_go(pv_evt, pv_head, req.responseText, pv_x, pv_y);
    }
}

function cancelPreview()
{
  pv_ok = false;
  //EG 04/12/2007 
  //tt_Hide();
  window.setTimeout('tt_Hide()', 3000);
}

//<!--
//function openPopup(theURL, winName, features) {
//	windowHandle = window.open(theURL, winName, features);
//	if (!windowHandle) { windowHandle.opener = self; }
//	windowHandle.focus();
//}
////-->
//function openVideo(theURL) {
//        windowHandle = window.open(theURL, 'video', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=650,height=450');
//        if (!windowHandle) { windowHandle.opener = self; }
//        windowHandle.focus();
//}
