﻿
// function: isFunction
// purpose: Determines If An Object is a Function
// create date: 02-24-2006
// create by: John Kane
function isFunction(a) {
    return typeof a == 'function';
}

// function: isObject
// purpose: Determines If An Object is an Object
// create date: 02-24-2006
// create by: John Kane
function isObject(a) {

  
    return (a && typeof a == 'object') || isFunction(a);
}

// function: isUndefined
// purpose: Determines If An Object is Undefined
// create date: 02-24-2006
// create by: John Kane
function isUndefined(a) {
    return typeof a == 'undefined';
} 

// function: PopulateDropDownList
// purpose: Populates a Drop Down List
// create date: 02-23-2006
// create by: John Kane
function PopulateDropDownList(theList, theTable, dataTextField, dataValueField, addDefault)
{
    // Empty Drop Down List
    clearList(theList);

    var rowExists = true;
    var rowCounter = 0;
    var currentRow;
    while (rowExists)
    {
    
        currentRow = theTable.getItem(rowCounter)
        rowExists = isObject(currentRow.get__rowObject());
        if ( rowExists )
        {
           var theText = currentRow.getProperty(dataTextField, "");
         
           var theValue = currentRow.getProperty(dataValueField, "");
           theList.options[rowCounter] = new Option(theText, theValue);
           rowCounter = rowCounter + 1;
        }
        
        
    }
     return rowCounter;
   
}

// function: clearList
// purpose: Clears a Drop Down List
// create date: 02-27-2006
// create by: John Kane
function clearList(theList)
{
   theList.options.length = 0;
}

// function: Show_Modal_Window
// purpose: Opens a Modal Window
// create date: 02-27-2006
// create by: John Kane
function Show_Modal_Window(url, title, qstr, width, height) 
{

    if ( window.showModalDialog )
    {
        var scropt = "dialogTop: px; dialogLeft: px; center: 1; dialogWidth: " + width + "px; dialogHeight: " + height + "px; help: 0; status: 0";
	    var url1 = "../UserControls/Dialog.aspx?title=" + title + "&width=" + width + "&height=" + height + "&pagenet=" + url + "&qstr=" + qstr;
	    var ret = showModalDialog(url1,"",scropt);
	    return ret;
    }
	else
	{
	    var url1 = "../UserControls/Dialog.aspx?title=" + title + "&pagenet=" + url + "&qstr=" + qstr;
	    PopupWindowCenter(url1, width, height, 0, 0, 0, 0);
	    return null;
	}
	
}

function PopupWindowCenter(url, width, height, resizable, toolbar, scrollbars, menubar, title) { 
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	var winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+'resizable=' + resizable + ', toolbar=' + toolbar + 'scrollbars=' + scrollbars + ', menubar=' + menubar;
	var theWindow = window.open(url, title, winprops);
	theWindow.focus();
} 

// Format Page
document.title = "Reliable Transcript Repository";

// function: stringReplace
// purpose: Replaces All Character Instances in a String
// create date: 03-01-2006
// create by: John Kane
function stringReplace(theString, oldCharacter, newCharacter)
{
    //window.alert(theString);
    while ( theString.indexOf(oldCharacter) >= 0)
    {
        theString = theString.replace(oldCharacter, newCharacter);
    }
    return theString;
}

function ShowTransparentFrame()
{

    // Get Screen Width and Height
    var screenWidth = document.body.clientWidth;
    var screenHeight = document.body.clientHeight;
    

    // Set Frame Attributes  
    var iTransparent = document.getElementById('ITransparent');
    
    // Set Transparency for IE
    if ( iTransparent.style.filter != "undefined" )
    {
        iTransparent.style.filter = "alpha (opacity=50)";
    }
    
    if ( iTransparent != null && iTransparent != "undefined" )
    {   
        iTransparent.style.top = 0;
        iTransparent.style.left = 0;
        iTransparent.style.height = screenHeight + "px";
        iTransparent.style.width = screenWidth + "px";
        iTransparent.style.visibility = "visible";
    }
}

function ScrollToBottom()
{
    if ( document.documentElement && document.documentElement.scrollHeight )
    {
       // document.documentElement.scrollTop = document.body.scrollHeight;
       var height = (document.body.scrollHeight) * (25/100);//document.body.scrollHeight * (25/100);
        document.documentElement.scrollTop = height;
    }

}


// function: writeActiveX
// purpose: Writes Out FLV Player - Must be Outside Page to AutoLoad Per (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp)
// create date: 07-26-2006
// create by: John Kane
function writeActiveX(classId, width, height, id, parameterName, parameterValue, parameterName2, parameterValue2, parameterName3, parameterValue3, parameterName4, parameterValue4)
{
    

    //var activeX = '&lt;object classid="' + classId + '" width="' + width + '" height="' + height + '" id="' + id + '"&gt;&lt;/object&gt;';
    var activeX = '<OBJECT classid="' + classId + '" width="' + width + '" height="' + height + '" id="' + id + '">';
    activeX += '<param name="' + parameterName + '" value="' + parameterValue + '"/>';
    activeX += '<param name="' + parameterName2 + '" value="' + parameterValue2 + '"/>';
    activeX += '<param name="' + parameterName3 + '" value="' + parameterValue3 + '"/>';
    activeX += '<param name="' + parameterName4 + '" value="' + parameterValue4 + '"/>';
    activeX +=  '</OBJECT>';
    //window.alert(activeX);
    document.write(activeX);
    
    //document.body.innerHTML = activeX;
}


function FmtMoney(A,D) {
	N=Math.abs(Math.round(A*100));
	S=((N<10)?"00":((N<100)?"0":""))+N;
	S=((A<0)?"-":"")+"$"+WGgroup(S.substring(0,(S.length-2))) + 
	      ((D>0)?"."+S.substring((S.length-2),S.length):"");
	return S;
}


function FmtNumber(A,D) {
	N=Math.abs(Math.round(A*100));
	S=((N<10)?"00":((N<100)?"0":""))+N;
	S=((A<0)?"-":"")+WGgroup(S.substring(0,(S.length-2))) + 
	      ((D>0)?"."+S.substring((S.length-2),S.length):"");
	return S;
}

function FmtPercent(A,D) {
	N=Math.abs(Math.round(A*100));
	S=((N<10)?"00":((N<100)?"0":""))+N;
	S=((A<0)?"-":"")+WGgroup(S.substring(0,(S.length-2))) + 
	      ((D>0)?"."+S.substring((S.length-2),S.length):"");
	S= S*100;
	S= FmtNumber(S,2) +"%"
	return S;
}
function WGgroup(S) {
	return (S.length<4)?S:(WGgroup(S.substring(0,S.length-3))+","+S.substring(S.length-3,S.length));
}
