    var lastMenuItem;
    var quoteCount = 0;
    var quote = null;
    var printed = new Array();

    function startVC() {
         var str = 'menubar=no,status=no,location=no,toolbar=no,directories=no,resizable=no,outerHeight=' + screen.availHeight + ',outerWidth=' + screen.availWidth + ',top=0,left=0';
         var wnd = window.open('page.html?category=vc&actionid=getbandwidth','vitalconsent', str);
         wnd.moveTo(0,0);
         if (document.all)
         {
                wnd.resizeTo(screen.availWidth,screen.availHeight);
         }
         else if (document.layers||document.getElementById)
         {
            if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
            {
                top.window.outerHeight = screen.availHeight;
                top.window.outerWidth = screen.availWidth;
            }
         }
         //window.open('page.html?category=vc&actionid=home?link=vc&source=index','vitalconsent','menubar=yes,status=yes,location=yes,toolbar=yes,directories=yes,resizable=no,scrollbars=yes,outerHeight=' + screen.availHeight + ',outerWidth=' + screen.availWidth + ',top=0,left=0');
    }

    function showPage( url ) {
        middleframe.document.location = url;
    }

    function menuClicked( menu ) {
       navmenu = document.getElementById('navwrapper');
       bannercell = document.getElementById('banner');
       if (menu == 'mrb') {
         navmenu.className='navwrapperpurple';
         bannercell.className='bannerpurple';
       }
       else if (menu == 'cmr') {
         navmenu.className='navwrapperpink';
         bannercell.className='bannerpink';
       }
       else if (menu == 'ycmr') {
         navmenu.className='navwrapperyellow';
         bannercell.className='banneryellow';
       }
       else if (menu == 'reflib') {
         navmenu.className='navwrappergreen';
         bannercell.className='bannergreen';
       }
       //else if (menu == 'gloss') {
       //  navmenu.className='navwrapperlavender';
       //  bannercell.className='bannerlavender';
       //}
       else {
         navmenu.className='navwrapper';
         bannercell.className='banner';
       }

       showSubMenu( menu, bannercell );
    }

    function showSubMenu( menu, bannercell ){
       if (menu == 'mrb') {
         str = '<table>';
         str += '<tr><td class="subheader">Medical Research Basics</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_basics.html?link=mrb_wimr&source=index#basics\');">What is Medical Research?</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_basics.html?link=mrb_wiir&source=index#involved\');">Who is Involved in Research?</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_basics.html?link=mrb_cmr&source=index#misunderstandings\');">Common Misunderstandings in Research</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_basics.html?link=mrb_wicr&source=index#whykids\');">Why Include Children in Research?</td></tr>';
         str += '</table>';
         bannercell.innerHTML = str;
         showPage('learn_basics.html?link=mrb_top&source=index');
       }
       else if (menu == 'cmr') {
         str = '<table>';
             str += '<tr><td class="subheader">A Deeper Understanding</td></tr>';
             str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_research.html?link=adr_pimr&source=index#protections\');">Protections in Medical Research</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_research.html?link=adr_rfp&source=index#reasons\');">Reasons For Participating</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_research.html?link=adr_dbrt&source=index#differences\');">Differences Between Research &amp; Therapy</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_research.html?link=adr_pci&source=index#conflicts\');">Potential Conflicts of Interest</td></tr>';
             str += '</table>';
             bannercell.innerHTML = str;
             showPage('learn_research.html?link=adr_top&source=index');
       }
       else if (menu == 'ycmr') {
         str = '<table>';
         str += '<tr><td class="subheader">Your Child &amp; Medical Research</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_yourchild.html?link=ycmr_orp&source=index#responsibilities\');">Ongoing Responsibilities as a Parent</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_yourchild.html?link=ycmr_ets&source=index#evaluating\');">Evaluating the Study</td></tr>';
         str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
         str += '        onclick="showPage(\'learn_yourchild.html?link=ycmr_cao&source=index#alternatives\');">Choosing Among the Options</td></tr>';
         str += '</table>';
         bannercell.innerHTML = str;
         showPage('learn_yourchild.html?link=ycmr_top&source=index');
       }
       else if (menu == 'reflib') {
         str = '<table>';
                 str += '<tr><td class="subheader">Reference Library</td></tr>';
                 str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
                 str += '        onclick="showPage(\'resource_faq.html?link=rl_faq&source=index\');">FAQs</td></tr>';
                 str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
                 str += '        onclick="showPage(\'resource_glossary.html?link=rl_gloss&source=index\');">Glossary</td></tr>';
                 str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
                 str += '        onclick="showPage(\'resource_links.html?link=rl_links&source=index\');">Links</td></tr>';
                 str += '<tr><td class="submenucell" onmouseover="this.className=\'submenucellhover\'" onmouseout="this.className=\'submenucell\'"';
                 str += '        onclick="showPage(\'resource_reports.html?link=rl_reports&source=index\');">Reports</td></tr>';
         str += '</table>';
         bannercell.innerHTML = str;
         showPage('reference_library.html?link=rl_top&source=index');
       }
       //else if (menu == 'gloss') {
       //  str = '<table>';
       //  str += '<tr><td class="subheader"></td></tr>'
       //  str += '</table>';
       //  bannercell.innerHTML = str;
       //  showPage('resource_glossary.html');
       //}
       else {
         str = '<table>';
         str += '<tr><td class="subheacer"></td></tr>';
         str += '</table>';
         bannercell.innerHTML = str;
       }
       showQuote();
    }

    function showQuote() {
        headercell = document.getElementById('header');
        str = '<table>';
        str += '<tr><td class="quotecell">';
        str += getRandomQuote();
        str += '</td></tr></table>';
        headercell.innerHTML = str;
    }

    function getRandomQuote() {
       switch (quoteCount) {
         case 0: quote = "&#34;There is no right or wrong answer; you do what you think is right for your child and your family.&#34;"; break;
         case 1: quote = "&#34;Making decisions with regard to your children's health is an overwhelming task, and trying to decipher the emotional from the practical can be tricky.&#34;"; break;
         case 2: quote = "&#34;When you're involved in anything new or that's part of a trial, you don't know.  You make a decision but nobody can ever tell you that things will be perfect or work out as you had planned.&#34;"; break;
         case 3: quote = "&#34;Knowing that in some small way I contributed to the research efforts is intrinsically rewarding to me as a parent and a mother.&#34;"; break;
                 case 4: quote = "&#34;He still has at least 10 years to go with this before we find out if it works.  But at least we have hope.&#34;"; break;
       }
       quoteCount = ++quoteCount % 5;
       return quote;
    }

    function getAdobe() {
       document.location = 'page.html?url=http://www.adobe.com/products/acrobat/readstep2.html&link=adobe&source=index';
    }

    function getFlash() {
           document.location = 'page.html?url=http://www.macromedia.com/go/getflashplayer&link=flash&source=index';
    }

    function goToKeris(link_id) {
       document.location = 'page.html?url=http://www.clinaero.com&link=' + link_id + '&source=index';
    }

    function goToCHB() {
       document.location = 'page.html?url=http://www.childrenshospital.org&link=chb&source=index';
    }

    function doSearch() {
       document.forms['searchform'].submit();
    }

    function showDocQuestions() {
         var str = 'menubar=no,status=no,location=no,toolbar=no,directories=no,resizable=yes,outerHeight=' + screen.availHeight + ',outerWidth=' + screen.availWidth + ',top=0,left=0';
         var wnd = window.open('page.html?category=vc&actionid=askquestion&link=docquestion&source=index','AskQuestion', str);
         wnd.focus();
         wnd.moveTo(0,0);
         if (document.all)
         {
                wnd.resizeTo(screen.availWidth,screen.availHeight);
         }
         else if (document.layers||document.getElementById)
         {
            if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
            {
                top.window.outerHeight = screen.availHeight;
                top.window.outerWidth = screen.availWidth;
            }
         }
    }

    function printContent() {
      contentFrame = window['middleframe'];
      if (contentFrame['searchframe']) {
        contentFrame = contentFrame['searchframe'];
      }
      printed[printed.length] = '' + contentFrame.document.location;
      contentFrame.focus();
      contentFrame.print();
    }

    function endSessionPost() {
      theForm = document.forms['exitForm'];
      str = '';
      for (i=0; i<printed.length; i++) {
        str += '<input type="hidden" name="printedPage';
        str += i;
        str += '" value="';
        str += printed[i];
        str += '"/>\n';
      }
      theForm.innerHTML = str;
      theForm.submit();
      for(i=0; i<1000000; i++) {
        i = i; //spin to let async http post complete
      }
    }

    function openjournal() {
    window.open('http://bostonchild.vitalconsent.com/journal/journal.html', 'journal',
        'width=800,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
    }

    function getParameter(sParam){

        var sKey = sParam + "=";

        var oParams = location.search.substring(1).split("&");
        for(var i = 0; i < oParams.length; i++)
            if(oParams[i].indexOf(sKey) == 0)
                return oParams[i].substring(sKey.length);
        return null;
    };

    function setInitialPage()
    {
        var initpage = getParameter('initialpage');
        if(initpage)
        {
            showPage(initpage);
        }
    }

function showPopup() {
    if ( !readCookie("beenheredonethat") ) {
        createCookie( "beenheredonethat", "" + new Date(), 365 );
        document.getElementById("qpopup").style.display = "";
    }
}


/***cookie***/
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function trackSelection() {
    var selection = "none";
    if ( document.getElementById("tou1").checked ) selection = "Parentetc";
    else if ( document.getElementById("tou2").checked ) selection = "ResearchSubject";
    else if ( document.getElementById("tou3").checked ) selection = "ResearchStaff";
    else if ( document.getElementById("tou4").checked ) selection = "IRB";
    else if ( document.getElementById("tou5").checked ) selection = "Other";
    javascript:urchinTracker('/whattypeofuser/' + selection);
}


