﻿function ListItemAdd(sCode, bCheckDup) {
	var tbl = GetElement("tbl" + sCode, "TABLE")
	var sID = GetElement("sel" + sCode, "SELECT").value
	var sText = GetElement("sel" + sCode, "SELECT").options[GetElement("sel" + sCode, "SELECT").selectedIndex].text
	if (bCheckDup) {
		for (var i=0; i < tbl.rows.length; i++) {
			if (tbl.rows[i].cells[0].innerHTML == sID) {
				window.alert(sText + " already exists!")
				return
			}
		}
	}
	var trNew = tbl.rows[0].cloneNode(true);
	var trNewE = tbl.insertRow(-1)
	trNewE.swapNode(trNew)
	tbl.rows(tbl.rows.length-1).style.display = ""
	tbl.rows(tbl.rows.length-1).cells[0].innerHTML = sID
	tbl.rows(tbl.rows.length-1).cells[1].innerHTML = sText
	GetElement("sel" + sCode, "SELECT").style.display = "none";
	GetElement("div" + sCode, "DIV").style.borderColor = "red"
	FieldChange(GetElement("div" + sCode, "DIV"))
}
function ListItemDel(sCode, oLastRow) {
	if (oLastRow == "") {
		window.alert("Please select an Item to Delete");
		return;
	}
	if (window.confirm("Delete " + oLastRow.cells[1].innerHTML + "?")) {
		oLastRow.removeNode(true);
		oLastRow = "";
		GetElement("div" + sCode, "DIV").style.borderColor = "red"
		FieldChange(GetElement("div" + sCode, "DIV"))
	}
}
function ListItemView(sCode, oLastRow) {
	if (oLastRow == "") {
		window.alert("Please select an Item to View");
		return;
	}
	switch (sCode) {
		case "Company"			: ViewCompany(oLastRow.cells[0].innerHTML); break
		case "Service"			: ViewService(oLastRow.cells[0].innerHTML); break
		case "ServiceSub"		: ViewServiceSub(oLastRow.cells[0].innerHTML); break
		case "Plan"				: ViewPlan(oLastRow.cells[0].innerHTML); break
		case "Fee"				: ViewFee(oLastRow.cells[0].innerHTML); break
		case "Award"			: ViewAward(oLastRow.cells[0].innerHTML); break
		default					: window.alert("Something Worng Here!")
	}
}
function TraverseLinkView(iService, iServiceSub, iPlan) {
	if (iPlan > 0) {
		ViewPlan(iPlan);
		return;
	}
	if (iServiceSub > 0) {
		ViewServiceSub(iServiceSub);
		return;
	}
	if (iService > 0) {
		ViewService(iService);
		return;
	}
}
function ViewAward(sAwardID) {
	ViewItemClickByID("ACSetup")
	MenuItemClickByID(1052)
	location.href = "cwMaintAward.aspx?AwardID=" + sAwardID
}
function ViewCompany(sCompanyID) {
	ViewItemClickByID("ACSetup")
	MenuItemClickByID(475)
	location.href = "cwMaintCompany.aspx?CompanyID=" + sCompanyID
}
function ViewService(sServiceID) {
	ViewItemClickByID("ACSetup")
	MenuItemClickByID(476)
	location.href = "cwMaintService.aspx?ServiceID=" + sServiceID
}
function ViewEditInv(sServiceID, sServiceSubID, sViewInv, sICLID) {
    if (sServiceSubID == "0") {
        ViewServiceEditInv(sServiceID, sViewInv, sICLID)
    } else {
        ViewServiceSubEditInv(sServiceID, sServiceSubID, sViewInv, sICLID) 
    }
}
function ViewServiceSubEditInv(sServiceID, sServiceSubID, sViewInv, sICLID) {
    //alert("cwMaintServiceSub.aspx?ServiceID=" + sServiceID + "&ServiceSubID=" + sServiceSubID + "&ViewInv=" + sViewInv + "&ICLID=" + sICLID + "&PlanID=0")
    ViewItemClickByID("ACSetup")
	MenuItemClickByID(477)
	location.href = "cwMaintServiceSub.aspx?ServiceSubID=" + sServiceSubID + "&ServiceID=" + sServiceID + "&ViewInv=" + sViewInv + "&ICLID=" + sICLID + "&PlanID=0" 
}
function ViewServiceEditInv(sServiceID, sViewInv, sICLID) {
    ViewItemClickByID("ACSetup")
    MenuItemClickByID(476)
    location.href = "cwMaintService.aspx?ServiceID=" + sServiceID + "&ViewInv=" + sViewInv + "&ICLID=" + sICLID
}
function ViewServiceSub(sServiceSubID) {
    ViewItemClickByID("ACSetup")
    MenuItemClickByID(477)
    location.href = "cwMaintServiceSub.aspx?ServiceSubID=" + sServiceSubID
}
function ViewPlan(sPlanID) {
	ViewItemClickByID("ACSetup")
	MenuItemClickByID(478)
	location.href = "cwMaintPlan.aspx?PlanID=" + sPlanID
}
function ViewFee(sFeeID) {
	ViewItemClickByID("ACSetup")
	MenuItemClickByID(479)
	location.href = "cwMaintFee.aspx?FeeID=" + sFeeID
}
function ViewInvChoice(sInvChoiceID) {
	ViewItemClickByID("ACSetup")
	MenuItemClickByID(480)
	location.href = "cwMaintInvChoice.aspx?InvChoiceID=" + sInvChoiceID
}
//PopUp Functions																																	
function PopUpClose() {
	GetElement("pnlPopUp", "DIV").style.display = "none"
	GetElement("frmPopUp", "IFRAME").src = ""
}
function DisplayPopUp(sCaption) {
	GetElement("pnlPopUp", "DIV").style.display = ""
	if (GetElement("pnlPopUp", "DIV").style.top.substr(0, 1) == "-") {
		GetElement("pnlPopUp", "DIV").style.top = "65pt"
		GetElement("pnlPopUp", "DIV").style.left = "165pt"
		GetElement("pnlPopUp", "DIV").style.zIndex = "100"
	}
	GetElement("divPopUpDrag", "DIV").innerHTML = sCaption
	//GetElement("divPopUpDrag", "DIV").style.zIndex = -1
}
function DisplayPopUpBig(sCaption) {
	GetElement("pnlPopUp", "DIV").style.display = ""
	if (GetElement("pnlPopUp", "DIV").style.top.substr(0, 1) == "-") {
		GetElement("pnlPopUp", "DIV").style.top = "25pt"
		GetElement("pnlPopUp", "DIV").style.left = "150pt"
	}
	GetElement("divPopUpDrag", "DIV").innerHTML = sCaption
}
//Fee Functions																																		
var oLastFeeRow = ""
function FeeDisplayPopUp() {
	DisplayPopUp("Edit Fee Item")
}
function FeeItemAdd() {
	FeeOpen(0)
}
function FeeAddRow() {
	var tbl = GetElement("tblFee", "TABLE")
	var trNew = tbl.rows[0].cloneNode(true)
	var trNewE = tbl.insertRow(-1)
	trNewE.swapNode(trNew)
	tbl.rows[tbl.rows.length-1].style.display = ""
	oLastFeeRow = tbl.rows[tbl.rows.length-1]
}
function FeeItemEdit() {
	if (oLastFeeRow == "") {
		window.alert("Please select an Item to Edit");
		return;
	}
	FeeOpen(oLastFeeRow.cells[0].innerHTML)
}
function FeeItemDel() {
	if (oLastFeeRow == "") {
		window.alert("Please select an Item to Delete");
		return;
	}
	if (window.confirm("Delete this Item?")) {
//		cwMaintWS.DeleteFeeItem(oLastFeeRow.cells[0].innerHTML, FeeOnItemDelSucceeded);
		PageMethods.DeleteFeeItem(oLastFeeRow.cells[0].innerHTML, FeeOnItemDelSucceeded);
	}
}
function FeeOnItemDelSucceeded(sResult) {
    if (sResult != "error") {
		oLastFeeRow.removeNode(true)
		oLastFeeRow = ""
		if (sResult != "") {
	        window.alert(sResult)
	        }
	}
}
//Commission Functions																																
var oLastCommRow = ""
function CommDisplayPopUp() {
	DisplayPopUp("Edit Commission Item")
}
function CommItemAdd() {
	CommOpen(0)
}
function CommAddRow() {
	var tbl = GetElement("tblComm", "TABLE")
	var trNew = tbl.rows[0].cloneNode(true)
	var trNewE = tbl.insertRow(-1)
	trNewE.swapNode(trNew)
	tbl.rows[tbl.rows.length-1].style.display = ""
	oLastCommRow = tbl.rows[tbl.rows.length-1]
}
function CommItemEdit() {
	if (oLastCommRow == "") {
		window.alert("Please select an Item to Edit");
		return;
	}
	CommOpen(oLastCommRow.cells[0].innerHTML)
}
function CommItemDel() {
	if (oLastCommRow == "") {
		window.alert("Please select an Item to Delete");
		return;
	}
	if (window.confirm("Delete this Item?")) {
//		cwMaintWS.DeleteCommItem(oLastCommRow.cells[0].innerHTML, CommOnItemDelSucceeded);
		PageMethods.DeleteCommItem(oLastCommRow.cells[0].innerHTML, CommOnItemDelSucceeded);
	}
}
function CommOnItemDelSucceeded(sResult) {
	if (sResult == "1") {
		oLastCommRow.removeNode(true)
		oLastCommRow = ""
	} else {
		window.alert(sResult)
	}
}
//Inv Choice Functions																																
var oLastInvRow = ""
function InvDisplayPopUp() {
	DisplayPopUp("Edit Inv Choice Item")
}
function MoveLevelDisplayPopUp() {
	DisplayPopUp("Move data")
}
function CopyDataDisplayPopUp() {
    DisplayPopUp("Copy data")
}
function InvItemAdd() {
	InvOpen(0)
}
function InvAddRow() {
	var tbl = GetElement("tblInv", "TABLE")
	var trNew = tbl.rows[0].cloneNode(true)
	var trNewE = tbl.insertRow(-1)
	trNewE.swapNode(trNew)
	tbl.rows[tbl.rows.length-1].style.display = ""
	oLastInvRow = tbl.rows[tbl.rows.length-1]
	InvItemCount()
}
function InvItemEdit() {
	if (oLastInvRow == "") {
		window.alert("Please select an Item to Edit");
		return;
	}
	InvOpen(oLastInvRow.cells[0].innerHTML)
}
function InvItemDel() {
	if (oLastInvRow == "") {
		window.alert("Please select an Item to Delete");
		return;
	}
	if (window.confirm("Delete this Item?")) {
//		cwMaintWS.DeleteInvChoiceLinkItem(oLastInvRow.cells[0].innerHTML, InvOnItemDelSucceeded);
		PageMethods.DeleteInvChoiceLinkItem(oLastInvRow.cells[0].innerHTML, InvOnItemDelSucceeded);
	}
}
function InvOnItemDelSucceeded(sResult) {
	if (sResult == "1") {
		oLastInvRow.removeNode(true)
		oLastInvRow = ""
		InvItemCount()
	} else {
		window.alert(sResult)
	}
}
function InvItemDelAll(sServiceID, sServiceSubID, sPlanID) {
	var sLevel = "Fund"
	if (sServiceSubID > "0") { sLevel = "SubFund" }
	if (sPlanID > "0") { sLevel = "Plan" }
	if ( ! window.confirm("Delete ALL Investment Choices defined at the " + sLevel + " level\nAre you Sure?")) { return }
	if ( ! window.confirm("Delete ALL Investment Choices defined at the " + sLevel + " level\nAre you REALLY Sure?")) { return }
	if ( ! window.confirm("Delete ALL Investment Choices defined at the " + sLevel + " level\nAre you REALLY, REALLY Sure?")) { return }
	PageMethods.DeleteAllInvChoiceLinkItems(sServiceID, sServiceSubID, sPlanID, InvItemDelAllSucceeded)
}
function InvItemDelAllSucceeded(sResult) {
	if (sResult == "Fund" || sResult == "SubFund" || sResult == "Plan") {
		var tbl = GetElement("tblInv", "TABLE")
		for (var i = 1; i < tbl.rows.length; i++) {
			if (tbl.rows[i].cells[1].innerHTML == sResult) {
				tbl.rows[i].removeNode(true)
				i--
			}
		}
		oLastInvRow = ""
		InvItemCount()
	} else {
		window.alert(sResult)
	}
}
function InvestmentReturnsImport() {
	GetElement("frmPopUp", "IFRAME").src = "cwInvestmentReturnDataImportDialog.aspx"; //?Type=Inv&ServiceID=" + sServiceID + "&ServiceSubID=" + sServiceSubID + "&PlanID=" + sPlanID + "&ImportLevel=Data"
	DisplayPopUp("Upload & Import Investment Return Data")
}
function InvImport(sServiceID, sServiceSubID, sPlanID) {
	GetElement("frmPopUp", "IFRAME").src = "cwMaintDataImport.aspx?Type=Inv&ServiceID=" + sServiceID + "&ServiceSubID=" + sServiceSubID + "&PlanID=" + sPlanID
	DisplayPopUp("Upload & Import Investment Data")
}
function InvImportD(sServiceID, sServiceSubID, sPlanID) {
	GetElement("frmPopUp", "IFRAME").src = "cwMaintDataImport.aspx?Type=Inv&ServiceID=" + sServiceID + "&ServiceSubID=" + sServiceSubID + "&PlanID=" + sPlanID + "&ImportLevel=Data"
	DisplayPopUp("Upload & Import Investment Data")
}
function InvImportR(sTab) {
    var sOwner
    if (sTab == 2) { sOwner = "Super" }
    if (sTab == 3) { sOwner = "Pension" }
    GetElement("frmPopUp", "IFRAME").src = "cwMaintDataImport.aspx?Type=InvR&Owner=" + sOwner
    DisplayPopUp("Upload & Import Current Returns")
}
function InvImportRH(sTab) {
    var sOwner
    if (sTab == 2) { sOwner = "Super" }
    if (sTab == 3) { sOwner = "Pension" }
    GetElement("frmPopUp", "IFRAME").src = "cwMaintDataImport.aspx?Type=InvH&Owner=" + sOwner
    DisplayPopUp("Upload & Import Returns History")
}
function InvImportSAA(sTab) {
    GetElement("frmPopUp", "IFRAME").src = "cwMaintDataImport.aspx?Type=InvS" 
    DisplayPopUp("Upload & Import SAA's")
}
function InvReport(sServiceID, sServiceSubID, sPlanID) {
	window.open("sysReportRender.aspx?RepName=cwDataCheckInvestmentListXL&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramServiceID=" + sServiceID + "&paramServiceSubID=" + sServiceSubID + "&paramPlanID=" + sPlanID, "Report", "Location=No, MenuBar=Yes")
}
function InvExport(sServiceID, sServiceSubID, sPlanID) {
	window.open("sysReportRender.aspx?RepName=cwInvestmentList&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramServiceID=" + sServiceID + "&paramServiceSubID=" + sServiceSubID + "&paramPlanID=" + sPlanID, "Report", "Location=No, MenuBar=Yes")
}
function GSTExport(sServiceSubTypeID) {
    window.open("sysReportRender.aspx?RepName=cwRptGSTFlags&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramSubServTypeID=" + sServiceSubTypeID, "Report", "Location=No, MenuBar=Yes")
}
function ReturnsExportFullFund(sInvType, sServiceID, sServiceSubID) {
    var sSectionID
    if (sInvType == 1) { sSectionID = "137" }
    if (sInvType == 2) { sSectionID = "26" }
    if (sInvType == 3) { sSectionID = "47" }
    if (sInvType == 4) { sSectionID = "137" }
    if (sInvType == 5) { sSectionID = "26" }
    window.open("sysReportRender.aspx?RepName=cwRptReturnsDataCheckFund&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramInvType=" + sInvType + "&paramSectionID=" + sSectionID + "&paramServiceID=" + sServiceID + "&paramServiceSubID=" + sServiceSubID, "Report", "Location=No, MenuBar=Yes")
}
function ReturnsExportFull(sInvType) {
    var sSectionID
    if (sInvType == 1) { sSectionID = "137" }
    if (sInvType == 2) { sSectionID = "26" }
    if (sInvType == 3) { sSectionID = "47" }
    if (sInvType == 4) { sSectionID = "137" }
    if (sInvType == 5) { sSectionID = "26" }
    window.open("sysReportRender.aspx?RepName=cwRptReturnsDataCheck&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramInvType=" + sInvType + "&paramSectionID=" + sSectionID, "Report", "Location=No, MenuBar=Yes")
}
function ReturnsExportFriendly(sInvType) {
    window.open("sysReportRender.aspx?RepName=cwReturnsList&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramInvType=" + sInvType, "Report", "Location=No, MenuBar=Yes")
}
function InvItemCount() {
	GetElement("spnInvTot", "SPAN").innerHTML = GetElement("tblInv", "TABLE").rows.length - 2 + " Investment Choices"
}
//Insurance Functions																																
function InsTableGet(sServiceID, sServiceSubID, sPlanID) {
   	GetElement("btnInsTableSave", "INPUT").style.display = "none"
	GetElement("imgWait", "IMG").style.display = ""
	//GetElement("PremLabel", "TD").style.display = ""
	//window.alert(sServiceID+","+sServiceSubID+","+sPlanID+","+GetElement("selInsType", "SELECT").value.split("~")[0]+","+GetElement("selInsType", "SELECT").value.split("~")[1])
	PageMethods.InsTableGet(sServiceID, sServiceSubID, sPlanID, GetElement("selInsType", "SELECT").value.split("~")[0], GetElement("selInsType", "SELECT").value.split("~")[1], InsTableGetSuccess)
}
function InsTableGetD(sServiceID, sServiceSubID, sPlanID) {
   	//GetElement("btnInsTableSave", "INPUT").style.display = "none"
	GetElement("imgWait", "IMG").style.display = ""
	GetElement("PremLabel", "TD").style.display = ""
	//window.alert(sServiceID+","+sServiceSubID+","+sPlanID+","+GetElement("selInsType", "SELECT").value.split("~")[0]+","+GetElement("selInsType", "SELECT").value.split("~")[1])
	PageMethods.InsTableGet(sServiceID, sServiceSubID, sPlanID, GetElement("selInsType", "SELECT").value.split("~")[0], GetElement("selInsType", "SELECT").value.split("~")[1], InsTableGetSuccess)
}
function GetFundList(sLevel, sItemId, sSubService) {
	//window.alert("Hi")
	PageMethods.GetFundList(sLevel, sItemId, sSubService, InsGetFundListSuccess)
	
}
function InsGetFundListSuccess(sResult) {
	//window.alert(sResult)
	var sHTML = "<table id='tblFundList' border='0' style='border-collapse:collapse'>"
	sHTML += "<tr><td>" + sResult + "</td></tr>"
	sHTML += "</table>"
	GetElement("divFundTable", "DIV").innerHTML = sHTML
	//GetElement("imgWait", "IMG").style.display = "none"
	SelectFunds();
	nSelFundCnt = 0
}
function InsTableGetSuccess(sResult) {
	//window.alert(sResult)
	var sHTML = "<table id='tblInsTable' border='1' style='border-collapse:collapse'>"
	var aRows = sResult.split("~")
	var aCells, aUC, bUCFlag
	for (var i = 0; i < aRows.length; i++) {
		if (i == 0) {
			aUC = new Array(); bUCFlag = false
			sHTML += "<tr valign='top'><td style='display:none'>&nbsp;</td><td>&nbsp;</td>"
			aCells = aRows[i].split("`")
			for (var j = 0; j < aCells.length; j++) {
				sHTML += "<td align='right'>" + 
						 "<input type='hidden' value='" + aCells[j] + "'>" +
						 aCells[j+1] + 
						 "</td>"
				aUC.push(aCells[j+2])
				if (aCells[j+2] !== "0") {bUCFlag = true}
				j++; j++
			}
			sHTML += "</tr>"
			if (bUCFlag) {
				sHTML += "<tr valign='top'><td style='display:none'>UC</td><td>Units Cost</td>"
				for (var j = 0; j < aUC.length; j++) {
					sHTML += "<td align='right'>" +
							 "<input type='text' class='StdInput' style='text-align:right; width:50pt' value='" + aUC[j] + "' onchange='InsTableSaveEnable()'>" +
							 "</td>"
				}
			}
		} else {
			sHTML += "<tr>"
			aCells = aRows[i].split("`")
			for (var j = 0; j < aCells.length; j++) {
				if (j == 0) {
					sHTML += "<td style='display:none'>" + aCells[j] + "</td>"
				}
				if (j == 1) {
					sHTML += "<td>" + aCells[j] + "</td>"
				}
				if (j > 1) {
					sHTML += "<td align='right'>" +
							 "<input type='text' class='StdInput' style='text-align:right; width:50pt' value='" + aCells[j] + "' onchange='InsTableSaveEnable()'>" +
							 "</td>"
				}
			}
			sHTML += "</tr>"
		}
	}
	sHTML += "</table>"
	GetElement("divInsTable", "DIV").innerHTML = sHTML
	GetElement("imgWait", "IMG").style.display = "none"
}
function InsTableSaveEnable() {
	GetElement("btnInsTableSave", "INPUT").style.display = ""
}
function InsTableSave() {
	if (! window.confirm("Save this Insurance Table Data?")) {return}
	var sData = ""
	var oTbl = GetElement("tblInsTable", "TABLE")
	for (var i = 2; i < oTbl.rows[0].cells.length; i++) {
		sData += oTbl.rows[0].cells[i].firstChild.value + ","
	}
	sData = sData.substr(0, sData.length - 1) + "~"
	for (var i = 1; i < oTbl.rows.length; i++) {
		sData += oTbl.rows[i].cells[0].innerHTML + ","
		for (var j = 2; j < oTbl.rows[i].cells.length; j++) {
			sData += oTbl.rows[i].cells[j].firstChild.value + ","
		}
		sData = sData.substr(0, sData.length - 1) + "~"
	}
	sData = sData.substr(0, sData.length - 1)
	//window.alert(sData)
	PageMethods.InsTableSave(sData, InsTableSaveSuccess)
}
function InsTableSaveSuccess(sResult) {
	//window.alert(sResult)
	GetElement("btnInsTableSave", "INPUT").style.display = "none"
}
function InsImport(sServiceID, sServiceSubID, sPlanID) {
	GetElement("frmPopUp", "IFRAME").src = "cwMaintDataImport.aspx?Type=Ins&ServiceID=" + sServiceID + "&ServiceSubID=" + sServiceSubID + "&PlanID=" + sPlanID + "&ImportLevel=Data"
	DisplayPopUp("Upload & Import Insurance Data")
}
function InsExport(sServiceID, sServiceSubID, sPlanID) {
    //alert("sysReportRender.aspx?RepName=cwDataCheckInsExport&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramServiceID=" + sServiceID + "&paramServiceSubID=" + sServiceSubID + "&paramPlanID=" + sPlanID)
	window.open("sysReportRender.aspx?RepName=cwDataCheckInsExport&RepFormat=EXCEL&RepPage=0&RepExport=Yes&paramServiceID=" + sServiceID + "&paramServiceSubID=" + sServiceSubID + "&paramPlanID=" + sPlanID, "Report", "Location=No, MenuBar=Yes")
}
function InsCalcCheck(sServiceID, sServiceSubID, sPlanID, sCoverAmt, sIPCoverAmt, sPremAAL, sIncludeComm, sState) {
	sCoverAmt = ShowPrompt("Please enter Death/Death TPD Cover Amount", sCoverAmt, "Insurance Calc Check") 
	if (sCoverAmt == null) {return}
	sIPCoverAmt = ShowPrompt("Please enter Income Protection Cover Amount", sIPCoverAmt, "Insurance Calc Check") 
	if (sIPCoverAmt == null) {return}
	sPremAAL = ShowPrompt("Enter P for Premiums or A for AALs", sPremAAL, "Insurance Calc Check") 
	if (sPremAAL == null) {return}
	sIncludeComm = ShowPrompt("Include Commissions?", sIncludeComm, "Insurance Calc Check") 
	if (sIncludeComm == null) {return}
	sState = ShowPrompt("Enter the State for Stamp Duty", sState, "Insurance Calc Check") 
	if (sState == null) {return}
	window.open("sysReportRender.aspx?RepName=cwDataCheckInsCalc&RepFormat=PDF&RepPage=0&RepExport=Yes&paramServiceID=" + sServiceID + "&paramServiceSubID=" + sServiceSubID + "&paramPlanID=" + sPlanID + "&paramCoverAmt=" + sCoverAmt + "&paramIPCoverAmt=" + sIPCoverAmt + "&paramPremiumAAL=" + sPremAAL + "&paramIncludeComm=" + sIncludeComm + "&paramState=" + sState, "Report", "Location=No, MenuBar=Yes")
}
//Link Functions																																
var oLastLinkRow = ""
function LinkItemAdd() {
	GetElement("selLinkType", "SELECT").style.display = ""
	GetElement("selLinkType", "SELECT").value = "0"
	GetElement("selLinkServiceSubID", "SELECT").style.display = ""
}
function LinkItemAddSelect() {
	var tbl = GetElement("tblLink", "TABLE")
	var sID = GetElement("selLinkServiceSubID", "SELECT").value
	var sText = GetElement("selLinkServiceSubID", "SELECT").options[GetElement("selLinkServiceSubID", "SELECT").selectedIndex].text
	for (var i=0; i < tbl.rows.length; i++) {
		if (tbl.rows[i].cells[1].innerHTML == sID) {
			window.alert(sText + " already exists!")
			return
		}
	}
	var trNew = tbl.rows[0].cloneNode(true);
	var trNewE = tbl.insertRow(-1)
	trNewE.swapNode(trNew)
	tbl.rows(tbl.rows.length-1).style.display = ""
	tbl.rows(tbl.rows.length-1).cells[0].innerHTML = GetElement("selLinkType", "SELECT").value
	tbl.rows(tbl.rows.length-1).cells[1].innerHTML = sID
	tbl.rows(tbl.rows.length-1).cells[2].innerHTML = GetElement("selLinkType", "SELECT").options[GetElement("selLinkType", "SELECT").selectedIndex].text
	tbl.rows(tbl.rows.length-1).cells[3].innerHTML = sText
	GetElement("selLinkType", "SELECT").style.display = "none";
	GetElement("selLinkServiceSubID", "SELECT").style.display = "none";
	GetElement("divLink", "DIV").style.borderColor = "red"
	FieldChange(GetElement("divLink", "DIV"))
}
function LinkItemDel() {
	if (oLastLinkRow == "") {
		window.alert("Please select a Link to Delete");
		return;
	}
	if (window.confirm("Delete " + oLastLinkRow.cells[3].innerHTML + "?")) {
		oLastLinkRow.removeNode(true);
		oLastLinkRow = "";
		GetElement("divLink", "DIV").style.borderColor = "red"
		FieldChange(GetElement("divLink", "DIV"))
	}
}
function LinkItemView() {
	ViewServiceSub(oLastLinkRow.cells[1].innerHTML)
}
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
