﻿function action_onMouseOver(caller)
{
	switch (caller.id.replace(/\d/gi, ""))
	{
		case "spnDelete":
			caller.style.borderColor = "red";
			window.status = arrLangClientOut[12];
			break;
		case "spnEdit":
			caller.style.borderColor = "green";
			window.status = arrLangClientOut[13];
			break;
		case "spnClose":
			caller.style.borderColor = "green";
			window.status = arrLangClientOut[8];
			break;
		case "spnContact":
			caller.style.color = "green";
			caller.className = "contactOver";
			window.status = arrLangClientOut[9];
			break;
		case "spnHelp":
			window.status = arrLangClientOut[10];
			break;
		case "spnShowRegID":
			caller.style.borderColor = "green";
			window.status = "show the registration ID";
			break;
	}
	caller.style.cursor = "pointer";
}

function action_onMouseOut(caller)
{
	switch (caller.id.replace(/\d/gi, ""))
	{
		case "spnContact":
			caller.style.color = "#6F6F6F";
			caller.className = "contactOut";
			break;
		case "spnHelp":
			break;
		case "spnShowRegID":
			caller.style.borderColor = "#555555";
			break;
		default:
			caller.style.borderColor = "#B6B6B6";
			break;
	}
	caller.style.cursor = "default";
	window.status = arrLangClientOut[37];
}

function helpHide()
{
	document.getElementById("divHelpTitle").style.display = "none";
	document.getElementById("iFrameHelp").style.display = "none";
}

function btn_onMouseOver(caller)
{
	switch (document.getElementById("hdnVL").value)
	{
		case "navl":
			caller.style.backgroundImage = "url(images/navlButtonOver.jpg)";
			break;
		case "allied":
			caller.style.backgroundImage = "url(images/oWinGreen.gif)";
			break;
		default:
			caller.style.backgroundImage = "url(images/sirvaButtonOver.jpg)";
			break;
	}
	window.status = caller.value;
}

//claimsOptions.asp has some extra checks to exclude certain scenarios... look into these cases.
function btn_onMouseOut(caller)
{
	switch (document.getElementById("hdnVL").value)
	{
		case "navl":
			caller.style.backgroundImage = "url(images/navlButtonOut.jpg)";
			break;
		case "allied":
			caller.style.backgroundImage = "url(images/oWin.jpg)";
			break;
		default:
			caller.style.backgroundImage = "url(images/sirvaButtonOut.jpg)";
			break;
	}
	window.status = "claims";
}

function languageChange(caller)
{
	var strPath = "";
	switch (caller.id)
	{
		case "spnToEnglish":
			strPath = window.location.href.replace(/l=f/, "l=e");
			if (document.getElementById("iFrameHelp").style.display == "inline")
			{
				strPath = strPath.replace(/h=0/, "h=1");
			} else
			{
				strPath = strPath.replace(/h=1/, "h=0");
			}
			window.location.href = strPath;
			break;
		case "spnToFrench":
			strPath = window.location.href.replace(/l=e/, "l=f")
			if (document.getElementById("iFrameHelp").style.display == "inline")
			{
				strPath = strPath.replace(/h=0/, "h=1");
			} else
			{
				strPath = strPath.replace(/h=1/, "h=0");
			}
			window.location.href = strPath;
			break;
	}
}

function currencyConversion(strLang, strValue)
{
	var testValue1;
	var testValue2;

	if (strLang == "f")
	{
		testValue1 = strValue;
		testValue2 = testValue1.replace(/,/g, " ");
		testValue1 = testValue2.replace(/\./g, ",");
		testValue2 = testValue1.replace(/\$/g, "");
		testValue1 = testValue2 + "$";
	}
	else
	{
		testValue1 = strValue;
		testValue2 = testValue1.replace(/,/g, ".");
		testValue1 = testValue2.replace(/\s/g, ",");
		testValue2 = testValue1.replace(/\$/g, "");
		testValue1 = "$" + testValue2;
	}
	return testValue1;
}

function format(strType, strValue)
{
	var arrPieces = "empty";
	strValue = strValue.replace(/,/gi, "");

	if (strType == "currency")
	{
		var returnValue = "";
		var bolDecimal = false;
		var strTempValue = "";
		var strDecimal = "";

		if (strValue.search(/\./gi) != -1)
		{
			bolDecimal = true;
			var intPosition = strValue.search(/\./gi);
			strDecimal = strValue.substr(intPosition, strValue.length);
			if (strValue.substr(0, intPosition).length > 0)
			{
				arrPieces = strValue.substr(0, intPosition).split("");
			}
		}
		else
		{
			arrPieces = strValue.split("");
		}

		if (arrPieces != "empty")
		{
			arrPieces = arrPieces.reverse();
			for (var i = 0; i < arrPieces.length; i++)
			{
				for (var n = 0; n < 3; n++)
				{
					if (i + n < arrPieces.length)
					{
						strTempValue += arrPieces[i + n];
					} else
					{
						break;
					}
				}
				i = i + 2
				strTempValue += ",";
			}
			arrPieces = strTempValue.split("");
			arrPieces = arrPieces.reverse();
			strTempValue = arrPieces.join("");
		}
	}

	if (bolDecimal)
	{
		switch (strDecimal)
		{
			case ".":
				strDecimal = ".00";
				break;
			case ".0":
				strDecimal = ".00";
				break;
		}

		if (strDecimal.length == 2)
		{
			strDecimal += "0";
		}

		if (strDecimal.length > 3)
		{
			strDecimal = strDecimal.substring(0, 3)
		}
	}

	if (arrPieces != "empty")
	{
		returnValue = strTempValue.substr(1, strTempValue.length - 1) + strDecimal.replace(/[A-Za-z]/gi, "");
	}
	else
	{
		returnValue = "0.00";
	}

	return returnValue;
}

function checkBrowser()
{
	if (!browserChecker())
	{
		switch (document.getElementById("hdnVL").value)
		{
			case "navl":
				document.forms[0].action = 'claimsUnsuportedBrowser.asp?c=n&l=' + document.getElementById("hdnLanguage").value;
				break;
			case "allied":
				document.forms[0].action = 'claimsUnsuportedBrowser.asp?c=a&l=' + document.getElementById("hdnLanguage").value;
				break;
			default:
				document.forms[0].action = 'claimsUnsuportedBrowser.asp?c=s&l=' + document.getElementById("hdnLanguage").value;
				break;
		}
		document.forms[0].submit();
	}
}

function clearPrevSelection()
{
	arrSpans = document.getElementsByTagName("div")
	for (var i = 0; i < arrSpans.length; i++)
	{
		if (arrSpans[i].className == "itemOption3")
		{
			arrSpans[i].className = "itemOption2"
		}
	}
}

function toggleHelp()
{
	if (window.screen.availWidth < 900)
	{
		newWindow = window.open("claimsHelpContentWin.asp?c=" + document.getElementById("hdnVL").value + "&pageID=" + document.getElementById("hdnPageID").value + "&l=" + document.getElementById("hdnLanguage").value, 'helpWindow', 'left=50,top=50,height=200px,width=200px,status=no,toolbar=no,menubar=no,location=no,directories=no,titlebar=no,scrollbars=yes,resizable=yes');
		document.getElementById("hdnBolHelp").value = 1;
	}
	else
	{
		if (document.getElementById("iFrameHelp").style.visibility == "visible")
		{
			helpHide();
			document.getElementById("spnHelp").style.visibility = "visible";
			document.getElementById("hdnBolHelp").value = 0;
		}
		else
		{
			document.getElementById("spnHelp").style.visibility = "hidden";
			document.getElementById("divHelpTitle").style.display = "block";
			document.getElementById("iFrameHelp").style.display = "inline";
			document.getElementById("iFrameHelp").className = "iFrameHelp";
			document.getElementById("hdnBolHelp").value = 1;
		}
	}
}

function setCopyrightText()
{
	var elemVL = document.getElementById("hdnVL");
	var elemCopyright = document.getElementById("divCopyRight");
	var vanline = "";
	if (elemVL)
		vanline = elemVL.value;

	if (elemCopyright)
	{
		switch (vanline)
		{
			case "navl":
				elemCopyright.innerHTML = arrLangClientOut[6];
				break;
			case "allied":
				elemCopyright.innerHTML = arrLangClientOut[7];
				break;
			default:
				elemCopyright.innerHTML = arrLangClientOut[78];
				break;
		}
	}
}
