﻿// JScript File
function windowFramePubMed(link,windowName,url,frameWidth,frameHeight) {
        fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width=" + frameWidth + ",height=" + frameHeight);fw.focus();
}

function windowFrame(windowName,frameWidth,frameHeight,url) {
	var w = frameWidth;
	var h = frameHeight;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var windowprops = "height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + ",location=no," + "scrollbars=yes,menubars=no,toolbars=no,resizable=yes,status=no";
	fw=window.open(url,'',windowprops);     
	fw.focus();
}
function windowFull(windowName,url)
{
    fw=window.open(url,windowName);
    fw.focus();
}
function windowFrameWithBrowserControls(windowName,frameWidth,frameHeight,url) {
  fw=window.open(url,windowName,"status=0,toolbar=0,menubar=1,scrollbars=1,resizable=1,location=0,directories=0,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  fw.focus();
}

function windowReference(windowName,url) {
   fw=window.open(url,"_blank","toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=790,height=600");     
   fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
   fw.focus();
}

function windowNonResizable(windowName,frameWidth,frameHeight,url, centered){
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  if(centered==true){
    fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight)/2 );
  }
  fw.focus();
}


//show hide on toc pages
function toggleToc(o) {
        var fold_image = new Array();
        fold_image[0] = "/images/ngc/arrowDown.gif";
        fold_image[1] = "/images/ngc/arrowLeft.gif";

        if(document.getElementById(o).style.display=='none') {
        document.getElementById(o).style.display='block';
        document.getElementById(o + "arrow").style.background='url(/images/icon_tocopen.gif) no-repeat 0px 2px';
         if(document.getElementById('toggleArrow')) {
        document.getElementById('toggleArrow').src=fold_image[0];
          }
         } else {
        document.getElementById(o).style.display='none';
        document.getElementById(o + "arrow").style.background='url(/images/icon_tocclosed.gif) no-repeat 0px 2px';
           if(document.getElementById('toggleArrow')) {
        document.getElementById('toggleArrow').src=fold_image[1];
           }
           }
         
         }

function EnterKeyPressed(e) {
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;

        return (keycode==13)?true:false;
}


function checkSubmitByEnter(e,btnId) {
    if (EnterKeyPressed(e)) {
        var btn=document.getElementById(btnId);
        
        if (btn.tagName.toLowerCase()=='a') {
           eval(unescape(btn.href).replace('javascript:', ''));
        } else {
            btn.click();
        }
        return false;
    } else {
        return true;
    }
}

