function spellCheckHTML(sIDTextArea,sIDHTML) {
         var oWDBasic;
         var sTmpString;
         var myDoc;
         var oTmpDoc;
         //var elem=window.event.srcElement;
         if (window.spellCheckNow=="1") {
			alert("Spell Check Process is busy. Please wait.");
			return;
         }
         window.spellCheckNow="1";    
         setTimeout('spellCheckRX("' + sIDTextArea + '","' + sIDHTML + '");',100);   
}

function spellCheckRX(sIDTextArea,sIDHTML) {      
         try {
			oWDBasic = new ActiveXObject("Word.Application");
         } catch (e) {
			window.spellCheckNow="";
			if (window.confirm("Can not activate spell checker. You probably do not have MS word on your computer or your internet settings prevent MS-word from functioning. Click 'OK' to see the instructions for the internet settings or 'Cancel' to close this window.")) {
				window.open('../helpSpell.htm',"SPELLHELP","width=500,height=450,scrollbars=Yes,sizeable");
			}
			return false;         
         }
         var bHTML=(document.frm["HTMLToggler"].value=='Plain Text');
         oWDBasic.DisplayAlerts =false;
		oTmpDoc = oWDBasic.Documents.Add();
		oTmpDoc.activate();
		oWDBasic.visible=true;
        // for (var i=0; i<aryDocID.length;i++) {
        if (bHTML) {
			myDoc=window.frames[sIDHTML].document.tbContentElement;
		} else {
			myDoc=window.frm[sIDTextArea];
		}
			if (myDoc.value!='') {
				if (bHTML) {
					oWDBasic.Selection.Text =myDoc.DocumentHTML;
				} else {
					oWDBasic.Selection.Text =myDoc.value;
				}			
				oWDBasic.Dialogs(828).Show();
				oWDBasic.visible=false;
				if ((oWDBasic.Selection.Text).length>1) {
					if (bHTML) {
						myDoc.DocumentHTML = oWDBasic.Selection.Text;
					} else {
						myDoc.value = oWDBasic.Selection.Text;
					}
				}
			}
		//}  
		 oTmpDoc.Close (0);
         oWDBasic.quit();
         window.spellCheckNow="";
         alert("Spelling Check Completed.");
}
function searchCustomer(FormName,ElemID) {
	var sUrl="../GenUtil/SearchCustomer.aspx?FormName=" + FormName
		+ "&ElemID=" + ElemID;
	openUrlWH(sUrl,"CustomerSearch",500,500);	
}
function addCharge(CUSTID) {
	if (CUSTID=='') {
		CUSTID=window.prompt("Please enter a customer number","");
		if (CUSTID==null) return;
		if (isNaN(parseInt(CUSTID))) {
			alert("please enter a valid Customer No");
			return;
		}
	}
	var sUrl='../WorkFlow/AddChargeList.aspx?CUSTID=' + CUSTID;
	openUrlWH(sUrl,"AdditionalCharge",600,600);	
}
function countySel(sID) {
	var elem=window.event.srcElement;
	var county=elem.value;
	var countyText=elem.options[elem.selectedIndex].text;
	var countyElem=document.all[sID];
	countyElem.value=county;
	var countyElem=document.all['CountyName' + sID];
	if (countyElem!=null) countyElem.innerHTML=countyText;
}
function countySearch(sID) {
	var sUrl="../GenUtil/CountySearch.aspx?ElemID=" + sID;
	openUrlWH(sUrl,"CountySearch",620,500);	
}
function submitAPP(APPID) {
	//alert("Are we here?");
	window.location='SubmitApp.aspx?APPID=' + APPID;
}
function viewAPP(APPID) {
	window.open("../Genutil/ApplicantInfo.aspx?APPID=" + APPID);
}
function finalAPP(APPID) {
	window.open("../WorkFlow/FinalReport.aspx?APPID=" + APPID);
}
function editSERResult(ASID) {
	var sUrl='../CMS/ServiceResult.aspx?ASID=' + ASID;
	window.open(sUrl);
}
function invDetail(INVNO) {
	var sUrl="../Admin/InvoiceDetail.aspx?InvoiceNo=" + INVNO;
	openUrlWH(sUrl,"InvoiceDetail",750,370);	
}
function clearMe() {
	var fm=document.frm;
	fm['Action'].value='';
	fm['ActionID1'].value='';
	fm['ActionID2'].value='';
}
function NoHold4Me(SERID) {
	var fm=document.frm;
	var cDate = new Date(); 
	var StopDate=myNowSring(cDate);
	StopDate=window.prompt("Please enter the date/time.",StopDate);
	if (StopDate==null) return;
	if (!isDate(StopDate)) {
		alert("Plaese enter a date format.");
		return;
	}
	fm['Action'].value='NOHOLD';
	fm['ActionID1'].value=SERID;
	fm['ActionID2'].value=StopDate;
	fm.submit();
}
function Hold4Me(SERID) {
	var fm=document.frm;
	var cDate = new Date(); 
	var HoldDate=myNowSring(cDate);
	HoldDate=window.prompt("Please enter the date/time.",HoldDate);
	if (HoldDate==null) return;
	if (!isDate(HoldDate)) {
		alert("Plaese enter a date format.");
		return;
	}
	var Msg="";
	Msg=window.prompt("Please enter reason why it should be stopped?",Msg);
	if (Msg==null) return;
	fm['Action'].value='HOLD';
	fm['ActionID1'].value=SERID;
	fm['ActionID2'].value=HoldDate;
	fm['ActionID3'].value=Msg;
	fm.submit();
}
function compSER(SERID) {
	var fm=document.frm;
	if (!confirm("Are you sure you want to change the status to completed?")) return;
	fm['Action'].value='COMP';
	fm['ActionID1'].value=SERID;
	fm.submit();
}
function compAPP(APPID) {
	var fm=document.frm;
	if (!confirm("Are you sure you want to change the status to completed?")) return;
	fm['Action'].value='COMPAPP';
	fm['ActionID1'].value=APPID;
	fm.submit();
}
function undoInv(INVNO) {
	var fm=document.frm;
	if (!confirm("Are you sure you want to undo this invoice?")) return;
	fm['Action'].value='UNDOINV';
	fm['ActionID1'].value=INVNO;
	fm.submit();
}
function doInv(CUSTID) {
	var fm=document.frm;
	if (!confirm("Are you sure you want to do invoice for this customer?")) return;
	var cDate = new Date(); 
	var invDate=myDateString(cDate);
	invDate=window.prompt("Please enter the invoice date.",invDate);
	if (invDate==null) return;
	if (!isDate(invDate)) {
		alert("Plaese enter a date format.");
		return;
	}
	fm['Action'].value='DOINV';
	fm['ActionID1'].value=CUSTID;
	fm['ActionID2'].value=invDate;
	fm.submit();
}
function doInvALL() {
	var fm=document.frm;
	if (!confirm("Are you sure you want to do invoice for ALL un-invoices customers?")) return;
	var cDate = new Date(); 
	var invDate=myDateString(cDate);
	invDate=window.prompt("Please enter the invoice date.",invDate);
	if (invDate==null) return;
	if (!isDate(invDate)) {
		alert("Plaese enter a date format.");
		return;
	}
	fm['Action'].value='INVALL';
	fm['ActionID1'].value=invDate;
	fm.submit();
}
function pending(SERID) {
	var fm=document.frm;
	if (!confirm("Are you sure you want to change the status to pending?")) return;
	fm['Action'].value='PEND';
	fm['ActionID1'].value=SERID;
	fm.submit();	

}
