﻿// JScript File

var pwd

if (!pwd)
{ 
    pwd = ""
}

var ieDOM = false, nsDOM = false;
var stdDOM = document.getElementById; 

function initMethod()
{
    //Determine the browser support for the DOM
    if( !stdDOM )
    {
        ieDOM = document.all;
        
        if( !ieDOM )
        {
            nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4));
        }
    }
}

function getObject(objectId)
{
    if (stdDOM) return document.getElementById(objectId);
    if (ieDOM) return document.all[objectId];
    if (nsDOM) return document.layers[objectId];
}

function getObjectStyle(objectId)
{
    if (nsDOM) return getObject(objectId);
    var obj = getObject(objectId);

    return obj.style;
    
}

function showDefault(objectId)
{
    showCell(objectId, "#E2E2E2", "#E2E2E2");
}

function showCell(objectId, foreColor, backColor)
{
    getObjectStyle(objectId).color = foreColor;
    getObjectStyle(objectId).backgroundColor = backColor;
}

function showNon()
{

}

function showWeak()
{
    showCell("pwWeak", "Black", "#FF6666");
    showDefault("pwMedium");
    showDefault("pwStrong");
}

function showMedium()
{
    showCell("pwWeak", "#FFCC66", "#FFCC66");
    showCell("pwMedium", "Black", "#FFCC66");
    showDefault("pwStrong");
}

function showStrong()
{
    showCell("pwWeak", "#80FF80", "#80FF80");
    showCell("pwMedium", "#80FF80", "#80FF80");
    showCell("pwStrong", "Black", "#80FF80");
}

function showUndetermined()
{

}

function passwordChanged(pwd)
{
    
    var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
    var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
    var enoughRegex = new RegExp("(?=.{6,}).*", "g");

    //var pwd = document.getElementById("ctl00_ContentPlaceHolder1_Password").value;
    
    if( false == enoughRegex.test(pwd) )
    {
        
        showWeak();
    }
    else if( strongRegex.test(pwd) )
    {
        
        showStrong();
    }
    else if( mediumRegex.test(pwd) )
    {
        
        showMedium();
    }
    else
    {
        
        showWeak();
    }

}

function clrField(el)
{

    document.getElementById(el).select();

}

function showBroker()
{
    var item = document.getElementById("showBroker");
    var link = document.getElementById("brokerLink");
    
    if (item.style.visibility == "hidden")
    { 
        var el=link;
        var pL=0;
        var pT=0;
    	
        while(el)
        {
            pL+=el.offsetLeft;
            el=el.offsetParent;
        }
    	
        el=link;
    	
        while(el)
        {
            pT+=el.offsetTop;
            el=el.offsetParent;
        }
        
        item.style.top = pT;
        item.style.left = pL;
        item.style.visibility = "visible";
    }
    else
    {
        item.style.visibility = "hidden";
    }
}

function txtApplicantName_Changed(el)
{
    var firstName = document.getElementById('ctl00_ContentPlaceHolder1_CreateCompany1_CreateLogin1_txtFirstName');
    var lastName = document.getElementById('ctl00_ContentPlaceHolder1_CreateCompany1_CreateLogin1_txtLastName');
    
    var nArray = el.value.split(" ");
    if (nArray != null)
    {
        if (firstName != null && nArray[0] != null)
        {
            firstName.value = nArray[0];
        }
        
        if (lastName != null && nArray[1] != null)
        {
            lastName.value = nArray[1];
        }
    }
}

function txtApplicantEmail_Changed(el)
{
    var email = document.getElementById('ctl00_ContentPlaceHolder1_CreateCompany1_CreateLogin1_txtEmail');
    
    if (email != null && el.value != null)
    {
        email.value = el.value;
    }
}

function txtPhone_Changed(el)
{
    var phone = document.getElementById('ctl00_ContentPlaceHolder1_CreateCompany1_CreateLogin1_txtPhone');
    
    if (phone != null && el.value != null)
    {
        phone.value = el.value;
    }
}