var Article =
        {
            images: function() {
                // add properties to the object
                this.imgList = null;
                this.imgText = null;
                this.imgIndex = null;
            },

            articles: function() {
                this.articleList = null;
                this.articleListIndex = null;
                this.XMLObject = null;
                this.feedId = null;
                this.feedName = null;
                this.filterCatagory = null;
            },

            articleSearch: function() {
                this.articleSearchList = null;
                this.articleSearchCategory = null;
                this.articleSearchDate = null;
                this.searchXMLObject = null;
                this.isArticleSearch = true;
            }
        }

        var firstLoad = false;
        var firstSearchLoad = false;

function getXML(articleIndex, articleId, feedId, feedName) {
    // check to see if the feedType has been sent in. if not set it.
    if (typeof (feedId) == 'undefined' || feedId == '') {
        feedType = 15;
    }

    // set the feedType
    Article.articles.feedId = feedId;

    // check to see if the feedName has been sent in. if not set it.
    if (typeof (feedName) == 'undefined' || feedName == '') {
        feedName = "Species_Research";
    }
    
    // set the feedName 
    if (Article.articles.feedName == null) {
        Article.articles.feedName = feedName;
    }

    var archiveYear = ''

    // check to see if articleIndex has been sent in. if not set it.
    if (articleIndex == null || typeof (articleIndex) == 'undefined' || articleIndex == '') {
        articleIndex = 0;
    }

//    if (Article.articles.XMLObject != null || typeof (Article.articles.XMLObject) != 'undefined') {
//        parseFeed(Article.articles.XMLObject, articleId, Article.articles.feedName, articleIndex)
//    } else {
        var xmlPath = ""
        xmlPath = "./getArticlesService.aspx?feedId=" + Article.articles.feedId;
        new Ajax.Request(xmlPath,
        {
            method: 'get',
            onSuccess: function(transport) {
                var response = transport.responseText || "no response text";
                //alert("Success! \n\n" + typeof(response));

                parseFeed(response, articleId, Article.articles.feedName, articleIndex);
                Article.articles.XMLObject = response;
            },
            onFailure: function() { alert('Something went wrong...'); }
        });
//    }
}

//entryTag, articleID, archiveYearPassed, feedType
function getXMLFromSearch(category, archiveYear) {
    var useArchive = false;
    var useArchiveStr = '';
    //alert(category + " : " + archiveYear)
    var categoryError = false;
    var categoryErrorMessage = "Please select a category";
    var archiveYearError = false;
    var archiveYearErrorMessage = "Please select a year";
    if (category == -1)
        categoryError = true;

    if (archiveYear == -1)
        archiveYearError = true;


    //alert("archiveYear: "+archiveYear)
    if (archiveYear == "-1") {
        //
        //var curdate = new Date()
        //var year = curdate.getYear();
        //archiveYear = year;

        var adObj = new Date();

        //adObj.setFullYear();
        adObj = adObj.getYear().toString()
        adObj = "20" + adObj.split("1")[1];
        //archiveYear = adObj;
        //alert(typeof (archiveYear) + adObj)

    }

    //alert(Number(archiveYear) + " = "  + Number(adObj))
    if (archiveYear != "-1" && Number(archiveYear) != Number(adObj)) {

        useArchiveStr = 'archives/';
        //archiveYear = archiveYearReset
        //alert(archiveYear +": here")
    } else {
        archiveYear = adObj

        /*var infoBox = document.getElementById("infoBox");
        if (infoBox != null || typeof (infoBox) == 'undefined' || category == -1) {
        infoBox.style.visibility = 'visible';
        infoBox.innerHTML = "<strong></strong><br/>"
        infoBox.innerHTML += "Please make a filter choice."
        }
        */

    }

    //alert("xml/" +useArchiveStr+archiveYear+"-"+category + ".xml")

    if (Article.articleSearch.searchXMLObject != null && Article.articleSearch.articleSearchCategory == category) {
        parseFeedSearch(Article.articleSearch.searchXMLObject)
        //alert("using cache")
    } else {
        //new Ajax.Request("searchResults.xml",

        new Ajax.Request("LatestArticlesForYearAndFeed.aspx?year=" + archiveYear + "&feedId=" + category,
                {
                    method: 'get',
                    onSuccess: function(transport) {
                        var response = transport.responseText || "no response text";
                        //alert("Success! \n\n" + typeof(response));

                        parseFeedSearch(response)
                        Article.articleSearch.searchXMLObject = response;
                        Article.articleSearch.searchCategory = category;
                        firstSearchLoad = false;
                        var infoBox = document.getElementById("infoBox");
                        if (infoBox != null || typeof (infoBox) == 'undefined') {
                            infoBox.style.visibility = 'hidden';
                            infoBox.innerHTML = "<strong></strong><br/>"
                            infoBox.innerHTML += ""
                        }
                    },
                    onFailure: function() {

                        var infoBox = document.getElementById("infoBox");
                        if (infoBox != null || typeof (infoBox) == 'undefined') {
                            infoBox.style.visibility = 'visible';
                            infoBox.innerHTML = "";
                            if (archiveYearError)
                                infoBox.innerHTML += "<strong>" + archiveYearErrorMessage + "</strong><br />";

                            if (categoryError)
                                infoBox.innerHTML += "<strong>" + categoryErrorMessage + "</strong>"; ;


                        }
                        //alert('Something went wrong...')


                    }
                });
    }

}


function parseFeed(xmlObj, articleId, category, articleIndex) {
    //alert(dateRange + " | " + category+ " | " + articleIndex)
    // convert string to XML object
    //var  = (new DOMParser()).parseFromString(xmlObj, "text/xml");
    var parser = new DOMParser();
    var xmlobjectDoc = parser.parseFromString(xmlObj, "text/xml");
    //alert(typeof(xmlobjectDoc))
    var xmlobject = xmlobjectDoc
    // get a reference to the root-element "feed"
    var root = xmlobject.getElementsByTagName('feed')[0];
    // get reference to "title" element
    var title = root.getElementsByTagName("title");
    // get reference to "subtitle" element
    var subtitle = root.getElementsByTagName("subtitle");
    // get reference to "updated" element
    var updated = root.getElementsByTagName("updated");
    // get reference to "i" element
    var id = root.getElementsByTagName("id");
    // get reference to "link alternate" element
    //var linkAlternateLen = root.getElementsByTagName("link")
    var linkAlternate = root.getElementsByTagName("link")[0].getAttribute("alternate");
    // get reference to "link enclosure" element
    //var linkEnclosure = root.getElementsByTagName("link")[1].getAttribute("enclosure");
    // get reference to "author" element
    //var authorName = root.getElementsByTagName("author")[0].getElementsByTagName("name");
    //var authorUri = root.getElementsByTagName("author")[0].getElementsByTagName("uri");
    //var authorEmail = root.getElementsByTagName("author")[0].getElementsByTagName("email");
    //var linkEnclosure = root.getElementsByTagName("link")[1].getAttribute("enclosure");
    // get reference to "channel" element

    var entry = root.getElementsByTagName("entry");
    var entriesArray = new Array();
    if (firstLoad != true) {
        for (i = 0; i < entry.length; i++) {
            //alert(entry[i].getElementsByTagName("entryId")[0].childNodes[0].nodeValue);
            var entryIdValue = entry[i].getElementsByTagName("entryId")[0].childNodes[0].nodeValue;
            //Article.articles.articleList = entryValue

            entriesArray[i] = entryIdValue
            //alert(Article.articles.articleList + entry.length)
        }

        Article.articles.articleList = entriesArray;
        if (articleIndex > 0) {

            Article.articles.articleListIndex = articleIndex;
        } else {

            Article.articles.articleListIndex = 0;
        }
        firstLoad = true
    }

    //Article.articles.articleList

    var data = getArticleById(xmlobject, articleId, category, articleIndex)
    var categoryName = formatCategoryName(category);
    var categoryTitle = document.getElementById("categoryTitle");
    var articleBody = document.getElementById("articleBody");
    articleBody.innerHTML = data.txt;
    Article.images.imgList = data.imgs;
    Article.images.imgText = data.imgsText;

    categoryTitle.innerHTML = categoryName
    categoryTitle.innerHTML += writeArticleWidget();

}

function parseFeedSearch(xmlObj) {
    //alert(dateRange + " | " + category+ " | " + articleIdNum)
    // convert string to XML object
    //var  = (new DOMParser()).parseFromString(xmlObj, "text/xml");
    var parser = new DOMParser();
    var xmlobjectDoc = parser.parseFromString(xmlObj, "text/xml");
    //alert(typeof(xmlobjectDoc))
    var xmlobject = xmlobjectDoc
    // get a reference to the root-element "feed"
    var root = xmlobject.getElementsByTagName('feed')[0];
    // get reference to "entryId" element
    var entryId = root.getElementsByTagName("entryId");
    // get reference to "title" element
    var title = root.getElementsByTagName("title");
    // get reference to "subtitle" element
    var subtitle = root.getElementsByTagName("shortTitle");
    // get reference to "updated" element
    var updated = root.getElementsByTagName("updated");
    // get reference to "id" element
    var id = root.getElementsByTagName("id");
    // get reference to "link alternate" element
    //var linkAlternateLen = root.getElementsByTagName("link")
    //var linkAlternate = root.getElementsByTagName("link")[0].getAttribute("alternate");
    // get reference to "link enclosure" element
    //var linkEnclosure = root.getElementsByTagName("link")[1].getAttribute("enclosure");
    // get reference to "author" element
    //            var authorName = root.getElementsByTagName("author")[0].getElementsByTagName("name");
    //            var authorUri = root.getElementsByTagName("author")[0].getElementsByTagName("uri");
    //            var authorEmail = root.getElementsByTagName("author")[0].getElementsByTagName("email");
    //            var linkEnclosure = root.getElementsByTagName("link")[1].getAttribute("enclosure");
    // get reference to "channel" element

    var entry = root.getElementsByTagName("entry");
    var entriesArray = new Array();
    if (firstSearchLoad != true) {
        for (i = 0; i < entry.length; i++) {
            var entryTitle = entry[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
            var entryId = entry[i].getElementsByTagName("entryId")[0].childNodes[0].nodeValue;
            //Article.articles.articleList = entryValue
            //alert(entryTitle + "," + entryId.split("~")[1])


            //var entryTitle = entryTitleRaw.replace(/,/gi, "__");
            entriesArray[i] = entryTitle + "|" + entryId
            //alert(Article.articles.articleList + entry.length)
        }
        Article.articleSearch.articleSearchList = entriesArray;
        Article.articles.articleListIndex = 0;

        firstSearchLoad = true
    }
    writeSearchResults();
    //Article.articles.articleList
    /*
    var data = getArticleById(xmlobject, dateRange, category, articleIdNum)
    var categoryName = formatCategoryName(category);
    var categoryTitle = document.getElementById("categoryTitle");
    var articleBody = document.getElementById("articleBody");
    articleBody.innerHTML = data.txt;
    Article.images.imgList = data.imgs;
    Article.images.imgText = data.imgsText;

            categoryTitle.innerHTML = categoryName
    categoryTitle.innerHTML += writeArticleWidget();
    */

    //alert(data.imgs);
    //alert(Article.images.imgList);
    //alert(Article.images.imgText);
    ///alert("whoWeAreArticle" + whoWeAreArticle);
    // now we have the RSS data we want as strings - do something now :-)

    //alert(tooltipstring);


}


function getSummaryById(xmlDoc, dateRange, category, articleIdNum) {
    var root = xmlDoc.getElementsByTagName('feed')[0];
    // get reference to "channel" element
    //alert(root)

    var entry = root.getElementsByTagName("entry");
    //var parser = new DOMParser();
    //var xmlEntryDoc = parser.parseFromString(xmlObj, "text/xml");

    // now get all "entry" tags in the feed and pull the ID
    for (i = 0; i < entry.length; i++) {
        var entryValue = entry[i].getElementsByTagName("id")[0].childNodes[0].nodeValue;
        entryCurId = entryValue.split(",")[1];
        var entryDateRange = entryCurId.split("-")[0];
        var entryCategory = entryCurId.split("-")[1].split(".")[0];
        var entryArticleIdNum = entryCurId.split("-")[1].split(".")[1];
        //entryId = curId.split(",")[1];
        //var id = entry[i].getElementsByTagName("id")[0].childNodes[0].nodeValue;
        // entryId = id.split(", ")[1];
        if (entryArticleIdNum == articleIdNum) {
            var title = entry[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
            // in the "item" we have a description, so get that
            var published = entry[i].getElementsByTagName("published")[0].childNodes[0].nodeValue;
            var pubDate = isoToStandardDate(published, 'numeric', '.');
            var summary = entry[i].getElementsByTagName("summary")[0].childNodes[0].nodeValue;
            // we also get the "pubDate" element in the "item"
            //var content = entry[i].getElementsByTagName("content")[0].childNodes[0].nodeValue;
            var content = getNodeText(entry[i].getElementsByTagName("content")[0].childNodes[0]) //.nodeValue;                  


            var html = '';
            html += '<div class="listSummaryItem">';
            html += '<img align="left" src="images\/ui\/icons\/newsIcon.jpg" class="rssSummaryImg"\/>';
            html += '<div style="height: 74px; display: inline; float: left;"><\/div>';
            html += '<span>' + pubDate + '<br\/>';
            html += '<strong>' + title.unescapeHTML() + '<\/strong><br\/>';
            html += summary.unescapeHTML();
            html += '<\/span>';
            html += '<\/div>';


        }
        return html;
    }
}

function getArticleById(xmlDoc, articleId, category, articleIndex) {
    var root = xmlDoc.getElementsByTagName("feed")[0];


    var entry = root.getElementsByTagName("entry");
    var entryArray = $A(entry);
    var entryIdsArray = new Array();
    //alert(typeof(entry)+ " : " + $A(entry).toString())
    // now get all "entry" tags in the feed and pull the ID
    for (i = 0; i < entryArray.length; i++) {
        var entryIdTagLoop = entry[i].getElementsByTagName("entryId")[0].childNodes[0].nodeValue;
        entryIdsArray[i] = entryIdTagLoop;
    }

    var iSig = 0;
    var articleID = getQueryKeyValue("articleID");
    if (typeof (Article.articles.isArticleSearch) == 'undefined') {
    
        if (articleID != '' && typeof (articleID) != 'undefined' && articleID != null) {
        
            Article.articles.articleListIndex = String(entryIdsArray.indexOf(Number(articleID)))
            Article.articles.isArticleSearch = false;
        } else {
          
        }
    }
   
    for (i = 0; i < entryIdsArray.length; i++) {
        var entryIdTag = entry[i].getElementsByTagName("entryId")[0].childNodes[0].nodeValue;
        var pubTag = entry[i].getElementsByTagName("published")[0].childNodes[0].nodeValue;
       


        entryCurId = entryIdTag;
        archiveYear = pubTag.split("-")[0];
        if (typeof (archiveYear) == 'undefined' || archiveYear == '')
            archiveYear = '';
        var id = entry[i].getElementsByTagName("id")[0].childNodes[0].nodeValue;
        if (i == Article.articles.articleListIndex) {
            //Article.articles.articleListIndex = parseInt(entryIdsArray.indexOf(articleIndex))
            //alert(entryIdsArray.indexOf(articleIndex));
            var title = entry[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
            // in the "item" we have a description, so get that
            var published = entry[i].getElementsByTagName("published")[0].childNodes[0].nodeValue;
            var pubDate = isoToStandardDate(published, "numeric", ".");
            //var summary = entry[i].getElementsByTagName("summary")[0].childNodes[0].nodeValue;
            // we also get the "pubDate" element in the "item"
            //var content = entry[i].getElementsByTagName("content")[0].childNodes[0].nodeValue;
            var content = getNodeText(entry[i].getElementsByTagName("content")[0]) //.nodeValue;
            var imgLen = entry[i].getElementsByTagName("cfns:image")

            var imgList = new Array();
            var imgText = new Array();
            for (j = 0; j < imgLen.length; j++) {
                imgList[j] = trimASPImagePath(entry[i].getElementsByTagName("cfns:image")[j].getAttribute("href"));
                imgText[j] = entry[i].getElementsByTagName("cfns:image")[j].getAttribute("mediaDescription");

            }
            var html = '';
            html += '<div class="fullArticle">';
            html += '<div class="articleTitle">' + title.unescapeHTML() + '<\/div>';
            if (category == "news") {
                html += '<img align="left" src="images\/ui\/icons\/newsIcon.jpg" class="rssSummaryImg"\/>';
                html += '<h3>&nbsp;<\/h3>';
            }
            if (category == "news") {
                html += '<span>' + pubDate + '<br\/>';
                html += '<\/span>';
            }

            //html += decodeURIComponent(content)
            html += content.unescapeHTML();
            html += '&nbsp;<\/div>';
            
            return { txt: html, imgs: imgList, imgsText: imgText };
            
        }
    }
}


function filterSearchMenu() { //v3.0

    var filterDate = document.getElementById("filterDate")
    var dateValue = filterDate.options[filterDate.selectedIndex].value
    var filterCategory = document.getElementById("filterCategory")
    var categoryValue = filterCategory.options[filterCategory.selectedIndex].value
    //entryTag, articleID, archiveYearPassed, feedType
    getXMLFromSearch(categoryValue, dateValue)
    Article.articles.filterCatagory = categoryValue;

    //if (restore) selObj.selectedIndex = 0;
}



function getNodeText(xmlNode) {
    if (!xmlNode) return '';
    if (typeof (xmlNode.textContent) != "undefined") return xmlNode.textContent;
    return xmlNode.firstChild.nodeValue;
}

function formatCategoryName(category) {

    var re = new RegExp("_", "g");
    var result = category.replace(re, " ");
    return result;

}


function randOrd() {
    return (Math.round(Math.random()) - 0.5);
}




function writeSSFeatureCallOut() {
    var sSFArray = new Array();
    sSFArray[0] = ["Species Research", "SuccessStoriesArticle.aspx?articleID=116&feedId=15"]; //species_research.1
    sSFArray[1] = ["Habitat Protection", "SuccessStoriesArticle.aspx?articleID=118&feedId=17"]; //habitat_protection.1
    sSFArray[2] = ["Animal Rescue & Rehabilitation", "SuccessStoriesArticle.aspx?articleID=117&feedId=16"]; //animal_rescue_and_rehabilitation.1
    sSFArray[3] = ["Conservation Education", "SuccessStoriesArticle.aspx?articleID=119&feedId=18"]; //conservation_education.1

    sSFArray.sort(randOrd);

    var successStoryDivText = document.getElementById("successStoryText");
    successStoryDivText.innerHTML = sSFArray[0][0];

    var sSfAnchor = document.getElementById("sSfAnchor");
    sSfAnchor.setAttribute("href", sSFArray[0][1])

    var sSfDiv = document.getElementById("sSfDiv");
    sSfDiv.setAttribute("onclick", "jumpToLocation('" + sSFArray[0][1] + "')")
}


function loadSummary() {
    writeRSSSummaryDiv();
    writeTipSummaryDiv();
}
function writeRSSSummaryDiv() {
    var feedSummary = document.getElementById("feedSummary");
    if (feedSummary)
        feedSummary.innerHTML = writeRSSSummary();
}
function writeTipSummaryDiv() {
    var tipSummary = document.getElementById("tipSummary");
    if (tipSummary)
        tipSummary.innerHTML = writeTipSummary();
}

function writeNavigationDiv(active) {
    var headerNavControls = document.getElementById("headerNavControls");
    if (headerNavControls)
        headerNavControls.innerHTML = writeNavigation(active);

}
function writeRSSSummary() {
    var html = '';
    var divOpenStr = '<div class="listSummaryItem">';
    var divCloseStr = '</div>';
    var spanOpenStr = '<span>';
    var spanCloseStr = '</span>';
    var dividerStr = '<div style="height:  74px; display: inline; float:left; vertical-align: top;">&nbsp;</div>';
    var newsIcon = '<img class="rssSummaryImg" align="left" src="images/ui/icons/newsIcon.jpg">';
    var pressIcon = '<img class="rssSummaryImg"  align="left" src="images/ui/icons/pressIcon.jpg">';
    var specialIcon = '<img class="rssSummaryImg"  align="left" src="images/ui/icons/specialIcon.jpg">';

    html += divOpenStr
    html += newsIcon + dividerStr

    html += spanOpenStr + '09.15.08<br \/>';
    html += '<a href="NewsEventsArticle.aspx?articleID=Announcements_And_Press_Releases.1"><strong>Fund helps birds in crisis around the world</strong></a><br \/>';
    html += '2 grants totaling $10,000';
    html += spanCloseStr + divCloseStr
    html += divOpenStr
    html += pressIcon + dividerStr
    html += spanOpenStr + '05.09.09<br \/>';
    html += '<a href="NewsEventsArticle.aspx?articleID=Announcements_And_Press_Releases.2"><strong>SW/BG Conservation Fund awards 1.5 million</strong></a> <br \/>';
    html += 'Fund announces grants to 151 organizations worldwide';
    html += '';
    html += spanCloseStr + divCloseStr
    html += divOpenStr
    html += specialIcon + dividerStr
    html += spanOpenStr + '11.01.09<br \/>';
    html += '<a href="NewsEventsArticle.aspx?articleID=Announcements_And_Press_Releases.3"><strong>Special announcement - Kenya Safari</strong> </a><br \/>';
    html += 'Travel to Kenya with our Fund';
    html += spanCloseStr + divCloseStr
    return html;
}

function writeTipSummary() {
    var html = '';
    var divOpenStr = '<div class="listSummaryItem ">';
    var divCloseStr = '</div>';
    var spanOpenStr = '<span>';
    var spanCloseStr = '</span>';
    var dividerStr = '<div style="height:  74px; display: inline; float:left;">&nbsp;</div>';
    var tipIcon = '<img class="rssSummaryImg"  align="left" src="images/ui/icons/makeAdifference.jpg" />';
    var tipText = '<br \/>';

    tipText += '<strong>Tip: 1</strong> <br \/>'
    tipText += 'Follow your kindergarten teacher\'s advice'

    html += divOpenStr
    html += tipIcon + dividerStr
    html += spanOpenStr + tipText
    html += spanCloseStr + divCloseStr
    return html;
}



function writeNavigation(active) {
    var ACW = ""
    var ACS = ""
    var ACG = ""
    var ACD = ""
    var ACN = ""
    switch (active) {

        case "who":
            ACW = "activeNav";
            break;

        case "success":
            ACS = "activeNav";
            break;

        case "grant":
            ACG = "activeNav";
            break;

        case "dif":
            ACD = "activeNav";
            break;

        case "news":
            ACN = "activeNav";
            break;
        default:

    }

    var html = '';
    html += '<div style="height: 25px; width: 650px; color: #FFFFFF; font-size: 11px; position: relative; font-weight:bold; vertical-align:top;">';
    html += '<a href="/whoWeAre.htm" class="' + ACW + '" " style="width:90px;"><span>WHO WE ARE<\/span><\/a>';
    html += '<a href="/successStories.htm" class="' + ACS + '" style="width:120px;"><span>SUCCESS STORIES<\/span><\/a>';
    html += '<a href="/grantInfo.htm" class="' + ACG + '" style="width:88px;"><span>GRANT INFO<\/span><\/a>';
    html += '<a href="/makeADifference.htm" class="' + ACD + '" style="width:129px;"><span>MAKE A DIFFERENCE<\/span><\/a>';
    html += '<a href="/NewsEvents.aspx" class="' + ACN + '" style="width:80px;"><span>NEWS FEED<\/span><\/a>';
    html += writeQuickLinks('script');
    html += '<\/div>';

    return html;

}

function writeQuickLinks(type) 
{
    var host = window.location.host;
    var firstdot = host.indexOf(".");
    var beforeFirstDot = host.substring(0, firstdot);
    var donateLink;

    if (beforeFirstDot == "qa") {
        donateLink = "http://qa.swbg-conservationfund.org/giving.htm";
    }
    else {
        donateLink = "https://www.swbg-conservationfund.org/giving.htm";
    }  


    var html = '';
    html += '<select onchange="jumpMenu(this,1)" class="quickLinks" id="Select1">';
    html += '  <option class="quickLinksMain">QUICK LINKS<\/option>';
    html += '  <option value="GeneralInterest.aspx" class="quickLinksMain">Explore<\/option>';
    html += '  <option value="whoWeAre.htm" class="quickLinksSub">Who We Are<\/option>';
    html += '  <option value="successStories.htm" class="quickLinksSub">Success Stories<\/option>';
    html += '  <option value="grantInfoA.htm" class="quickLinksSub">Grant Info <\/option>';
    html += '  <option value="makeADifference.htm" class="quickLinksSub">Make a Difference <\/option>';
    html += '  <option value="NewsEvents.aspx" class="quickLinksSub">News & Events <\/option>';
    html += '  <option value="grantInfo.htm" class="quickLinksMain">Grant Seeker <\/option>';
    html += '  <option value="grantApplication.htm" class="quickLinksSub">Grant Application <\/option>';
    html += '  <option value="grantPolicies.htm" class="quickLinksSub">Grant Policies <\/option>';
    html += '  <option value="grantFAQ.htm" class="quickLinksSub">Grant FAQ\'s <\/option>';
    html += '  <option value="index.htm" class="quickLinksMain">Home <\/option>';
    html += '  <option value="' + donateLink + '" ';
    html += '  class="quickLinksMain">Make a Donation<\/option>';
    //    html += '  <option value="MakeDonation.aspx" class="quickLinksMain">Make a Donation<\/option>'; 
    html += '  <option value="contactUs.aspx" class="quickLinksMain">Contact US <\/option>';
    html += '  <option value="Faqs.aspx" class="quickLinksMain">FAQ <\/option>';
    html += '  <option value="sitemap.htm" class="quickLinksMain">Sitemap <\/option>';
    html += '<\/select>';
    if (type == 'home') {
        if (isMinIE7) {
            //alert(isMinIE7)
            html += '<div style="border: 0px solid #ff0000; width:108px; height: 15px; margin-left: 543px; margin-top: 3px; padding-left: 0px;">';

        } else if (isMinIE6) {
            //alert(isMinIE6)
            html += '<div style="border: 0px solid #ff0000; width:108px; height: 15px; margin-left: 543px; margin-top: 3px; padding-left: 20px;">';
        } else {

            html += '<div style="border: 0px solid #00ff00; width:108px; height: 15px; margin-left: 543px; margin-top: 3px;">';
        }
        html += '<span id="emailSignup" class="emailUpdatesA" onclick="emailUpdatesConfirm()">Want Email Updates?</span>';
        html += '</div>';
    } else {
   
        if (isMinIE6) {
            html += '<div style="margin-top: -7px; margin-left: -25px; border: 0px solid #ff0000; width: 130px; padding-left: 10px; position: absolute; font-weight: normal;"><br/><br/>';
            html += '<span id="emailSignup" class="emailUpdatesA" onclick="emailUpdatesConfirm()">Want Email Updates?</span>';
            html += '</div>';
        } else {
        html += '<div style="margin-top: 22px; border: 0px solid #0000ff; width: 134px; padding-left: 10px; margin-left: 524px; position: absolute; ">';
            html += '<span id="emailSignup" style="font-weight: normal; color: #ffffff;" class="emailUpdatesA" onclick="emailUpdatesConfirm()">Want Email Updates?</span>';
            html += '</div>';
        }
    }
    if (type == 'script') {
        /* html += '<select onchange="jumpMenu(this,1)" class="quickLinks" id="Select1">';
        html += '  <option class="quickLinksMain">QUICK LINKS<\/option>';
        html += '  <option value="GeneralInterest.aspx" class="quickLinksMain">Explore<\/option>';
        html += '  <option value="whoWeAre.htm" class="quickLinksSub">Who We Are<\/option>';
        html += '  <option value="successStories.htm" class="quickLinksSub">Success Stories<\/option>';
        html += '  <option value="grantInfoA.htm" class="quickLinksSub">Grant Info <\/option>';
        html += '  <option value="makeADifference.htm" class="quickLinksSub">Make a Difference <\/option>';
        html += '  <option value="NewsEvents.aspx" class="quickLinksSub">News & Events <\/option>';
        html += '  <option value="grantInfo.htm" class="quickLinksMain">Grant Seeker <\/option>';
        html += '  <option value="grantApplication.htm" class="quickLinksSub">Grant Application <\/option>';
        html += '  <option value="grantPolicies.htm" class="quickLinksSub">Grant Policies <\/option>';
        html += '  <option value="grantFAQ.htm" class="quickLinksSub">Grant FAQ\'s <\/option>';
        html += '  <option value="index.htm" class="quickLinksMain">Home <\/option>';
        html += '  <option value="' + donateLink + '" ';
        html += '  class="quickLinksMain">Make a Donation<\/option>';
        html += '  <option value="contactUs.aspx" class="quickLinksMain">Contact US <\/option>';
        html += '  <option value="Faqs.aspx" class="quickLinksMain">FAQ <\/option>';
        html += '  <option value="sitemap.htm" class="quickLinksMain">Sitemap <\/option>';
        html += '<\/select>';
        */
        return html;
    }
    if (type == 'home') {
        var quickLinks = document.getElementById('quickLinks')
        if (quickLinks != null || typeof (quickLinks) != 'undefined') {
            quickLinks.innerHTML = html;
        }
    }
    //return html;	


}


function scrollImages(direction) {
    //alert(Article.images.imgIndex);

    //if (Article.images.imgIndex >= Article.images.imgList.length || Article.images.imgIndex == Article.images.imgList.length - 1)
    //return;
    //  alert('is4')

    if (Article.images.imgList.length > 1) {

        var img1 = document.getElementById("img1");
        var img2 = document.getElementById("img2");
        var img1Caption = document.getElementById("img1Caption");
        var img2Caption = document.getElementById("img2Caption");
        //

        //alert(direction)
        switch (direction) {
            case "forward":

                if (Article.images.imgIndex != Article.images.imgList.length - 1) {
                    img1.src = Article.images.imgList[Article.images.imgIndex]
                    img2.src = Article.images.imgList[Article.images.imgIndex + 1]
                    img1Caption.innerHTML = Article.images.imgText[Article.images.imgIndex]
                    img2Caption.innerHTML = Article.images.imgText[Article.images.imgIndex + 1]
                    if (Article.images.imgIndex == Article.images.imgList.length - 1)
                        return;

                    Article.images.imgIndex++

                }

                break;

            case "back":
                //alert('here')
                if (Article.images.imgIndex > 1) {
                    Article.images.imgIndex--
                    img1.src = Article.images.imgList[Article.images.imgIndex - 1]
                    img2.src = Article.images.imgList[Article.images.imgIndex]
                    img1Caption.innerHTML = Article.images.imgText[Article.images.imgIndex - 1]
                    img2Caption.innerHTML = Article.images.imgText[Article.images.imgIndex]
                }


                break;

        }

    }

}

function writeArticleWidget() {

    //alert(Article.images.imgList.length);
    var imgList = Article.images.imgList;
    var imgTextList = Article.images.imgText;
    var articleID = getQueryKeyValue("articleID");
    if (imgList.length == 1) {
        Article.images.imgIndex = 1;
    }
    if (imgList.length >= 2) {
        Article.images.imgIndex = 1;
    }

    //alert(Article.images.imgIndex);
    var imgArray = Article.images.imgList;

    var articleWidget = document.getElementById("articleWidget");
    var img1 = '';
    var img2 = '';
    var img1IsValid = true;
    var img2IsValid = true;
    if (imgList[0] == '' || imgList[0] == null || typeof (imgList[0]) == 'undefined') {
        img1 = 'images/ui/noImageA.jpg';
        img1IsValid = false;
    } else {
        img1 = imgList[0];
    }

    if (imgList[1] == '' || imgList[1] == null || typeof (imgList[1]) == 'undefined') {
        img2 = 'images/ui/noImageB.jpg';
        img2IsValid = false;
    } else {
        img2 = imgList[1];
    }

    var imgText1 = '';
    var imgText2 = '';

    if (imgTextList[0] == '' || imgTextList[0] == null || typeof (imgTextList[0]) == 'undefined') {
        if (img1IsValid) {
            imgText1 = 'BEC File Image';
        } else {
            imgText1 = '';
        }
    } else {
        imgText1 = imgTextList[0];
    }

    if (imgTextList[1] == '' || imgTextList[1] == null || typeof (imgTextList[1]) == 'undefined') {
        if (img2IsValid) {
            imgText2 = 'BEC File Image';
        } else {
            imgText2 = '';
        }
    } else {
        imgText2 = imgTextList[1];
    }

    var html = '';
    html += '<div class="articleImgWidgetDiv" id="articleImgWidget">';
    html += '  <div class="articleImgsDiv" id="articleImgs" align="center">';

    html += '    <div class="articleImg"> <img src="' + img1 + '" alt="" id="img1"\/><br\/>';
    html += '<span class="articleImgCaption" id="img1Caption">' + imgText1 + '<\/span><\/div>';
    //if (imgList.length > 1) {
    html += '    <div class="articleImg"> <img src= "' + img2 + '" alt="" id="img2"\/><br\/>';
    html += '<span class="articleImgCaption" id="img2Caption">' + imgText2 + '<\/span><\/div>';
    //}
    html += '  <\/div>';
    //if (imgList.length > 2) {
    html += '  <div class="articleImgControls" id="articleImgsControls" align="center">';
    html += '    <div class="articleImgControlsImg" style=" height:29px;" >';
    //alert(articleID.length)
    if (imgList.length > 2) {
        html += '			<img src="images\/ui\/icons\/picsNav.jpg" id="picNavImg" alt="" border="0" usemap="#picsNav" \/>';
        html += '			<map name="picsNav" >';
        html += '				<area shape="rect" coords="1,1,25,28" href="pic"  onmouseover="swapNavState(\'pic\',\'left\')" onmouseout="restoreNavState(\'pic\')" onclick="scrollImages(\'back\'); return false;" \/>';
        html += '				<area shape="rect" coords="144,1,172,29" href="pic" onmouseover="swapNavState(\'pic\',\'right\')" onmouseout="restoreNavState(\'pic\')" onclick="scrollImages(\'forward\'); return false;" \/>';
        html += '			<\/map>';
    }
    html += '  	<\/div>';
    //}
    //if (articleID.length > 0 && articleID != '' || typeof (articleID) != 'undefiined' || articleID != null) {
    html += '   <div class="articleImgControlsArt">';
    html += '			<img src="images\/ui\/icons\/articlesNav.jpg" id="articleNavImg" alt="" border="0" usemap="#articleNav" \/>';
    html += '			<map name="articleNav" >';
    html += '				<area shape="rect" coords="1,1,25,28" href="" onmouseover="swapNavState(\'article\',\'left\')" onmouseout="restoreNavState(\'article\')" onclick="scrollArticles(\'back\'); return false;" \/>';
    html += '				<area shape="rect" coords="144,1,172,29" href="" onmouseover="swapNavState(\'article\',\'right\')" onmouseout="restoreNavState(\'article\')" onclick="scrollArticles(\'forward\'); return false;" \/>';
    html += '			<\/map>';
    html += '  <\/div>';
    //}
    html += '<\/div>'
    //html += '<a href="#" onclick="scrollArticles(\'back\'); return false;" >Previous</a> | <a href="#" onclick="scrollArticles(\'forward\'); return false;" >Next</a>';
    return html;

}

function swapNavState(type, state) {


    var picNavImg = document.getElementById("picNavImg");
    var articleNavImg = document.getElementById("articleNavImg");
    if (type == 'pic' && state == 'left') {
        picNavImg.src = 'images/ui/icons/picsNavLeft.jpg'
    }

    if (type == 'pic' && state == 'right') {
        picNavImg.src = 'images/ui/icons/picsNavRight.jpg'
    }

    if (type == 'article' && state == 'left') {
        articleNavImg.src = 'images/ui/icons/articlesNavLeft.jpg'
    }

    if (type == 'article' && state == 'right') {
        articleNavImg.src = 'images/ui/icons/articlesNavRight.jpg'
    }

}

function restoreNavState(type) {


    var picNavImg = document.getElementById("picNavImg");
    var articleNavImg = document.getElementById("articleNavImg");
    if (type == 'pic') {
        picNavImg.src = 'images/ui/icons/picsNav.jpg'
    }



    if (type == 'article') {
        articleNavImg.src = 'images/ui/icons/articlesNav.jpg'
    }

}
function scrollArticles(direction) {

    if (Article.articles.articleList.length > 1) {
        //alert(Article.articles.articleListIndex)
        switch (direction) {
            case "forward":
                if (Article.articles.articleListIndex != Article.articles.articleList.length - 1) {
                    Article.articles.articleListIndex++;
                    // articleID, archiveYearPassed, feedType, entryTag
                    var indexOfItem = Article.articles.articleList.indexOf(Article.articles.articleList[Article.articles.articleListIndex])
                    //alert(indexOfItem)
                    getXML(indexOfItem, "", Article.articles.feedType, Article.articles.feedName);

                    if (Article.articles.articleListIndex == Article.articles.articleList.length - 1)
                        return;



                }

                break;

            case "back":

                if (Article.articles.articleListIndex > 0) {
                    Article.articles.articleListIndex--;
                    // articleID, archiveYearPassed, feedType, entryTag,
                    var indexOfItem = Article.articles.articleList.indexOf(Article.articles.articleList[Article.articles.articleListIndex])
                    //alert(indexOfItem)

                    getXML(indexOfItem, "", Article.articles.feedType, Article.articles.feedName);

                }


                break;

        }
        //alert(Article.articles.articleListIndex);
    }

}


function showSuccessSearchForm() {

    var categoryTitleDiv = document.getElementById("categoryTitleDiv")
    var articleSearch = document.getElementById("articleSearch")
    var searchButton = document.getElementById("searchButton")

    var html = '';
    html += '<h1>Search Past Projects</h1> ';
    html += '<table border="0">';
    html += '<tr><td>';
    html += '  <select name="filterDate" id="filterDate" style="margin-left: 15px;">';
    html += '    <option value="-1">Filter by date<\/option> ';
    html += '    <option value="2009">2009<\/option>    ';
    html += '    <option value="2008">2008<\/option>    ';
    html += '    <option value="2007">2007<\/option>     ';
    html += '    <option value="2006">2006<\/option>      ';
    html += '    <option value="2005">2005<\/option>';
    html += ' 	 <option value="2004">2004<\/option>';
    html += '<\/select>';
    html += '</td><td>';
    html += '  <select name="filterCategory" id="filterCategory" style="margin-left: 70px;" >';
    html += '    <option value="-1">Filter by category<\/option> ';
    html += '    <option value="15">Species Research<\/option>    ';
    html += '    <option value="16">Animal Rescue and Rehabilitation<\/option>     ';
    html += '    <option value="17">Habitat Protection<\/option>      ';
    html += '    <option value="18">Conservation Education <\/option>';
    html += '<\/select>';
    html += '</td></tr>';
    html += '<tr><td colspan="2">';
    html += '<div id="infoBox" class="errorBoxSmall" ></div>';
    html += '<input name="search" type="button" class="submitBtn" value="" onclick="filterSearchMenu()" \/>';
    html += '</td></tr>';
    html += '</table>';
    categoryTitleDiv.style.display = 'none';
    searchButton.style.visibility = 'hidden';

    articleSearch.style.display = 'block';
    articleSearch.innerHTML = html;

}
function showSearchForm() {

    var categoryTitleDiv = document.getElementById("categoryTitleDiv")
    var articleSearch = document.getElementById("articleSearch")
    var searchButton = document.getElementById("searchButton")

    var html = '';
    html += '<h1>Search Archives</h1> ';
    html += '<table border="0">';
    html += '<tr><td>';
    html += '  <select name="filterDate" id="filterDate" style="margin-left: 15px;">';
    html += '    <option value="-1">Filter by date<\/option> ';
    html += '    <option value="2009">2009<\/option>    ';
    html += '    <option value="2008">2008<\/option>    ';
    html += '    <option value="2007">2007<\/option>     ';
    html += '    <option value="2006">2006<\/option>      ';
    html += '    <option value="2005">2005<\/option>';
    html += ' 	 <option value="2004">2004<\/option>';
    html += '<\/select>';
    html += '</td><td>';
    html += '  <select name="filterCategory" id="filterCategory" style="margin-left: 70px;" >';
    html += '    <option value="-1">Filter by category<\/option> ';
    html += '    <option value="15">Species Research<\/option>    ';
    html += '    <option value="16">Animal Rescue and Rehabilitation<\/option>     ';
    html += '    <option value="17">Habitat Protection<\/option>      ';
    html += '    <option value="18">Conservation Education <\/option>';
    html += '<\/select>';
    html += '</td></tr>';
    html += '<tr><td colspan="2">';
    html += '<div id="infoBox" class="errorBoxSmall" ></div>';
    html += '<input name="search" type="button" class="submitBtn" value="" onclick="filterSearchMenu()" style="margin-left: 55px; margin-top: 25px;"\/>';
    html += '</td></tr>';
    html += '</table>';
    categoryTitleDiv.style.display = 'none';
    searchButton.style.visibility = 'hidden';

    articleSearch.style.display = 'block';
    articleSearch.innerHTML = html;

}
function writeSearchResults() {

    var articleBody = document.getElementById("articleBody");
    var html = '';
    html += '<div style="padding-left: 10px;" class="interiorText-new">';
    html += '			  <br\/>';
    html += '			  <br\/>';
    html += '			  <ul class="arrowUL listOutside">';
    for (i = 0; i < Article.articleSearch.articleSearchList.length; i++) {
        var articleId = Article.articleSearch.articleSearchList[i].split('|')[1];
        var title = Article.articleSearch.articleSearchList[i].split('|')[0];


        html += '			  <li class="searchList"><a href="SuccessStoriesArticle.aspx?articleID=' + articleId + '&feedId=' + Article.articles.filterCatagory + '">' + title.unescapeHTML() + '<\/a><\/li>';
    }
    html += '			  ';
    html += '			  <\/ul>';
    html += '			  <\/div>';
    html += '<br\/>';

    articleBody.innerHTML = html;

}

function writePageFooter() {
    var footerLinks = document.getElementById("footerLinks")

    var html = '';
    html += '<ul>';
    html += '    <li><a href="http:\/\/www.swbg-animals.org\/" name="All About ANIMALS">All About ANIMALS<\/a><\/li>';
    html += '    <li><a href="contactUs.aspx" name="Contact Us">Contact Us<\/a><\/li>';
    html += '    <li><a href="http:\/\/abap-wildlife.org\/" name="WildLIFE e-Newsletter">WildLIFE e-Newsletter<\/a><\/li>';
    html += '    <li><a href="Faqs.aspx" name="FAQs">FAQs<\/a><\/li>';
    html += '    <li><a href="sitemap.htm" name="Sitemap">Sitemap<\/a><\/li>';
    html += '    <li><a href="http:\/\/www.worldsofdiscovery.com\/worldsofdiscovery\/terms.html" target="_blank" name="Terms & Conditions">Terms &amp; Conditions<\/a><\/li>';
    html += '    <li><a href="privacyPolicy.htm" name="Privacy Policy">Privacy Policy<\/a><\/li>';
    html += '    <li><a href="http:\/\/www.seaworldcares.com\/" name="SeaWorld Cares">SeaWorld Cares<\/a><\/li>';            
    html += '<\/ul><br clear="all"/><br clear="all"/>';

    html += '<table><tr>';
    html += '    <td><div class="social-footer"><a href="http://www.facebook.com/pages/SeaWorld-Busch-Gardens-Fund/87807413509" target="_blank" name="Join us on Facebook">';
    html += '           <img src="./images/ui/facebook.jpg" alt="Join us on Facebook" height="32" width="32" \/><div>Become a Fan<\/div>';
    html += '        <\/a><\/div><\/td>';
    html += '    <td><div class="social-footer"><a href="http://www.twitter.com/JulieScardina" target="_blank" name="Join us on Twitter"><img src="./images/ui/twitter.jpg" alt="Join us on Twitter" height="32" width="32" \/><div>Follow Us<\/div><\/a><\/div><\/td>';
    html += '<\/table><br clear="all"/><br clear="all"/>';
    
    footerLinks.innerHTML = html;
}


function shoppingConfirm() {
    var where_to = confirm("You are now leaving the SWBG Conservation Fund site & going to Busch Garden's secure shopping page.");
    if (where_to == true) {
        //window.location =
        window.open("http://commerce.4adventure.com/estore/scripts/skins/BGS/conservation.aspx", "", "");
    }
    else {
        //window.location="";
    }
}

function newsletterconfirmation() {
    var where_to = confirm("You are now leaving the SWBG Conservation Fund & going to  Busch Garden's WildLIFE e-newsletter signup page.");
    if (where_to == true) {
        //window.location =
        window.open("http://cs.silverpop.com/abec/swbg-conservationfund/preferences.sp", "", "");
    }
    else {
        //window.location="";
    }
}
function emailUpdatesConfirm() {
    var where_to = confirm("You are now leaving the SWBG Conservation Fund site & going to Busch Garden's e-mail updates sign-up page.");
    if (where_to == true) {
        window.open("http://cs.silverpop.com/abec/preferences/index.sp?pid=WOD", "", "");
    }
}

function saveWildlifeUpdatesConfirm() {

    var where_to = confirm("You are now leaving the SWBG Conservation Fund site & going to Busch Garden's Online Charity Auction.");
    if (where_to == true) {
        //window.location =
        window.open("http://www.auctionwire.com/savewildlife", "", "");
    }
    else {
        //window.location="";
    }
}

        