function getUFDCThumb(link, thumb, divID)
{
    var dataSource = link.replace("images/whitecover.gif", thumb); 
    var obj = document.getElementById(divID);
    obj.innerHTML = dataSource;
}

function showYears()
{
    var note1=document.getElementById('boxPub');
    note1.style.visibility='visible';
}

function hideYears()
{
    var zxcevt = window.event || arguments.callee.caller.arguments[0];
    var obj = document.getElementById('boxPub');
    if (zxcCkEventObj(zxcevt,obj))
        obj.style.visibility = 'hidden';
}

function showFormats()
{
    var note1=document.getElementById('boxFormat');
    note1.style.visibility='visible';
}

function hideFormats()
{
    var zxcevt = window.event || arguments.callee.caller.arguments[0];
    var obj = document.getElementById('boxFormat');
    if (zxcCkEventObj(zxcevt,obj))
        obj.style.visibility = 'hidden';
}

function zxcCkEventObj(zxce,zxcp)
{
    if (!zxce) var zxce=window.event;
    zxce.cancelBubble=true;
    if (zxce.stopPropagation) zxce.stopPropagation();
    if (zxce.target) zxceobj=zxce.target;
    else if (zxce.srcElement) zxceobj=zxce.srcElement;
    if (zxceobj.nodeType==3) zxceobj=zxceobj.parentNode;
    var zxceobj=(zxce.relatedTarget)?zxce.relatedTarget:(zxce.type=='mouseout')?zxce.toElement:zxce.fromElement;
    if (!zxceobj||zxceobj==zxcp) return false;
    while (zxceobj.parentNode)
    {
        if (zxceobj==zxcp) return false;
        zxceobj=zxceobj.parentNode;
    }
    return true;
}

function showxrefs(ig, query)
{
    var dataSource = "wrapper.jsp?type=lookup&query=" + query + "&ig=" + ig;
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById('dymdiv');
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                if (result.length > 1)
                {
                    obj.innerHTML = obj.innerHTML.substring(0, obj.innerHTML.length - 1);
                    obj.innerHTML += result;
                    new Effect.Highlight(obj);
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function checkHomeIG(homeIG, url, sessionID)
{
    if (homeIG == 'null')
    {
        setInnerHTML('homeIGBar', 'select your institution first...');        
        new Effect.Highlight(document.getElementById('homeIGBar'), {startcolor: '#cc0000', endcolor: '#ffffff'});
    }
    else
    {
        window.location.href=url
    }
}

function setInnerHTML(elementID, value)
{
    if (document.getElementById)
    {
        // this is the way the standards work
        var element = document.getElementById(elementID);
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        var element = document.all[elementID];
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        var element = document.layers[elementID];
    }

    if (element != null)
    {
        element.innerHTML = value;
    }
}

function setElementStyle(elementID, newStyle)
{
    if (document.getElementById)
    {
        // this is the way the standards work
        var style = document.getElementById(elementID).style;
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        var style = document.all[elementID].style;
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        var style = document.layers[elementID].style;
    }

    if (newStyle == "toggle")
    {
        style.display = style.display? "":"block";
    }
    else
    {
        style.display = newStyle;
    }
}

function setHomeIG(homeIG, homeIGLabel, divID, ig, sessionID, searchDid)
{
    var div = document.getElementById(divID);
    var style = div.style;
    var dataSource = "wrapper.jsp?type=sethomeig&homeig=" + homeIG + "&ig=" + ig + "&S=" + sessionID;
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        XMLHttpRequestObject.open("GET", dataSource);
        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                document.getElementById('homeIGBar').innerHTML = "Home Institution - " + homeIGLabel;
                var link = String(document.getElementById('loginLink').href);
                var pos1 = link.indexOf("https");
                var pos2 = link.indexOf("'", pos1);
                if (pos2 == -1)
                {
                    pos2 = link.indexOf('"', pos1);
                }
                var newLink = link.substr(pos1, pos2 - pos1);
                document.getElementById('loginLink').onclick = null;
                document.getElementById('loginLink').href = newLink;
                setElementStyle('IGMenuSpinner', 'none');
                document.getElementById('spinner').src = "images/clear.gif";
                if (!searchDid.match("null"))
                    window.location.reload();
            }
            else
            {
                setElementStyle('IGMenuSpinner', 'inline');
                document.getElementById('spinner').src = "images/progressDots.gif";
            }
        }
        XMLHttpRequestObject.send(null);
    }
    style.display = "none";
}

function showIGMenu(divID, ig, sessionID, searchDone)
{
    var div = document.getElementById(divID);
    var style = div.style;
    var html = "";

    html += "&nbsp;&nbsp;";
    html += "<select onChange=\"";
    html += "setHomeIG(this.value, this.options[this.selectedIndex].text, 'IGMenu', '" + ig + "','" +  sessionID + "','" + searchDone + "')\">";
    html += "<option value=\"\">--choose your home institution--</option>";
    html += "<option value=\"am\">Florida A&M University</option>";
    html += "<option value=\"fa\">Florida Atlantic University</option>";
    html += "<option value=\"gc\">Florida Gulf Coast University</option>";
    html += "<option value=\"fi\">Florida International University</option>";
    html += "<option value=\"fs\">Florida State University</option>";
    html += "<option value=\"nc\">New College of Florida</option>";
    html += "<option value=\"cf\">University of Central Florida</option>";
    html += "<option value=\"uf\">University of Florida</option>";
    html += "<option value=\"nf\">University of North Florida</option>";
    html += "<option value=\"sf\">University of South Florida</option>";
    html += "<option value=\"wf\">University of West Florida</option>";
    html += "</select>";

    div.innerHTML = html;
    setElementStyle(divID, 'inline');
}

function poprelated(docnumber, sessionid, ip)
{
    var dataSource = "wrapper.jsp?type=poprelated&sysid=" + docnumber + "&session=" + sessionid + "&ip=" + ip;
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        XMLHttpRequestObject.open("GET", dataSource);
        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {}
        }
        XMLHttpRequestObject.send(null);
    }
}

function poptitle(docnumber, ip, ig)
{
    var dataSource = "wrapper.jsp?type=poptitle&sysid=" + docnumber + "&ip=" + ip + "&ig=" + ig;
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        XMLHttpRequestObject.open("GET", dataSource);
        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {}
        }
        XMLHttpRequestObject.send(null);
    }
}

function showonlinecount(url, query)
{
    var dataSource = "wrapper.jsp?type=onlinecnt&query=" + query + "&url=" + url;
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById('recordcount');
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                if (result.length > 1)
                {
                    obj.innerHTML = obj.innerHTML.substring(0, obj.innerHTML.length - 1);
                    obj.innerHTML += ", " + result;
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function getElementsByName_iefix(tag, name)
{
    var elem = document.getElementsByTagName(tag);
    var arr = new Array();
    for(i = 0,iarr = 0; i < elem.length; i++) {
        att = elem[i].getAttribute("name");
        if(att == name) {
            arr[iarr] = elem[i];
            iarr++;
        }
    }
    return arr;
}

function isEmpty(object) 
{
    for (var i in object) 
    { 
        return false; 
    }
    
    return true;
}

function listEntries(booksInfo) 
{
    if (isEmpty(booksInfo))
    {
        var cells = getElementsByName_iefix("td", "gt");
        for (i = cells.length - 1 ; i > -1 ; i--)
        {
            cells[i].parentNode.removeChild(cells[i]);
        }
    }
    
    var numPics = 0;
    for (i in booksInfo) 
    {
        // Create a DIV for each book
        var book = booksInfo[i];
        var thumbnailDiv = document.getElementById(book.bib_key);

        // Add a link to each book's information page
        var a = document.createElement("a");
        var full = document.getElementById(book.bib_key + "L");
        a.href = full.href;
        a.className = "nav";
        a.title = "Go to the full record";

        // Display a thumbnail of the book's cover
        var img = document.createElement("img");
        img.border = "0";
        img.alt = "Go to the full record";
        if (book.thumbnail_url != undefined)
        {
            img.src = book.thumbnail_url;    
            a.appendChild(img);
            a.appendChild(document.createElement("br"));
        }
        
        if (book.thumbnail_url != undefined)
        {
            numPics++;
            thumbnailDiv.replaceChild(a, thumbnailDiv.lastChild);
        }
    }

    if (numPics == 0)
    {
        var cells = getElementsByName_iefix("td", "gt");
        for (i = cells.length - 1 ; i > -1 ; i--)
        {
            cells[i].parentNode.removeChild(cells[i]);
        }
    }
}

function URLEncode (clearString) {
    var output = '';
    var x = 0;
    clearString = clearString.toString();
    var regex = /(^[a-zA-Z0-9_.]*)/;
    while (x < clearString.length) {
        var match = regex.exec(clearString.substr(x));
        if (match != null && match.length > 1 && match[1] != '') {
            output += match[1];
            x += match[1].length;
        } else {
            if (clearString[x] == ' ')
                output += '+';
            else {
                var charCode = clearString.charCodeAt(x);
                var hexVal = charCode.toString(16);
                output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
            }
            x++;
        }
    }
    return output;
}

function listEntry(booksInfo, ig) 
{
    
    if (isEmpty(booksInfo))
    {
        var img = getElementsByName_iefix("img", "gt");
        img[0].parentNode.removeChild(img[0]);
    }
    
    for (i in booksInfo) 
    {
        // Create a DIV for each book
        var book = booksInfo[i];
        var thumbnailDiv = document.getElementById(book.bib_key);

        // Add a link to each book's information page
        var a = document.createElement("a");
        a.href = book.info_url;
        a.target = "_blank";
        a.className = "nav";

        var ag = document.createElement("a");
        ag.href = book.info_url;
        ag.target = "_blank";
        ag.className = "nav";

        if (book.preview == "noview")
        {
            a.href = "forward.jsp?ig=" + ig + ".jsp&type=googleinfo&link=" + URLEncode(a.href);
            ag.href = "forward.jsp?ig=" + ig + ".jsp&type=googleinfo&link=" + URLEncode(a.href);
            a.title = "find additional information at Google Books";
            ag.title = "find additional information at Google Books";
            ag.innerHTML = "more info @<br>";
        }
        else if (book.preview == "partial")
        {
            a.href = "forward.jsp?ig=" + ig + ".jsp&type=googlepreview&link=" + URLEncode(a.href);
            ag.href = "forward.jsp?ig=" + ig + ".jsp&type=googlepreview&link=" + URLEncode(a.href);
            a.title = "preview available at Google Books";
            ag.title = "preview available at Google Books";
            ag.innerHTML = "preview @<br>";
        }
        else
        {
            a.href = "forward.jsp?ig=" + ig + ".jsp&type=googleread&link=" + URLEncode(a.href);
            ag.href = "forward.jsp?ig=" + ig + ".jsp&type=googleread&link=" + URLEncode(a.href);
            a.title = "read this book at Google Books";
            ag.title = "read this book at Google Books";
            ag.innerHTML = "read @<br>";
        }
            
        // Display a thumbnail of the book's cover
        var img = document.createElement("img");
        img.border = "0";
        if (book.thumbnail_url != undefined)
        {
            img.src = book.thumbnail_url;    
            a.appendChild(img);
            a.appendChild(document.createElement("br"));
        }
        
        var img2 = document.createElement("img");
        img2.border = "0";
        img2.src = "images/google.png";
        img2.className = "googleTM";
        ag.appendChild(img2);

        if (img.src != undefined)
        {
            thumbnailDiv.replaceChild(a, thumbnailDiv.lastChild);
            thumbnailDiv.appendChild(ag);
        }
        else
        {
            thumbnailDiv.replaceChild(ag, thumbnailDiv.lastChild);
        }
    }
}

function listEntryUX(booksInfo)
{
    return listEntry(booksInfo, "ux");    
}

function listEntryUF(booksInfo)
{
    return listEntry(booksInfo, "uf");    
}

function listEntryNF(booksInfo)
{
    return listEntry(booksInfo, "nf");    
}

function listEntryWF(booksInfo)
{
    return listEntry(booksInfo, "wf");    
}
function listEntryFS(booksInfo)
{
    return listEntry(booksInfo, "fs");    
}

function listEntrySF(booksInfo)
{
    return listEntry(booksInfo, "sf");    
}

function listEntryAM(booksInfo)
{
    return listEntry(booksInfo, "am");    
}

function listEntryGC(booksInfo)
{
    return listEntry(booksInfo, "gc");    
}

function listEntryFI(booksInfo)
{
    return listEntry(booksInfo, "fi");    
}

function listEntryFA(booksInfo)
{
    return listEntry(booksInfo, "fa");    
}

function listEntryCF(booksInfo)
{
    return listEntry(booksInfo, "cf");    
}

function listEntryNC(booksInfo)
{
    return listEntry(booksInfo, "nc");    
}

function search(query, type, ig) 
{
    // Add a script element with the src as the user's Google Book Search query. 
    // JSON output is specified by including the alt=json-in-script argument
    // and the callback function is also specified as a URI argument.
    //var time = "&time=" + new java.util.Date().getTime(); 
    var scriptElement = document.createElement("script");
    if (type == "full")
    {
        if (ig == "ux")
            type = "listEntryUX";
        else if (ig == "uf")
            type = "listEntryUF";
        else if (ig == "nf")
            type = "listEntryNF";
        else if (ig == "wf")
            type = "listEntryWF";
        else if (ig == "fs")
            type = "listEntryFS";
        else if (ig == "sf")
            type = "listEntrySF";
        else if (ig == "am")
            type = "listEntryAM";
        else if (ig == "gc")
            type = "listEntryGC";
        else if (ig == "fi")
            type = "listEntryFI";
        else if (ig == "fa")
            type = "listEntryFA";
        else if (ig == "cf")
            type = "listEntryCF";
        else if (ig == "nc")
            type = "listEntryNC";
    }
    else
    {
        type = "listEntries";
    }

    scriptElement.setAttribute("id", "jsonScript");
    scriptElement.setAttribute("src",
            "http://books.google.com/books?bibkeys=" + 
            escape(query) + "&jscmd=viewapi&callback=" + type); 
    scriptElement.setAttribute("type", "text/javascript");
    // make the request to Google Book Search
    document.documentElement.firstChild.appendChild(scriptElement);
    //console.info(scriptElement);
}

function getGoogleBooksLink(dataSource, divID)
{

    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                obj.innerHTML += result;
                if (result.length > 1)
                {
                    new Effect.Highlight(obj);
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function resolveLink(dataSource, divID)
{

    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                obj.innerHTML += result;
                if (result.length > 1)
                {
                    new Effect.Highlight(obj);
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function getDtSession()
{
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        XMLHttpRequestObject.open("GET", "wrapper.jsp?type=dtsession", false);
        XMLHttpRequestObject.send(null);
        return XMLHttpRequestObject.responseText;
    }
}


function getDtThumb(dataSource, divID)
{
    var XMLHttpRequestObject = false;
    var result;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("GET", dataSource, true);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState != 4)
            {
                return;
            }
            obj.innerHTML = XMLHttpRequestObject.responseText;
        }
        XMLHttpRequestObject.send(null);
    }
}

function getDtThumbs(dataSource, divIDs)
{
    var recordIDs = divIDs.split(";");
    
    for (var i = 0 ; i < recordIDs.length ; i++)
    {
        var newDataSource = dataSource.replace("placeholder", recordIDs[i]);
        newDataSource = newDataSource.replace("\n", "");
        var func = "getDtThumb('"+newDataSource+"','"+recordIDs[i]+"')";
        setTimeout(func, i*1000+1);
    }
}

function getBriefCirc(dataSource, divID, crldivID, URequestDivID)
{
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        var obj2 = document.getElementById(URequestDivID);
        
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                obj.innerHTML = result;
                if (result.indexOf("Request") > -1 || result.indexOf("Available") > -1)
                {
                    setInnerHTML(crldivID, "");
                }
                new Effect.Highlight(obj, {startcolor: '#ffff99', endcolor: '#f5f5f5'});
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function showResponses(dataSource, divID)
{
    var sysnum = divID.substring(12);
    var XMLHttpRequestObject = false;
    var link = "";
    var igx = dataSource.indexOf("ig=");
    var ig = dataSource.substring(igx+3,igx+5)

        if (window.XMLHttpRequest) 
        {
            XMLHttpRequestObject = new XMLHttpRequest();
        } 
        else if (window.ActiveXObject) 
        {
            XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
        }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                var pos = result.indexOf("http");
                var pos2 = result.indexOf("\">");
                if (pos < 0)
                {
                    link = result;    
                }
                else
                {
                    link = result.substring(pos, pos2);
                }
                if (result.length > 1)
                {
                    if (result.indexOf("ill") > 0)
                    {
                        obj.innerHTML = "<a class=\"specialLink\" href=\"" + link + "\" target=\"_blank\"><img class=\"link_button\" src=\"images/getit.gif\" title=\"Your library can get this title for you. Click to place a request.\"></a>";
                    }
                    else if (result.indexOf("https") > 0)
                    {
                        obj.innerHTML = "<a class=\"specialLink\" href=\"" + link + "\"><img class=\"link_button\" src=\"images/getit.gif\" title=\"This title is currently checked out. Click to place a hold on this title.\"></a>";
                    }
                    else
                    {
                        obj.innerHTML = "<a class=\"specialLink\" href=\"#" + link + "\"><img class=\"link_button\" src=\"images/getit_green_small.gif\" title=\"This title is available in your library. Click to see what is available.\"></a>&nbsp;";
                    }
                    obj.innerHTML += "<br /><span class=\"specialLink\">Place a request for this title</span>";
                    if (ig.indexOf("cf") < 0)
                    {
                        obj.innerHTML += ",<br /><span class=\"specialLink\">or see what is available in your own library.</span><br />";
                    }
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function highlightItem(tag)
{
    var styleA = document.getElementsByName_iefix()
}

function addtoRequestHOLs(dataSource, divID)
{
    var sysnum = divID.substring(12);
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function hideDiv(whichDiv)
{
    var buttons = getElementsByName_iefix("span", whichDiv);

    for (var i = buttons.length - 1 ; i > -1 ; i--)
    {
        if (document.getElementById)
        {
            var style2 = buttons[i].style;
            //style2.display = style2.display? "":"none";
            style2.display = "none";
        }
    }
}

function getDOWNLinks(dataSource, divID, trID, tdID)
{

    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        var td = document.getElementById(tdID);
        var tr = document.getElementById(trID);
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                obj.innerHTML = result;
                if (result.length > 1)
                {
                    if (result.indexOf("Create set") > -1)
                    {
                        td.innerHTML = "Down links (create):";
                    }
                }
                else
                {
                    tr.deleteCell(0);
                    tr.deleteCell(0);
                    tr.display = "none";
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}
function getLKRLinks(dataSource, divID, trID)
{

    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        var tr = document.getElementById(trID);
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                if (result.length > 1)
                {
                    obj.innerHTML = result;
                }
                else
                {
                    tr.display = "none";
                    tr.deleteCell(0);
                    tr.deleteCell(0);
                }
                
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function AddToList(dataSource)
{

    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var button = document.getElementById('viewListButton');
        var docNo = dataSource.substring(dataSource.indexOf("doc=")+4,dataSource.indexOf("&S="));
        var title = document.getElementById("Obj" + docNo);
        var label = document.getElementById("LBL" + docNo);
        var link = document.getElementById("LNK" + docNo);
        var c_string = "folder_added_" + docNo;
        setCookie(c_string, docNo, '1');

        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                if (result.indexOf("redo") > -1)
                {
                    //checkbox.checked = false;
                    //checkbox.click();
                    link.click();
                }
                else
                {
                    var temp = result.substring(0, result.length -1);
                    title.setAttribute('class','mySelect');
                    title.setAttribute('className','mySelect');
                    if (temp == "0")
                    {
                        button.value = "My Folder is empty";
                        document.getElementById('liststatus').src = "images/emptylist.png";
                    }
                    else
                    {
                        if (temp == "1")
                        {
                            button.value = "My Folder has " + temp + " item";
                        }
                        else
                        {
                            button.value = "My Folder has " + temp + " items";
                        }
                        document.getElementById('liststatus').src = "images/list.png";
                    }
                    label.innerHTML = "added";
                    new Effect.Highlight(label);
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function RemoveFromList(dataSource)
{

    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var button = document.getElementById('viewListButton');
        var docNo = dataSource.substring(dataSource.indexOf("doc=")+4,dataSource.indexOf("&S="));
        var title = document.getElementById("Obj" + docNo);
        var label = document.getElementById("LBL" + docNo);
        var c_string = "folder_added_" + docNo;
        del_cookie(c_string);
        
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                var result = XMLHttpRequestObject.responseText;
                var temp = result.substring(0, result.length -1);
                title.removeAttribute('class','mySelect');
                title.removeAttribute('className','mySelect');
                if (temp == "0")
                {
                    button.value = "My Folder is empty";
                    document.getElementById('liststatus').src = "images/emptylist.png";
                }
                else
                {
                    if (temp == "1")
                    {
                        button.value = "My Folder has " + temp + " item";
                    }
                    else
                    {
                        button.value = "My Folder has " + temp + " items";
                    }
                    document.getElementById('liststatus').src = "images/list.png";
                }
                label.innerHTML = "add";
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

/*function ListFunc(dataSource, divID, checkbox)
{
    var docNo = dataSource.substring(dataSource.indexOf("doc=")+4,dataSource.indexOf("&S="));
    var my_id = "CK" + docNo;
    var my_checkbox = document.getElementById(my_id);
    var countSource = dataSource + "&type=count";

    if (my_checkbox.checked)
    {
        my_checkbox.setAttribute('checked','checked');
        dataSource = dataSource + "&type=add";
        AddToList(dataSource, divID, checkbox);
    }
    else
    {
        my_checkbox.removeAttribute('checked','checked');
        dataSource = dataSource + "&type=remove";
        RemoveFromList(dataSource, divID);
    }
}*/

function ListFunc(dataSource)
{
    var docNo = dataSource.substring(dataSource.indexOf("doc=")+4,dataSource.indexOf("&S="));
    var image = document.getElementById("IMG" + docNo);
    var label = document.getElementById("LBL" + docNo);
    var link = document.getElementById("LNK" + docNo);
    var countSource = dataSource + "&type=count";

    if (label.innerHTML == "add")
    {
        image.setAttribute('src','images/list.png');
        dataSource = dataSource + "&type=add";
        AddToList(dataSource);
    }
    else
    {
        image.setAttribute('src','images/emptylist.png');
        dataSource = dataSource + "&type=remove";
        RemoveFromList(dataSource);
    }
}

function renewItem(dataSource, divID, button)
{

    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject) 
    {
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("GET", dataSource);

        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200) 
            {
                obj.innerHTML = XMLHttpRequestObject.responseText;
                button.disabled = true;
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function renewAll(thisForm, button)
{
    var i = 0;

    for (i = 0 ; i < thisForm.length ; i++)
    {
        if (thisForm[i].type == 'button' && thisForm[i].disabled == false)
        {
            thisForm[i].click();
        }
    }
    button.disabled = true;
}

function SortMe() 
{
    var sortSelect = document.sortField.selectedIndex;
    var sortURL = document.sortField[sortSelect].value;
    window.location=sortURL;
}

function loadURL(URL)
{
    window.location = "?" + URL;
}

function ResMe() 
{
    var resSelect = document.nres.selectedIndex;
    var resURL = document.nres[resSelect].value;
    window.location=resURL;
}

function handleSearch(nFilter, sessionID)
{
    var catsearch = document.getElementById("catsearch");
    var property = catsearch[catsearch.selectedIndex].value;
    var terms = encodeURIComponent(document.getElementById("box").value);
    alert(terms);
    
    var removeterms = ["I","S","N","Ne","No","Nao","Ntk","Ntt","D","Nty","Ntx","Dx","in_dym","in_dim_search"];
     
    var addterms = ["S="+sessionID,"N="+nFilter,"Ntk="+property,"Ntt="+terms,"Nty=1"];

    var newurl = ConstructURL("CURRENTURL", removeterms, addterms);

    location.search = newurl;
}

function ConstructURL(url,removeterms,addterms) {
    var params = BuildURLArray(url);
    var newurl = "";
    for (var i=0; i<params.length; i++) {
        val = CheckArray(removeterms,params[i][0]);
        if (val == -1)
            newurl = newurl + "&" + params[i][0] + "=" + params[i][1];
    }
    for (var i=0; i<addterms.length; i++) {
        newurl = newurl + "&" + addterms[i];
    }
    if (newurl.length > 0) {
        newurl = newurl.substr(1);
        newurl = "?"+newurl;
    }
    else {
        newurl = "?N="+eneroot;
    }
    return newurl;
}

function BuildURLArray(oldurl) {
    var returnArray = new Array();
    var url;
    if (oldurl == "CURRENTURL")
        url = location.search;
    else if (oldurl == "BLANKURL") {

    }
    else {
        var tokens = oldurl.split("?");
        url = "?"+tokens[1];
    }               
    if (url) {
        url = url.substr(1);
        var params = url.split("&");
        for (var i=0; i<params.length; i++) {
            var param = params[i].split("=");
            returnArray[i] = param;
        }
    }
    return returnArray;
}

function CheckArray(removeterms,checkterm) {
    for (var i=0; i<removeterms.length; i++) {
        if (removeterms[i] == checkterm)
            return 1;
    }
    return -1;
}


function handleKeyPress(e,form)
{
    var keynum;

    if(window.event) // IE
        keynum = e.keyCode;
    else if(e.which) // Netscape/Firefox/Opera
        keynum = e.which;

    if (keynum == 13)
    {
        checkTerm();
    }
    else
        return keynum;
}

function switchLayer(whichLayer, niftyLink, switchLinks)
{
    if (niftyLink != null)
    {
        if (document.getElementById)
        {
            // this is the way the standards work
            var style2 = document.getElementById(whichLayer).style;
            style2.display = style2.display? "":"none";
        }
        else if (document.all)
        {
            // this is the way old msie versions work
            var style2 = document.all[whichLayer].style;
            style2.display = style2.display? "":"none";
        }
        else if (document.layers)
        {
            // this is the way nn4 works
            var style2 = document.layers[whichLayer].style;
            style2.display = style2.display? "":"none";
        }

        if (switchLinks == true)
        {
            flipLink(niftyLink);
        }
    }
}

function toggleDiv(whichDiv, actionLink, changeLinks)
{
    if (document.getElementById)
    {
        // this is the way the standards work
        var style2 = document.getElementById(whichDiv).style;
        style2.display = style2.display? "":"none";
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        var style2 = document.all[whichDiv].style;
        style2.display = style2.display? "":"none";
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        var style2 = document.layers[whichDiv].style;
        style2.display = style2.display? "":"none";
    }

    if (changeLinks == true)
    {
        toggleLinkSimple(actionLink, "", "Show Detailed Item List");
    }
}

function toggleLayer(whichLayer, actionLink, changeLinks)
{
    setElementStyle(whichLayer, "toggle");

    if (changeLinks == true)
    {
        toggleLink(actionLink);
    }
    else if (changeLinks == false)
    {
        var style2 = document.getElementById("refineLink").style;
        style2.display = style2.display? "":"none";
    }
    else if (changeLinks == 'non')
    {
        var style2 = document.getElementById("DimBR").style;
        style2.display = style2.display? "":"block";
    }
}

function toggleLinkSimple(actionLink, text1, text2)
{
    actionLink.innerHTML = actionLink.innerHTML ? text1 : text2;
}

function flipLink(niftyLink)
{
    if (niftyLink.innerHTML == "[hide other search options]")
    {
        niftyLink.innerHTML = "[see other search options]";
    }
    else
    {
        niftyLink.innerHTML = "[hide other search options]"; 
    }
}

function toggleLink(actionLink)
{
    if (actionLink.innerHTML == "[ show ]")
    {
        var desc, str, links, i;
        links = document.getElementsByTagName('a');
        for (i in links)
        {
            str = links[i].href;
            desc = links[i].innerHTML;
            if (str && desc)
                if (str.match("S=") && !desc.match("Library of Congress") && 
                    !desc.match("National Library of Medicine") && !desc.match("Superintendent of Documents"))
                {
                    var pos = str.indexOf("&CNS=");
                    if (pos > -1)   
                    {
                        links[i].href = str.substr(0, pos+5) + "S";
                        var pos2 = str.indexOf("&", pos+1);
                        if (pos2 > -1)
                            links[i].href += str.substr(pos2);
                    }
                    else
                        links[i].href = str + "&CNS=S";
                }
        }
        actionLink.innerHTML = "[ hide ]";
    }
    else
    {
        var desc, str, links, i;
        links = document.getElementsByTagName('a');
        for (i in links)
        {
            str = links[i].href;
            desc = links[i].innerHTML;
            if (str && desc)
                if (str.match("S=") && !desc.match("Library of Congress") && 
                    !desc.match("National Library of Medicine") && !desc.match("Superintendent of Documents"))
                {
                    var pos = str.indexOf("&CNS=");
                    if (pos > -1)   
                    {
                        links[i].href = str.substr(0, pos+5) + "H";
                        var pos2 = str.indexOf("&", pos+1);
                        if (pos2 > -1)
                            links[i].href += str.substr(pos2);
                    }
                    else
                        links[i].href = str + "&CNS=H";
                }
        }
        actionLink.innerHTML = "[ show ]";
    }
}

function mapWindow(maplink, instgroup)
{
   if(instgroup.match("nf"))
   {
        window.open(maplink,'mapdisplay','height=730,width=600,left=200,top=100,scrollbars=yes,resizable=yes');
   }
   else if (instgroup.match("fa"))
   {
        window.open(maplink,'mapdisplay','height=440,width=1240,left=50,top=100,scrollbars=yes,resizable=yes');
   }
   else if (instgroup.match("fi"))
   {
        window.open(maplink,'mapdisplay','height=730,width=950,left=200,top=100,scrollbars=yes,resizable=yes,toolbar=yes');
   }
   else
   {
        window.open(maplink,'mapdisplay','height=600,width=1050,left=200,top=100,scrollbars=yes,resizable=yes');
   }
}

function popup(height, width, pagename)
{
    var pageToOpen=pagename;
    var parms = "height=" + height + ",width=" + width;
    parms += ",scrollbars,resizable";

    var w = window.open(pagename, "win1", parms); 
}

function openpopup(pagename)
{
    var pageToOpen=pagename;
    var w = window.open(pagename, "win1", 
            "height=400,width=700,toolbar,location=yes,scrollbars,resizable,menubar=yes");
}
function changeView()
{            
    var viewIndex = document.selectView.ViewList.selectedIndex;
    var viewName = document.selectView.ViewList[viewIndex].value;
    window.location=viewName;
}

function PopupWindow(popupurl) 
{
    sfxwindow=window.open(popupurl,'sfxwin',
            'width=600,toolbar=yes,status=yes,scrollbars=yes,resizable=yes');
}

function PrintWindow(popupurl) 
{
    printwindow=window.open(popupurl,'printwin','width=800,menubar=yes,scrollbars=yes,resizable=yes');
}

function addAll()
{
    var i = 0;
    
    var dataSources = document.getElementsByName("recordID");
    for (i = 0 ; i < dataSources.length ; i++)
    {
        AddToList(dataSources[i].value + "&type=add");
    }
}

var nextCheck = true;
function checkAll(thisForm, actionLink)
{
    var i = 0;
    nextCheck = !nextCheck;

    for (i = 0 ; i < thisForm.length ; i++)
    {
        if (thisForm[i].type == 'checkbox' && thisForm[i].checked == nextCheck)
        {
            thisForm[i].click();
        }
    }

    if (nextCheck == false)
        actionLink.value = "Uncheck All";
    else
        actionLink.value = "Check All";
}

function pause(millisecondi)
{
    var now = new Date();
    var exitTime = now.getTime() + millisecondi;
 
    while(true)
    {
        now = new Date();
        if (now.getTime() > exitTime) 
            return;
    }
}

function submitForm(thisForm)
{
    thisForm.submit();
}

function ViewSelected(url)
{
    window.location.href=url
}

function toggleDimension(whichLayer, whichIMG)
{

    var div;
    var style2;
    var img;
    var br;

    if (document.getElementById)
    {
        // this is the way the standards work
        div = document.getElementById(whichLayer);
        style2 = document.getElementById(whichLayer).style;
        img = document.getElementById(whichIMG);
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        div = document.all[whichLayer].style;
        style2 = document.all[whichLayer].style;
        img = document.all[whichIMG];
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        div = document.layers[whichLayer].style;
        style2 = document.layers[whichLayer].style;
        img = document.layers[whichIMG];
    }
    
    if (style2.display == "none")
    {
        //img.src = "images/twistie1a.gif";
        img.src = "images/triang_dn.gif";
        new Effect.BlindDown(div);
    }
    else
    {
        //img.src = "images/twistie1.gif";
        img.src = "images/triang_ri.gif";
        new Effect.BlindUp(div);
    }
}

function open_window_delivery (loc)
{

    var he = screen.availHeight-51;
    var wi  = screen.availWidth-12;
    winprops = 'screenX=0,screenY=0,left=0,top=0,location=no,menubar=no,status,height='+he+',width='+wi+',scrollbars,resizable';

    var w = window.open (loc,
            "windlv",
            winprops
            );
    w.focus();
}

function showProblemReportForm(boxID, rec, ig)
{   
    var dataSource = "wrapper.jsp?type=bibrecreport&doc=" + rec + "&ig=" + ig;
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest)
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject)
    {
        XMLHttpRequestObject.open("GET", dataSource);
        XMLHttpRequestObject.onreadystatechange = function()
        {   
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200)
            {
                var obj = document.getElementById(boxID);
                var result = XMLHttpRequestObject.responseText;
                if (result.length > 1)
                {
                    hideBoolHelp('BibRecordProblemReportLink', false);
                    showboolhelp(boxID);
                    obj.innerHTML = result;
                    window.scrollBy(0,150);
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function sendEmailReport(text, addree, docno, igee, divID, subject, pickuploc, procStat) 
{   
    var dataSource = "wrapper.jsp?type=emailreport&text=" + text + "&email=" + addree + "&doc=" + docno + "&ig=" + igee + "&subj=" + subject + "&pickup=" + pickuploc;
    var XMLHttpRequestObject = false;

        if (window.XMLHttpRequest)
        {
            XMLHttpRequestObject = new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        {
            XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
        }

        if(XMLHttpRequestObject)
        {
            XMLHttpRequestObject.open("GET", dataSource);
            XMLHttpRequestObject.onreadystatechange = function()
            {   
                if (XMLHttpRequestObject.readyState == 4 &&
                        XMLHttpRequestObject.status == 200)
                {
                    if (divID.match("BibRecordProblemReport"))
                    {
                        var obj = document.getElementById(divID);
                        obj.innerHTML = "Thank you for the report!"; 
                        hideBoolHelp('BibRecordProblemReportLink', false);
                    }
                }
            }
            XMLHttpRequestObject.send(null);
        }
}

function showBoolHelp(boxID)
{   
    var dataSource = "wrapper.jsp?type=boolhelp";
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest)
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(XMLHttpRequestObject)
    {
        XMLHttpRequestObject.open("GET", dataSource);
        XMLHttpRequestObject.onreadystatechange = function()
        {   
            if (XMLHttpRequestObject.readyState == 4 &&
                    XMLHttpRequestObject.status == 200)
            {
                var obj = document.getElementById(boxID);
                var result = XMLHttpRequestObject.responseText;
                if (result.length > 1)
                {
                    showboolhelp(boxID);
                    obj.innerHTML = result;
                    //dimTheElement(obj);
                }
            }
        }
        XMLHttpRequestObject.send(null);
    }
}
function hideBoolHelp(boxID, clearHtml)
{   
    var obj = document.getElementById(boxID);
    obj.style.visibility = 'hidden';
    
    if (clearHtml)
        obj.innerHTML = "";
}   
function showboolhelp(boxID)
{       
    var obj = document.getElementById(boxID);
    obj.style.visibility = 'visible';
}
function checkIfAdded(c_name)
{
    var value = "";
    var myImage = "";
    var myLabel = "";
    var myRecId = c_name.split(",");
    
    for (var i=0; i < myRecId.length; i++)
    {
        value = getCookie("folder_added_" + myRecId[i]);
        if (value.length > 0)
        {
            myImage = document.getElementById("IMG" + value);
            myLabel = document.getElementById("LBL" + value);
            myImage.setAttribute('src','images/list.png');
            myLabel.innerHTML = "added";
        }
    }
}
function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    var mins = exdate.getMinutes();
    exdate.setMinutes(mins+40);
    exdate.setDate(exdate.getDate());
    document.cookie = c_name+ "=" +escape(value)+
        ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return "";
}
function del_cookie(name) 
{
    document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
} 
function deleteCookieFromChkLst(key_list)
{
    var rec_keys = key_list.split(",");

    for (var i=0; i < rec_keys.length; i++)
    {
        del_cookie("folder_added_" + rec_keys[i]);
    }
}
function deleteAllCookies()
{
    var thecookie = document.cookie.split(";")
    for (var i = 0;i < thecookie.length;i++) 
    {
        document.cookie = thecookie[i] + "; expires=Thu, 01-Jan-70 00:00:01 GMT;";
    }        
}
