﻿
    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 + "&name=" + windowName ,'',windowprops);     
	    fw.focus();
    }

    function windowFrameWithoutName(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 windowFrameWithBrowserControls(windowName,frameWidth,frameHeight,url) {
      fw=window.open(url + "&name=" + windowName, 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) {
       var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
       fw=window.open(url + "&name=" + windowName , windowName,"toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=yes,left=0,top=0,width=850,height=600");     
       fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
       }
       else
       {
         fw=window.open(url + "&name=" + windowName , windowName,"toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=yes,left=200,top=200,width=850,height=600");
       }
       fw.focus();
    }

    function windowScrollable(windowName,frameWidth,frameHeight,url, centered){
         var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
      fw=window.open(url, windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
      
      if(centered==true){
        fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
      }}
      else
      {
        fw=window.open(url, windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight);
      }
      fw.focus();
    }

    function windowNonResizable(windowName,frameWidth,frameHeight,url, centered){
    var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
      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 );
      }
      }
      else
      {
      fw=window.open(url, windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight);   
      }
      fw.focus();
    }

    function resizeToHTML(){
      alert(document.getElementById('table').offsetHeight);
    }

    function switchMenu(obj, switcher) {
        var el = document.getElementById(obj);
        var sw = document.getElementById(switcher);
        
        if ( el.style.display != 'none' ) {
            el.style.display = 'none';
            sw.innerHTML = 'Show';
        }
        else {
            el.style.display = '';
            sw.innerHTML = 'Hide';
        }
    }

    /*
    function launchAssessment(aid, resourceID) {
      fw=window.open("assessment.aspx?aid=" + aid + "&resourceID=" + resourceID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
      fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
      fw.focus();
    }

    function launchBookAssessment(resourceID) {
      fw=window.open("assessmentPrep.aspx?resourceID=" + resourceID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
      fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
      fw.focus();
    }

    function launchTopicAssessment(topicID) {
      fw=window.open("assessmentPrep.aspx?topicID=" + topicID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
      fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
      fw.focus();
    }
    */

    function setcookie(args)
    {
	    var aryArgs = args.split("|");
	    var Audio = aryArgs[0];
	    var Volume = aryArgs[1];
	    document.cookie='audio=' + Audio;
	    document.cookie='volume=' + Volume;
    }

    function getCookie(name) {
      var result = null;
      var myCookie = " " + document.cookie + ";";
      var searchName = "courseStatus=";
      var startOfCookie = myCookie.indexOf(searchName);
      var endOfCookie;
      if (startOfCookie != -1) {
        startOfCookie += searchName.length;
        endOfCookie = myCookie.indexOf(";",startOfCookie);
        result = unescape(myCookie.substring(startOfCookie,endOfCookie));
      }
      return result;
    }

    function closeAndReloadParent(parentURL) {
      if ( top.opener != null && top.opener.closed == false ) {
        top.opener.location.href = parentURL;    
        top.opener.focus();
      } else {
        newwin = window.open(parentURL);
        newwin.focus();
      }
      window.close();
    }

    function reloadParentOpener(parentURL) {  
      if ( top.opener != null && top.opener.closed == false ) { 
        top.opener.location.href = parentURL;        
      } else {
        newwin = window.open(parentURL);
      }
    }

    function reloadParent(parentURL) {  
        parent.location.href = parentURL;        
    }

    function closeAndRedirectParent(redirectURL) {
      if ( top.opener != null && top.opener.closed == false ) {
        top.opener.location.href = redirectURL;    
        top.opener.focus();
      } else {
        newwin = window.open(redirectURL);
        newwin.focus();
      }
      window.close();
    }

    /*
    function showDrugInfo(cpNum) {
      fw=window.open("/drugContent.aspx?cpNum=" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=550,height=550");     
      fw.moveTo((screen.Width-550)/2,(screen.Height-550)/2 );
      fw.focus();
    }

    function showDrugClass(className) {
      windowReference("Drug", "/drugClassification.aspx?className=" + escape(className))
    }

    function PopupGlossaryTerm(glossaryID) {
      fw=window.open("glossaryPopup.aspx?glossaryID=" + glossaryID, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=650,height=550");     
      fw.moveTo((screen.Width-650)/2,(screen.Height-550)/2 );
      fw.focus();
    }

    function PopupGlossarySource() {
      fw=window.open("glossarySourcePopup.aspx", 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=650,height=550");     
      fw.moveTo((screen.Width-650)/2,(screen.Height-550)/2 );
      fw.focus();
    }
    */

    function PlayLecture(file) {
	    fw=window.open(file,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,left=0,top=0,width=700,height=500");     
	    fw.focus();
    }

    function toggleBlock(blockID) {
	    if (document.getElementById) {
		    var subNodes = document.getElementById(blockID);
		    subNodes.style.display = (subNodes.style.display == 'block') ? 'none' : 'block';
	    }
    }

    function searchGuideline() {
       var url = "http://www.guidelines.gov/search/searchresults.aspx?Type=3&num=10&txtSearch=" + escape(frmMain.Text1.value);
       fw=window.open(url,"_blank","");     
       fw.focus();
    }

    function searchAM() {
       var url = "http://www.accessmedicine.com/search/searchAM.aspx?searchFor=A&searchStr=" + escape(frmMain.Text2.value);
       fw=window.open(url,"_blank","");     
       fw.focus();
    }

    function toggleDiv(whichDiv,imgName)
    {
    var div = document.getElementById(whichDiv);
    var img = document.getElementById(imgName);
    if(div.style.display == 'none')
    {
    div.style.display = 'block';
    img.src = '/images/icon_minus.gif';
    } else {
    div.style.display = 'none';
    img.src = '/images/icon_plus.gif';
    }
    }
function browser_name() { 
var browserName = ""; 

var ua = navigator.userAgent.toLowerCase(); 
 if ( ua.indexOf( "safari" ) != -1 ) { 
browserName = "safari"; 
} 
 if ( ua.indexOf( "msie" ) != -1 ) { 
 browserName = "msie"; 
}
return browserName; 
}; 