﻿// JScript File

var obj;

function toggleCertificateTemplateDropdown(checkboxName, dropdownName)
{
    obj = document.getElementById(checkboxName);
    if (obj.checked == true)
    {
        obj = document.getElementById(dropdownName);
        obj.disabled = false;
    }
    else
    {
        obj = document.getElementById(dropdownName);
        obj.disabled = true;
    }
}

function CheckIsIE() 
{ 
if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { return true;} 
else { return false; } 
} 

function PrintCertificatePage(control) 
{ 

if (CheckIsIE() == true) 
{ 
document.viewFrame.focus(); 
document.viewFrame.print(); 
} 
else 
{ 
window.frames['viewFrame'].focus(); 
window.frames['viewFrame'].print(); 
} 

} 

function quickpopup(url, width, height)
 {
   mywindow = window.open(url,"","resizable=yes,scrollbars=yes,width=" + width + ",height=" + height);
 } 

function hideControl(controlName){


   if (document.getElementById)
   {
  	   obj = document.getElementById(controlName);
  	   if(obj != null){
	      
	      obj.style.display = "none";
	   }
   }
}

var popupWindow;

function popup(url,winwidth,winheight,windowName,callingUrl) {
   
   if (document.getElementById)
   {
      obj = document.getElementById(callingUrl);
	   obj.value = document.location;
	   
	   //alert("obj.value is " + obj.value);
	   //alert("obj.name is" + obj.name);
	   
	   form = document.getElementById('helpform');
	   form.elements[0].name = "different";
	}
	
	

	
	if(popupWindow) popupWindow.close();
	
	winleft = (screen.width / 2) - (winwidth / 2); // center the window right to left
	wintop = (screen.height / 3) - (winheight / 2); // center the window top to bottom
	// the values get inserted into the features parameter of the window.open command...

	paramString = "height=" + winheight + ", width=" + winwidth + ", top=" + wintop + ", left=" + winleft + ", menubar=no, status=no, toolbar=no, location=no, resizable=no, scrollbars=yes";
	
	form.target= windowName;
   form.action=url;
   form.method="POST";
   popupWindow = window.open("",windowName,paramString);
	
   //alert(form.getElementById('hdUrlInfo'));
   //alert(form.elements[0].name);	  
   form.submit();
	//popupWindow.location.reload(true);
	popupWindow.focus();	
}

function popupPlayerTimed(url,winwidth,winheight,windowName) {
    string="popupPlayer('" + url + "'," + winwidth + "," + winheight + ",'" + windowName + "');";
    //alert(string);
    setTimeout(string,50);
}

function popupNativeCoursePlayer(url,winwidth,winheight,windowName) {
   
	if(popupWindow) popupWindow.close();
	
	winleft = (screen.width / 2) - (winwidth / 2); // center the window right to left
	wintop = (screen.height / 3) - (winheight / 2); // center the window top to bottom
	// the values get inserted into the features parameter of the window.open command...
	
	url = url + "&clientheight=" + screen.height;
    
    if(navigator.userAgent.indexOf("Firefox")!=-1) {
      url = url + "&firefox=1";
    }

paramString = "height=" + winheight + ", width=" + winwidth + ", top=" + wintop + ", left=" + winleft + ", menubar=no, status=yes, toolbar=no, location=no, resizable=no, scrollbars=no";
	
   popupWindow = window.open(url,windowName,paramString);

	popupWindow.focus();	
}

function popupScormCoursePlayer(url,winwidth,winheight,windowName) {
   
	if(popupWindow) popupWindow.close();
	
	winleft = (screen.width / 2) - (winwidth / 2); // center the window right to left
	wintop = (screen.height / 3) - (winheight / 2); // center the window top to bottom
	// the values get inserted into the features parameter of the window.open command...

paramString = "height=" + winheight + ", width=" + winwidth + ", top=" + wintop + ", left=" + winleft + ", menubar=no, status=yes, toolbar=no, location=no, resizable=yes, scrollbars=no";
	
   popupWindow = window.open(url,windowName,paramString);

	popupWindow.focus();	
}

var popupSummaryWindow;
function popupSummary(url,winwidth,winheight,windowName) {
   
   if(popupSummaryWindow) popupSummaryWindow.close();
	
	winleft = (screen.width / 2) - (winwidth / 2); // center the window right to left
	wintop = (screen.height / 3) - (winheight / 2); // center the window top to bottom
	// the values get inserted into the features parameter of the window.open command...

	paramString = "height=" + winheight + ", width=" + winwidth + ", top=" + wintop + ", left=" + winleft + ", menubar=no, status=no, toolbar=no, location=no, resizable=no, scrollbars=yes";
	
	popupSummaryWindow = window.open(url,windowName,paramString);
	popupSummaryWindow.focus();	
}



///
/// <summary>
/// Create a object tag for displaying a flash file
///
/// Created By: Cang Sam
/// </summary>
///
/// <param name="name">The name of the flash</param>
/// <param name="height">The height of the flash</param>
/// <param name="width">The width of the flash</param>
/// <param name="autoplay">Play automatically</param>
/// <param name="menu">Show the menu</param>
/// <param name="loop">Loop the flash</param>
/// <param name="src">The source</param>
function CreateFlash(
name,
alt,
width,
height,
autoplay,
menu,
loop,
src)
{    
    var objectTag = "";
    objectTag = '<object ';
    objectTag += ' id="' + name + '" ';
    objectTag += ' name="' + name + '" ';    
    objectTag += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
    objectTag += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" ';
    objectTag += ' height="' + height + '" ';
    objectTag += ' width="' + width + '" ';
    objectTag += ' loop="' + loop + '" ';    
    objectTag += ' > ';
    
    objectTag += ' <param name="loop" value="' + loop + '"></param> ';
    objectTag += ' <param name="menu" value="' + menu + '"></param> ';
    objectTag += ' <param name="play" value="' + autoplay + '"></param> ';
    objectTag += ' <param name="movie" value="' + src + '"></param> ';
    objectTag += ' <param name="wmode" value="transparent"></param> ';
    
    objectTag += ' <embed ';
    objectTag += ' name="' + name + '" ';    
    objectTag += ' height="' + height + '" ';
    objectTag += ' width="' + width + '" ';
    objectTag += ' loop="' + loop + '" ';
    objectTag += ' menu="' + menu + '" ';
    objectTag += ' play="' + autoplay + '" ';
    objectTag += ' src="' + src + '" ';    
    objectTag += ' type="application/x-shockwave-flash" ';
    objectTag += ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ';
    objectTag += ' wmode="transparent" ';  
    objectTag += ' />';
    
    //objectTag += alt;
    
    objectTag += ' </object>';
    
    document.write(objectTag);
}


///
/// <summary>
/// Create a object tag for displaying a video file
///
/// Created By: Cang Sam
/// </summary>
///
/// <param name="name">The name of the video</param>
/// <param name="height">The height of the video</param>
/// <param name="width">The width of the video</param>
/// <param name="play">Play automatically</param>
/// <param name="showcontrol">Show the controls</param>
/// <param name="src">The source</param>
function CreateVideo(
name, 
alt,
width,
height,
autoplay,
showcontrol,
src)
{
    var objectTag = "";
    objectTag = '<object ';
    objectTag += ' id="' + name + '" ';
    objectTag += ' name="' + name + '" ';
    objectTag += ' height="' + height + '" ';
    objectTag += ' width="' + width + '" ';
    objectTag += ' src="' + src + '" ';
    objectTag += ' > ';
    
    objectTag += ' <param name="Controller" value="true"></param> ';
    objectTag += ' <param name="Autoplay" value="' + autoplay + '"></param> ';
    objectTag += ' <param name="Autostart" value="' + autoplay + '"></param> ';
    objectTag += ' <param name="ShowControls" value="' + showcontrol + '"></param> ';
    objectTag += ' <param name="windowlessVideo" value="true"></param> ';    
    
    objectTag += ' <embed ';
    objectTag += ' name="' + name + '" ';    
    objectTag += ' height="' + height + '" ';
    objectTag += ' width="' + width + '" ';
    objectTag += ' Controller="true" ';
    objectTag += ' Autoplay="' + autoplay + '" ';
    objectTag += ' Autostart="' + autoplay + '" ';
    objectTag += ' ShowControls="' + showcontrol + '" ';
    objectTag += ' src="' + src + '" ';   
    objectTag += ' windowlessVideo="true" ';
    if(src.indexOf(".mov") > 1)
    {
        objectTag += ' style="visibility:hidden" ';
    }
     
    objectTag += ' />';
    
    //objectTag += alt;
    
    objectTag += ' </object>';
    
    document.write(objectTag);
}

///
/// <summary>
/// Opens the digital asset selector window.
///
/// Created By: Cang Sam
/// </summary>
///
/// <param name="selectedFtb">The id of the ftb launching this selector</param>
/// <param name="path">
///     The relative path to the digital asset administration area.
///     (ie: ../../digitalassets/)
/// </param>
/// <param name="width">The width of the video</param>
/// <param name="play">Play automatically</param>
/// <param name="showcontrol">Show the controls</param>
/// <param name="src">The source</param>
function LaunchDigitalAssetSelector(
selectedFtb,
path)
{
    //selectedFtb = this.id;
    selectedFtb = selectedFtb.substr(0, selectedFtb.length-4);
    daSelectorWindow = window.open(
        path + 'listdigitalassets.aspx?ftb=' + selectedFtb,
        'daselector',
        'toolbar=no,directory=no,resizable=no,scrollbars=false,status=no,menubar=no,height=767,width=830');    
    daSelectorWindow.focus();
}

///
/// <summary>
/// determine what class the buttons should have
///
/// Created By: Stacey Scott
/// </summary>
///
function SetButtonClass()
{    
    var form = document.forms[0];
    //loop through all the elements on the form.
     for (j=0; j<form.length; j++) 
     {      
     
        //check to see if it's a button
        if(form.elements[j].type == 'submit' || form.elements[j].type == 'button')
        {
            //check if the button is enabled or disabled
            if (form.elements[j].disabled == true)
            {            
                form.elements[j].className = "dsblFormButton";
            }
            else
            {
                if ((!form.elements[j].className == "pagingbutton") &&
                    (!form.elements[j].className == "formButton")) {                
                    form.elements[j].className = "pagingbutton";
                }
            } 
        }
    }
}

///
/// <summary>
/// Create a object tag for displaying a dynamic Knowledge Check flash piece
///
/// Created By: Mike Waugh
/// </summary>
///
/// <param name="name">The name of the flash</param>
/// <param name="height">The height of the flash</param>
/// <param name="width">The width of the flash</param>
/// <param name="autoplay">Play automatically</param>
/// <param name="menu">Show the menu</param>
/// <param name="loop">Loop the flash</param>
/// <param name="src">The source</param>
/// <param name="content">The content XML file path</param>
/// <param name="config">The config XML file path for skinning KC</param>
function CreateRIA(
name,
alt,
width,
height,
autoplay,
menu,
loop,
src,
content,
config)
{    
    var objectTag = "";
    objectTag = '<object ';
    objectTag += ' id="' + name + '" ';
    objectTag += ' name="' + name + '" ';    
    objectTag += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
    objectTag += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" ';
    objectTag += ' height="' + height + '" ';
    objectTag += ' width="' + width + '" ';
    objectTag += ' loop="' + loop + '" ';    
    objectTag += ' > ';
    
    objectTag += ' <param name="loop" value="' + loop + '"></param> ';
    objectTag += ' <param name="menu" value="' + menu + '"></param> ';
    objectTag += ' <param name="play" value="' + autoplay + '"></param> ';
    objectTag += ' <param name="movie" value="' + src + '"></param> ';
	objectTag += ' <param name="FlashVars" value="filename=' + content + '&config_file=' + config + '" />';
    objectTag += ' <param name="wmode" value="transparent"></param> ';
    
    objectTag += ' <embed ';
    objectTag += ' name="' + name + '" ';    
    objectTag += ' height="' + height + '" ';
    objectTag += ' width="' + width + '" ';
	objectTag += ' FlashVars="filename=' + content + '&config_file=' + config + '" ';
    objectTag += ' loop="' + loop + '" ';
    objectTag += ' menu="' + menu + '" ';
    objectTag += ' play="' + autoplay + '" ';
    objectTag += ' src="' + src + '" ';    
    objectTag += ' type="application/x-shockwave-flash" ';
    objectTag += ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ';
    objectTag += ' wmode="transparent" ';  
    objectTag += ' />';
    
    //objectTag += alt;
    
    objectTag += ' </object>';
    
    document.write(objectTag);
}
	
function displayRIAPreview(filename, displayFile, width, height, managerPath){
    var winWidth = parseInt(width) + 40;
    var winHeight = parseInt(height) + 210;
	window.open("preview.aspx?filename=" + filename + "&displayFile=" + displayFile + "&w=" + width + "&h=" + height + "&managerPath=" + managerPath, "", "menubars=no, width=" + winWidth + ", height=" + winHeight);
}

/* Trevor */
function isIE6() {
    return (navigator.userAgent.indexOf("MSIE 6.0") > 0);
}

function overlayAdhoc(dialog) {
    var elm = document.getElementById("AdhocDialogMask");
    var height, width;

    if(isIE6()){
	    var clientWidth = document.documentElement.clientWidth;
	    var clientHeight = document.documentElement.clientHeight;
	    width = Math.max(Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), clientWidth) + 'px';
	    height = Math.max(Math.max(document.documentElement.scrollHeight, document.body.scrollWidth), clientHeight) + 'px';
    }
    else {
	    width = '100%';
	    height = '100%';
    }
    elm.style.width = width;
    elm.style.height = height;
    
    elm.style.visibility = (elm.style.visibility == "visible") ? "hidden" : "visible";

    var el = document.getElementById(dialog);
    el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
    //alert('finished');
}

/*
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
*/

function pngfix() {

    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])

    if ((version >= 5.5) && (document.body.filters)) 
    {
        for(var i=0; i<document.images.length; i++)
        {
	    var img = document.images[i]
	    var imgName = img.src.toUpperCase()
	    if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	    {
	        var imgID = (img.id) ? "id='" + img.id + "' " : ""
	            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	                    var imgStyle = "display:inline-block;" + img.style.cssText 
	        if (img.align == "left") imgStyle = "float:left;" + imgStyle
	        if (img.align == "right") imgStyle = "float:right;" + imgStyle
	        if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	        var strNewHTML = "<span " + imgID + imgClass + imgTitle
	            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	        img.outerHTML = strNewHTML
	        i = i-1
	    }
        }
    }
}

window.onload= function() {
    SetButtonClass();
    pngfix();
}

window.onload=SetButtonClass;
