function updateBilling(nType,strPathOffset,strParameters)
{
	try
	{
		window.open(strPathOffset + "updateBilling.asp?Type=" + escape(nType) + "&" + strParameters,"","width=500,height=430,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no");
	}
	catch(e){}
}
function printWireForm(strPathOffset,strParameters)
{
	try
	{
		window.open(strPathOffset + "wireTransferForm.asp?" + strParameters,"","width=700,height=700,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no");
	}
	catch(e){}
}
function forwardVCardDialog(strID,strVCardName,strTitle,strCompany,strPathOffset)
{
	try
	{	
		if (!strPathOffset || strPathOffset == undefined)
			strPathOffset = "";
		var strURL = "vcardForward.asp?ID=" + escape(strID);
		strURL += "&VCardName=" + escape(strVCardName);
		strURL += "&Title=" + escape(strTitle);
		strURL += "&Company=" + escape(strCompany);
		window.open(strPathOffset + strURL,"","width=500,height=430,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no");
	}
	catch(e){}
}
function downloadVCard()
{
	try
	{
		window.open("vCardDownload.vcf?VCardID=" + escape(g_strVCardID) + "&Name=" + escape(g_strFirstName) + "%20" + escape(g_strLastName));	
	}
	catch(e){}
}
function forwardVCard()
{
	try
	{
		forwardVCardDialog(g_strVCardID,g_strFirstName + " " + g_strLastName,g_strJobTitle,g_strCompanyName);
	}
	catch(e){}
}
function addBookmark(strServerNamePath) 
{
	var strURL = "http://" + strServerNamePath + "/" + escape(g_strVCardID);
	var strTitle = "VCARDLINK- " + g_strLastName;
	if (g_strFirstName != "" && g_strFirstName != undefined && g_strFirstName != null)
		strTitle += ", " + g_strFirstName;
	if (window.sidebar) 
	{ 
		window.sidebar.addPanel(strTitle,strURL,""); 
	} 
	else if(document.all) 
	{
		window.external.AddFavorite(strURL,strTitle);
	} 
	else if(window.opera && window.print) 
	{
		return true;
	}
}
function shareVCardDialog(strID)
{
	try
	{
		var strURL = "../vcardForward.asp?ID=" + escape(strID);
		strURL += "&Type=1";
		window.open(strURL,"","width=500,height=430,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no");
	}
	catch(e){}
}
function resetPassword(bInAccount,strUsername,strUID)
{
	try
	{
		var strPathOffset = "";
		if (strUID != undefined)
			strPathOffset = "../";
		else
			strUID = "";
		if (bInAccount || strUID != "")
			window.open(strPathOffset + "passwordReset.asp?Username=" + escape(strUsername) + "&UID=" + escape(strUID),"","width=600,height=325,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no");
		else
		{
			if (document.theForm.Username.value == "")
			{
				alert("Please enter your username and then click the link.");
				document.theForm.Username.focus();
				return;
			}
			window.open("passwordReset_step1.asp?Username=" + escape(strUsername),"","width=600,height=325,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no");
		}
	}
	catch(e){}
}
function trimString (str) 
{
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function validateForm(bSilent)
{
	try
	{
		var objColl = document.getElementsByTagName("input");

		var nErrorCount = 0;
		for (i = 0; i < objColl.length; i++)
		{
//alert(objColl[i].name);
//alert(objColl[i].className);
			if (objColl[i].className.substr(0,8) == "required")
			{
				objColl[i].className = "required";

				if (objColl[i].value.length < 1)
				{
					nErrorCount++;
					objColl[i].className = "requiredEmpty";
				}
			}
		}
		objColl = document.getElementsByTagName("select");
		for (i = 0; i < objColl.length; i++)
		{
			if (objColl[i].className.substr(0,8) == "required")
			{
				try
				{
					document.getElementById(objColl[i].name + "Table").className = "required";
				}catch(e){}

				if (objColl[i].value == "")
				{
					nErrorCount++;
					try
					{
						document.getElementById(objColl[i].name + "Table").className = "requiredEmpty";
					}catch(e){}
				}
			}
		}
		if (nErrorCount > 0 && bSilent == undefined)
		{
			alert("Please complete all required fields");
			return false;
		}
		else
			return true;
	}
	catch(e){}
	return false;
}
function submitForm()
{
	try
	{
		if(validateForm())
			document.theForm.submit();
	}
	catch(e){}
}
function encodeXML(strXML)
{
	if (strXML == undefined || strXML == null)
		return;
	regExp = /&/gi;
	strXML = strXML.replace(regExp,"&amp;");
	regExp = /'/gi;
	strXML = strXML.replace(regExp,"&apos;");
	regExp = /"/gi;
	strXML = strXML.replace(regExp,"&quot;");
	regExp = /</gi;
	strXML = strXML.replace(regExp,"&lt;");
	regExp = />/gi;
	strXML = strXML.replace(regExp,"&gt;");
	
	return strXML;
}
var g_bChecked = false;
function checkAll()
{
	try
	{
		g_bChecked = !g_bChecked;
		var objColl = document.getElementsByTagName("input");
		for (i = 0; i < objColl.length; i++)
		{
			if (objColl[i].type == "checkbox")
				objColl[i].checked = g_bChecked;
		}
	}
	catch(e){}
}
function validateEmail(x)
{
	regExp = / /gi;
	x = x.replace(regExp,"");
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) 
		return true;
	else 
		return false;
}
function commaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}
function getElementLeft(objElement)
{ 
	xPos = objElement.offsetLeft; 
	tempEl = objElement.offsetParent; 
	xParentPos = 0;
	while (tempEl != null) 
	{ 
		xPos += tempEl.offsetLeft; 
		tempEl = tempEl.offsetParent; 
		try
		{
			if (tempEl != null && tempEl.name.substr(0,4) == "tbl_")
				xParentPos = tempEl.clientWidth/2;
		}catch(e){}
	} 
	xPos += xParentPos;
	return xPos; 
}
function getElementTop(objElement,bBottom) 
{ 
	yPos = objElement.offsetTop; 
	tempEl = objElement.offsetParent; 
	yParentPos = 0;
	while (tempEl != null) 
	{ 
		yPos += tempEl.offsetTop; 
		tempEl = tempEl.offsetParent;
		try
		{
			if (tempEl != null && tempEl.name.substr(0,4) == "tbl_")
				yParentPos = tempEl.clientHeight/2;
		}catch(e){}
	}
	if (bBottom)
		yPos += objElement.offsetHeight;
	return yPos; 
} 
