﻿function getScrollTop()
{
	if (!document.documentElement.scrollTop)
		return document.body.scrollTop;
	else
		return document.documentElement.scrollTop;
}

function hide(strID)
{
	document.getElementById(strID).style.display = "none";
}

function show(strID)
{
	document.getElementById(strID).style.display = "";
}

function showTableRow(strID)
{
	document.getElementById(strID).style.display = "";
}

function showBlock(strID)
{
	document.getElementById(strID).style.display = "block";
}

function showHide(strID)
{
	if (document.getElementById(strID).style.display == "none")
		show(strID);
	else
		hide(strID);
}

function showHideBlock(strID)
{
	if (document.getElementById(strID).style.display == "none")
		showBlock(strID);
	else
		hide(strID);


}

function stripNonNumbers(str)
{
	var strNew = "";
	for (var i = 0; i < str.length; i++)
	{
		if ((strOriginal.charCodeAt(i) >= 48) && (strOriginal.charCodeAt(i) <= 57))
			strNew = strNew + strOriginal.charAt(i);
	}
}

function isNumberKey(evt)
{

	var e = evt;

	if (window.event)
	{ // IE
		var charCode = e.keyCode;
	} 
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	return true;

}


function formatSSN(txtBox)
{
	var intStartChar = 0;
	var strIn = document.getElementById(txtBox.value);
	var strIn = stripNonNumbers(strIn);
	var intLen = strIn.length;

	if (intLen >= 3)
	{
		strNew = strIn.subString(0, 2) + "-";
		intStartChar = 3;
	}
	if (strIn.length >= 5)
	{
		strNew = strIn.subString(3, 2) + "-";
		intStartChar = 5;
	}

	strNew = strIn.subString(intStartChar, intLen - intStartChar - 1);
	
}

function showHideBlock()
{
	if (document.getElementById(strID).style.display == "none")
		showBlock(strID);
	else
		hide(strID);

}

function imposeMaxLength(obj, MaxLen)
{
	if (obj.value.length >= MaxLen)
	{
		obj.value = obj.value.substring(0, MaxLen);
	}
}



function showHideBlock(strID)
{
	if (document.getElementById(strID).style.display == "none")
		showBlock(strID);
	else
		hide(strID);

}

function clearTextBoxIfValue(txtBox, strValue)
{

	if (txtBox.value == strValue)
	{
		txtBox.value = "";
	}
}


function findPos(obj) {

	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function confirmState(strYear) 
{
    var response = confirm("You have not entered any state tax return information.\n\nWould you like to enter state tax return information now?\n\nPlease note that adding a state return after you submit requires you to contact us, request to add a state, and pay for additional fees by credit card.");
	if (response)
	{
		document.location = "/tax_return/" + strYear + "/state/";
	}
	else 
	{
		document.location = "/tax_return/" + strYear + "/finish/calculate.aspx";
		
	}
}

function imposeMaxLength(event, object, MaxLen) 
{
	var key = event.keyCode ? event.keyCode : event.which;
   if (key == 8)
    {
        // 8 is the keycode for the backspace key
        return true;
       } else
    {
        return (object.value.length <= MaxLen);
    }
}








