if (window != parent) top.location.href = location.href;

function showPhoto(src,caption)
{
    PhotoWin = window.open('','','height=600,width=500,resizable=yes');
    PhotoWin.document.write('<html><head><link rel=stylesheet href="/styles.css" type=text/css><title>View Photo</title></head><body>');
    PhotoWin.document.write('<p><img src="/gallery/d/'+src+'/photo" height="550"><br>'+caption+'</body></html>');
    return false;
}

function searchSubmit()
{
    var search=document.forms['search'].elements['searchtext'].value;
    search=encodeURI(search);
    window.location="http://rooseveltinstitution.org/_search/_"+search;
    return false;
}

menuHeadHeight = 18;

function positionMenu(id)
{
    var menuHead = document.getElementById('act'+(id-1));
    if (menuHead)
    {
        var pos = elementPosition(menuHead);
        var menuContainer = document.getElementById('menu'+id+'Container');

        if (menuContainer)
        {
            menuContainer.style.left = pos[0];
            menuContainer.style.top = pos[1] + menuHeadHeight;
        }
    }
}

function elementPosition(elem) {
    var x = 0;
    var y = 0;
            
    while (elem) {	
        x += elem.offsetLeft;
        y += elem.offsetTop;
        elem = elem.offsetParent;
    }
    return [x,y];
}



timeoutLength=8000;
timeoutId=0;
panelShowing=1;
maxPanels=1;

function showNextPanel()
{
    hideThis = document.getElementById("show"+panelShowing);
    panelShowing ++;
    showThis = document.getElementById("show"+panelShowing);
    if (!showThis)
    {
        maxPanels = panelShowing-1;
        panelShowing=1;
        showThis = document.getElementById("show"+panelShowing);
    }

    swapPanel(hideThis,showThis);
    return false;
}
function showPrevPanel()
{
    hideThis = document.getElementById("show"+panelShowing);
    panelShowing --;
    if (panelShowing == 0)
        panelShowing = maxPanels;
    
    showThis = document.getElementById("show"+panelShowing);

    swapPanel(hideThis,showThis);
    return false;
}
function swapPanel(hideThis,showThis)
{
    hideThis.style.display = 'none';
    showThis.style.display = 'block';
    continueFlipping();
}
function pauseFlipping()
{
    window.clearTimeout(timeoutId);
    return false;
}
function continueFlipping()
{
    pauseFlipping();
    timeoutId = window.setTimeout ('showNextPanel()',timeoutLength);
    return false;
}




function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

ajax_request_index = 0;

function ajax_request(query,callback)
{
    ajax_request_index++;
    var ro = createRequestObject();
    eval("ajax_ro_"+ajax_request_index+"=ro;");
    eval("ro.onreadystatechange = function() { if(ajax_ro_"+ajax_request_index+".readyState == 4) {"+callback+"(ajax_ro_"+ajax_request_index+".responseText);}};");
    ro.open('GET', '/ajax.php?'+query);
    ro.send(null);
}
