/* javascript.js */

/*
 * Global variables
 */
/*
 * Browser properties BEGIN - PLEASE DO NOT MODIFY: CODE GENERATED AUTOMATICALLY
 */
var browserVendor = "MSIE" ;
var browserVendorDetails = "Microsoft Internet Excplorer" ;
var browserEngine = "MSIE" ;
var browserVersionMajor = 6 ;
var browserVersionMinor = 0 ;
var browserHostOS = "WINNT51" ;
var isBrowserSupported = true ;
var hasUserBeenWarned = false ; 
/*
 * Browser properties END - PLEASE DO NOT MODIFY: CODE GENERATED AUTOMATICALLY
 */


// insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement() for Netscape 6/Mozilla
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) {
    HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode) {
        switch (where) {
        case 'beforeBegin':
            this.parentNode.insertBefore(parsedNode,this)
            break;
        case 'afterBegin':
            this.insertBefore(parsedNode,this.firstChild);
            break;
        case 'beforeEnd':
            this.appendChild(parsedNode);
            break;
        case 'afterEnd':
         if (this.nextSibling) {
               this.parentNode.insertBefore(parsedNode,this.nextSibling);
         }
         else {
            this.parentNode.appendChild(parsedNode);
         }
            break;
        }
    }

    HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML = r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where,parsedHTML)
    }


    HTMLElement.prototype.insertAdjacentText = function(where,txtStr)   {
        var parsedText = document.createTextNode(txtStr)
        this.insertAdjacentElement(where,parsedText)
    }
}

/*
 * Image rollover function used by aao cluster homepage
 */
function swap(iname,swapGfc) {
    document.images[iname].src = swapGfc;
}

/*
 * open a new window
 */
function openWin(url,str)
{
   return openLargeWin(url,str);
}

/*
 * Used by generic popup function to generate params string
 */
function getArgs(width,height,center,menu){
    xposition=0; yposition=0;

    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        if (menu==0){
            xposition = (screen.width - width) - 10;
            yposition = (screen.height - height) - 58;
        }
        else if(menu==1){
            xposition = (screen.width - width) / 2;
            yposition = ((screen.height - height) / 2) - 67;
        }
    }

    if (navigator.appName == 'Netscape'){
        width = width + 25;
        height = height + 25;
    }

    args="width="+width+",height="+height
        +",toolbar="+menu+",menubar="+menu
        +",screenx="+ xposition+",screeny="+yposition
        +",left="+xposition+",top="+yposition
        +",resizable=1,scrollbars=1,";

    return args;
}

/*
 * Generic popup function for use in fragments
 */
function openPopup(pageToLoad, winName, width, height, center){
    args=getArgs(width,height,center,0);
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        if(window.popup){
            popup.close();
            popup=window.open(pageToLoad,winName,args);
        }
    }
    
    popup=window.open(pageToLoad,winName,args);
}

/*
 * Opens a large popup window.
 */
function openLargeWin(url,windowname) {
    popWin = window.open(url,windowname,'width=730,height=412,innerWidth=730,innerHeight=412,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,menubar=yes,status=yes,address=yes,location=yes,toolbar=yes');
    popWin.focus();
        return false;
}

function fireMenuItem(menu,href,target)
{
    var form = document.forms[menu];
    var oldTarget = form.target;
    form.action=href;
    form.target=target;
    form.submit();
    if (browserHostOS.indexOf("MAC") == -1) {
      form.target = oldTarget;
    }
}

function fireMenuItemGet(menu,href,target)
{
    if (target != null && target == '_blank') {
        newWin = window.open(href);
        newWin.focus();
    } else {
        document.location = href;
    }
}

function openAdWin(url,windowname) {
    popWin = window.open(url,windowname,'width=730,height=412,innerWidth=730,innerHeight=412,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,menubar=yes,status=yes,address=yes,location=yes,toolbar=yes');
    popWin.focus();
}

function openFeedbackWin(url) 
{
    fedbackWin= window.open(url,"feedbackWin",'width=450,height=550,innerWidth=450,innerHeight=550,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    fedbackWin.focus();
}


function openURLFeedbackWin() 
{
   var url = "/misc/feedback?feedback_badurl=" + location.href;
    fedbackWin= window.open(url,"feedbackWin",'width=450,height=550,innerWidth=450,innerHeight=550,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    fedbackWin.focus();
}


function openHelpWin(url) 
{
    fedbackWin= window.open(url,"help",'width=450,height=350,innerWidth=450,innerHeight=350,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    fedbackWin.focus();
}


function openSearchTipsWin(url) 
{
    searchTipsWin= window.open(url,"searchTipsWin",'width=450,height=350,innerWidth=450,innerHeight=350,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    searchTipsWin.focus();
}

/*
 * id: the MeSH subject id, truncated at after the TOC@@MESH@ character
 *  description: the item description string
*/
function meshSearchSubmitForm(id, description) 
{
    var msForm = document.forms['meshSearch'];
    msForm.elements['restrictterm_mesh'].value = id;
    msForm.elements['restrictdesc_mesh'].value = description;
    msForm.submit();
    return false;
}

function openEcommerceWin(url) 
{
    fedbackWin= window.open(url,"help",'width=730,height=412,innerWidth=730,innerHeight=412,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    fedbackWin.focus();
}

function openEcommerceWinAndSubmit(url, form) 
{
    fedbackWin= window.open(url,"help",'width=730,height=412,innerWidth=730,innerHeight=412,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    form.submit();
    fedbackWin.focus();
}

function validateEcommerceBillingProvinceFields(form, userZone)
{
    isBillingProvinceDisabled = false ;
    isBillingUSAProvinceDisabled = false ;
    if (userZone.length > 0) {
      if ( (userZone == 'usa') || (userZone == 'canada') ) {isBillingProvinceDisabled = true;}
      else {isBillingUSAProvinceDisabled = true;}
    } else {
      if (form.elements['ecomm_bill_USAStatesCanadaProvinces'].value != '') {isBillingProvinceDisabled = true ;}
    }
    form.elements['ecomm_bill_State'].disabled = isBillingProvinceDisabled ;
    if (isBillingProvinceDisabled) {
       form.elements['ecomm_bill_State'].style.backgroundColor = "#EEEEEE";
    }
    else {
       form.elements['ecomm_bill_State'].style.backgroundColor = "#FFFFFF";
    }
    form.elements['ecomm_bill_USAStatesCanadaProvinces'].disabled = isBillingUSAProvinceDisabled ;
    return false ;
}

function validateEcommerceShippingProvinceFields(form, userZone) 
{
	isShippingDisabled = false ;
	isShippingProvinceDisabled = false ;
	isShippingUSAProvinceDisabled = false ;
	if (userZone.length > 0) {
	  if ( (userZone == 'usa') || (userZone == 'canada')) {isShippingProvinceDisabled = true}
	  else {isShippingUSAProvinceDisabled = true}
	} else {
	  if (form.elements['ship_USAStates'].value != '') {isShippingProvinceDisabled = true ;}
	}
    form.elements['ship_State'].disabled = isShippingProvinceDisabled ;
    if (isShippingProvinceDisabled) {
       form.elements['ship_State'].style.backgroundColor = "#EEEEEE";
    }
    else {
       form.elements['ship_State'].style.backgroundColor = "#FFFFFF";
    }
    form.elements['ship_USAStates'].disabled = isShippingUSAProvinceDisabled ;
    return false ;
}

function validateEcommerceShippingFields(form, countryId) 
{
	isShippingDisabled = false ;
	if(countryId == 'usa'){
		if (form.elements['ship_isSame'].checked == true) {isShippingDisabled = true ;}
		form.elements['ship_Title'].disabled = isShippingDisabled ;
		form.elements['ship_FirstName'].disabled = isShippingDisabled ;
		form.elements['ship_LastName'].disabled = isShippingDisabled ;
		form.elements['ship_StreetAddress'].disabled = isShippingDisabled ;
		form.elements['ship_StreetAddress1'].disabled = isShippingDisabled ;		
		form.elements['ship_City'].disabled = isShippingDisabled ;
		form.elements['ship_USAStates'].disabled = isShippingDisabled ;
		form.elements['ship_PostalCodeZIP'].disabled = isShippingDisabled ;
		form.elements['ship_Country'].disabled = isShippingDisabled ;
	} else {
		if (form.elements['ship_isSame'].checked == true) {isShippingDisabled = true ;}
		form.elements['ship_Title'].disabled = isShippingDisabled ;
		form.elements['ship_FirstName'].disabled = isShippingDisabled ;
		form.elements['ship_LastName'].disabled = isShippingDisabled ;
		form.elements['ship_StreetAddress'].disabled = isShippingDisabled ;
		form.elements['ship_StreetAddress1'].disabled = isShippingDisabled ;		
		form.elements['ship_City'].disabled = isShippingDisabled ;
		form.elements['ship_State'].disabled = isShippingDisabled ;
		form.elements['ship_PostalCodeZIP'].disabled = isShippingDisabled ;
		form.elements['ship_Country'].disabled = isShippingDisabled ;		
	}
}

function redirectMain(dest)
{
    try {
        opener.location.href=dest;
    }
    catch (errorCaught) {alert('You have navigated away from the page where the shopping cart was opened. Please refresh the main browser to display the new content.')};
}

function refreshMain()
{
    try {
        opener.location.reload(); 
    }
    catch (errorCaught) {}
}

function openAddAlertWin(url) 
{
    fedbackWin= window.open(url,"help",'width=650,height=412,innerWidth=730,innerHeight=412,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    fedbackWin.focus();
}

function changeActionAndSubmit(formName, actionPrefix)
{
  var form = document.forms[formName] ;
  if (form.elements['termsConditions1'].checked) {
    var oldAction = form.action ;
    form.action = actionPrefix + oldAction ;
  }
  form.submit();  
}

function changeActionAndSubmitFinal(formName, newAction)
{
  var form = document.forms[formName] ;
  if (form.elements['termsConditions1'].checked) {
    form.action = newAction;
  }
  form.submit();  
}

function changeFormActionCommand(formName, commandName, commandValue, brandingURL)
{
    var form = document.forms[formName];
    form.action = brandingURL ;
    form.target = "_top";
    form.elements[commandName].value = commandValue;

	if(undefined!=form.elements["login"]) {
		form.elements["login"].value="false";
	}
    if(commandValue != null && commandValue != "") {
        form.submit();
    }
    return false;
}

function submitToClose(formName, toURL)
{
    var form = document.forms[formName];
    form.action = toURL;
    form.submit();
    return false;
}

function switchTermsCheckboxes(formName, id)
{
  var form = document.forms[formName];
  if (id == '1') {form.elements['termsConditions2'].checked = form.elements['termsConditions1'].checked;}
  else {form.elements['termsConditions1'].checked = form.elements['termsConditions2'].checked;}
  return false;
}

/*
 * formName = the name of the form (string)
 * mode = the pick mode (string): 'browseBy' or 'browseLetter' or 'find'
 * value = the pick value string
 */
function journalSubscribeSubmitForm(formName, mode, value)
{
    var form = document.forms[formName];
    form.elements['product'].value = value;
    if(value != null && value != "") 
    {
        form.submit();
    }
    return false;
}

/*
 * formName = the name of the form (string)
 * mode = the pick mode (string): 'browseBy' or 'browseLetter' or 'find'
 * value = the pick value string
 */
function journalPickerSubmitForm(formName, mode, value)
{
    var form = document.forms[formName];
    form.elements['pickMode'].value = mode;
    form.elements['pickValue'].value = value;
    if(value != null && value != "") 
    {
        form.submit();
    }
    return false;
}

/*
 * url = the url (string) for the journal picker popup
 */
function journalPickerOpenWindow(url)
{
    var title = "journalPickerWindow";
    var options = "width=400,height=400,innerWidth=400,innerHeight=400,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes";
    var journalPickerWin = window.open(url, title, options);

    journalPickerWin.opener = self;
    journalPickerWin.focus();

    return false;
}

/*
 * Adds a journal to opener's list of journals selected (only if it is not already present)
 *
 * acronym = the journal acronym (string)
 * title = the journal title (string)
 */
function journalPickerAddItem(acronym, title)
{
    var docRef = self.opener.document;

    // Check if journal is already in the list
    if(docRef == null)
    {
        return false;
    }

    return searchFormAddRestriction(acronym,title,docRef)
}


/*
 * Updates the visibility of the journal results list and the "other" block.
 */
function journalPickerUpdateVisibility(documentRef)
{
    var holder = documentRef.getElementById("jp_results_holder");
    var other = documentRef.getElementById("jp_other");
    
    if(journalPickerItemHasNoResults(documentRef))  
    {
        holder.style.visibility = "hidden";
        if(other != null)
        {
            other.style.visibility = "visible";
        }
    }
    else
    {
        holder.style.visibility = "visible";
        if(other != null)
        {
            other.style.visibility = "hidden";
        }
    }

    return false;
}


function journalPickerItemHasNoResults(documentRef)
{
    var items = documentRef.getElementsByTagName("div");
    for(var i = 0; i < items.length; i++)
    {
        var id = items.item(i).getAttribute("id");
        if(id != null && id.indexOf("jp_result_") == 0) 
        {
            return false;
        }
    }

    return true;
}

function openImgWin(url,windowname) {
    imgWin = window.open(url,windowname,'width=640,height=480,innerWidth=640,innerHeight=480,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    imgWin.focus();
}


function openVideoWin(url,windowname,videoTitle) {
   // get same style sheets as current page
   var styles = document.styleSheets;
   var numberOfStyleSheets = styles.length;
   var cssLinks = "";
   for (var n = 0; n < numberOfStyleSheets; n++) {
      cssLinks += '<link href="' + document.styleSheets[n].href + '" type="text/css" rel="stylesheet">';
   }
   // find the title of the article which is placed into a hidden input in a form
   var title = "";
    var form = document.forms["titleForm"];
   if (form != null) {
      var item = form.elements["titleInput"];
      if (item != null) {
         title = item.value;
      }
   }
   // open a blank window
    imgWin = window.open("",windowname,'width=640,height=480,innerWidth=640,innerHeight=480,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    imgWin.focus();
   // replace with the follwing html
   var markup = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
      + '<html><head xmlns:xhtml="http://www.w3.org/1999/xhtml"><META http-equiv="Content-Type" content="text/html; charset=utf-8">'
      + cssLinks + '<script src="/webfiles/includes/scripts/RoboHelp_CSH.js" language="javascript"></script>'
      + '<script src="/retrieve/javascript" language="javascript"></script>'
      + '</head><body>'
      + '<table width="100%" cellpadding="0" cellspacing="0" border="0">'
      + '<tr><td width="50%" class="popup_grey_cell"><p class="page_title_text">Video</p></td>'
      + '<td width="50%" class="popup_grey_cell2"><p class="popup_text">'
      + '<a href="#" onClick="JavaScript: window.close();" class="popup_link">close</a></p></td>'
      + '</tr><tr><td colspan="2" class="img_cell"><embed src="'
      + url + '" controls="true" width="400" height="300" autoplay="true"/></td>'
      + '</tr><tr><td colspan="2"><span class="popup_cell_centered"><p class="popup_text"><span class="text_small">'
      + '<span class="text_bold">' + title + '</span><br><br>' + videoTitle + '</span></p></span></td>'
      + '</tr></table><br></body></html>';
   imgWin.document.open('text/html','replace');
   imgWin.document.write(markup);
   imgWin.document.close();
}


/*
 * Called from the serach form
 * to delete an item from the picker list.
 */
function searchFormWithinItemDelete(jid)
{
    var jpickerList= document.getElementById("jpickerList");
    var item = document.getElementById("restrictBlock_" + jid);

    // Check if the item is present
    if(item == null)
    {
        return false;
    }
    
    jpickerList.removeChild(item);

    return searchFormWithinUpdateVisibility(document);
}

/*
 * Returns the number true if restricitions exist
 */
function searchFormHasNoResults(docRef)
{
    var items = docRef.getElementsByTagName("div");
    for(var i = 0; i < items.length; i++)
    {
        var id = items.item(i).getAttribute("id");
        if(id != null && id.indexOf("restrictBlock_") == 0) 
        {
            return false;
        }
    }

    return true;
}

function searchFormWithinUpdateVisibility(docRef)
{
    if(searchFormHasNoResults(docRef))  
    {
        searchFormWithinMode(false, docRef);
    }
    else
    {
        searchFormWithinMode(true, docRef);
    }

    return false;
}


/*
 * Called from the serach form
 * to change the within mode.
 */
function searchFormWithinMode(mode, docRef)
{
    var jpickerWithin = docRef.getElementById("jpickerWithin");
    var searchDefaultWithin = docRef.getElementById("searchDefaultWithin");

    if (mode)
    {
        searchDefaultWithin.style.display = "none";
        jpickerWithin.style.display = "block";

    }
    else
    {
        searchDefaultWithin.style.display = "block";
        jpickerWithin.style.display = "none";
    }
}

function searchFormAddRestriction(jid,title,docRef)
{
    var jpickerList= docRef.getElementById("jpickerList");
    var item = docRef.getElementById("restrictBlock_" + jid);

   // Check if the item is present
    if(item != null)
    {
        return false;
    }

    //  Add a new restriction
    var html = searchFormCreateRestriction(jid,title);
    
    jpickerList.insertAdjacentHTML("beforeEnd",html);

    searchFormWithinMode(true,docRef);

    return false;
}

/*
 * Creates the HTML for the chosen journal
 */
function searchFormCreateRestriction(jid,title)
{
    var html = "<div class=\"search_text\" id=\"restrictBlock_" + jid +"\" name=\"restrictBlock_" + jid +"\">";
    html = html + "<input name=\"restrictname_"+ jid +"\" type=\"hidden\" value=\""+ jid +"\"/>";
    html = html + "<input name=\"restrictterm_"+ jid +"\" type=\"hidden\" value=\""+ jid +"\"/>";
    html = html + "<input name=\"restricttype_"+ jid +"\" type=\"hidden\" value=\"journal\"/>";
    html = html + "<input name=\"restrictdesc_"+ jid +"\" type=\"hidden\" value=\""+ title +"\"/>";
    html = html + " - <span class=\"text_bold\">"+ title +"</span>";
    html = html + " (<span class=\"text_small\"><a href=\"#\" onclick=\"JavaScript:return searchFormWithinItemDelete('"+ jid +"');\" class=\"search_link\">delete</a></span>)";
    html = html + "</div>";

    return html;        
}

function doAllPeriodicalSearch()
{
    var items = document.getElementsByTagName("div");
    var jpickerList= document.getElementById("jpickerList");
    for(var i = 0; i < items.length; i++)
    {
    var item = items.item(i);
        var id = item.getAttribute("id");
        if(id != null && id.indexOf("restrictBlock_") == 0) 
    {
            jpickerList.removeChild(item);  
    }
    }
    searchFormWithinMode(false, document);
    return false;
}

function doSaveSearch(uri_)
{
    var form = document.forms["resultForm"];
    var saveSearchWindow = window.open('about:blank','savedWin','width=600,height=350,innerWidth=450,innerHeight=350,top=0,left=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
    var oldTarget = form.target;
    var oldAction = form.action;

    form.action = uri_;
    form.target = 'savedWin';
    form.submit();
    if (browserHostOS.indexOf("MAC") == -1) {
      form.target = oldTarget;
      form.action = oldAction;
    }

    saveSearchWindow.focus();
}

function doEditSearch(uri_)
{
    var form = document.forms["resultForm"];
    form.action = uri_;
    form.submit();
    return false;
}


var njumps = 0;

function doViewMultiplAbstracts(uri_)
{
    //  Only do the comand if something is checked.
    var form = document.forms["resultForm"];

    var items = form.elements;
    for(var i = 0; i < items.length; i++)
    {
        var item = items.item(i)
        id = item.getAttribute("name");
        if(id == "article_id" && item.checked) 
        {
            form.action = uri_;
            form.submit();
            return false;
        }
    }
    njumps = 0;
    return false;
}

function doJump() {
   njumps++;
}

function backToResultList() {
   var nj = -njumps - 1;
   njumps = 0;
   history.go(nj);
}

function doComboBoxFire(form_,field_,trigger_)
{
    var form = document.forms[form_];
    var orginal = form.elements[field_];
    var newVal = trigger_.value;
    if (orginal.value != newVal)
    {
        orginal.value = newVal;
        form.submit();
    }
    return false;
}


function doSortComboBoxFire(form_,field_,trigger_)
{
    var form = document.forms[form_];
    var orginal = form.elements[field_];
    var newVal = trigger_.value;
    if (orginal.value != newVal)
    {
        orginal.value = newVal;
        form.elements["search_reqfirst"].value = 1;
        form.submit();
    }
    return false;
}

function doSearchPage(start_)
{
    var form = document.forms["resultForm"];
    form.elements["search_reqfirst"].value = start_;
    form.submit();
    return false;
}

function doSingleSearch(mode_)
{
    var form = document.forms["resultForm"];
    if (mode_ == "medline")
    {
        form.elements["search_mode"].value = "medline";
    }
   else {
      form.elements["search_mode"].value = "journal";
      form.elements["search_medline"].value = "no";
    }
    form.elements["search_reqfirst"].value = "1";
    form.submit();
    return false;
}

function openArticle(uri_,target_)
{
    var form = document.forms["resultForm"];
    var oldTarget = form.target;
    var oldAction = form.action;
    form.action = uri_;
    form.target = target_;
    form.submit();
    if (browserHostOS.indexOf("MAC") == -1) {
      form.target = oldTarget; // Note: These lines interfered with MAC IE5
      form.action = oldAction;
    }
    return false;
}

function doAddTOCAlert(uri_)
{
    //var form = document.forms["resultForm"];
    //form.action = uri_;
    //form.submit();
    var windowOptions = "width=650,height=450,innerWidth=600,innerHeight=400,top=0,left=50,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes";
    addtocwin = window.open(uri_,"AddTOCAlert",windowOptions);
    
    return false;
}


function doVolumeList(uri_)
{
    var form = document.forms["resultForm"];
    form.action = uri_;
    form.submit();
    return false;
}

function doIssueMove(uri_,key_)
{
    var form = document.forms["resultForm"];
    form.elements["issue_key"].value = key_;
    form.action = uri_;
    form.submit();
    return false;
}

function checkTermsAndFields(formname,fieldname)
{
    var form=eval('document.'+formname);
    var field=eval('document.'+formname+'.'+fieldname);

    if (field.checked != true) {
        window.alert('Please read and agree to the registered user agreement before proceeding.'); 
        return false;
    }
    
    form.submit();  

}

/*
 * formName = the name of the form (string)
 * action = where the for is to be submitted
 */
function genericSubmitForm(formName, action)
{
    var form = document.forms[formName];
    form.action=action;
    form.submit();
    return false;
}

/*
 * checkBrowserCompliance - check the brower compliance.
 * Phoenix site is optimized for IE 5.0, Netscape 6.2 and higher
 */

function checkBrowserCompliance()
{
    var UserAgent = navigator.userAgent;
    var browserName = navigator.appName;
    var MSIEVersion;
    var NetscapeVersion;
    if (browserName == "Microsoft Internet Explorer"){
        var MSIEVersion = UserAgent.substring(30,33);
    }
    if ( (browserName == "Microsoft Internet Explorer") && (MSIEVersion < 5.0)){
        browserCompliantMessage()
    }

    if (browserName == "Netscape") {
        var NetscapeVersion = getNSBrowserVersion(UserAgent);
    }
    
    if ((browserName == "Netscape") && (NetscapeVersion < 7.0)){
        browserCompliantMessage()
    }

    if ( (browserName != "Netscape")  && (browserName != "Microsoft Internet Explorer") ){
        browserCompliantMessage()
    }
}

/*
 * getNSBrowserVersion - check the netscape browser version
 * This routine will fail if a new version of Netscape comes out with a 
 * totally different UserAgent  structure.
 *
 */

function getNSBrowserVersion(UserAgent)
{
    var ver=UserAgent.indexOf('Netscape/')
    var ver6=UserAgent.indexOf('Netscape6/')
    if (ver > 0){
        nsversion = UserAgent.substring(ver+9,ver+12);
    
    }else if (ver6 > 0){
        nsversion = UserAgent.substring(ver6+10,ver6+14);
    
    }
    else{
        // At this stage we consider that the browser is of version 5 or a lower version
        nsversion = 0
    }
    return nsversion;
}

/*
 * browserCompliantMessage
 * Show the pop-up window for Browser Compliance.
 *
 */
 
function browserCompliantMessage()
{
//  var url = "/webfiles/browserCompliance.html";
    var url = "/misc/browsersupport";
    var windowOptions = "width=500,height=450,innerWidth=450,innerHeight=400,top=0,left=50,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes";
    browserCompatbilityWin= window.open(url,"BrowserCompliance",windowOptions);
}


function ecommerceCompliantMessage()
{
    var url = "/misc/ecommercesupport";
    var windowOptions = "width=500,height=450,innerWidth=450,innerHeight=400,top=0,left=50,screenX=0,screenY=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes";
    browserCompatbilityWin= window.open(url,"EcommerceCompliance",windowOptions);
}

/*
 * id: The author in the form lastname_initials
 *  description: the author display string
*/
function authorSearchSubmitForm(formName, id, description) 
{
    var msForm = document.forms[formName];
    msForm.elements['restrictterm_author'].value = id;
    msForm.elements['restrictdesc_author'].value = description;
    msForm.submit();
    return false;
}

/*
 * uri: the uri to submit the form to
 *  
*/
function doLogout(uri) 
{
    var form = document.forms['loginForm'];
    form.elements['login'].value = "";
    form.elements['logout'].value = "true";
    
    if ((i = uri.indexOf('user/register')) > -1) {
        form.action=uri.substring(0,i);
    }

    form.submit();

    return false;
}

//openEcommerceWin('/ecommerce/buy?command=addPPV&amp;article=PIIS0895706103009695');

function addSubs(baseurl,entrypoint, pageUrlWhereShoppingCartInitiated)
{
	var url = baseurl + '/ecommerce/reviewcart?command=addSubscription';
	var list = '';
	var form = document.forms["subscribe1"];

	var items = form.elements;
    for(var i = 0; i < items.length; i++)
    {
		var item = items.item(i)
        type = item.getAttribute("type");
        if(type == "checkbox" && item.checked) 
        {
        	list = list + '&product=' + item.getAttribute("name");
	    }
    }

	if(form.elements['region'].value == "0")
	{
	alert ('Please select Geographic Region');
	return false;
	}

	if (list == '')  alert ('Please select journal title(s) to subscribe');
	else {
	      form.action = url+list+"&entrypoint="+entrypoint+"&pageUrlWhereShoppingCartInitiated="+pageUrlWhereShoppingCartInitiated+"&region="+form.elements['region'].value;
		  form.submit();
	}
}

/*
 * uri: the uri to submit the form to
 *  
*/
function openSearchArticle(uri)
{
    var form = document.forms['resultsListTop'];

    form.action = uri;
    form.submit();

    return false;
}

function registerNow(formName, uri) {
    var form = document.forms[formName];
    blankField(form, 'login');
    blankField(form, 'password');
    blankField(form, 'username');

    return genericSubmitForm(formName, uri);
}

function blankField(form, fieldName) {
    if (form != null) {
        var field = form.elements[fieldName];
        if (field != null) {
            field.value = '';
        }
    }
}

function redirect(url) {
    if (document.images) {
        location.replace(url);
    }
    else {
        location.href = url;
    }
}

function verisignPopUp(url) {
    sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=725,height=450');
    self.name = "mainWin";
}

function limitAmountOfTextInFeedbackTextArea(field, maxlimit) {
   if (field.value.length > maxlimit) {
      field.value = field.value.substring(0, maxlimit);
      alert("The maximum number of characters that can be entered in this field is " + maxlimit);
   }
//   alert(field.value);
}

/* menus.js */

// showMenu: This function allows the user to expand and contract the menus to show subordinate options.
function showMenu(MenuName) {
    var MenuItems = document.getElementById(MenuName); 
    MenuItems.style.display = (MenuItems.style.display == "") ?  "none" : ""; 
}

/* RoboHelp_CSH.js */

// eHelp® Corporation
// Copyright© 1998-2002 eHelp® Corporation.All rights reserved.
// RoboHelp_CSH.js
// The Helper function for WebHelp Context Sensitive Help

//     Syntax:
//     function RH_ShowHelp(hParent, a_pszHelpFile, uCommand, dwData)
//
//     hParent
//          Reserved - Use 0
//   
//     pszHelpFile
//          WebHelp: 
//               Path to help system start page ("http://www.myurl.com/help/help.htm" or "/help/help.htm")
//               For custom windows (defined in Help project), add ">" followed by the window name ("/help/help.htm>mywin")
//
//          WebHelp Enterprise: 
//               Path to RoboEngine server ("http://RoboEngine/roboapi.asp")
//               If automatic merging is turned off in RoboEngine Configuration Manager, specify the project name in the URL ("http://RoboEngine/roboapi.asp?project=myproject")
//               For custom windows (defined in Help project), add ">" followed by the window name ("http://RoboEngine/roboapi.asp>mywindow")
//
//     uCommand
//          Command to display help. One of the following:
//                    HH_HELP_CONTEXT     // Displays the topic associated with the Map ID sent in dwData
//                                          if 0, then default topic is displayed.              
//               The following display the default topic and the Search, Index, or TOC pane. 
//               Note: The pane displayed in WebHelp Enterprise will always be the window's default pane.
//                    HH_DISPLAY_SEARCH 
//                    HH_DISPLAY_INDEX
//                    HH_DISPLAY_TOC
//
//     dwData
//          Map ID associated with the topic to open (if using HH_HELP_CONTEXT), otherwise 0
//
//     Examples:
//     <p>Click for <A HREF='javascript:RH_ShowHelp(0, "help/help.htm", 0, 10)'>Help</A> (map number 10)</p>
//     <p>Click for <A HREF='javascript:RH_ShowHelp(0, "help/help.htm>mywindow", 0, 100)'>Help in custom window (map number 100)</A></p>


var gbNav6=false;
var gbNav61=false;
var gbNav4=false;
var gbIE4=false;
var gbIE=false;
var gbIE5=false;
var gbIE55=false;

var gAgent=navigator.userAgent.toLowerCase();
var gbMac=(gAgent.indexOf("mac")!=-1);
var gbSunOS=(gAgent.indexOf("sunos")!=-1);
var gbOpera=(gAgent.indexOf("opera")!=-1);

var HH_DISPLAY_TOPIC = 0;
var HH_DISPLAY_TOC = 1;
var HH_DISPLAY_INDEX = 2;
var HH_DISPLAY_SEARCH = 3;
var HH_HELP_CONTEXT = 15;

var gVersion=navigator.appVersion.toLowerCase();

var gnVerMajor=parseInt(gVersion);
var gnVerMinor=parseFloat(gVersion);

gbIE=(navigator.appName.indexOf("Microsoft")!=-1);
if(gnVerMajor>=4)
{
    if(navigator.appName=="Netscape")
    {
        gbNav4=true;
        if(gnVerMajor>=5)
            gbNav6=true;
    }
    gbIE4=(navigator.appName.indexOf("Microsoft")!=-1);
}
if(gbNav6)
{
    document.gnPageWidth=innerWidth;
    document.gnPageHeight=innerHeight;
    var nPos=gAgent.indexOf("netscape");
    if(nPos!=-1)
    {
        var nVersion=parseFloat(gAgent.substring(nPos+10));
        if(nVersion>=6.1)
            gbNav61=true;
    }
}else if(gbIE4)
{
    var nPos=gAgent.indexOf("msie");
    if(nPos!=-1)
    {
        var nVersion=parseFloat(gAgent.substring(nPos+5));
        if(nVersion>=5)
            gbIE5=true;
        if(nVersion>=5.5)
            gbIE55=true;
    }
}

function RH_ShowHelp(hParent, a_pszHelpFile, uCommand, dwData)
{
    // this function only support WebHelp
    var strHelpPath = a_pszHelpFile;
    var strWnd = "";
    var nPos = a_pszHelpFile.indexOf(">");
    if (nPos != -1)
    {
        strHelpPath = a_pszHelpFile.substring(0, nPos);
        strWnd = a_pszHelpFile.substring(nPos+1); 
    }
    if (isServerBased(strHelpPath))
        RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData);
    else
        RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData);
}

function RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData)
{
    // hParent never used.
    ShowWebHelp_Server(strHelpPath, strWnd, uCommand, dwData);
}

function RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData)
{
    // hParent never used.
    ShowWebHelp(strHelpPath, strWnd, uCommand, dwData);
}


function ShowWebHelp_Server(strHelpPath, strWnd, uCommand, nMapId)
{
    var a_pszHelpFile = "";
    if (uCommand == HH_HELP_CONTEXT)
    {
        if (strHelpPath.indexOf("?") == -1)
            a_pszHelpFile = strHelpPath + "?ctxid=" + nMapId;
        else
            a_pszHelpFile = strHelpPath + "&ctxid=" + nMapId;
    }
    else
    {
        if (strHelpPath.indexOf("?") == -1)
            a_pszHelpFile = strHelpPath + "?ctxid=0";
        else
            a_pszHelpFile = strHelpPath + "&ctxid=0";
    }

    if (strWnd)
        a_pszHelpFile += ">" + strWnd;

    if (gbIE4)
    {
        a_pszHelpFile += "&cmd=newwnd&rtype=iefrm";
        loadData(a_pszHelpFile);
    }
    else if (gbNav4)
    {
        a_pszHelpFile += "&cmd=newwnd&rtype=nswnd";
        var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
        window.open(a_pszHelpFile, "__webCshStub", sParam);
    }
    else
    {
        var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
        if (gbIE5)
            window.open("about:blank", "__webCshStub", sParam);
        window.open(a_pszHelpFile, "__webCshStub");
    }
}


function ShowWebHelp(strHelpPath, strWnd, uCommand, nMapId)
{
    var a_pszHelpFile = "";
    if (uCommand == HH_DISPLAY_TOPIC)
    {
        a_pszHelpFile = strHelpPath + "#<id=0";
    }
    if (uCommand == HH_HELP_CONTEXT)
    {
        a_pszHelpFile = strHelpPath + "#<id=" + nMapId;
    }
    else if (uCommand == HH_DISPLAY_INDEX)
    {
        a_pszHelpFile = strHelpPath + "#<cmd=idx";
    }
    else if (uCommand == HH_DISPLAY_SEARCH)
    {
        a_pszHelpFile = strHelpPath + "#<cmd=fts";
    }
    else if (uCommand == HH_DISPLAY_TOC)
    {
        a_pszHelpFile = strHelpPath + "#<cmd=toc";
    }
    if (strWnd)
        a_pszHelpFile += ">>wnd=" + strWnd;

    if (a_pszHelpFile)
    {
        if (gbIE4)
            loadData(a_pszHelpFile);
        else if (gbNav4)
        {
            var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
            window.open(a_pszHelpFile, "__webCshStub", sParam);
        }
        else
        {
            var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
            if (gbIE5)
                window.open("about:blank", "__webCshStub", sParam);
            window.open(a_pszHelpFile, "__webCshStub");
        }
    }
}

function isServerBased(a_pszHelpFile)
{
    if (a_pszHelpFile.length > 0)
    {
        var nPos = a_pszHelpFile.lastIndexOf('.');
        if (nPos != -1 && a_pszHelpFile.length >= nPos + 4)
        {
            var sExt = a_pszHelpFile.substring(nPos, nPos + 4);
            if (sExt.toLowerCase() == ".htm")
            {
                return false;
            }
        }
    }
    return true;
}

function getElement(sID)
{
    if(document.getElementById)
        return document.getElementById(sID);
    else if(document.all)
        return document.all(sID);
    return null;
}

function loadData(sFileName)
{
    if(!getElement("dataDiv"))
    {
        if(!insertDataDiv())
        {
            gsFileName=sFileName;
            return;
        }
    }
    var sHTML="";
    if(gbMac)
        sHTML+="<iframe name=\"__WebHelpCshStub\" src=\""+sFileName+"\"></iframe>";
    else
        sHTML+="<iframe name=\"__WebHelpCshStub\" style=\"visibility:hidden;width:0;height:0\" src=\""+sFileName+"\"></iframe>";
    
    var oDivCon=getElement("dataDiv");
    if(oDivCon)
    {
        if(gbNav6)
        {
            if(oDivCon.getElementsByTagName&&oDivCon.getElementsByTagName("iFrame").length>0)
            {
                oDivCon.getElementsByTagName("iFrame")[0].src=sFileName;
            }
            else
                oDivCon.innerHTML=sHTML;
        }
        else
            oDivCon.innerHTML=sHTML;
    }
}

function insertDataDiv()
{
    var sHTML="";
    if(gbMac)
        sHTML+="<div id=dataDiv style=\"display:none;\"></div>";
    else
        sHTML+="<div id=dataDiv style=\"visibility:hidden\"></div>";

    document.body.insertAdjacentHTML("beforeEnd",sHTML);
    return true;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
