﻿
function windowFrame(windowName,frameWidth,frameHeight,url) {
    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=yes,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
        fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight-20)/2 );
    }else{
        fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
    }
    
    fw.focus();
}

function windowVideo(windowName,frameWidth,frameHeight,url) {
	var w = 950;
	var h = 700;
	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 preloadImage(){
    var myimages = new Array();
    for (var x=0; x<preloadImage.arguments.length; x++){
    myimages[x] = new Image();
    myimages[x].src = preloadImage.arguments[x];
    }
}

function EnterKeyPressed(e) {
        var keycode;
        if (window.event) 
        {
            keycode = window.event.keyCode;
        }
        else if (e) 
        {
            keycode = e.which;
        }
        
        return (keycode==13)?true:false;
}

function windowReference(windowName,url) {
 var b_name="";
 
  b_name=browser_name();

  if(b_name=="msie" )
  {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=780,height=500");     
 
   fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
   }
   else
   {
    fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=200,top=200,width=780,height=500"); 
   }
   
   fw.focus();
}

function windowReferenceSlideShow(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=1,resizable=yes,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=1,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight); 
   }
  fw.focus();
}

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; 
}
function reloadParentWindow(parentUrl, referURL) {
    if ( top.opener != null && top.opener.closed == false ) {							
	    if (parentUrl == null) {
		    parentUrl = top.opener.location.href;
	    }
	    if (referURL == null) {
		    referURL = escape(top.opener.location.href);
	    }			
		
	    if (parentUrl.indexOf("#") > 0){			  
	      top.opener.top.location.reload();
	    } else if (parentUrl.indexOf("?") > 0) {
	      top.opener.parent.location.href = parentUrl + "/" + referURL;
	    }	else {
	      top.opener.location.href = parentUrl + "/" + referURL;
	    }
    }								
	
    self.close();
}

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) {top.location.href=parentURL;}

function showDrugInfo(cpNum) {
var b_name="";
  b_name=browser_name();
   if(b_name=="msie" )
  {
  fw=window.open("/drugContentPopup.aspx?mid=" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=900,height=550");     
  fw.moveTo((screen.Width-900)/2,(screen.Height-550)/2 );
  }
  else{
  fw=window.open("/drugContentPopup.aspx?mid=" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=900,height=550"); 
  }
  fw.focus();
}

function showDrugClass(catid) {
  windowReference("Drug", "/drugClassification.aspx?catID=" + escape(catid));
}

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 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(id) {
	if (document.getElementById) {
		var subNavDiv = document.getElementById(id);
		var subNavImg = document.getElementById('img' + id);
		var subNavAuthorClosed = document.getElementById(id + "|c");
		var subNavAuthorExpanded = document.getElementById(id + "|e");

		subNavDiv.style.display = (subNavDiv.style.display == 'block') ? 'none' : 'block';
		subNavImg.src = (subNavImg.src.substr(subNavImg.src.lastIndexOf('/')+1) == 'update_plus.gif') ? 'images/update_minus.gif' : 'images/update_plus.gif'
		if(subNavAuthorClosed)
			subNavAuthorClosed.style.display = (subNavAuthorClosed.style.display == '') ? 'none' : '';
		if(subNavAuthorExpanded)
			subNavAuthorExpanded.style.display = (subNavAuthorExpanded.style.display == '') ? 'none' : '';
	}	
}

function windowOffScreen(windowName,frameWidth,frameHeight,url){
fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=3200,top=3200,width=" + frameWidth + ",height=" + frameHeight);
}

function hideMenu(id) {
	if (document.getElementById) document.getElementById(id).style.display = 'none';
}

function launchAssessment(aid, resourceID) {
 var b_name="";
  b_name=browser_name();
   if(b_name=="msie" )
  {
  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 );
  }
  else
  {
  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=200,top=200,width=660,height=580");     
  }
  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 launchCurriculum(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=0," + "scrollbars=1,menubar=0,toolbar=1,resizable=1,status=0";
    fw=window.open(url,windowName,windowprops);
	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 launchClipContent(windowName,url, centered){
    var frameWidth = 550;
    var frameHeight = 350;
   //debugger;
    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 toggleBlock(blockID) {
	if (document.getElementById) {
		var subNodes = document.getElementById(blockID);
		subNodes.style.display = (subNodes.style.display == 'block') ? 'none' : 'block';
	}
}

function toggleAC() {
	if (document.getElementById) {
		var div = document.getElementById('divAC');
		var img = document.getElementById('iAC');
		img.src = (div.style.display == 'block') ? '/images/icon_arrow_closed.gif' : '/images/icon_arrow_open.gif';
		div.style.display = (div.style.display == 'block') ? 'none' : 'block';
	}
}

function searchGuideline(strText) {
   var url = "http://www.guidelines.gov/search/search.aspx?type=external&term=" + escape(strText);
   fw=window.open(url,"_blank","");     
   fw.focus();
}

function searchAM(strText) {
   var url = "http://www.accessmedicine.com/search/searchAM.aspx?searchFor=A&searchStr=" + escape(strText);
   fw=window.open(url,"_blank","");     
   fw.focus();
}

function PopupGlossaryTerm(glossaryID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("../glossaryPopup/" + glossaryID, 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=550,height=485");     
  fw.moveTo((screen.Width-550)/2,(screen.Height-485)/2 );
  }
  else
  {
  fw=window.open("../glossaryPopup/" + glossaryID, 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=550,height=485");
  }
  fw.focus();
}

function windowReferenceWithSize(windowName,w,h,url) {
 var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=" + w + ",height=" + h);
 
   fw.moveTo((screen.Width-w)/2,(screen.Height-h)/2 );
   }
   else
   {
    fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=200,top=200,width=" + w + ",height=" + h); 
   }
   
   fw.focus();
}

// Show the case text for CUSTOM CURRICULUM
function showCase(id) {
    var divID;
    var linkID;
    var linkText;
    var b_name="";
    b_name=browser_name();
    divID = "divCase_" + id;
    linkID = "lnkView_" + id;
    if(b_name=="msie"){
        linkText = document.getElementById(linkID).innerText;
    } else {
        linkText = document.getElementById(linkID).textContent;
    }
    
    if (linkText == 'Hide all') {
        document.getElementById(divID).style.display = 'none';
        if(b_name=="msie"){
            document.getElementById(linkID).innerText = 'View all';
        } else {
            document.getElementById(linkID).textContent = 'View all';
        }
    } else {
        document.getElementById(divID).style.display = 'block';
        if(b_name=="msie"){
            document.getElementById(linkID).innerText = 'Hide all';
        } else {
            document.getElementById(linkID).textContent = 'Hide all';
        }
    }
}

// Show the learning objectives text for CUSTOM CURRICULUM
function showObjective(id,all) {
    var divShortID;
    var divAllID;
    divShortID = "divObjectShort_" + id;
    divAllID = "divObjectAll_" + id;
    
    if (all == true) {
        document.getElementById(divShortID).style.display = 'none';
        document.getElementById(divAllID).style.display = 'block';
    } else {
        document.getElementById(divShortID).style.display = 'block';
        document.getElementById(divAllID).style.display = 'none';
    }
}

//function validateSearchTerm() 
//{
//    var doc = document.forms[0];
//    //var obj = document.getElementById("<%= txtFullTextSearch.ClientID %>"); 
//    alert ('hi');
//    alert (doc.txtFullTextSearch.value);
//    if(doc.txtFullTextSearch.value == "")
//    {
//        alert("Please input a search string.");
//        return false;
//    }
//    else 
//    {
//        var str = document.getElementById("searchStr");
//        str.value = obj.value;
//        return true;
//    }
//} 

//function search_onclick() 
//{
//    if (validateSearchTerm())
//      {
//            return true;            
//      }
//     else
//      {
//            return false;
//      }  
//}
