﻿
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 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 reloadParent(parentURL) {top.location.href=parentURL;}

function showDrugInfo(cpNum) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("/drugs/content/popup/" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=940,height=600");     
  fw.moveTo((screen.Width-920)/2,(screen.Height-550)/2 );
  }
  else
  {
   fw=window.open("/drugs/content/popup/" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=940,height=600");     
  }
  fw.focus();
}

function showDrugClass(catid) {
  windowReference("Drug", "/drugClassification.aspx?catID=" + escape(catid));
}

function windowNonResizable(windowName,frameWidth,frameHeight,url, centered){
var b_name="";
  b_name=browser_name();
   if(b_name=="msie" )
  {
  fw=window.open(((url.length> 0 && url.charAt(0) != '/') ? "../" : "") + 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 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 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';
    }
}

/* borrowed from ACP */
function launchChapterAssessment(resourceID, chapterNo) {
    var b_name = "";
    b_name = browser_name();

    if (b_name == "msie") {
        fw = window.open("/selfassessnumofquestions.aspx?resourceID=" + resourceID + "&chapter=" + chapterNo, "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("/selfassessnumofquestions.aspx?resourceID=" + resourceID + "&chapter=" + chapterNo, "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 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;
//      }  
//}
