﻿function windowFrame(windowname,frameWidth,frameHeight,url) {
  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 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 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);     
  var b_name="";
  b_name=browser_name();
  if(b_name=="msie" )
  {
  if(centered==true){
    fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight)/2 );
  }
  }
  fw.focus();
}

function popupGlossary(name){

    if(window.radopen)
    {
    var oWnd = window.radopen("/popup_glossary.aspx?name=" + escape(name) + "","CasePopup");
    oWnd.add_close(clearSession);
    }
    else
    {
    windowReference("CasePopup","/popup_glossary.aspx?name=" + escape(name))
    }
}
function popupNonGlossary(name){
  var url = "popup_nonGlossary.aspx?name=" + escape(name);
  var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open(url,'PopupnonGlossary',"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=425,height=400");     
  fw.moveTo((screen.Width-425)/2,(screen.Height-400)/2 );
    }
  else{
    fw=window.open(url,'PopupnonGlossary',"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=425,height=400");     
  }
  fw.focus();
}

function openWindow(url, windowname, feature){
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open(url,windowname,feature);     
  fw.moveTo((screen.Width-600)/2,(screen.Height-500)/2 );
    }
  else{
      fw=window.open(url,windowname,feature,'left=200,top=200');
  }
  fw.focus();
}

function resizeToHTML(){
  alert(document.getElementById('table').offsetHeight);
}

function launchAssessment(resourceID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("assessmentHome.aspx?resourceID=" + resourceID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,left=0,top=0,width=750,height=650");     
  fw.moveTo((screen.Width-750)/2,(screen.Height-600)/2 );
  }
  else
  {
   fw=window.open("assessmentHome.aspx?resourceID=" + resourceID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,left=200,top=200,width=750,height=650");     
  }
  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 showDrugInfo(cpNum) {
var b_name="";
  b_name=browser_name();
  if(b_name=="msie" )
  {
  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 );
  }
  else
  {
  fw=window.open("../drugContent.aspx?cpNum=" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=550,height=550");     
  }
  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 MM_preloadImages() {
	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];}}
}
function Reset(state, txtype, selindex)
			{	
				if (txtype == "dropdown")
				{
					eval("document.fmCMEPhysRegister." + state + "[" + selindex + "].selected = true");
					//document.fmCase.txt1.focus();
				}
				else
				{
					eval("document.fmCMEPhysRegister." + state + ".value = ''");
					//document.fmCase.txt1.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; 
}; 

//Rad Window

 function LaunchCasePopup(caseid,popupType)
{
if (location.pathname.indexOf('casePopup')!=-1)
{
 if (popupType == 'case'){
              
                document.getElementById(popupType).style.display = 'block'
                document.getElementById('commentary').style.display = 'none'
                document.getElementById('references').style.display = 'none'
                document.getElementById('figure').style.display = 'none'
                document.getElementById('table').style.display = 'none'
            }
            if (popupType == 'commentary'){
              
                document.getElementById(popupType).style.display = 'block'
                document.getElementById('case').style.display = 'none'
                document.getElementById('references').style.display = 'none'
                document.getElementById('figure').style.display = 'none'
                document.getElementById('table').style.display = 'none'
            }
            if (popupType == 'references'){
              
                document.getElementById(popupType).style.display = 'block'
                document.getElementById('case').style.display = 'none'
                document.getElementById('commentary').style.display = 'none'
                document.getElementById('figure').style.display = 'none'
                document.getElementById('table').style.display = 'none'
            }
            if (popupType == 'figure'){
                
                document.getElementById(popupType).style.display = 'block'
                document.getElementById('case').style.display = 'none'
                document.getElementById('references').style.display = 'none'
                document.getElementById('commentary').style.display = 'none'
                document.getElementById('table').style.display = 'none'
            }
            if (popupType == 'table'){
                
                document.getElementById(popupType).style.display = 'block'
                document.getElementById('case').style.display = 'none'
                document.getElementById('references').style.display = 'none'
                document.getElementById('figure').style.display = 'none'
                document.getElementById('commentary').style.display = 'none'
            }
} else {
 var oWnd = window.radopen("/casePopup.aspx?caseID=" + caseid + "&popupType=" + popupType + "","CasePopup");
    oWnd.add_close(clearSession);
}
}

function GetRadWindow()
{
	var oWindow = null;
	if (window.radWindow) { oWindow = window.radWindow;}
	else if (window.frameElement && window.frameElement.radWindow) { oWindow = window.frameElement.radWindow;}
	return oWindow;
}

function CloseWindow()
{
	var oWindow = GetRadWindow();
	if(oWindow != null) {
	    oWindow.Close();
	} else {
	    window.close();
	}
}
