﻿// JScript File

// -----------------------------------------------------------------
// function fnReplaceUI() - replace the UI with element ID
// ----------------------------------------------------------------- 
function fnReplaceUI(argStrShowEleID, argStrHideEleID)
{
        document.getElementById(argStrShowEleID).style.display = '';            
        document.getElementById(argStrHideEleID).style.display = 'none';            
}

// ---------------------------------------------------------------------------
// function fnGetRequestParameter() - Get request parameter by client script
// --------------------------------------------------------------------------- 
function fnGetRequestParameter(parameterName) 
{   
    // get the querystring
    var queryString = window.top.location.search.substring(1);
    // Add "=" to the parameter name (i.e. parameterName=value)
    var parameterName = parameterName + "=";
    
    if ( queryString.length > 0 ) 
    {
        // Find the beginning of the string
        begin = queryString.indexOf ( parameterName );

        // If the parameter name is not found, skip it, otherwise return the value
        if ( begin != -1 ) 
        {
            // Add the length (integer) to the beginning
            begin += parameterName.length;

            // Multiple parameters are separated by the "&" sign
            end = queryString.indexOf ( "&" , begin );

            if ( end == -1 ) 
            {
                end = queryString.length
            }
        
            // Return the string
            return unescape ( queryString.substring ( begin, end ) );
        }
        
        // Return "null" if no parameter has been found
        return "null";
    }
}

// --------------------------------------------------------------------------------
// function fnCheckJavaPlugin() - Check whether Java is installed in the browser
// -------------------------------------------------------------------------------- 
function fnCheckJavaPlugin() 
{
    var javaVersion = null;
    
    try 
    {
        javaVersion = document.getElementById('detectPluginApplet').getJavaVersion();
    }
    catch (e) 
    {
        javaVersion = null;
    }

    if (javaVersion == null || !navigator.javaEnabled()) 
    {
        //document.location.href = "http://" + argStrRHubIP + "/as/wapi/output_page?page=/meeting/pc_manual_download.htm&ram=1188824796";
        //window.resizeTo(700, 700);
        return false;
    }
    else
    {	
        return true;
    }
}

// --------------------------------------------------------------------------------
// function fnCreateAltDiv() - Create the alt block for display
// -------------------------------------------------------------------------------- 
function fnCreateAltDiv(strID, intWidth, intHeight) { 
	var objNewDiv = document.createElement('div');
	objNewDiv.setAttribute('id', strID);
	   
	objNewDiv.innerHTML = 
		'<div id="Alt" class="cssAltText" style="position: absolute; top: 0; left: 0; width: ' + intWidth + '; height: ' + intHeight + '; visibility: hidden;">' +
		'</div>';
	
	document.body.appendChild(objNewDiv);
} 

// --------------------------------------------------------------------------------
// function fnShow() - Show tag
// -------------------------------------------------------------------------------- 
function fnShow(strTag){
	object = document.getElementById(strTag);
	object.style.visibility = "visible";
}

// --------------------------------------------------------------------------------
// function fnHide() - Hide tag
// -------------------------------------------------------------------------------- 
function fnHide(strTag){
	object = document.getElementById(strTag);
	object.style.visibility = "hidden";
}

// --------------------------------------------------------------------------------
// function fnShowHelp() - Show alt text
// -------------------------------------------------------------------------------- 
function fnShowHelp(strAltText){
	if (document.getElementById('AltBlock') == null)
	{
		 fnCreateAltDiv('AltBlock', 190, 70);
	}

	document.getElementById('Alt').style.left = event.clientX + 10;
	document.getElementById('Alt').style.top = event.clientY + 10;
	fnShow('Alt');
	document.getElementById('Alt').innerText = strAltText;
}   


// --------------------------------------------------------------------------------------
// function fnOpenPopupWindow - Open a child window with the URL provided from argument
// argument: argStrURL - the URL of the child window
// -------------------------------------------------------------------------------------- 
function fnOpenPopupWindow(argStrURL) 
{
    window.open(argStrURL);            
    return false;         
}         

// --------------------------------------------------------------------------------
// function fnToggleDisplay() - Toggle the display of the object
// --------------------------------------------------------------------------------   
function fnToggleDisplay(argStrEleID)
{
    if (document.getElementById(argStrEleID).style.display == 'none')
    {
        document.getElementById(argStrEleID).style.display = '';
    }
    else
    {
        document.getElementById(argStrEleID).style.display = 'none';
    }       
}  