﻿// JScript File
var browser = '';

function initPage(divSelectedArrowId) {
    browser = whichBrs();
    if ( browser == 'IE' ) {
        obj=document.getElementById(divSelectedArrowId);
        if (obj != null) obj.style.top = '-5px';
    }
     
}


var defaultUserText = 'Username';
var defaultPasswordText = 'Password';

var UsernameBoxId = '';
var PasswordBoxId = '';
var PasswordTextBoxId = '';

function hookUpLoginBox( _UsernameBoxId, _PasswordBoxId, _PasswordTextBoxId ) {
    UsernameBoxId = _UsernameBoxId;
    PasswordBoxId = _PasswordBoxId;
    PasswordTextBoxId = _PasswordTextBoxId;
    
    obj=document.getElementById(UsernameBoxId);
    if ( obj != null) {
        obj.value = defaultUserText;
        obj.onfocus = function () {
            this.value= (this.value==defaultUserText) ? '' : this.value;
        };
        obj.onblur = function () {
            this.value= (this.value=='') ? defaultUserText : this.value;
        };
    }
    
	var theTextBox = document.getElementById(PasswordTextBoxId);
	var thePassBox = document.getElementById(PasswordBoxId);
          
    if ( theTextBox != null && thePassBox != null ) {
        
        theTextBox.style.display = 'block';
        thePassBox.style.display = 'none';             
              
        if ( theTextBox != null ) {
            theTextBox.onfocus = function () {
                changeTextToPass();
            };
        }
        
        if ( thePassBox != null) {
            thePassBox.onblur = function () {
                restorePassToText();
            };
        }
    }
}

// This function swaps the passed TextBox to a Password Box.
function changeTextToPass ()
{
	var theTextBox = document.getElementById(PasswordTextBoxId);
	var thePassBox = document.getElementById(PasswordBoxId);
    theTextBox.style.display = 'none';
    thePassBox.style.display = 'block';
    thePassBox.focus(); 
}

function restorePassToText ()
{
   
	var theTextBox = document.getElementById(PasswordTextBoxId);
	var thePassBox = document.getElementById(PasswordBoxId);   
	
	// If the passbox has no content, then change it back to a TextBox.
	if (thePassBox.value == "")
	{
	  theTextBox.style.display = 'block';
      thePassBox.style.display = 'none';		
	}
}


function whichBrs() {
    var agt = navigator.userAgent.toLowerCase();
    if (agt.indexOf("opera") != -1) return 'Opera';
    if (agt.indexOf("staroffice") != -1) return 'Star Office';
    if (agt.indexOf("beonex") != -1) return 'Beonex';
    if (agt.indexOf("chimera") != -1) return 'Chimera';
    if (agt.indexOf("netpositive") != -1) return 'NetPositive';
    if (agt.indexOf("phoenix") != -1) return 'Phoenix';
    if (agt.indexOf("firefox") != -1) return 'Firefox';
    if (agt.indexOf("safari") != -1) return 'Safari';
    if (agt.indexOf("skipstone") != -1) return 'SkipStone';
    if (agt.indexOf("msie") != -1) return 'IE';
    if (agt.indexOf("netscape") != -1) return 'Netscape';
    if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
    if (agt.indexOf('\/') != -1) {
        if (agt.substr(0, agt.indexOf('\/')) != 'mozilla') {
            return navigator.userAgent.substr(0, agt.indexOf('\/'));
        }
        else
            return 'Netscape';
    }
    else if (agt.indexOf(' ') != -1)
        return navigator.userAgent.substr(0, agt.indexOf(' '));
    else
        return navigator.userAgent;
}

