﻿
//http://sharkysoft.com/tutorials/jsa/content/036.html
function toUSCurrency (input)
{
    // Make sure input is a string:
    input += "";

    // Keep original copy of input string:
    var original_input = input;

    // Strip leading dollar sign if necessary:
    if (input . charAt (0) == "$")
	    input = input . substring (1, input . length);
    else if
    (
	    input . substring (0, 2) == "-$"
    ||	input . substring (0, 2) == "+$"
    )
	    input = input . charAt (0) + input . substring (2, input . length);

    // Get float value:
    var amount = parseFloat (input);

    // Return unmodified input if we weren't able to convert it:
    if (isNaN (amount))
	    return original_input;


    // Express amount in pennies, rounded to the nearest penny:
    amount = Math . round (100 * amount);

    // Prepare to add a US currency prefix:
    var prefix = "$";
    if (amount < 0)
    {
	    prefix = "-" + prefix;
	    amount = - amount;
    }

    // Convert amount to string and pad with leading zeros if necessary:
    var string;
    if (amount < 10)
	    string = "00" + amount;
    else if (amount < 100)
	    string = "0" + amount;
    else
	    string = "" + amount;

    // Insert prefix:
    string = prefix + string;

    // Insert decimal point before last two digits:
    string =
	    string . substring (0, string . length - 2) +
	    "." +
	    string . substring (string . length - 2, string . length);

    // Return formatted currency string:
    return string;
}


function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}  
function ChangeNoOfStepsToAccCreation(plan)
{
    var noOfSteps = document.getElementById("spNoOfSteps");
    if(noOfSteps != null)
    {
        if(plan == "1")
        noOfSteps.innerText = "2";
        else
        noOfSteps.innerText = "3";
    }
    var step3 = document.getElementById("spStep3");
    if(step3 != null)
    {
        if(plan == "1")
        {
            step3.style.visibility = "hidden";
            step3.style.display="none";
        }
        else
        {
            step3.style.visibility = "visible";
            step3.style.display="inline";
        }    
    }
}

function WindowTopX(popUpHeight)
{
var h=0;
	if (document.all || document.layers) 
		h = screen.availHeight;
	else if (window.innerHeight)
		h = window.innerHeight + 200;
		if(h>popUpHeight)
			topPos = (h-popUpHeight)/2;
		else
			topPos=0;
		
			return topPos;
}
function WindowLeftY(popUpWidth)
{
var w=0;
	if (document.all || document.layers)
		w = screen.availWidth;
	else if(window.innerWidth)
		w=window.innerWidth;
		var leftPos;
		if(w>popUpWidth)
			leftPos=(w-popUpWidth)/2;
		else
			leftPos=0;
			return leftPos;
}