function newRecordForDocumentAttachement(inForm, rowData, fromWhere, updateComplaintFlow)
{
	var trRef,sumTableSize,newRow,newCell;
    trRef=document.all.refDocumentAttachmentTable.rows(document.all.refDocumentAttachmentTable.rows.length-1);

	sumtableSize=document.all.documentAttachementDetails.rows.length-1;
	newRow=document.all.documentAttachementDetails.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newRow.rowId = sumtableSize;
	// Setting Document Operation
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.children(2).value = rowData[5];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	// Setting Document Name
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.children(0).innerText = rowData[0];
	newCell.children(1).value = rowData[0];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	// Setting Document URL, Document URL Name after Upload, Document Content Type, respondentIdentifier
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	newCell.children(0).innerText = rowData[1];
	newCell.children(1).value = rowData[1];
	newCell.children(2).value = rowData[2];
	newCell.children(3).value = rowData[6];
	newCell.children(4).value = rowData[10];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	var resName;
	if(!updateComplaintFlow)
	{
		/*if(fromWhere != 'update')
		{*/
			// setting Respondent name
			resName = rowData[7];
			if(resName == "- Select -" || resName == null)
			{
			    resName = "";
		    }
			newCell=newRow.insertCell();
			newCell.insertAdjacentHTML("AfterBegin",trRef.cells(3).innerHTML);
			newCell.children(0).innerText = resName;
			newCell.children(1).value = rowData[7];
			newRow.cells(0).align = "left";
			newRow.cells(0).valign = "top";
			newRow.cells(0).className = "fieldlabel";
		//}

		// Setting IsDOcumentPublic Information
		newCell=newRow.insertCell();
		newCell.insertAdjacentHTML("AfterBegin",trRef.cells(4).innerHTML);
		newCell.children(0).checked = (rowData[3] == "1");
		newCell.children(1).value = (rowData[3] == "1");
		if(rowData[8] == "1")
		{
			newCell.children(0).disabled = false;
			newCell.children(1).value = 0;
		}
		else
		{
			newCell.children(0).disabled = true;
			newCell.children(1).value = 0;
		}

		// Setting IsDisciplinaryDocument Information
		newCell=newRow.insertCell();
		newCell.insertAdjacentHTML("AfterBegin",trRef.cells(5).innerHTML);
		newCell.children(0).checked = (rowData[8] == "1");
		newCell.children(1).value = (rowData[8] == "1");
		if(resName == "")
		{
			newCell.children(0).disabled = true;
			newCell.children(1).value = 0;
		}

		// Setting IsFinalDisciplinaryDocument Information
		newCell=newRow.insertCell();
		newCell.insertAdjacentHTML("AfterBegin",trRef.cells(6).innerHTML);
		if(rowData[10] != null && rowData[10] != "")
		{
			newCell.children(0).checked = (rowData[9] == "1");
			newCell.children(1).value = (rowData[9] == "1");
		}
		else
		{
		    newCell.children(0).disabled = true;
		}
		if(rowData[8] == "1")
		{
			newCell.children(0).disabled = false;
			newCell.children(1).value = 0;
		}
		else
		{
			newCell.children(0).disabled = true;
			newCell.children(1).value = 0;
		}

	}

	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

}

function setUpChangeComplaintStatusForm(inForm)
{
	var url = '/enforcement/setUpChangeComplaintStatusForm.do';
	inForm.action = url;
	inForm.changeComplaintStatus.disabled = true;
	inForm.submit();
}

function setUpChangeStipulationStatusForm(inForm)
{
	var url = '/enforcement/setUpChangeStipluationStatusForm.do';
	inForm.action = url;
	inForm.changeStipulationStatus.disabled = true;
	inForm.submit();
}

function validateChangeComplaintStatusForm(obj)
{
	var inForm = obj.form;

	if(inForm.complaintStatus.selectedIndex == 0)
	{
		alert(sGlobalMessageArr[MSG_SELECT_COMPLAINT_STATUS]);
		inForm.complaintStatus.focus();
		return false;
	}

	//if Complaint Status selected is Assigned For Investigation, make Investigator selection mandatory

	if(inForm.complaintStatus.options[inForm.complaintStatus.selectedIndex].value == '1713')
	{
		if(inForm.Investigator.selectedIndex == 0)
		{
			alert(sGlobalMessageArr[MSG_SELECT_INVESTIGATOR]);
			inForm.Investigator.focus();
			return false;
		}
	}

	disableObjectAndSubmit(obj);
}


function validateChangeStipulationStatusForm(obj)
{
	var inForm = obj.form;
	if(inForm.stipulationStatus.selectedIndex == 0)
	{
		alert(sGlobalMessageArr[MSG_SELECT_STIPULATION_STATUS]);
		inForm.stipulationStatus.focus();
		return false;
	}
	inForm.action=inForm.action+'?methodToCall=changeStipulationStatus';
	disableObjectAndSubmit(obj);
}


function disableEnableDispositionAndInvestigators(inForm)
{
	//if Complaint Status selected is either Closed or Dismissal, enable Disposition dropdown otherwise disable
	if(document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1750' ||
		document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1706')
	{
		document.getElementById("disposition").disabled = false;
	}
	else
	{
		document.getElementById("disposition").disabled = true;
	}

	//if Complaint Status selected is Assigned For Investigation, enable Investigator dropdown  and make it mandatory
	if(document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1713')
	{
		document.getElementById("Investigator").disabled = false;
		//document.getElementById("Investigator").value = document.getElementById("investigatorId").value;
		//document.getElementByName('assignedToRole').value = '203'; //roleId of Investigator
	}
	else
	{
		document.getElementById("Investigator").disabled = true;
	}
	//Chief Investigator
/*	if(document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1745' ||
		document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1752' ||
		document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1719')
	{
		document.getElementByName('assignedToRole').value = '227'; //roleId of Chief Investigator
	}
	//Complaint Admin
	if(document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1749' ||
		document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1750')
	{
		document.getElementByName('assignedToRole').value = '235'; //roleId of Complaint Admin
	}

	if(document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1706' ||
		document.getElementById("complaintStatus").options[document.getElementById("complaintStatus").selectedIndex].value == '1746')
	{
		document.getElementByName('assignedToRole').value = '0'; //roleId null
	} */

	return true;
}

function newRecordForDocumentAttachementForRespondent(inForm, rowData, fromWhere)
{
	var trRef,sumTableSize,newRow,newCell;
    trRef=document.all.refDocumentAttachmentTable.rows(document.all.refDocumentAttachmentTable.rows.length-1);

	sumtableSize=document.all.documentAttachementDetails.rows.length-1;
	newRow=document.all.documentAttachementDetails.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newRow.rowId = sumtableSize;
	// Setting Document Operation
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.children(2).value = rowData[5];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	// Setting Document Name
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.children(0).innerText = rowData[0];
	newCell.children(1).value = rowData[0];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	// Setting Document URL, Document URL Name after Upload, Document Content Type, respondentIdentifier
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	newCell.children(0).innerText = rowData[1];
	newCell.children(1).value = rowData[1];
	newCell.children(2).value = rowData[2];
	newCell.children(3).value = rowData[6];
	newCell.children(4).value = rowData[10];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	// Setting IsDOcumentPublic Information
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(3).innerHTML);
	newCell.children(0).checked = (rowData[3] == "1");
	newCell.children(1).value = (rowData[3] == "1");
	if(rowData[8] == "1")
	{
		newCell.children(0).disabled = false;
		newCell.children(1).value = 0;
	}
	else
	{
		newCell.children(0).disabled = true;
		newCell.children(1).value = 0;
	}

	// Setting IsDisciplinaryDocument Information
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(4).innerHTML);
	if(rowData[10] != null && rowData[10] != "")
	{
		newCell.children(0).checked = (rowData[8] == "1");
		newCell.children(1).value = (rowData[8] == "1");
	}
	else
	{
	    newCell.children(0).disabled = true;
	}

	// Setting IsFinalDisciplinaryDocument Information
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(5).innerHTML);
	if(rowData[10] != null && rowData[10] != "")
	{
		newCell.children(0).checked = (rowData[9] == "1");
		newCell.children(1).value = (rowData[9] == "1");
	}
	else
	{
	    newCell.children(0).disabled = true;
	}

	if(rowData[8] == "1")
	{
		newCell.children(0).disabled = false;
		newCell.children(1).value = 0;
	}
	else
	{
		newCell.children(0).disabled = true;
		newCell.children(1).value = 0;
	}

	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

}

//For Document uploading section from public site
function validateAndSubmitUploadFormForPublic(inForm){

	if(trim(document.all.documenturl_1.value)=="")
	{
		alert("Please specify the file to be uploaded.");
		document.all.documenturl_1.focus();
		return false;
	}

	var pathname = document.all.documenturl_1.value;

	var docname = pathname.substring(pathname.lastIndexOf('\\')+1);

	docname = docname.substring(0,docname.lastIndexOf('.'));

	// Set Hidden field documentAttachmentOperation for Each Attachment selected
	if(document.all.documenturl_1.value!="")
	{
		document.all.documentAttachmentOperation_1.value="I";
		document.all.documentname_1.value=docname;
	}
}

function validateUploadFormForPublic(inForm)
{

    var argArray = new Array();
    var returnedArray = window.showModalDialog('/enforcement/complaintform_public_document_upload.jsp', argArray, 'dialogHeight:150px;dialogWidth:530px;scroll:no;status:no');

	if(returnedArray !=null)
	{
		var noOfAttachment = returnedArray[0].length;
		var noOfDocumentDataItems = returnedArray.length;
		for(i=0;i<noOfAttachment;i++)
		{
			var rowData = new Array();
			for(j=0;j<noOfDocumentDataItems;j++)
			{
				rowData[j] = returnedArray[j][i];
			}

			addRecordForDocumentAttachementForPublic(inForm, rowData);
		}
	}

}

function addRecordForDocumentAttachementForPublic(inForm, rowData)
{

	var trRef,sumTableSize,newRow,newCell;
    trRef=document.all.refDocumentAttachmentTable.rows(document.all.refDocumentAttachmentTable.rows.length-1);

	sumtableSize=document.all.documentAttachementDetails.rows.length-1;
	newRow=document.all.documentAttachementDetails.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newRow.rowId = sumtableSize;

	// Setting Document Operation
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	//newCell.children(2).value = rowData[5];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	// Setting Document Name
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.children(0).innerText = rowData[0];
	newCell.children(1).value = rowData[0];
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	// Setting Document URL,Document URL Name after Upload, Document Content Type
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	//newCell.children(0).innerText = rowData[1];
	newCell.children(1).value = rowData[1];
	newCell.children(2).value = rowData[2];
	newCell.children(3).value = rowData[6];
}

function getDataFromUploadForm(inForm, fromWhere)
{
    var arrParam = new Array();
    if(inForm.respondents == null || inForm.respondents == 'undefined')
    {
        return;
    }

    var respondentFlow = false;
    if(inForm.respondents.length == 0)
    {
    	respondentFlow = true;
    }
//    alert("respondentFlow : " + respondentFlow);
    var updateComplaintFlow = false;
    if(fromWhere == "update" && (!respondentFlow))
    {
    	updateComplaintFlow = true;
    }

//    alert("updateComplaintFlow : " + updateComplaintFlow);

    arrParam[0] = inForm.respondents;
    arrParam[1] = respondentFlow;
    arrParam[2] = updateComplaintFlow;

	var returnedArray = window.showModalDialog('/enforcement/uploadDocument.jsp', arrParam, 'dialogHeight:360px;dialogWidth:530px;scroll:no;status:no');
	if(returnedArray !=null)
	{
		var noOfAttachment = returnedArray[0].length;
		var noOfDocumentDataItems = returnedArray.length;
		for(i=0;i<noOfAttachment;i++)
		{
			var rowData = new Array();
			for(j=0;j<noOfDocumentDataItems;j++)
			{
				rowData[j] = returnedArray[j][i];
			}

			if(respondentFlow)
			{
				newRecordForDocumentAttachementForRespondent(inForm, rowData, fromWhere);
			}
			else
			{
				newRecordForDocumentAttachement(inForm, rowData, fromWhere, updateComplaintFlow);
			}
		}
	}
}

function getRespondentListBox(inForm)
{

    if(inForm.textValues != null)
    {
        var len = inForm.textValues.length;
        if(len != null && len != 'undefined')
        {
	        for(i=0;i<len;i++)
	        {
	            var text  = inForm.textValues[i].value;
	            var value = inForm.idValues[i].value;
	            populateRespondentListBox(inForm,text,value);
	        }
        }
        else
        {
            populateRespondentListBox(inForm,inForm.textValues.value,inForm.idValues.value);
        }
    }
    return inForm.respondentsListBox;
}

function populateRespondentListBox(inForm,text,value)
{
	var sizeOfList = inForm.respondentsListBox.length;
	if(sizeOfList == 1)
	{
		inForm.respondentsListBox.options[1] = new Option(text,value);
	}
	else
	{
		inForm.respondentsListBox.options[sizeOfList] = new Option(text,value);
	}
}

function deleteDocumentAttachementRecordPublic(inForm)
{
	for(i=document.all.documentAttachementDetails.rows.length-2;i>0;i--)
	{
		if(inForm.chkDocumentAttachment[i-2])
		{
			if(inForm.chkDocumentAttachment[i-2].checked)
			{
				document.all.documentAttachementDetails.deleteRow(i);
			}
		}
	}
}

function deleteRecordForDocumentAttachement(inForm)
{
	for(i=document.all.documentAttachementDetails.rows.length-4;i>0;i--)
	{
		if(inForm.chkDocumentAttachment[i-1].checked)
		{
			document.all.documentAttachementDetails.deleteRow(i+2);
		}
	}

}

function deleteRecordForDocumentAttachementUpdateFlow(inForm)
{
	for(i=document.all.documentAttachementDetails.rows.length-4;i>=0;i--)
	{
		if(inForm.chkDocumentAttachment[i].checked)
		{
			if(inForm.documentAttachmentId[i].value !="")
			{
				inForm.documentAttachmentOperation[i].value="D";
				document.all.documentAttachementDetails.rows(i+2).style.display = "none";
			}
			else
			{
				document.all.documentAttachementDetails.deleteRow(i+2);
			}
		}
	}
}

function deleteRecordForDocumentAttachementForRespondent(inForm)
{
	for(i=document.all.documentAttachementDetails.rows.length-4;i>=0;i--)
	{
		if(inForm.chkDocumentAttachment[i].checked)
		{
			if(inForm.documentAttachmentId[i].value !="")
			{
				inForm.documentAttachmentOperation[i].value="D";
				document.all.documentAttachementDetails.rows(i+2).style.display = "none";
			}
			else
			{
				document.all.documentAttachementDetails.deleteRow(i+2);
			}
		}
	}
}

function newRecordForAllegations(inForm)

{
    var allegationstable = document.getElementById("allegationDetails");
    var trRef,sumTableSize,newRow,newCell;


	var allegationTableRowCount = document.getElementById("allegationDetails").rows.length;
	var atPosition = allegationTableRowCount;
	//alert(allegationTableRowCount);
	atPosition = allegationTableRowCount;
	//var atPosition = 0;

	var refRow = document.getElementById("allegationRow");

	var newTR = allegationstable.insertRow(atPosition);
	var td1;
	td1 = document.createElement("td");

	newTR.appendChild(td1);
	td1.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);
	td1.colSpan=3;
}

function newRecordForAddComplainant(inForm)
{

    var addcomplainanttable = document.getElementById("addComplainantDetails");
    var trRef,sumTableSize,newRow,newCell;

	var addComplainantTableRowCount = document.getElementById("addComplainantDetails").rows.length;
	var atPosition = addComplainantTableRowCount;
	atPosition = addComplainantTableRowCount;

	var refRow = document.getElementById("addComplainantRow");

	var newTR = addcomplainanttable.insertRow(atPosition);
	var td1;
	td1 = document.createElement("td");

	newTR.appendChild(td1);
	td1.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);

	document.getElementById('removeComplainantSection').disabled=false;
}

function newRecordForWitness(inForm)
{
    var witnesstable = document.getElementById("witnessDetails");
    var trRef,sumTableSize,newRow,newCell;

	var witnessTableRowCount = document.getElementById("witnessDetails").rows.length;
	var atPosition = witnessTableRowCount;
	atPosition = witnessTableRowCount;

	var refRow = document.getElementById("witnessRow");

	var newTR = witnesstable.insertRow(atPosition);
	var td1;
	td1 = document.createElement("td");

	newTR.appendChild(td1);
	td1.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);

	document.getElementById('removeWitnessSection').disabled=false;
}

function newRecordForTermsOfStipulation(inForm)
{
    var termsOfStipulationTable = document.getElementById("termsOfStipulationDetails");
    var trRef,sumTableSize,newRow,newCell;

	var termsOfStipulationTableRowCount = document.getElementById("termsOfStipulationDetails").rows.length;
	var atPosition = termsOfStipulationTableRowCount;
	//atPosition = witnessTableRowCount;

	var refRow = document.getElementById("TermsOfStipulationRow");

	var newTR = termsOfStipulationTable.insertRow(atPosition);
	var td1;
	td1 = document.createElement("td");

	newTR.appendChild(td1);
	td1.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);
}

function newRecordForAttorney(inForm)
{
    var attorneytable = document.getElementById("attorneyDetails");
    var trRef,sumTableSize,newRow,newCell;

	var attorneyTableRowCount = document.getElementById("attorneyDetails").rows.length;
	var atPosition = attorneyTableRowCount;
	atPosition = attorneyTableRowCount -1;

	var refRow = document.getElementById("attorneyRow");
	refRow.children(0).children(0).value = attorneyRefCount;

    var newRadioName;
	var newRadioButton;
	var newRadioObject;

	newRadioName = 'rbLawSuit'+attorneyRefCount;

	newRadioButton = createRadioButton(newRadioName, 'yes');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(0).children(1);
	addRadioButtonObject(newRadioButton, newRadioObject, 'Yes');

	newRadioButton = createRadioButton(newRadioName, 'no');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(0).children(2);
	addRadioButtonObject(newRadioButton, newRadioObject, 'No');

	newRadioName = 'rbLawSuitDismissed'+attorneyRefCount;

	newRadioButton = createRadioButton(newRadioName, 'yes');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(1).children(1);
	addRadioButtonObject(newRadioButton, newRadioObject, 'Yes');

	newRadioButton = createRadioButton(newRadioName, 'no');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(1).children(2);
	addRadioButtonObject(newRadioButton, newRadioObject, 'No');

	newRadioName = 'rbHasValidJudgement'+attorneyRefCount;

	newRadioButton = createRadioButton(newRadioName, 'yes');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(2).children(1);
	addRadioButtonObject(newRadioButton, newRadioObject, 'Yes');

	newRadioButton = createRadioButton(newRadioName, 'no');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(2).children(2);
	addRadioButtonObject(newRadioButton, newRadioObject, 'No');

	newRadioName = 'rbHasArbitrationParticipation'+attorneyRefCount;

	newRadioButton = createRadioButton(newRadioName, 'yes');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(3).children(1);
	addRadioButtonObject(newRadioButton, newRadioObject, 'Yes');

	newRadioButton = createRadioButton(newRadioName, 'no');
	newRadioObject = refRow.children(0).children(3).children(0).children(12).children(1).children(0).children(0).children(3).children(2);
	addRadioButtonObject(newRadioButton, newRadioObject, 'No');

	attorneyRefCount++;

	var newTR = attorneytable.insertRow(atPosition);
	var td1;
	td1 = document.createElement("td");

	newTR.appendChild(td1);
	td1.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);
	attorneyTableRowCount = document.getElementById("attorneyDetails").rows.length;

	document.getElementById('removeAttorneySection').disabled=false;
}

function addRadioButtonObject(radioObject, parentObject, value)
{
	var newRadioButton = radioObject;
	var parentObject = parentObject;
	parentObject.innerHTML = "";
	parentObject.appendChild(newRadioButton);
	parentObject.innerHTML = parentObject.innerHTML + value;
}

function createRadioButton(name, value)
{
	var newRadioName = name;
 	var newrad = "<INPUT TYPE='RADIO' NAME=";
	newrad = newrad + newRadioName;
	newrad = newrad + " ID=";
	newrad = newrad + newRadioName;
	newrad = newrad + " VALUE=";
	newrad = newrad + value;
	newrad = newrad + ">";
	var newRadioButton = document.createElement(newrad);
	return newRadioButton;
}


function newRecordForAllegationsForAdmin(inForm)
{
	var allegationstable = document.getElementById("allegationDetails");

	var allegationTableRowCount = document.getElementById("allegationDetails").rows.length;
	var atPosition = allegationTableRowCount;
	atPosition = atPosition - 1;
	//var atPosition = 0;

	var refRow = document.getElementById("allegationRow");

	var newTR = allegationstable.insertRow(atPosition);
	var td1;
	td1 = document.createElement("td");

	newTR.appendChild(td1);
	td1.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);
	td1.colSpan=3;
}

function deleteRecordForAllegations(inForm)
{

	/*for(i=document.all.allegationDetails.rows.length-3;i>=0;i--)
	{
		if(inForm.chkAllegations[i].checked)
		{
			inForm.allegationOperation[i].value="D";
			document.all.allegationDetails.deleteRow(i+1);
		}
	}*/

	if (inForm.chkAllegations[0]) {
		for(i=inForm.chkAllegations.length-1;i>=0;i--)
		{
			if(inForm.chkAllegations[i].checked)
			{
				if(inForm.allegationId[i].value !="")
				{
					alert("Deleting...");
					inForm.allegationOperation[i].value="D";
					document.all.allegationDetails.rows(i+1).style.display="none";
				}
				else
				{
					document.all.allegationDetails.deleteRow(i+1);
				}
			}
		}
		if (inForm.chkAllegations.length == 1) inForm.removeAllegation.disabled = true;
	}
	enableDisableRemoveButton();
}


function enableDisableRemoveButton() {

	inForm = document.all;
	var atleastOneItemSelectedForRemoval = false;

	if (inForm.chkAllegations.length > 1) {
		for(i=inForm.chkAllegations.length-1;i>=0;i--)
		{
			if (inForm.chkAllegations[i].checked == true) {
				atleastOneItemSelectedForRemoval = true;
				break;
			}
		}
	}

	if (atleastOneItemSelectedForRemoval) {
		inForm.removeAllegation.disabled = false;
	} else {
		inForm.removeAllegation.disabled = true;
	}
}

function deleteRecordForWitness(inForm)
{
	if (inForm.removeWitness[0])
	 {
		for(i=inForm.removeWitness.length-1;i>=0;i--)
		{
			if(inForm.removeWitness[i].checked)
			{
				document.all.witnessDetails.deleteRow(i+1);
			}
		}
		if (inForm.removeWitness.length == 1)
		{
		 	inForm.removeWitnessSection.disabled = true;
		}
	}
	//enableDisableRemoveWitnessButton();
}

function enableDisableRemoveWitnessButton()
{
	inForm = document.all;
	var atleastOneItemSelectedForRemoval = false;

	if (inForm.removeWitness.length > 1) {
		for(i=inForm.removeWitness.length-1;i>=0;i--)
		{
			if (inForm.removeWitness[i].checked == true) {
				atleastOneItemSelectedForRemoval = true;
				break;
			}
		}
	}

	if (atleastOneItemSelectedForRemoval) {
		inForm.removeWitnessSection.disabled = false;
	} else {
		inForm.removeWitnessSection.disabled = true;
	}
}

function deleteRecordForAttorney(inForm)
{
	if (inForm.removeAttorney[0])
	 {
		for(i=inForm.removeAttorney.length-1;i>=0;i--)
		{
			if(inForm.removeAttorney[i].checked)
			{
				document.all.attorneyDetails.deleteRow(i+1);
			}
		}
		if (inForm.removeAttorney.length == 1)
		{
		 	inForm.removeAttorneySection.disabled = true;
		}
	}
	//enableDisableRemoveAttorneyButton();
}

function enableDisableRemoveAttorneyButton()
{
	inForm = document.all;
	var atleastOneItemSelectedForRemoval = false;

	if (inForm.removeAttorney.length > 1) {
		for(i=inForm.removeAttorney.length-1;i>=0;i--)
		{
			if (inForm.removeAttorney[i].checked == true) {
				atleastOneItemSelectedForRemoval = true;
				break;
			}
		}
	}

	if (atleastOneItemSelectedForRemoval) {
		inForm.removeAttorneySection.disabled = false;
	} else {
		inForm.removeAttorneySection.disabled = true;
	}
}

function deleteRecordForAllegationsUpdateFlow(inForm)
{

	for(i=document.all.allegationDetails.rows.length-3;i>=0;i--)
	{
		if(inForm.chkAllegations[i].checked)
		{
			if(inForm.allegationId[i].value !="")
			{
				inForm.allegationOperation[i].value="D";
				document.all.allegationDetails.rows(i+1).style.display="none";
				inForm.chkAllegations[i].checked = false;
			}
			else
			{
				document.all.allegationDetails.deleteRow(i+1);
			}

		}
	}
	enableDisableRemoveButton();

}

function populateLicenseeDetailTable(inForm)
{
	var trRef,sumTableSize,newRow,newCell;

    trRef=document.all.refLicenseeDetailTable.rows(document.all.refLicenseeDetailTable.rows.length-1);

	sumtableSize=document.all.licenseeDetails.rows.length;
	newRow=document.all.licenseeDetails.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newRow.className="rowcolor";


	newRow.rowId = sumtableSize;

	//RadioButton
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	//License Name
    newCell=newRow.insertCell();
    newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
    newRow.cells(1).children(0).innerText = returnSelectedTextInCombo(inForm.licensename, inForm.licensename.value)
    //if(inForm.rdbSelectDetailType[0].checked)
    //    newRow.cells(1).children(0).innerText = inForm.licenseefirstname.value+ " "+ inForm.licenseelastname.value;
    //else
    //    newRow.cells(1).children(0).innerText = inForm.licenseebusinessname.value;
    //inForm.licensenames.value = inForm.licensename.value;
    //alert(trRef.cells(1).innerHTML)
    //alert(newCell.innerHTML)
    //newCell.children(1).children(0).value = inForm.licensename.value
    //newCell.children(1).children(0).name = "licensenames";
    //newRow.cells(1).align = "left";
    //newRow.cells(1).valign = "top";
    //newRow.cells(1).className = "fieldlabel";

    //Respondant Name
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	if(inForm.rdbSelectDetailType[0].checked)
		newRow.cells(2).children(0).innerText = inForm.licenseefirstname.value + " " + inForm.licenseemiddlename.value + " " + inForm.licenseelastname.value;
	else
		newRow.cells(2).children(0).innerText = inForm.licenseebusinessname.value;
	//inForm.licensenames.value = inForm.licensename.value;
	//alert(trRef.cells(1).innerHTML)
	//alert(newCell.innerHTML)
	newCell.children(1).children(0).value = inForm.licensename.value
	newCell.children(1).children(0).name = "licensenames";
	newRow.cells(2).align = "left";
	newRow.cells(2).valign = "top";
	newRow.cells(2).className = "fieldlabel";

	//License Number
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(3).innerHTML);
	newRow.cells(3).children(0).innerText = inForm.licensenumber.value;
	newCell.children(1).children(0).value = inForm.licensenumber.value;
	newCell.children(1).children(0).name = "licensenumbers";
	newRow.cells(3).align = "left";
	newRow.cells(3).valign = "top";
	newRow.cells(3).className = "fieldlabel";

//  Business Details (Speciality Area)
    newCell=newRow.insertCell();
    newCell.insertAdjacentHTML("AfterBegin",trRef.cells(4).innerHTML);
    if(returnSelectedTextInCombo(inForm.licenseespecialityarea, inForm.licenseespecialityarea.value) != '- Select -')
    {
        newRow.cells(4).children(0).innerText = returnSelectedTextInCombo(inForm.licenseespecialityarea, inForm.licenseespecialityarea.value)
    }
    //newCell.children(3).children(0).value = inForm.licensenumber.value;
    //newCell.children(3).children(0).name = "licensenumbers";
    //newRow.cells(3).align = "left";
    //newRow.cells(3).valign = "top";
    //newRow.cells(3).className = "fieldlabel";

	//Address Details
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(5).innerHTML);

	newRow.cells(5).children(0).innerText = inForm.licenseeaddressline1.value+" "+inForm.licenseeaddressline2.value+" "+inForm.licenseecity.value+" "+inForm.licenseestate.value+" "+inForm.licenseezip.value;

	newCell.children(1).children(0).value = inForm.licenseefirstname.value;
	newCell.children(1).children(0).name = "licenseefirstnames";
	newCell.children(1).children(1).value = inForm.licenseelastname.value;
	newCell.children(1).children(1).name = "licenseelastnames";
	newCell.children(1).children(2).value = inForm.licenseebusinessname.value;
	newCell.children(1).children(2).name = "licenseebusinessnames";
	newCell.children(1).children(3).value = inForm.licenseespecialityarea.value;
	newCell.children(1).children(3).name = "licenseespecialityareas";

	if(inForm.rdbSelectDetailType[0].checked)
		newCell.children(1).children(4).value = "candidate";
	else
		newCell.children(1).children(4).value = "business";

	newCell.children(1).children(4).name = "isCandidateOrbusiness";
	newCell.children(1).children(5).value = inForm.licenseeaddressline1.value;
	newCell.children(1).children(5).name = "licenseeaddressline1s";
	newCell.children(1).children(6).value = inForm.licenseeaddressline2.value;
	newCell.children(1).children(6).name = "licenseeaddressline2s";
	newCell.children(1).children(7).value = inForm.licenseecity.value;
	newCell.children(1).children(7).name = "licenseecitys";
	newCell.children(1).children(8).value = inForm.licenseestate.value;
	newCell.children(1).children(8).name = "licenseestates";
	newCell.children(1).children(9).value = inForm.licenseezip.value;
	newCell.children(1).children(9).name = "licenseezips";

	// to define primary key for add flow

	var sizeOfList = inForm.respondents.length;

	newCell.children(1).children(10).value = -sizeOfList;
	newCell.children(1).children(10).name = "respondentId";
	newCell.children(1).children(11).value = inForm.licId.value;
	newCell.children(1).children(11).name = "licenseId";
	newCell.children(1).children(12).value = inForm.licenseemiddlename.value;
	newCell.children(1).children(12).name = "licenseemiddlenames";
	newCell.children(1).children(13).value = inForm.licenseefax.value;
	newCell.children(1).children(13).name = "licenseefaxs";
	newCell.children(1).children(14).value = inForm.licenseeemail.value;
	newCell.children(1).children(14).name = "licenseeemails";

	newRow.cells(3).align = "left";
	newRow.cells(3).valign = "top";
	newRow.cells(3).className = "fieldlabel";

	newCell=newRow.insertCell();

	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(6).innerHTML);
	//complaintForm.respondentStatus.options[1].selected = true;
	//newCell.children(1).children(0).value = returnSelectedTextInCombo(inForm.respondentStatus, inForm.respondentStatus.value);

	newCell.children(1).children(0).value = "";
	newCell.children(1).children(0).name = "respondentStatusValue";

	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(7).innerHTML);
	newCell.children(0).name = "chkRespondentDisciplinaryAction";
	newCell.children(0).id = "chkRespondentDisciplinaryAction";
	newCell.children(1).name = "respondentDisciplinaryActionValue";
	newCell.children(1).id = "respondentDisciplinaryActionValue";
	//newCell.children(1).value = "respondentDisciplinaryActionValue";


	var name = "";
	if(trim(inForm.licenseefirstname.value) == "")
	{
	    if(trim(inForm.licenseelastname.value) == "")
	    {
	        name = inForm.licenseebusinessname.value;
	    }
	    else
	    {
	        name = inForm.licenseelastname.value;
	    }
	}
	else
	{
		if(trim(inForm.licenseelastname.value) == "")
		{
			name = inForm.licenseefirstname.value;
		}
		else
		{
			name = inForm.licenseefirstname.value;
			name += " ";
			name += inForm.licenseelastname.value;
		}
	}

	populateRespondentList(inForm,name);
	emptyLicenseeDetailForm(inForm);
}



function deleteLicenseeRecord(inForm)
{
	var index = inForm.respondents.length;
	var recreateList = 0;
	for(i=document.all.licenseeDetails.rows.length-3;i>=0;i--)
	{
		if(inForm.chkLicenseeDetail[i].checked)
		{
			var temp = (i+2);
			temp = temp-1;
			if(	removeFromRespondentList(inForm,-temp))
			{
				document.all.licenseeDetails.deleteRow(i+2);
				recreateList = 1;
			}
		}
	}

	sumtableSize=document.all.licenseeDetails.rows.length;

	if(recreateList == 1)
	{
		inForm.respondents.length = 0;
		inForm.respondents.options[0] = new Option("- Select -","");
//		inForm.chkDisciplinaryDocument.disabled = true;
//		inForm.chkFinalDisciplinaryDocument.disabled = true;
//		inForm.chkDisciplinaryDocument.checked = false;
//		inForm.chkFinalDisciplinaryDocument.checked = false;

		for(var j=2;j<sumtableSize;j++)
		{
			var value = document.all.licenseeDetails.rows[j].cells(1).children(0).innerText;
			populateRespondentList(inForm,value);
		}
	}

}

function emptyLicenseeDetailForm(inForm)
{
	inForm.licenseeaddressline1.value =""
	inForm.licenseeaddressline2.value =""
	inForm.licenseecity.value =""
	inForm.licenseestate.value =""
	inForm.licenseezip.value =""
	inForm.licensename.value =""
	inForm.licensenumber.value =""
	inForm.licenseefirstname.value =""
	inForm.licenseemiddlename.value = ""
	inForm.licenseelastname.value =""
	inForm.licenseebusinessname.value =""
	inForm.licenseefax.value =""
	inForm.licenseeemail.value =""
	inForm.licId.value =""
	inForm.rdbSelectDetailType[0].checked = false;
	inForm.rdbSelectDetailType[1].checked = false;
	inForm.licenseefirstname.disabled =true;
	inForm.licenseelastname.disabled = true;
	inForm.licenseebusinessname.disabled = true;
    if(inForm.licenseespecialityarea)
    {
        inForm.licenseespecialityarea.disabled = true;
        inForm.licenseespecialityarea.options[0].selected = true;
    }


}

function emptyLicenseeDetailFormForPublicSite(inForm)
{
	inForm.licenseecity.value =""
	inForm.licenseestate.value =""
	inForm.licenseezip.value =""
	inForm.licensename.value =""
	inForm.licensenumber.value =""
	inForm.licenseefirstname.value =""
	inForm.licenseelastname.value =""
	inForm.licenseemiddlename.value =""
	inForm.licenseebusinessname.value =""
	inForm.licId.value =""
	inForm.rdbSelectDetailType[0].checked = false;
	inForm.rdbSelectDetailType[1].checked = false;
	inForm.licenseefirstname.disabled =true;
	inForm.licenseelastname.disabled = true;
	inForm.licenseebusinessname.disabled = true;
    if(inForm.licenseespecialityarea)
    {
        inForm.licenseespecialityarea.disabled = true;
        inForm.licenseespecialityarea.options[0].selected = true;
    }
}

function enableOrDisableLicenseeInformation(inForm)
{
	if(inForm.rdbSelectDetailType[0].checked)
	{
		inForm.licenseefirstname.disabled = false;
		inForm.licenseemiddlename.disabled = false;
		inForm.licenseelastname.disabled = false;
		inForm.licenseebusinessname.disabled = true;
		inForm.licenseebusinessname.value = "";
        if(inForm.licenseespecialityarea)
        {
    		inForm.licenseespecialityarea.disabled = true;
    		inForm.licenseespecialityarea.options[0].selected = true;
        }
	}
	else
	{
		inForm.licenseefirstname.disabled =true;
		inForm.licenseemiddlename.disabled =true;
		inForm.licenseelastname.disabled = true;
		inForm.licenseefirstname.value ="";
		inForm.licenseemiddlename.value ="";
		inForm.licenseelastname.value = "";
		inForm.licenseebusinessname.disabled = false;
        if(inForm.licenseespecialityarea)
            inForm.licenseespecialityarea.disabled = false;
	}
}

function enableWitnessFields(inForm)
{
//	alert("inside enableWitnessFields");

	//variables will be accessed from the form
	var lastNameOnPage = "witnessLastName";
	var firstNameOnPage = "witnessFirstName";
	var zipCodeOnPage = "witnessZipCode";
	var phoneOnPage = "witnessPhone";
	//var faxOnPage = "fax";
	var emailAddressOnPage = "witnessEmailAddress";

//	alert(inForm.witnessLastName.length);
	//Enable witness last name
	if(inForm.witnessLastName.length-1)
	{
		for(var i=0;i<inForm.witnessLastName.length-1;i++)
		{
			inForm.witnessLastName[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessLastName.disabled = false;
	}

	//Enable witness first name
	if(inForm.witnessFirstName.length-1)
	{
		for(var i=0;i<inForm.witnessFirstName.length-1;i++)
		{
			inForm.witnessFirstName[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessFirstName.disabled = false;
	}

	//Enable witness middle name
	if(inForm.witnessMiddleName.length-1)
	{
		for(var i=0;i<inForm.witnessMiddleName.length-1;i++)
		{
			inForm.witnessMiddleName[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessMiddleName.disabled = false;
	}

	//Enable witness suffix
	if(inForm.witnessSuffix.length-1)
	{
		for(var i=0;i<inForm.witnessSuffix.length-1;i++)
		{
			inForm.witnessSuffix[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessSuffix.disabled = false;
	}

	//Enable witness address
	if(inForm.witnessAddress.length-1)
	{
		for(var i=0;i<inForm.witnessAddress.length-1;i++)
		{
			inForm.witnessAddress[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessAddress.disabled = false;
	}

	//Enable witness city
	if(inForm.witnessCity.length-1)
	{
		for(var i=0;i<inForm.witnessCity.length-1;i++)
		{
			inForm.witnessCity[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessCity.disabled = false;
	}

	//Enable witness state
	if(inForm.witnessState.length-1)
	{
		for(var i=0;i<inForm.witnessState.length-1;i++)
		{
			inForm.witnessState[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessState.disabled = false;
	}


	//Enable witness zip
	if(inForm.witnessZipCode.length-1)
	{
		for(var i=0;i<inForm.witnessZipCode.length-1;i++)
		{
			inForm.witnessZipCode[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessZipCode.disabled = false;
	}

	//Enable witness phone
	if(inForm.witnessPhone.length-1)
	{
		for(var i=0;i<inForm.witnessPhone.length-1;i++)
		{
			inForm.witnessPhone[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessPhone.disabled = false;
	}

	//Enable witness fax
	if(inForm.witnessFax.length-1)
	{
		for(var i=0;i<inForm.witnessFax.length-1;i++)
		{
			inForm.witnessFax[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessFax.disabled = false;
	}

	//Enable witness email

	if(inForm.witnessEmailAddress.length-1)
	{
		for(var i=0;i<inForm.witnessEmailAddress.length-1;i++)
		{
			inForm.witnessEmailAddress[i].disabled = false;
		}
	}
	else
	{
		inForm.witnessEmailAddress.disabled = false;
	}

}

function setChkBoxValue(obj, fromWhere, site)
{
    var inForm = obj.form;

    /* Function : Validating for textarea's text length before submitting
       Author	: Janardhana
    */
    if (inForm.otherReasonDescription.value !=null && inForm.otherReasonDescription.value !="")
    {
    	if ((inForm.otherReasonDescription.value).length > 4000){
    	alert ("Number of characters exceeds the maximum(4000) allowed.");
    	inForm.otherReasonDescription.focus();
    	return false;
    	}
    }

	var allAllegations = new Array()
		allAllegations = inForm.allegations;
	var allAllegationsOperations = new Array();
		allAllegationsOperations = inForm.allegationOperation;

	for (i=0; i<(allAllegations.length - 1); i++){

	 if (allAllegations[i].value !=null && allAllegations[i].value !="" && allAllegationsOperations[i].value != "D")
    	{
	    	if ((allAllegations[i].value).length > 4000){
	    	alert ("Number of characters exceeds the maximum(4000) allowed.");
	    	allAllegations[i].focus();
	    	return false;
	    	}
    	}
	}
	//Validation is completed

    if(null != complaintForm.isdocumentpublic && complaintForm.isdocumentpublic != 'undefined')
    {
		for(i=0;i<complaintForm.isdocumentpublic.length;i++)
		{
			if(complaintForm.isdocumentpublic[i].checked)
			{
				complaintForm.isDocumentPublic[i].value= "1";
			}
			else
			{
				complaintForm.isDocumentPublic[i].value= "0";
			}
		}
    }

    if(null != complaintForm.isdisciplinarydocument && complaintForm.isdisciplinarydocument != 'undefined')
    {
    	for(i=0;i<complaintForm.isdisciplinarydocument.length;i++)
		{
			if(complaintForm.isdisciplinarydocument[i].checked)
			{

				complaintForm.isDisciplinaryDocument[i].value= "1";
			}
			else
			{
				complaintForm.isDisciplinaryDocument[i].value= "0";
			}
		}
    }

    if(null != complaintForm.isfinaldisciplinarydocument && complaintForm.isfinaldisciplinarydocument != 'undefined')
    {
		for(i=0;i<complaintForm.isfinaldisciplinarydocument.length;i++)
		{
			if(complaintForm.isfinaldisciplinarydocument[i].checked)
			{

				complaintForm.isFinalDisciplinaryDocument[i].value= "1";
			}
			else
			{
				complaintForm.isFinalDisciplinaryDocument[i].value= "0";
			}
		}
    }

    if(null != complaintForm.chkRespondentDisciplinaryAction && complaintForm.chkRespondentDisciplinaryAction != 'undefined')
    {
    	if(complaintForm.chkRespondentDisciplinaryAction.length > 1)
    	{
			for(i=0;i<complaintForm.chkRespondentDisciplinaryAction.length;i++)
			{
				if(complaintForm.chkRespondentDisciplinaryAction[i].checked)
				{

					complaintForm.respondentDisciplinaryActionValue[i].value= "1";
				}
				else
				{
					complaintForm.respondentDisciplinaryActionValue[i].value= "0";
				}
			}
    	}
    	else
    	{
    		if(complaintForm.chkRespondentDisciplinaryAction.checked)
    		{
    			complaintForm.respondentDisciplinaryActionValue.value= "1";
    		}
    		else
    		{
    			complaintForm.respondentDisciplinaryActionValue.value= "0";
    		}
    	}
    }


		var checkReturn = validateComplaintForm(inForm, fromWhere, site);

		SelectAllFromList(inForm.selectedComplaintType);
		SelectAllFromList(inForm.selectedComplaintSubStatus);

		if( checkReturn == true)
		{
			disableObjectAndSubmit(obj);
		}
		else
		{
		    return false;
		}
}

function populateChargeEventsTable(inForm)
{
	var trRef,sumTableSize,newRow,newCell;
    trRef=document.all.refChargeEventsTable.rows(document.all.refChargeEventsTable.rows.length-1);

	sumtableSize=document.all.ChargeEventsTable.rows.length;
	newRow=document.all.ChargeEventsTable.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newRow.className="rowcolor";

	newRow.rowId = sumtableSize;

	//Check Box
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newRow.cells(0).children(1).children(0).value = "I";
	newRow.cells(0).children(1).children(0).name = "operation";
	newRow.cells(0).children(1).children(1).name = "chargeeventids";
	newRow.cells(0).align = "center";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	//Activity Date
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newRow.cells(1).children(0).innerText = inForm.activitydate.value;
    newRow.cells(1).children(1).children(0).value = inForm.activitydate.value;
    newRow.cells(1).children(1).children(0).name = "activitydates";
    newRow.cells(1).children(1).children(1).value = inForm.nextcontactdate.value;
    newRow.cells(1).children(1).children(1).name = "nextcontactdates";
	newRow.cells(1).align = "center";
	newRow.cells(1).valign = "top";
	newRow.cells(1).className = "fieldlabel";

	//Activity
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	newRow.cells(2).children(0).innerText = inForm.activity.value;
    newRow.cells(2).children(1).children(0).value = inForm.activity.value;
    newRow.cells(2).children(1).children(0).name = "activities";
	newRow.cells(2).align = "center";
	newRow.cells(2).valign = "top";
	newRow.cells(2).className = "fieldlabel";

	//Performed by the User
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(3).innerHTML);
	newRow.cells(3).innerText = inForm.username.value;
	inForm.performedbyusers.value = inForm.username.value;
	newRow.cells(3).align = "center";
	newRow.cells(3).valign = "top";
	newRow.cells(3).className = "fieldlabel";

	//Notes
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(4).innerHTML);
	newRow.cells(4).children(0).innerText = inForm.notes.value;
    newRow.cells(4).children(1).children(0).value = inForm.notes.value;
    newRow.cells(4).children(1).children(0).name = "eventnotes";
	newRow.cells(4).align = "center";
	newRow.cells(4).valign = "top";
	newRow.cells(4).className = "fieldlabel";

	emptyChargeEventsForm(inForm);
}

function emptyChargeEventsForm(inForm)
{
	inForm.activity.value = "";
	inForm.notes.value = "";
	inForm.activitydate.value = "";
	inForm.nextcontactdate.value = "";
}

function deleteChargeEventsRecord(inForm)
{
	for(i=document.all.ChargeEventsTable.rows.length-2;i>=0;i--)
	{
		if(inForm.chkChargeEvent[i].checked)
		{
			var chargeeventid = document.all.ChargeEventsTable.rows(i+1).cells(0).children(1).children(1).value;
			if(chargeeventid != 0)
			{
			    if(inForm.deletedeventids.value == "")
			    {
			        inForm.deletedeventids.value = chargeeventid;
			    }
			    else
			    {
			        inForm.deletedeventids.value = inForm.deletedeventids.value + "," + chargeeventid;
			    }
			}
			document.all.ChargeEventsTable.deleteRow(i+1);
		}
	}
}

function selectAllChargeEvents(inForm, flag)
{
    if(inForm.chkChargeEvent.length)
    {
        for(i=0;i<inForm.chkChargeEvent.length;i++)
        {
            inForm.chkChargeEvent[i].checked = flag;
        }
    }
    else
    {
        inForm.chkChargeEvent.checked = flag;
    }
}



function validateComplaintForm(inForm, fromWhere, site)
{

	if(fromWhere == 'update')
    {
        if(inForm.isMigratedData.value == 'true')
        {
            return true;
        }
    }
	if(fromWhere == 'update')
    {
		enableWitnessFields(inForm);
		enableAttorneyTableForUpdateComplaintInAdminSite(inForm)
    }


    if(document.all.licenseeDetails.rows.length <= 2 && fromWhere != "update")
	{
		alert("At least one respondent information is required.");
		complaintForm.licensename.focus();
		return false;
	}

    if(fromWhere == "update")
    {
    	if (!validateComplaintFormWitnessesForAdminSiteUpdate(inForm)) return false;
    	if (!adminSiteUpdateComplaint_validateAttorney(inForm)) return false;

    }

    if(fromWhere != "update")
    {
//	    if(complaintForm.complaintchargetype != null && complaintForm.complaintchargetype.options[0].selected)
//		{
//			alert("Complaint type is mandatory.");
//			complaintForm.complaintchargetype.focus();
//			return false;
//		}


		if(complaintForm.status != null && complaintForm.status != 'undefined')
		{
			if(complaintForm.status.options[0].selected)
			{
				alert("Investigation Status is mandatory.");
				complaintForm.status.focus();
				return false;
			}
		}
		if(complaintForm.complaintcharges && complaintForm.complaintcharges.value=="")
		{
			alert("Complaint summary is mandatory.");
			complaintForm.complaintcharges.focus();
			return false;
		}
    }
    else
    {

        if(inForm.origin.value == 'Admin')
        {
    		if(complaintForm.complainantfirstname.value=="")
    		{
    			alert("Complainant first name is mandatory.");
    			complaintForm.complainantfirstname.focus();
    			return false;
    		}

    		if(complaintForm.complainantlastname.value=="")
    		{
    			alert("Complainant last name is mandatory.");
    			complaintForm.complainantlastname.focus();
    			return false;
    		}

    		//if (!validateComplaintFormWitnessesForAdminSite(inForm)) return false;
        }

    }


    //Removed to allow for historic data.
    //if (!validateAllegationsData('allegationDate','allegations',complaintForm)) return false;

    if(complaintForm.complaintdate && complaintForm.complaintdate.value == "")
    {
		alert("Complaint Date is mandatory.");
		complaintForm.complaintdate.focus();
		return false;
    }


	if(complaintForm.complaintRecontactDate && complaintForm.complaintRecontactDate.value != null && complaintForm.complaintRecontactDate.value != '')
	{
		if(complaintForm.Investigator.value == null || complaintForm.Investigator.value == 'undefined' || complaintForm.Investigator.value == '' )
		{
			alert("Please select Investigator to provide Recontact Date");
			complaintForm.Investigator.focus();
			return false;
		}
	}

    if(complaintForm.complaintRecontactDate && checkDates(complaintForm.complaintRecontactDate.value, complaintForm.complaintdate.value) < 0)
    {
        alert("Complaint Recontact Date should be after or same as Complaint Date.");
        inForm.complaintRecontactDate.value = "";
        inForm.complaintRecontactDate.focus();
        return false;
    }

    if(complaintForm.complaintChargeRecontactDate && checkDates(complaintForm.complaintChargeRecontactDate.value, complaintForm.complaintdate.value) < 0)
    {
        alert("Complaint Charge Recontact Date should be after or same as Complaint Date.");
        inForm.complaintChargeRecontactDate.value = "";
        inForm.complaintChargeRecontactDate.focus();
        return false;
    }


	if(complaintForm.rdbSelectDetailType != null && complaintForm.rdbSelectDetailType[1].checked && complaintForm.licenseebusinessname.value=="")
	{
		alert("Business name is mandatory.");
		complaintForm.licenseebusinessname.focus();
		return false;
	}



    if(site != 'public' && fromWhere != 'update')
    {
		if(complaintForm.complainantfirstname.value=="")
		{
			alert("Complainant first name is mandatory.");
			complaintForm.complainantfirstname.focus();
			return false;
		}

		if(complaintForm.complainantlastname.value=="")
		{
			alert("Complainant last name is mandatory.");
			complaintForm.complainantlastname.focus();
			return false;
		}
    }
    else if(site == 'public')
    {
		if(trim(complaintForm.complainantfirstname.value)=="")
		{
			alert("Complainant first name is mandatory.");
			complaintForm.complainantfirstname.focus();
			return false;
		}
		if(trim(complaintForm.complainantlastname.value)=="")
		{
			alert("Complainant last name is mandatory.");
			complaintForm.complainantlastname.focus();
			return false;
		}
		if(trim(complaintForm.complainantaddressline1.value)=="")
		{
			alert("Complainant address line 1 is mandatory.");
			complaintForm.complainantaddressline1.focus();
			return false;
		}
		/*
		if(trim(complaintForm.complainantaddressline2.value)=="")
		{
			alert("Complainant address line 2 is mandatory.");
			complaintForm.complainantaddressline2.focus();
			return false;
		}
		*/
		if(trim(complaintForm.complainantcity.value)=="")
		{
			alert("Complainant city is mandatory.");
			complaintForm.complainantcity.focus();
			return false;
		}
		if(!complaintForm.complainantstate.disabled)
		{
			if(complaintForm.complainantstate.value=="")
			{
				alert("Complainant state is mandatory.");
				complaintForm.complainantstate.focus();
				return false;
			}
		}

		if(trim(complaintForm.complainantzip.value)=="")
		{
			alert("Complainant zip is mandatory.");
			complaintForm.complainantzip.focus();
			return false;
		}
		if(complaintForm.complainantcountry.value=="")
		{
			alert("Complainant country is mandatory.");
			complaintForm.complainantcountry.focus();
			return false;
		}
		if(trim(complaintForm.complainanthomephone.value)=="")
		{
			alert("Complainant phone number is mandatory.");
			complaintForm.complainanthomephone.focus();
			return false;
		}
		/*
		if(trim(complaintForm.complainantemail.value)=="")
		{
			alert("Complainant email is mandatory.");
			complaintForm.complainantemail.focus();
			return false;
		}
		*/
    }

	if(complaintForm.complainantzip.value!="")
	{
		if(!validateZIP(complaintForm.complainantzip))
		{
			complaintForm.complainantzip.focus();
			return false;
		}
	}

	if(complaintForm.complainanthomephone.value!="")
	{
	    /*
		if(!checkInternationalPhone(complaintForm.complainanthomephone.value))
		{
			alert("Enter valid phone number in the format specified.");
			complaintForm.complainanthomephone.focus();
			return false;
		}
		*/
	}

	if(complaintForm.complainanthomephone.value !=null && isNaN(complaintForm.complainanthomephone.value))
	{
		alert('Invalid phone number. Enter phone number without using hyphens or spaces and only digits.');
		complaintForm.complainanthomephone.focus();
		return false;
	}
	if(complaintForm.complainantemail.value!="")
	{
		if(!echeck(complaintForm.complainantemail.value))
		{
			complaintForm.complainantemail.focus();
			return false;
		}
	}


    if(fromWhere != "update")
    {

    	if (inForm.lastName) {
    		//Witness section exists.
    		if (!validateComplaintFormWitnessesForAdminSite(inForm)) return false;
    	}
    	if (!adminSiteAddComplaint_validateAttorney(inForm)) return false;
    }

	//Added by Venkatesh
	//Removed the validation to allow for historic data.
	//if (!validateAllegationsData('allegationDate','allegations',complaintForm)) return false;

    return true;
}

function validateAllegationsData(dateFieldName, eventFieldName, inForm ) {
	var noOfEvents = eval("inForm." + dateFieldName + ".length");

	noOfEvents = noOfEvents - 1;
	for (i=0;i<parseInt(noOfEvents);i++) {
		var dateValue = eval("inForm." + dateFieldName + "["+ i +"].value");

		var eventValue = eval("inForm." + eventFieldName + "["+ i +"].value");


		//Date must not be older than 2 years
		if (dateValue != "") {
			dateObject=getDateObject(dateValue,"/");
			var today = new Date();
			var today = new Date(today.getYear(), today.getMonth(), today.getDate());
			var difference = Math.ceil((today.getTime()  - dateObject.getTime())/(1000*60*60*24));
			if (difference > 730) {
				alert("Date cannot be older than 2 years");
				eval("inForm." + dateFieldName + "["+ i +"].focus()");
				return false;
			}

			if (today.getTime()  < dateObject.getTime()) {
				alert("Future dates are not allowed.");
				return false;
			}

		}

		if (trim(dateValue) == "" &&  trim(eventValue) == "") {
			alert("Please enter event details.");
			eval("inForm." + eventFieldName + "["+ i +"].focus()");
			return false;
		}

		var eventValue = eval("inForm." + eventFieldName + "["+ i +"].value");
		if (trim(dateValue) != "" &&  trim(eventValue) == "") {
			alert("Please enter event details.");
			eval("inForm." + eventFieldName + "["+ i +"].focus()");
			return false;
		}

		if (trim(eventValue) != "" &&  trim(dateValue) == "") {
			alert("Please enter date details.");
			eval("inForm." + dateFieldName + "["+ i +"].focus()");
			return false;
		}
	}
	return true;
}


function validateAddRespondentOperation(inForm)
{
	var trRef,sumTableSize;

	sumtableSize=document.all.licenseeDetails.rows.length-2;
	if(parseInt(sumtableSize) > 0)
	{
		for(i=2;i<document.all.licenseeDetails.rows.length;i++)
		{
			trRef=document.all.licenseeDetails.rows(i);
            if(trRef.cells(3).children(1).children(0).value != '')
            {
    			if(trRef.cells(3).children(1).children(0).value == inForm.licensenumber.value)
    			{
    				alert("Respondent already added.");
    				inForm.licensename.value="";
    				inForm.licensenumber.value = "";
    				inForm.licenseefirstname.value = "";
        			inForm.licenseemiddlename.value = "";
    				inForm.licenseelastname.value = "";
    				inForm.licenseebusinessname.value = "";
    				inForm.licenseespecialityarea.value = "";
    				inForm.licenseeaddressline1.value = "";
    				inForm.licenseeaddressline2.value = "";
    				inForm.licenseecity.value = "";
    				inForm.licenseestate.value = "";
    				inForm.licenseezip.value = "";
    				inForm.licenseefax.value = "";
    				inForm.licenseeemail.value = "";
    				return false;
    			}
            }
		}
	}


	if(inForm.licensename != null && inForm.licensename.options[0].selected)
	{
			alert("License name is mandatory.");
			inForm.licensename.focus();
			return false;
	}
	if(inForm.licensenumber.value == "" && inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "" && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value for License Number and First Name / Last Name or Business Name.");
		inForm.licensenumber.focus();
		return false;
	}
	if((inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "")  && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value either for First Name/Last Name or Business Name.");
		return false;
	}

	if(inForm.licenseezip.value!="")
	{
		if(!validateZIP(inForm.licenseezip))
		{
			inForm.licenseezip.focus();
			return false;
		}
	}
	populateLicenseeDetailTable(inForm);

	return true;
}

function populateRespondentList(inForm,value)
{
	var sizeOfList = inForm.respondents.length;
	if(sizeOfList == 1)
	{
		inForm.respondents.options[1] = new Option(value,-sizeOfList);
	}
	else
	{
		inForm.respondents.options[sizeOfList] = new Option(value,-sizeOfList);
	}
}

function removeFromRespondentList(inForm,index)
{
	var resIndex = inForm.respondents.value;
	var docLength = inForm.documentname.length;

	if(index == resIndex && docLength > 0)
	{
		alert(" You have attached document to this respondent, remove documents first");
		return false;
	}
	return true;
}

function enableCheckboxes(inForm)
{
    setRespondentName(inForm);
	var respondentvalue = inForm.respondents.value;
	if(respondentvalue != null && respondentvalue != "")
	{
		inForm.chkDisciplinaryDocument.disabled = false;
		inForm.chkFinalDisciplinaryDocument.disabled = false;
		inForm.isdocumentpublic_1.disabled = false;
		inForm.chkDisciplinaryDocument.checked = true;
	}
	else
	{
		inForm.chkDisciplinaryDocument.disabled = true;
		inForm.chkFinalDisciplinaryDocument.disabled = true;
		inForm.isdocumentpublic_1.disabled = true;
		inForm.chkDisciplinaryDocument.checked = false;
		inForm.chkFinalDisciplinaryDocument.checked = false;
		inForm.isdocumentpublic_1.checked = false;
	}
}

function setCheckBoxes(inForm)
{
	if(inForm.chkDisciplinaryDocument.checked)
	{
		inForm.chkFinalDisciplinaryDocument.disabled = false;
		inForm.isdocumentpublic_1.disabled = false;
	}
	else
	{
		inForm.chkFinalDisciplinaryDocument.disabled = true;
		inForm.isdocumentpublic_1.disabled = true;
		inForm.chkFinalDisciplinaryDocument.checked = false;
		inForm.isdocumentpublic_1.checked = false;
	}
}

function validatePopulateChargeEventsTable(inForm)
{
    if(inForm.activity.value == "")
    {
        alert("Enter the value for activity");
        inForm.activity.focus();
        return false;
    }
    if(inForm.notes.value == "")
    {
        alert("Enter the value for notes");
        inForm.notes.focus();
        return false;
    }
    if(inForm.activitydate.value == "")
    {
        alert("Please select the activity date");
        return false;
    }
    populateChargeEventsTable(inForm);
}

function validateNBuildUploadData(inForm)
{
	if(trim(document.all.documentname_1.value)!="" && trim(document.all.documenturl_1.value)=="")
	{
		alert("Please specify the file to be uploaded. If you provided document name by mistake, remove the name specified.");
		document.all.documenturl_1.focus();
		return false;
	}
	if(trim(document.all.documentname_1.value)=="" && trim(document.all.documenturl_1.value)!="")
	{
		alert("Please specify the name of the attachment");
		document.all.documentname_1.focus();
		return false;
	}

	if(trim(document.all.documentname_1.value)=="" && trim(document.all.documenturl_1.value)=="")
	{
	    alert(" Please provide name of the attachment and file to be uploaded.");
		document.all.documentname_1.focus();
		return false;
	}
	// Set Hidden field isDocumentAvailableForPublic for Each Attachment selected

	if(document.all.isdocumentpublic_1.checked)
	{
		document.all.isDocumentPublic_1.value="1";
	}

	// Set Hidden field documentAttachmentOperation for Each Attachment selected
	if(document.all.documentname_1.value!="")
	{
		document.all.documentAttachmentOperation_1.value="I";
	}

	if(document.all.chkDisciplinaryDocument.checked)
	{
		document.all.chkDisciplinaryDocument.value="1";
	}

	if(document.all.chkFinalDisciplinaryDocument.checked)
	{
		document.all.chkFinalDisciplinaryDocument.value="1";
	}
}

function getRespondentDataFromSearchIndividualLicenseeForm(inForm)
{
	var arrParam = new Array();
    arrParam[0] = "/shared/common/pageSearchIndividualLicensee.jsp";

	var returnedArray = window.showModalDialog('/showLicenseNumberSearchForm.do', arrParam, 'dialogHeight:650px;dialogWidth:750px;scroll:no;status:no');

	if(returnedArray !=null)
	{
		var rowDataLength = returnedArray.length;

		inForm.respondentLicenseNumber.value = returnedArray[5];
		inForm.respondentLicenseId.value = returnedArray[8];

		inForm.respondentLicenseName.value = "";
		inForm.respondentLicenseStatus.value = "";
		inForm.respondentFirstName.value = "";
		inForm.respondentMiddleName.value = "";
		inForm.respondentLastName.value = "";
		inForm.respondentSuffix.value = "";
		inForm.respondentBusinessName.value = "";
		inForm.respondentBusinessAddress1.value = "";
		inForm.respondentBusinessAddress2.value = "";
		inForm.respondentBusinessCity.value = "";
		inForm.respondentBusinessState.value = "";
		inForm.respondentBusinessZip.value = "";
		inForm.respondentBusinessPhone.value = "";
		inForm.respondentBusinessExtn.value = "";
		inForm.respondentHomeAddress1.value = "";
		inForm.respondentHomeAddress2.value = "";
		inForm.respondentHomeCity.value = "";
		inForm.respondentHomeState.value = "";
		inForm.respondentHomeZip.value = "";
		inForm.respondentMobile.value = "";
		inForm.respondentHomePhone.value = "";
		inForm.respondentFax.value = "";
		inForm.respondentEmail.value = "";

		/*if(returnedArray[9] != 'null')
		{*/
			inForm.respondentFirstName.value = returnedArray[9];
			inForm.respondentLastName.value = returnedArray[10];
			inForm.respondentMiddleName.value = returnedArray[11];

			/* Code added for setting Suffix value */
			if(returnedArray[12] != "")
			{
				for(var i =1 ;i<inForm.respondentSuffix.options.length;i++)
				{
				var value1 = inForm.respondentSuffix.options[i].value.toUpperCase();
				var value2 = returnedArray[12].toUpperCase();
				//alert("Value in drop down= "+value1);
				//alert("Returned Value = "+value2);
				if(value1 == value2)
					{
					//alert("Option matching is "+i);
					inForm.respondentSuffix.options[i].selected= true;
					break;
					}
				}
			}

			inForm.respondentBusinessName.value = returnedArray[13];
			inForm.respondentBusinessAddress1.value = returnedArray[14];
			inForm.respondentBusinessAddress2.value =  returnedArray[15];
			inForm.respondentBusinessCity.value = returnedArray[17];
			if(returnedArray[16] != "")
				inForm.respondentBusinessState.value = returnedArray[16];
			inForm.respondentBusinessZip.value =  returnedArray[18];
			inForm.respondentBusinessPhone.value =  returnedArray[19];
			inForm.respondentBusinessExtn.value = returnedArray[20];
			inForm.respondentHomeAddress1.value = returnedArray[21];
			inForm.respondentHomeAddress2.value =  returnedArray[22];
			inForm.respondentHomeCity.value = returnedArray[24];
			if(returnedArray[23] != "")
				inForm.respondentHomeState.value = returnedArray[23];
			inForm.respondentHomeZip.value = returnedArray[25];
			inForm.respondentMobile.value = returnedArray[27];
			inForm.respondentHomePhone.value =  returnedArray[26];
			inForm.respondentFax.value = returnedArray[28];
			inForm.respondentEmail.value =  returnedArray[29];
			inForm.respondentLicenseName.value = returnedArray[30];
			inForm.respondentLicenseStatus.value = returnedArray[32];
	//	}
	}
}

function getComplainantDataFromSearchIndividualLicenseeForm(inForm)
{
	var arrParam = new Array();
    arrParam[0] = "/shared/common/pageSearchIndividualLicensee.jsp";

var returnedArray = window.showModalDialog('/showLicenseNumberSearchForm.do', arrParam, 'dialogHeight:650px;dialogWidth:750px;scroll:no;status:no');

	if(returnedArray !=null)
	{
		var rowDataLength = returnedArray.length;

		inForm.complainantLicenseNumber.value = returnedArray[5];
		inForm.complainantLicenseId.value = returnedArray[8];

		inForm.complainantLicenseName.value = "";
		inForm.complainantLicenseStatus.value = "";
		inForm.complainantFirstName.value = "";
		inForm.complainantMiddleName.value = "";
		inForm.complainantLastName.value = "";
		inForm.complainantSuffix.value = "";
		inForm.complainantBusinessName.value = "";
		inForm.complainantBusinessAddress1.value = "";
		inForm.complainantBusinessAddress2.value = "";
		inForm.complainantBusinessCity.value = "";
		inForm.complainantBusinessState.value = "";
		inForm.complainantBusinessZip.value = "";
		inForm.complainantBusinessPhone.value = "";
		inForm.complainantBusinessExtn.value = "";
		inForm.complainantMobile.value = "";
		inForm.complainantFax.value = "";
		inForm.complainantEmail.value = "";

		/*if(returnedArray[9] != 'null')
		{*/
			inForm.complainantFirstName.value = returnedArray[9];
			inForm.complainantLastName.value = returnedArray[10];
			inForm.complainantMiddleName.value = returnedArray[11];
			if(returnedArray[12] != "")
			{
				for(var i =1 ;i<inForm.complainantSuffix.options.length;i++)
				{
				var value1 = inForm.complainantSuffix.options[i].value.toUpperCase();
				var value2 = returnedArray[12].toUpperCase();
				//alert("Value in drop down= "+value1);
				//alert("Returned Value = "+value2);
				if(value1 == value2)
					{
					//alert("Option matching is "+i);
					inForm.complainantSuffix.options[i].selected= true;
					break;
					}
				}
			}
			//inForm.complainantSuffix.value = returnedArray[12];
			inForm.complainantBusinessName.value = returnedArray[13];
			inForm.complainantBusinessAddress1.value = returnedArray[14];
			inForm.complainantBusinessAddress2.value =  returnedArray[15];
			inForm.complainantBusinessCity.value = returnedArray[17];
			if(returnedArray[16] != "")
				inForm.complainantBusinessState.value = returnedArray[16];
			inForm.complainantBusinessZip.value =  returnedArray[18];
			inForm.complainantBusinessPhone.value =  returnedArray[19];
			inForm.complainantBusinessExtn.value = returnedArray[20];
			inForm.complainantMobile.value = returnedArray[27];
			inForm.complainantFax.value = returnedArray[28];
			inForm.complainantEmail.value =  returnedArray[29];
			inForm.complainantLicenseName.value = returnedArray[30];
			inForm.complainantLicenseStatus.value = returnedArray[32];
			 //Complainant Type is set as Licensee as the complainant is selected from the existing licensee's
			inForm.complainantType.value = "1803";

	//	}
	}
}

function getDataFromSearchLicenseNumberForm(inForm)
{


	var arrParam = new Array();
	//arrParam[0] = "/shared/common/pageSearchLicenseNumber.jsp";
    arrParam[0] = "/shared/common/pageSearchLicensee.jsp";

	var returnedArray = window.showModalDialog('/showLicenseNumberSearchForm.do?showBusinessOption=1', arrParam, 'dialogHeight:650px;dialogWidth:830px;scroll:no;status:no');
	if(returnedArray !=null)
	{
		var rowDataLength = returnedArray.length;


		inForm.licensenumber.value = returnedArray[7];
		inForm.licId.value = returnedArray[8];

		inForm.licenseefirstname.value = "";
		inForm.licenseelastname.value = "";
		inForm.licenseeaddressline1.value = "";
		inForm.licenseeaddressline2.value = "";
		inForm.licenseecity.value = "";
		inForm.licenseezip.value = "";
		inForm.licenseestate.value = "";
    	inForm.licenseebusinessname.value = "";
	    inForm.licenseefirstname.disabled = true;
		inForm.licenseelastname.disabled = true;
		inForm.licenseebusinessname.disabled = true;


		if(returnedArray[9] != 'null')
		{


			inForm.licenseefirstname.value = returnedArray[9];
			inForm.licenseelastname.value = returnedArray[10];
			inForm.rdbSelectDetailType[0].checked = true;
            inForm.licenseeaddressline1.value = returnedArray[11];
			inForm.licenseeaddressline2.value = returnedArray[12];
			inForm.licenseecity.value = returnedArray[13];
            if(inForm.licenseespecialityarea)
                inForm.licenseespecialityarea.disabled = true;

            if(returnedArray[14] !='null')
            {
               inForm.licenseezip.value = returnedArray[14];
            }

			if(returnedArray[15] !='null')
            {
 		       inForm.licenseestate.value = returnedArray[15];
			}

			if(returnedArray[15] =="")
            {
				inForm.licenseestate[0].selected = true;
            }

 		    inForm.licensename.value = returnedArray[16];
  	        inForm.licenseefirstname.disabled = false;
  	        inForm.licenseemiddlename.disabled = false;
			inForm.licenseelastname.disabled = false;
			if(returnedArray[18] != 'null')
			{
				inForm.licenseemiddlename.value = returnedArray[18];
			}
			if(returnedArray[19] != 'null')
			{
				inForm.licenseeemail.value = returnedArray[19];
			}
		}

		else
		{

        	inForm.licenseebusinessname.value = returnedArray[4];
			inForm.licenseeaddressline1.value = returnedArray[11];
			inForm.licenseeaddressline2.value = returnedArray[12];
			inForm.licenseecity.value = returnedArray[13];

			if(returnedArray[14] !='null')
            {
			   inForm.licenseezip.value = returnedArray[14];
            }

			if(returnedArray[15] !='null')
            {
 				inForm.licenseestate.value = returnedArray[15];
            }

          	if(returnedArray[15] =="")
            {
				inForm.licenseestate[0].selected = true;
            }

 		    inForm.licensename.value = returnedArray[16];
			inForm.licenseebusinessname.disabled = false;
            if(inForm.licenseespecialityarea)
                inForm.licenseespecialityarea.disabled = false;
			inForm.rdbSelectDetailType[1].checked = true;
		}
	}
}


function getDataFromSearchLicenseNumberFormForPublicSite(inForm)
{

	var arrParam = new Array();
	//arrParam[0] = "/shared/common/pageSearchLicenseNumber.jsp";
    arrParam[0] = "/shared/common/pageSearchLicensee.jsp";

	var returnedArray = window.showModalDialog('/showLicenseNumberSearchForm.do?showBusinessOption=1', arrParam, 'dialogHeight:650px;dialogWidth:830px;scroll:no;status:no');
	if(returnedArray !=null)
	{
		var rowDataLength = returnedArray.length;


		inForm.licensenumber.value = returnedArray[7];
		inForm.licId.value = returnedArray[8];

		inForm.licenseefirstname.value = "";
		inForm.licenseelastname.value = "";
		inForm.licenseemiddlename.value = "";
//		inForm.licenseeaddressline1.value = "";
//		inForm.licenseeaddressline2.value = "";
		inForm.licenseecity.value = "";
		inForm.licenseezip.value = "";
		inForm.licenseestate.value = "";
    	inForm.licenseebusinessname.value = "";
	    inForm.licenseefirstname.disabled = true;
		inForm.licenseelastname.disabled = true;
		inForm.licenseemiddlename.disabled = true;
		inForm.licenseebusinessname.disabled = true;


		if(returnedArray[9] != 'null')
		{


			inForm.licenseefirstname.value = returnedArray[9];
			inForm.licenseelastname.value = returnedArray[10];
			if(returnedArray[18] != 'null')
			{
				inForm.licenseemiddlename.value = returnedArray[18];
			}

			inForm.rdbSelectDetailType[0].checked = true;
            inForm.licenseeaddressline1.value = returnedArray[11];
			inForm.licenseeaddressline2.value = returnedArray[12];
			inForm.licenseecity.value = returnedArray[13];
            if(inForm.licenseespecialityarea)
                inForm.licenseespecialityarea.disabled = true;

            if(returnedArray[14] !='null')
            {
               inForm.licenseezip.value = returnedArray[14];
            }

			if(returnedArray[15] !='null')
            {
 		       inForm.licenseestate.value = returnedArray[15];
			}

			if(returnedArray[15] =="")
            {
				inForm.licenseestate[0].selected = true;
            }

 		    inForm.licensename.value = returnedArray[16];
  	        inForm.licenseefirstname.disabled = false;
			inForm.licenseelastname.disabled = false;
			inForm.licenseemiddlename.disabled = false;


		}

		else
		{

        	inForm.licenseebusinessname.value = returnedArray[4];
//			inForm.licenseeaddressline1.value = returnedArray[11];
//			inForm.licenseeaddressline2.value = returnedArray[12];
			inForm.licenseecity.value = returnedArray[13];

			if(returnedArray[14] !='null')
            {
			   inForm.licenseezip.value = returnedArray[14];
            }

			if(returnedArray[15] !='null')
            {
 				inForm.licenseestate.value = returnedArray[15];
            }

          	if(returnedArray[15] =="")
            {
				inForm.licenseestate[0].selected = true;
            }

 		    inForm.licensename.value = returnedArray[16];
			inForm.licenseebusinessname.disabled = false;
            if(inForm.licenseespecialityarea)
                inForm.licenseespecialityarea.disabled = false;
			inForm.rdbSelectDetailType[1].checked = true;
		}
	}
}

function validateAddRespondentOperationForPublicSite(inForm)
{

	var trRef,sumTableSize;

	sumtableSize=document.all.licenseeDetails.rows.length-2;
	if(parseInt(sumtableSize) > 0)
	{
		for(i=2;i<document.all.licenseeDetails.rows.length;i++)
		{
			trRef=document.all.licenseeDetails.rows(i);
            if(trRef.cells(3).children(1).children(0).value != '')
            {
    			if(trRef.cells(3).children(1).children(0).value == inForm.licensenumber.value)
    			{
    				alert("Repondent already added.");
    				inForm.licensename.value="";
    				inForm.licensenumber.value = "";
    				inForm.licenseefirstname.value = "";
    				inForm.licenseelastname.value = "";
    				inForm.licenseebusinessname.value = "";
//    				inForm.licenseeaddressline1.value = "";
//    				inForm.licenseeaddressline2.value = "";
    				inForm.licenseecity.value = "";
    				inForm.licenseestate.value = "";
    				inForm.licenseezip.value = "";
    				return false;
    			}
            }
		}
	}


	if(inForm.licensename != null && inForm.licensename.options[0].selected)
	{
		alert("License name is mandatory.");
		inForm.licensename.focus();
		return false;
	}
//	if(inForm.rdbSelectDetailType != null && inForm.rdbSelectDetailType[0].checked && inForm.licenseefirstname.value=="")
//	{
//		alert("Candidate first name is mandatory.");
//		inForm.licenseefirstname.focus();
//		return false;
//	}
//	if(inForm.rdbSelectDetailType != null && inForm.rdbSelectDetailType[0].checked && inForm.licenseelastname.value=="")
//	{
//		alert("Candidate last name is mandatory.");
//		inForm.licenseelastname.focus();
//		return false;
//	}
	if(inForm.licensenumber.value == "" && inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "" && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value for License Number and First Name / Last Name or Business Name.");
		inForm.licensenumber.focus();
		return false;
	}
	if((inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "")  && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value either for First Name/Last Name or Business Name.");
		return false;
	}
	if(inForm.licenseezip.value!="")
	{
		if(!validateZIP(inForm.licenseezip))
		{
			inForm.licenseezip.focus();
			return false;
		}
	}

	populateLicenseeDetailTableForPublicSite(inForm);

	return true;

}

function populateLicenseeDetailTableForPublicSite(inForm)
{
	var trRef,sumTableSize,newRow,newCell;

    trRef=document.all.refLicenseeDetailTable.rows(document.all.refLicenseeDetailTable.rows.length-1);

	sumtableSize=document.all.licenseeDetails.rows.length;
	newRow=document.all.licenseeDetails.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newRow.className="rowcolor";


	newRow.rowId = sumtableSize;

	//RadioButton
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newRow.cells(0).align = "left";
	newRow.cells(0).valign = "top";
	newRow.cells(0).className = "fieldlabel";

	//License Name
    newCell=newRow.insertCell();
    newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
    newRow.cells(1).children(0).innerText = returnSelectedTextInCombo(complaintForm.licensename, complaintForm.licensename.value)

    //Respondant Name
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	if(complaintForm.rdbSelectDetailType[0].checked)
		newRow.cells(2).children(0).innerText = complaintForm.licenseefirstname.value+ " " + complaintForm.licenseemiddlename.value + " "+ complaintForm.licenseelastname.value;
	else
		newRow.cells(2).children(0).innerText = complaintForm.licenseebusinessname.value;
	newCell.children(1).children(0).value = complaintForm.licensename.value
	newCell.children(1).children(0).name = "licensenames";
	newRow.cells(2).align = "left";
	newRow.cells(2).valign = "top";
	newRow.cells(2).className = "fieldlabel";

	//License Number
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(3).innerHTML);
	newRow.cells(3).children(0).innerText = complaintForm.licensenumber.value;
	newCell.children(1).children(0).value = complaintForm.licensenumber.value;
	newCell.children(1).children(0).name = "licensenumbers";
	newRow.cells(3).align = "left";
	newRow.cells(3).valign = "top";
	newRow.cells(3).className = "fieldlabel";

//  Business Details (Speciality Area)
    //newCell=newRow.insertCell();
    //newCell.insertAdjacentHTML("AfterBegin",trRef.cells(4).innerHTML);
    //if(returnSelectedTextInCombo(complaintForm.licenseespecialityarea, complaintForm.licenseespecialityarea.value) != '- Select -')
    //{
    //    newRow.cells(4).children(0).innerText = returnSelectedTextInCombo(complaintForm.licenseespecialityarea, complaintForm.licenseespecialityarea.value)
    //}

	//Address Details
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(4).innerHTML);

//	newRow.cells(4).children(0).innerText = complaintForm.licenseeaddressline1.value+" "+complaintForm.licenseeaddressline2.value+" "+complaintForm.licenseecity.value+" "+complaintForm.licenseestate.value+" "+complaintForm.licenseezip.value;
	newRow.cells(4).children(0).innerText = complaintForm.licenseecity.value+" "+complaintForm.licenseestate.value+" "+complaintForm.licenseezip.value;

	newCell.children(1).children(0).value = complaintForm.licenseefirstname.value;
	newCell.children(1).children(0).name = "licenseefirstnames";
	newCell.children(1).children(1).value = complaintForm.licenseelastname.value;
	newCell.children(1).children(1).name = "licenseelastnames";
	newCell.children(1).children(2).value = complaintForm.licenseebusinessname.value;
	newCell.children(1).children(2).name = "licenseebusinessnames";
	//newCell.children(1).children(3).value = complaintForm.licenseespecialityarea.value;
	newCell.children(1).children(3).name = "licenseespecialityareas";


	if(complaintForm.rdbSelectDetailType[0].checked)
		newCell.children(1).children(4).value = "candidate";
	else
		newCell.children(1).children(4).value = "business";

	newCell.children(1).children(4).name = "isCandidateOrbusiness";
	newCell.children(1).children(5).value = complaintForm.licenseeaddressline1.value;
	newCell.children(1).children(5).name = "licenseeaddressline1s";
	newCell.children(1).children(6).value = complaintForm.licenseeaddressline2.value;
	newCell.children(1).children(6).name = "licenseeaddressline2s";
	newCell.children(1).children(7).value = complaintForm.licenseecity.value;
	newCell.children(1).children(7).name = "licenseecitys";
	newCell.children(1).children(8).value = complaintForm.licenseestate.value;
	newCell.children(1).children(8).name = "licenseestates";
	newCell.children(1).children(9).value = complaintForm.licenseezip.value;
	newCell.children(1).children(9).name = "licenseezips";

	newCell.children(1).children(10).value = complaintForm.licId.value;
	newCell.children(1).children(10).name = "licenseId";

	newCell.children(1).children(11).name = "licenseemiddlenames";
	newCell.children(1).children(11).value = complaintForm.licenseemiddlename.value;


	newRow.cells(3).align = "left";
	newRow.cells(3).valign = "top";
	newRow.cells(3).className = "fieldlabel";

	emptyLicenseeDetailFormForPublicSite(inForm);

}

function deleteLicenseeRecordForPublicSite(inForm)
{
	for(i=document.all.licenseeDetails.rows.length-3;i>=0;i--)
	{
		if(inForm.chkLicenseeDetail[i].checked)
		{
			document.all.licenseeDetails.deleteRow(i+2);
		}
	}

}
function submitSendCorrespondence(oForm)
{
	if(oForm.email[0].checked)
	{
		continueToPrintQueue(oForm);
	}
	else if(oForm.email[1].checked)
	{
		oForm.submit();
	}
}
function continueToPrintQueue(oForm)
{
	    oForm.action = "setupAddItemToPrintQueue.do";
	    oForm.target = "_self";
	    oForm.submit();
}
function previewDocument(inForm)
{

	    var arrayForIDs = new Array(inForm.Id.length);
	    var arrayForRespondentIds = new Array(inForm.Id.RespondentIds);
        var arrayForRecipientType = new Array(inForm.recipientType.length);
        var arrayForAttributeValue = new Array();

		var param1 = "";
		var param2 = "";
		var param3 = "";
        if(inForm.Id.length>1)
		{
			for(var i=0;i<inForm.Id.length;i++)
			{
                arrayForIDs[i] = inForm.Id[i].value;
                param1 = param1+"Id=" + inForm.Id[i].value + "&";
		    }
		}
		else
		{
			arrayForIDs[0] = inForm.Id.value;
			param1 = "Id=" + inForm.Id.value + "&";
		}

        if(inForm.RespondentIds.length>1)
		{
			for(var i=0;i<inForm.RespondentIds.length;i++)
			{
                arrayForRespondentIds[i] = inForm.RespondentIds[i].value;
                param1 = param1+"RespondentIds=" + inForm.RespondentIds[i].value + "&";
		    }
		}
		else
		{
			arrayForRespondentIds[0] = inForm.RespondentIds.value;
			param1 = "RespondentIds=" + inForm.RespondentIds.value + "&";
		}

		if(inForm.recipientType.length>1)
		{
				for(var i=0;i<inForm.recipientType.length;i++)
				{
                     arrayForRecipientType[i] = inForm.recipientType[i].value;
                     param2 = param2+"recipientType=" + inForm.recipientType[i].value + "&";
				}
		}
		else
		{
                arrayForRecipientType[0] = inForm.recipientType.value;
                param2 = "recipientType=" + inForm.recipientType.value + "&";
		}

		if(inForm.licenseApplicantId &&  inForm.licenseApplicantId.length>1)
		{
				for(var i=0;i<inForm.licenseApplicantId.length;i++)
				{
                     param2 = param2+"licenseApplicantId=" + inForm.licenseApplicantId[i].value + "&";
				}
		}
		else
		{
                param2 = "licenseApplicantId=" + inForm.licenseApplicantId.value + "&";
		}

		if(inForm.attributeValue == null)
		{
			param3 = param3 + "attributeValue=";
		}

		else if(inForm.attributeValue.length > 0)
		{
			for(var i=0;i<inForm.attributeValue.length;i++)
			{
                 param3 = param3 + "attributeValue=" + inForm.attributeValue[i].value + "&";
			}
		}
		else
		{
			param3 = param3 + "attributeValue=" + inForm.attributeValue.value;
		}


		var param4 = "&templateId="+inForm.templateId.value;
		var param5 = "";
		if(inForm.email[0].checked)
		{
			param5 = "&email="+inForm.email[0].value;
		}
		else if(inForm.email[1].checked)
		{
			param5 = "&email="+inForm.email[1].value;
		}

		var param6 = "&templateType="+inForm.templateType.value;
		var param7 = "&methodToCall="+inForm.methodToCall.value;
		var param8 = "&sendTo=" + inForm.sendTo.value;

		var url = "/licenseprocessing/sendCorrespondence.do?"+param1+param2+param3+param4+param5+param6+param7+param8;
		var height = 550;
		var width = 590;

		inForm.target="new";
		inForm.submit();
		inForm.target="self";
}

function validateSSN(ssnField)
{
    var valid = "0123456789";
    var contents = trim(ssnField.value);
    if (contents != '')
    {

        for (var i=0; i < contents.length; i++)
        {
            temp = "" + contents.substring(i, i+1);
            if (valid.indexOf(temp) == "-1")
            {
                alert("SSN should only be numeric");
                ssnField.value = "";
                ssnField.focus();
                return false;
            }
        }
        if(contents.length != 9)
        {
        	alert("SSN should consist of 9 digits");
        	ssnField.value = "";
        	ssnField.focus();
        	return false;
        }
    }
    return true;
}
function validateSearchComplaintForm(obj)
{
	var inForm = obj.form;
	var monthOfStartDate = 0;
	var yearOfStartDate = 0;
    var monthOfEndDate = 0;
	var yearOfEndDate = 0;
	var startDate;
	var endDate;
	var splitDateForStart;
    var splitDateForEnd;
	var monthRange = 0;
	var yearRange = 0;

    var checkDataGivenForSearch = "false";

	if(searchComplaintForm.licenseName.value != "")
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.licenseNumber.value) != "" && trim(searchComplaintForm.licenseNumber.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.licenseSSN.value) != "" && trim(searchComplaintForm.licenseSSN.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.licenseFirstName.value) != ""  && trim(searchComplaintForm.licenseFirstName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.licenseMiddleName.value) != ""  && trim(searchComplaintForm.licenseMiddleName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.licenseLastName.value) != ""  && trim(searchComplaintForm.licenseLastName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.licenseBusinessName.value) != ""  && trim(searchComplaintForm.licenseBusinessName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}

	if(trim(searchComplaintForm.complaintFirstName.value) != ""  && trim(searchComplaintForm.complaintFirstName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.complaintMiddleName.value) != ""  && trim(searchComplaintForm.complaintMiddleName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.complaintLastName.value) != ""  && trim(searchComplaintForm.complaintLastName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.businessName.value) != "" && trim(searchComplaintForm.businessName.value).length > 0)
	{
         checkDataGivenForSearch = "true";
	}

	if (searchComplaintForm.complaintStatus){
		if(searchComplaintForm.complaintStatus.value != "")
		{
	         checkDataGivenForSearch = "true";
		}
	}

	if(searchComplaintForm.startDate.value != "")
	{
         checkDataGivenForSearch = "true";
	}
	if(searchComplaintForm.endDate.value != "")
	{
         checkDataGivenForSearch = "true";
	}

	if(searchComplaintForm.crStartDate.value != "")
	{
         checkDataGivenForSearch = "true";
	}
	if(searchComplaintForm.crEndDate.value != "")
	{
         checkDataGivenForSearch = "true";
	}

	if(searchComplaintForm.ComplaintRecipt.value != "")
	{
         checkDataGivenForSearch = "true";
	}
	if(searchComplaintForm.complaintChargeType.value != "")
	{
         checkDataGivenForSearch = "true";
	}
	if(searchComplaintForm.investigator.value != "")
	{
         checkDataGivenForSearch = "true";
	}
	if(searchComplaintForm.disposition.value != "")
	{
         checkDataGivenForSearch = "true";
	}


	if(trim(searchComplaintForm.complaintNo.value) != "" && trim(searchComplaintForm.complaintNo.value).length > 0)
	{
	    if(isNotNumeric(trim(searchComplaintForm.complaintNo.value)))
	    {
	        alert("Can enter only numbers in Complaint Number field");
	        return false;
	    }

        checkDataGivenForSearch = "true";
	}
	if(trim(searchComplaintForm.stipulationNo.value) != "" && trim(searchComplaintForm.stipulationNo.value).length > 0)
	{
	    if(isNotNumeric(trim(searchComplaintForm.stipulationNo.value)))
	    {
	        alert("Can enter only numbers in Stipulation Number field");
	        return false;
	    }

        checkDataGivenForSearch = "true";
	}

	if(trim(searchComplaintForm.licenseSSN.value) != "" && trim(searchComplaintForm.licenseSSN.value).length > 0)
	{
		return validateSSN(searchComplaintForm.licenseSSN);
	}
	if(trim(searchComplaintForm.complaintSSN.value) != "" && trim(searchComplaintForm.complaintSSN.value).length > 0)
	{
		return validateSSN(searchComplaintForm.complaintSSN);
	}
    if(checkDataGivenForSearch != "true")
	{
       alert("Please enter or select atleast one criteria to search");
	   return false;
	}
	if(searchComplaintForm.startDate.value != "" && searchComplaintForm.endDate.value == "")
	{
        alert("Enter Complaint Entered End Date");
		return false;
	}
    if(searchComplaintForm.startDate.value == "" && searchComplaintForm.endDate.value != "")
	{
        alert("Enter Complaint Entered Start Date");
		return false;
	}
	if(searchComplaintForm.crStartDate.value != "" && searchComplaintForm.crEndDate.value == "")
	{
        alert("Enter Complaint Recieved End Date");
		return false;
	}
    if(searchComplaintForm.crStartDate.value == "" && searchComplaintForm.crEndDate.value != "")
	{
        alert("Enter Complaint Recieved Start Date");
		return false;
	}
	if(Date.parse(searchComplaintForm.startDate.value) > Date.parse(searchComplaintForm.endDate.value))
	{
        alert("Complaint Entered Start Date Cannot Exceed Complaint Entered End Date");
		return false;
	}
	if(Date.parse(searchComplaintForm.crStartDate.value) > Date.parse(searchComplaintForm.crEndDate.value))
	{
        alert("Complaint Recieved Start Date Cannot Exceed Complaint Recieved End Date");
		return false;
	}

}

function setRespondentName(inForm)
{
    var options = inForm.respondents.options;
    var text = options[options.selectedIndex].text;
    inForm.respondentName.value = text;
}

function loadDynamicAtrributesForTemplate(obj)
{
	var inForm = obj;
	var templateId = inForm.templateId.value;

	var tblLength = document.all.testTable.rows.length;
	var foundOneAttribute = false;

	deleteRowsInDymanicFieldTable(document.all.dynamicFieldTbl);
	for(i=0;i<tblLength;i++)
	{
		var trRef=document.all.testTable.rows(i);
		if(trRef.cells(0).innerText == templateId)
		{
			foundOneAttribute = true;
			var attributeRowRef = document.all.hdnTemplateAttRowTbl.rows(0);
			var dynamicFieldTblLen = document.all.dynamicFieldTbl.rows.length;
			var newRow=document.all.dynamicFieldTbl.insertRow(dynamicFieldTblLen);

			newRow.style.backgroundColor = trRef.style.backgroundColor;

			newRow.rowId = dynamicFieldTblLen;

			// Setting the Attribute Id
			newCell=newRow.insertCell();
			newCell.insertAdjacentHTML("AfterBegin",attributeRowRef.cells(0).innerHTML);
			newRow.cells(0).children(0).value=trRef.cells(1).innerText;
			newRow.cells(0).align = "left";
			newRow.cells(0).valign = "top";
			newRow.cells(0).className = "fieldlabel";
			newRow.cells(0).width = "15";


			// Setting Attribute Name
			newCell=newRow.insertCell();
			newCell.insertAdjacentHTML("AfterBegin",attributeRowRef.cells(1).innerHTML);
			newRow.cells(1).innerText = trRef.cells(2).innerText;
			newRow.cells(1).align = "left";
			newRow.cells(1).valign = "top";
			newRow.cells(1).className = "fieldlabel";
			newRow.cells(1).width = "1%";

			// Setting Attribute Type
			newCell=newRow.insertCell();
			newCell.insertAdjacentHTML("AfterBegin",attributeRowRef.cells(2).innerHTML);
			newRow.cells(2).innerHTML= trRef.cells(5).innerHTML;
			newRow.cells(2).align = "left";
			newRow.cells(2).valign = "top";
			newRow.cells(2).className = "fieldlabel";
			newRow.cells(1).width = "30%";

		}
	}

	if(foundOneAttribute)
	{
		document.all.dynamicFieldTbl.style.display="";
		if(!inForm.email[1].checked)
		{
			//inForm.Preview.disabled=false;
		}
		//inForm.Submit.disabled=false;
	}
	else
	{
		document.all.dynamicFieldTbl.style.display="none";
		//inForm.Preview.disabled=true;
		//inForm.Submit.disabled=true;
	}
	if(inForm.templateId.value != "")
	{
		inForm.Submit.disabled=false;
		if(!inForm.email[1].checked)
		{
			inForm.Preview.disabled=false;
		}
	}else
	{
		inForm.Submit.disabled=true;
		inForm.Preview.disabled=true;
	}

}

function deleteRowsInDymanicFieldTable(tblObj)
{
	var rowLength = tblObj.rows.length;
	for(i=(rowLength-1);i>=1;i--)
	{
		tblObj.deleteRow(i);
	}
}

function enableDisableEmailOption(inForm)
{
	//	var inForm = obj.form;
	var sentTo = inForm.sendTo.value;

	if(inForm.emailAddress && inForm.emailAddress.length)

	{
		if(inForm.emailAddress[sentTo].value == "")
		{
			document.all.emailRow.style.display="none";
			//inForm.email[0].checked=true;
		}
		else
		{
			document.all.emailRow.style.display="";
			//inForm.email[0].checked=false;
		}
	}
	else
	{
		if(inForm.emailAddress && inForm.emailAddress.value == "")
		{
			document.all.emailRow.style.display="none";

			//inForm.email[0].checked=true;
		}
		else
		{
			document.all.emailRow.style.display="";
			//inForm.email[0].checked=false;
		}

	}

}

function addComplaintNotes(inForm)
{

	if(trim(inForm.complaintNotesArea.value) == "")
	{
		alert(sGlobalMessageArr[ MSG_ENTER_COMPLAINT_NOTE ]);
		inForm.complaintNotesArea.focus();
		return false;
	}

	if(inForm.complaintNotesArea.value.length > 4000)
	{
		alert('Complaint notes exceeded desired limit of 4000');
	}

	populateComplaintNotesTable(inForm);
	return true;
}

function removeComplaintNotes(inForm)
{
	if(inForm.chkComplaintNote.length)
	{
		for(var i=0;i<inForm.chkComplaintNote.length;i++)
		{

			if(inForm.chkComplaintNote[i].checked)
			{
				var row = document.all.item(inForm.chkComplaintNote[i].value);
				row.cells(1).children(0).children(3).value = "D";
				row.style.display = "none";
			}
		}
	}
}

function addComment(inForm)
{
	if(inForm.relatedto.value == "")
	{
		alert(sGlobalMessageArr[ MSG_ENTER_RELATED_TO ]);
		inForm.relatedto.focus();
		return false;
	}

	if(trim(inForm.progressNotes.value) == "")
	{
		alert(sGlobalMessageArr[ MSG_ENTER_PROGRESS_NOTE ]);
		inForm.progressNotes.focus();
		return false;
	}

	populateCommentsTable(inForm);
	return true;
}

function removeComment(inForm)
{
	if(inForm.chkComment.length)
	{
		for(var i=0;i<inForm.chkComment.length;i++)
		{

			if(inForm.chkComment[i].checked)
			{
				var row = document.all.item(inForm.chkComment[i].value);
				row.cells(1).children(0).children(3).value = "D";
				row.style.display = "none";
			}
		}
	}
}

function populateComplaintNotesTable(inForm)
{
	var trRef,sumTableSize,newRow,newCell;
    trRef=document.all.refComplaintNotesTable.rows(document.all.refComplaintNotesTable.rows.length-1);
	sumtableSize=document.all.complaintNotesDetails.rows.length;
	var newId = - (sumtableSize);

	var operation = "I";

	newRow=document.all.complaintNotesDetails.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newRow.className="rowcolor";

	newRow.id = newId;

	//first TD
	newCell=newRow.insertCell();
	newCell.style.width = "2%";

	//CheckBox and Comments
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);

	newCell.children(0).children(0).value = newId;
    newCell.children(0).children(1).id = "complaintNoteID";
	newCell.children(0).children(1).name = "complaintNoteID";
	newCell.children(0).children(1).value = newId;

	newCell.children(0).children(2).id = "complaintNotes";
	newCell.children(0).children(2).name = "complaintNotes";
	newCell.children(0).children(2).value = inForm.complaintNotesArea.value;

	newCell.children(0).children(3).id = "complaintNoteOperation";
	newCell.children(0).children(3).name = "complaintNoteOperation";
	newCell.children(0).children(3).value = operation;

	newCell=newRow.insertCell();

	newCell.innerHTML = inForm.currentDateValue.value;

	newCell=newRow.insertCell();
	newCell.innerHTML = inForm.complaintNotesArea.value;

	newRow.cells(1).align = "left";
	newRow.cells(1).valign = "top";
	newRow.cells(1).className = "fieldlabel";

	inForm.complaintNotesArea.value = "";

}

function populateCommentsTable(inForm)
{
	var trRef,sumTableSize,newRow,newCell;
    trRef=document.all.refCommentsTable.rows(document.all.refCommentsTable.rows.length-1);
	sumtableSize=document.all.commentDetails.rows.length;
	var newId = - (sumtableSize);

	var operation = "I";

	newRow=document.all.commentDetails.insertRow(sumtableSize);
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newRow.className="rowcolor";

	newRow.id = newId;

	//first TD
	newCell=newRow.insertCell();
	newCell.style.width = "2%";

	//CheckBox and Comments
	newCell=newRow.insertCell();
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);

	newCell.children(0).children(0).value = newId;
    newCell.children(0).children(1).id = "commentID";
	newCell.children(0).children(1).name = "commentID";
	newCell.children(0).children(1).value = newId;

	newCell.children(0).children(2).id = "comments";
	newCell.children(0).children(2).name = "comments";
	newCell.children(0).children(2).value = inForm.progressNotes.value;

	newCell.children(0).children(3).id = "commentOperation";
	newCell.children(0).children(3).name = "commentOperation";
	newCell.children(0).children(3).value = operation;

	newCell.children(0).children(4).id = "relatedToValue";
	newCell.children(0).children(4).name = "relatedToValue";
	newCell.children(0).children(4).value = inForm.relatedto.options[inForm.relatedto.selectedIndex].value;

	newCell.children(0).children(5).id = "commentsDate";
	newCell.children(0).children(5).name = "commentsDate";
	newCell.children(0).children(5).value = '';

	newCell=newRow.insertCell();
	newCell.innerHTML = document.getElementById("commentDate").value;

	newCell=newRow.insertCell();

	newCell.innerHTML = inForm.relatedto.options[inForm.relatedto.selectedIndex].innerHTML;

	newCell=newRow.insertCell();
	newCell.innerHTML = inForm.progressNotes.value;

	newRow.cells(1).align = "left";
	newRow.cells(1).valign = "top";
	newRow.cells(1).className = "fieldlabel";

	inForm.progressNotes.value = "";

}

function validateUpdateRespondentDetails(inForm)
{
//    if(inForm.respondentDate && inForm.respondentDate.value == "")
//    {
//		alert("Respondent Date is mandatory.");
//		inForm.respondentDate.focus();
//		return false;
//    }
//
//	if(inForm.status != null && inForm.status != 'undefined')
//	{
//		if(inForm.status.value == "")
//		{
//			alert("Investigation Status is mandatory.");
//			inForm.status.focus();
//			return false;
//		}
//	}
//
//	if(trim(inForm.respondentSummary.value) == "")
//	{
//		alert("Respondent summary is mandatory.");
//		inForm.respondentSummary.focus();
//		return false;
//	}

	if (inForm.respondentEmail) {
		if(trim(inForm.respondentEmail.value) != "")
		{
			var email = inForm.respondentEmail.value;
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (!filter.test(email)) {
				alert("Please enter a valid email address.");
				inForm.respondentEmail.select();
				inForm.respondentEmail.focus();
				return false;
			}
		}
	}

	if(inForm.chkRespondentDisciplinaryAction.checked)
	{
		inForm.chkRespondentDisciplinaryActionValue.value = 1;
	}
	else
	{
		inForm.chkRespondentDisciplinaryActionValue.value = 0;
	}

    if(null != inForm.isdocumentpublic && inForm.isdocumentpublic != 'undefined')
    {
		for(i=0;i<inForm.isdocumentpublic.length;i++)
		{
			if(inForm.isdocumentpublic[i].checked)
			{

				inForm.isDocumentPublic[i].value= "1";
			}
			else
			{
				inForm.isDocumentPublic[i].value= "0";
			}
		}
    }

    if(null != inForm.isdisciplinarydocument && inForm.isdisciplinarydocument != 'undefined')
    {
    	for(i=0;i<inForm.isdisciplinarydocument.length;i++)
		{
			if(inForm.isdisciplinarydocument[i].checked)
			{
				inForm.isDisciplinaryDocument[i].value= "1";
			}
			else
			{
				inForm.isDisciplinaryDocument[i].value= "0";
			}
		}
    }

    if(null != inForm.isfinaldisciplinarydocument && inForm.isfinaldisciplinarydocument != 'undefined')
    {
		for(i=0;i<inForm.isfinaldisciplinarydocument.length;i++)
		{
			if(inForm.isfinaldisciplinarydocument[i].checked)
			{
				inForm.isFinalDisciplinaryDocument[i].value= "1";
			}
			else
			{
				inForm.isFinalDisciplinaryDocument[i].value= "0";
			}
		}
    }

	if(inForm.chkUpdateAddress.value == 1)
	{
		if(inForm.indResAddress1.value == "")
		{
			alert("Enter the Address1");
			inForm.indResAddress1.focus();
			return false;
		}
		if(inForm.indResCity.value == "")
		{
			alert("Enter the city");
			inForm.indResCity.focus();
			return false;
		}

		if(inForm.indResCountryNew.value == "")
		{
			alert("Select the Country");
			inForm.indResCountryNew.focus();
			return false;
		}

		if(inForm.indResZipCode.value == "")
		{
			alert("Enter the Zip");
			inForm.indResZipCode.focus();
			return false;
		}
	   if(inForm.indResCountryNew.value == "US")
		{
			if(inForm.indResStateNew.value == "")
			{
				alert("Select the state");
				inForm.indResStateNew.focus();
				return false;
			}
		}

		if(inForm.indResZipCode.value != "")
		{
			flag = validateZIP(inForm.indResZipCode);
			if(!flag)
			{
				inForm.indResZipCode.value= "";
				inForm.indResZipCode.focus();
				return false;
			}
		}

		if(inForm.indResHomePhone.value != "")
		{
			flag = checkInternationalPhone(inForm.indResHomePhone.value)
			if(!flag)
			{
				alert("Please enter a valid phone number");
				inForm.indResHomePhone.value= "";
				inForm.indResHomePhone.focus();
				return false;
			}
		}

		if(inForm.indMobileNo.value != "")
		{
			flag = checkInternationalPhone(inForm.indMobileNo.value)
			if(!flag)
			{
				alert("Please enter a valid mobile number");
				inForm.indMobileNo.value= "";
				inForm.indMobileNo.focus();
				return false;
			}
		}

		if(inForm.indFaxNo.value != "")
		{
			flag = checkInternationalPhone(inForm.indFaxNo.value)
			if(!flag)
			{
				alert("Please enter a valid fax number");
				inForm.indFaxNo.value= "";
				inForm.indFaxNo.focus();
				return false;
			}
		}


	}
	SelectAllFromList(inForm.selectedComplaintType);
	SelectAllFromList(inForm.selectedRespondentSubStatus);
	inForm.submit();
    return true;

}

function County(name)
{
    this.name = name;
}

function State(stateName, countyList)
{
    this.stateName = stateName;
    this.countyList = countyList;
}

function showSelectedCounty(inForm, countyToBeShown, selectedCounty)
{

       var dummyLength = 0;
       var totalCountyLength = countyToBeShown.length;
       var countyName;
       //
	   do
	   {
	   	   countyName = countyToBeShown.options[dummyLength].value;

		   if(countyName == selectedCounty)
		   {

			  countyToBeShown.options[dummyLength].selected = true;
			  break;
		    }

		  dummyLength++;

	   }
       while(dummyLength<totalCountyLength );
}

function loadAndSelectCounties(inForm, StateListBox, CountyListBox, StateOther, countyName)
{

	CountyListBox.options.length = 0;
	CountyListBox.options[0] = new Option("- Select -", "");
	var selectedIndex = StateListBox.selectedIndex;

	if (selectedIndex > 0)
	{
		StateOther.value = "";
		StateOther.disabled = true;
		for (i=0;i<countyList[selectedIndex].length;i++)
		{
			j = i+1;
			CountyListBox.options[j] = new Option(countyList[selectedIndex][i], countyList[selectedIndex][i]);
			if(countyName == countyList[selectedIndex][i])
			CountyListBox.options[j].selected = true;
		}
	}
	else
	{

        StateListBox.disabled = true;
        CountyListBox.disabled = true;
        StateOther.disabled = false;
	}
}

function enableState(country,county,state)
{
	  if(country !="US")
	  {
		  county.disabled = true;
		  state.disabled = true;
          //stateOther.disabled = false;
      }
	  else
	  {
		  county.disabled = false;
		  state.disabled = false;
          //stateOther.disabled = true;
	  }

}

function processAddressOption(inForm)
{
	var isChecked = inForm.chkUpdateAddress.checked;
	if(isChecked)
		inForm.chkUpdateAddress.value=1;
	else
		inForm.chkUpdateAddress.value=0;

	inForm.indResAddress1.disabled=!isChecked;
	inForm.indResAddress2.disabled=!isChecked;
	inForm.indResCity.disabled=!isChecked;
	inForm.indResStateNew.disabled=!isChecked;
	inForm.indResZipCode.disabled=!isChecked;
	inForm.indResCounty.disabled=!isChecked;
	inForm.indResCountryNew.disabled=!isChecked;
	inForm.indResHomePhone.disabled=!isChecked;
	inForm.indMobileNo.disabled=!isChecked;

	if(!isChecked)
	{
		inForm.indResAddress1.value="";
		inForm.indResAddress2.value="";
		inForm.indResCity.value="";
		inForm.indResStateNew.value="";
		inForm.indResZipCode.value="";
		inForm.indResCounty.value="";
		inForm.indResCountryNew.value="US";
		inForm.indResHomePhone.value="";
		inForm.indMobileNo.value="";
		//enableState(inForm.indResCountryNew.value,inForm.indResCounty,inForm.indResStateNew)
	}
}

function validateAddRespondentDetails(inForm)
{

	var respondentLicenseNumbers = inForm.respondentLicenseNumbers.value;
	// Truncating the Final "," from the Input String
	respondentLicenseNumbers = respondentLicenseNumbers.substring(0,respondentLicenseNumbers.length-1);
	//alert(respondentLicenseNumbers);

	var inputRespondentLicenseNumbers = respondentLicenseNumbers.split(",");

	for(i=0;i<inputRespondentLicenseNumbers.length;i++)
	{
	    if(inputRespondentLicenseNumbers[i] != '')
        {
            if(inputRespondentLicenseNumbers[i] == inForm.licensenumber.value)
    		{
    			alert("Respondent already added.");
    			inForm.licensename.value="";
    			inForm.licensenumber.value = "";
    			inForm.licenseefirstname.value = "";
    			inForm.licenseemiddlename.value = "";
    			inForm.licenseelastname.value = "";
    			inForm.licenseebusinessname.value = "";
    			inForm.licenseespecialityarea.value = "";
    			inForm.licenseeaddressline1.value = "";
    			inForm.licenseeaddressline2.value = "";
    			inForm.licenseecity.value = "";
    			inForm.licenseestate.value = "";
    			inForm.licenseezip.value = "";
    			return false;
    		}
        }
	}

	if(inForm.licensename != null && inForm.licensename.options[0].selected)
	{
			alert("License name is mandatory.");
			inForm.licensename.focus();
			return false;
	}
	if(inForm.licensenumber.value == "" && inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "" && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value for License Number and First Name / Last Name or Business Name.");
		inForm.licensenumber.focus();
		return false;
	}
	if((inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "")  && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value either for First Name/Last Name or Business Name.");
		return false;
	}

	if(inForm.licenseezip.value!="")
	{
		if(!validateZIP(inForm.licenseezip))
		{
			inForm.licenseezip.focus();
			return false;
		}
	}

	if(inForm.rdbSelectDetailType[0].checked)
		inForm.isCandidateOrbusiness.value = "candidate";
	else
		inForm.isCandidateOrbusiness.value = "business";

	if(inForm.chkRespondentDisciplinaryAction.checked)
	{
		inForm.chkRespondentDisciplinaryActionValue.value = 1;
	}
	else
	{
		inForm.chkRespondentDisciplinaryActionValue.value = 0;
	}

    if(null != inForm.isdocumentpublic && inForm.isdocumentpublic != 'undefined')
    {
		for(i=0;i<inForm.isdocumentpublic.length;i++)
		{
			if(inForm.isdocumentpublic[i].checked)
			{

				inForm.isDocumentPublic[i].value= "1";
			}
			else
			{
				inForm.isDocumentPublic[i].value= "0";
			}
		}
    }

    if(null != inForm.isdisciplinarydocument && inForm.isdisciplinarydocument != 'undefined')
    {
    	for(i=0;i<inForm.isdisciplinarydocument.length;i++)
		{
			if(inForm.isdisciplinarydocument[i].checked)
			{

				inForm.isDisciplinaryDocument[i].value= "1";
			}
			else
			{
				inForm.isDisciplinaryDocument[i].value= "0";
			}
		}
    }

    if(null != inForm.isfinaldisciplinarydocument && inForm.isfinaldisciplinarydocument != 'undefined')
    {
		for(i=0;i<inForm.isfinaldisciplinarydocument.length;i++)
		{
			if(inForm.isfinaldisciplinarydocument[i].checked)
			{

				inForm.isFinalDisciplinaryDocument[i].value= "1";
			}
			else
			{
				inForm.isFinalDisciplinaryDocument[i].value= "0";
			}
		}
    }
	SelectAllFromList(inForm.selectedComplaintType);
	SelectAllFromList(inForm.selectedRespondentSubStatus);

	return true;
}

function enableDisableCheckBoxesForRespondent(obj)
{
//	alert(" row : " + obj.parentElement.parentElement.rowId);
//	alert(" avail chk box : " + obj.parentElement.parentElement.cells(3).children(1).value);
//
//	alert(obj.checked);

	obj.parentElement.parentElement.cells(3).children(0).checked = false;
	obj.parentElement.parentElement.cells(3).children(1).value = 0;
	obj.parentElement.parentElement.cells(5).children(0).checked = false;
	obj.parentElement.parentElement.cells(5).children(1).value = 0;

	if(obj.checked)
	{
		obj.parentElement.parentElement.cells(3).children(0).disabled = false;
		obj.parentElement.parentElement.cells(5).children(0).disabled = false;
	}
	else
	{
		obj.parentElement.parentElement.cells(3).children(0).disabled = true;
		obj.parentElement.parentElement.cells(5).children(0).disabled = true;
	}
}

function enableDisableCheckBoxes(obj)
{
//	alert(" row : " + obj.parentElement.parentElement.rowId);
//	alert(" avail chk box : " + obj.parentElement.parentElement.cells(3).children(1).value);
//
//	alert(obj.checked);

	obj.parentElement.parentElement.cells(4).children(0).checked = false;
	obj.parentElement.parentElement.cells(4).children(1).value = 0;
	obj.parentElement.parentElement.cells(6).children(0).checked = false;
	obj.parentElement.parentElement.cells(6).children(1).value = 0;

	if(obj.checked)
	{
		obj.parentElement.parentElement.cells(4).children(0).disabled = false;
		obj.parentElement.parentElement.cells(6).children(0).disabled = false;
	}
	else
	{
		obj.parentElement.parentElement.cells(4).children(0).disabled = true;
		obj.parentElement.parentElement.cells(6).children(0).disabled = true;
	}
}

function enabledisablePreview(obj)
{

	var inForm = obj;
	if(inForm.email[1].checked)
	{
		document.all.item("Preview").disabled = true;
	}
	else if(inForm.email[0].checked && inForm.templateId.value != "" && !document.all.item("Submit").disabled == true)
	{
		document.all.item("Preview").disabled = false;
	}

}

function showRespondentDetails(inForm, targetForm)
{
	var trRef,sumTableSize, respondentLicenseNumbers;
	respondentLicenseNumbers = "";
	sumtableSize=document.all.licenseeDetails.rows.length-1;
	if(parseInt(sumtableSize) > 0)
	{
		for(i=1;i<document.all.licenseeDetails.rows.length;i++)
		{
			trRef=document.all.licenseeDetails.rows(i);
			respondentLicenseNumbers=respondentLicenseNumbers+trRef.cells(3).children(1).children(0).value+",";
		}
	}
	//alert(respondentLicenseNumbers);
	targetForm.respondentLicenseNumbers.value=respondentLicenseNumbers;
	targetForm.action="/enforcement/setupAddRespondent.do";
	targetForm.submit();
}

function enableStateOnly(country,state)
{

	  if(country !="US")
	  {
		  //county.disabled = true;
		  state.disabled = true;
          // stateOther.disabled = false;
      }
	  else
	  {
		  //county.disabled = false;
		  state.disabled = false;
          // stateOther.disabled = true;
	  }
}

function addWitness(obj)
{
	var inForm = obj.form;

	var trRef,sumTableSize,newRow,newCell;

    var dynamicTable = document.createElement("TABLE");
    var dynamicTableBody = document.createElement("TBODY");
    //dynamicTable.appendChild(dynamicTableBody);

    //var witnessDetailsTableBody = document.all.witnessDetailsTable.getElementsByTagName("TBODY")[0];
    //alert(witnessDetailsTableBody);
    //document.all.witnessDetailsTable.appendChild(witnessDetailsTableBody);

    //witnessDetailsTableBody.appendChild(dynamicTable);

	//table heading
	trRef=document.all.refWitnessTable.rows(0);

	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("beforeEnd",trRef.cells(0).innerHTML);
	//alert(1)
	newCell.colSpan = 4;
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";
	//alert(2)
	dynamicTableBody.appendChild(newRow);

	// First row of the table
	trRef=document.all.refWitnessTable.rows(1);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;
	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(3).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	// Second row of the table
    trRef=document.all.refWitnessTable.rows(2);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(3).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	// Third row of the table
	trRef=document.all.refWitnessTable.rows(3);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.colSpan = 4;
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	// Forth row of the table
	trRef=document.all.refWitnessTable.rows(4);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.colSpan = 4;
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	// Fifth row of the table
	trRef=document.all.refWitnessTable.rows(5);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	newCell.colSpan = 2;
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	// Sixth row of the table
	trRef=document.all.refWitnessTable.rows(6);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(2).innerHTML);
	newCell.colSpan = 2;
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	// Seventh row of the table
	trRef=document.all.refWitnessTable.rows(7);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.colSpan = 3;
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	// Eight row of the table
	trRef=document.all.refWitnessTable.rows(8);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(1).innerHTML);
	newCell.colSpan = 3;
	newCell.align = "left";
	newCell.valign = "top";
	newCell.className = "fieldlabel";

	dynamicTableBody.appendChild(newRow);

	trRef=document.all.refWitnessTable.rows(9);
	// Set the Operation and Id
	//alert(trRef.cells(0).children(0).children.length);
	newRow=document.createElement("TR");
	newRow.style.backgroundColor = trRef.style.backgroundColor;

	newCell=document.createElement("TD");
	newRow.appendChild(newCell);
	newCell.insertAdjacentHTML("AfterBegin",trRef.cells(0).innerHTML);

	newCell.children(0).children(0).name = "witnessId";
	newCell.children(0).children(0).value = "0";
	newCell.children(0).children(1).name = "witnessOperation";
	newCell.children(0).children(1).value = "I";

	dynamicTableBody.appendChild(newRow);



	dynamicTable.appendChild(dynamicTableBody);
    dynamicTable.style.width = "95%";
    dynamicTable.className = "tableborderwithbg";
    //witnessDetailsTableBody.appendChild(dynamicTable);
    //document.all.witnessDetailsTable.appendChild(dynamicTable);

    var witnessDetailsTableBody = document.all.witnessDetailsTable.getElementsByTagName("TBODY")[0];
    var witnessDetailsTableTR = witnessDetailsTableBody.getElementsByTagName("TR")[0];
    var witnessDetailsTableTD = witnessDetailsTableTR.getElementsByTagName("TD")[0];

    //alert(witnessDetailsTableTD.innerHTML);
    witnessDetailsTableTD.appendChild(dynamicTable);
    //alert(witnessDetailsTableTD.innerHTML);

}

////////////////////////////////////////////////
///// added by rishabhj ////////////////////////
////////////////////////////////////////////////
var numbers = '0123456789';
var lower = 'abcdefghijklmnopqrstuvwxyz';
var upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

function isValid(param,val) {
	if (param == "") return true;
	for (i=0; i<param.length; i++) {
		if (val.indexOf(param.charAt(i),0) == -1) return false;
	}
	return true;
}

function showPopUp() {
	var answer = confirm ("Your complaint is not complete and will not be submitted at this time.  Would you like to continue?");
	if (answer) {
		alert ("Your complaint was not submitted.");
		document.forms[0].action = "/index_login.jsp";
		document.forms[0].submit();
	}
	else {
		return false;
	}
}

function changeActionPathAndSubmit(path) {
	document.forms[0].action = path;
	document.forms[0].submit();
}

function validateComplaintFormPersonalInfo(obj) {

	var inForm = obj.form;

	if(inForm.lastName.value == "") {
		alert(getMessageToDisplay(0));
		inForm.lastName.focus();
		return false;
	}

	if(inForm.firstName.value == "") {
		alert(getMessageToDisplay(1));
		inForm.firstName.focus();
		return false;
	}

	if(inForm.address.value == "") {
		alert(getMessageToDisplay(2));
		inForm.address.focus();
		return false;
	}

	if(inForm.city.value == "") {
		alert(getMessageToDisplay(3));
		inForm.city.focus();
		return false;
	}

	if(inForm.state.value == "") {
		alert(getMessageToDisplay(4));
		inForm.state.focus();
		return false;
	}

	 if(inForm.zipCode.value == "") {
		alert(getMessageToDisplay(5));
		inForm.zipCode.focus();
		return false;
	}

	if(inForm.zipCode.value != "")
	{
		flag = validateZIPWithFiveDigits(inForm.zipCode);
		if(!flag)
		{
			inForm.zipCode.value= "";
			inForm.zipCode.focus();
			return false;
		}
	}

	var phone = inForm.phone.value;
	var mobilephone = inForm.mobilephone.value;

	if(phone == "") {
		alert("Please enter the home phone.");
		inForm.phone.focus();
		return false;
	}

	if(phone != "") {
		var isNumerals = isValid(phone, numbers);
		if (!isNumerals) {
			alert("Please enter only numeric characters for the home phone.");
			inForm.phone.value = "";
			inForm.phone.focus();
			return false;
		}
	}

	if(phone != "" && phone.length != 10) {
		alert("Please enter the full home phone.");
			inForm.phone.select();
			inForm.phone.focus();
			return false;
	}


	if(mobilephone != "") {
		var isNumerals = isValid(mobilephone, numbers);
		if (!isNumerals) {
			alert("Please enter only numeric characters for the mobile phone.");
			inForm.mobilephone.value = "";
			inForm.mobilephone.focus();
			return false;
		}
	}

	if(mobilephone != "" && mobilephone.length != 10) {
		alert("Please enter the full mobile phone.");
			inForm.mobilephone.select();
			inForm.mobilephone.focus();
			return false;
	}

	//Added the validation for Review appraiser business phone

	if(inForm.businessPhone){

	var businessphone = inForm.businessPhone.value;
		if(businessphone != "") {
			var isNumerals = isValid(businessphone, numbers);
			if (!isNumerals) {
				alert("Please enter only numeric characters for the business phone.");
				inForm.businessPhone.value = "";
				inForm.businessPhone.focus();
				return false;
			}
		}

		if(businessphone != "" && businessphone.length != 10) {
			alert("Please enter the full business phone.");
				inForm.businessPhone.select();
				inForm.businessPhone.focus();
				return false;
		}
	}

	if(inForm.fax.value != "")
	{
		flag = checkInternationalPhone(inForm.fax.value)
		if(!flag)
		{
			alert("Please enter a valid fax number");
			inForm.fax.value= "";
			inForm.fax.focus();
			return false;
		}
	}

	var email = inForm.emailAddress.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(email)) {
		alert("Please enter a valid email address.");
		inForm.emailAddress.select();
		inForm.emailAddress.focus();
		return false;
	}

	disableObjectAndSubmit(obj);
}

function validateComplaintFormSearchBroker(obj) {

	var inForm = obj.form;

	if (inForm.registrationNumber.value == "" && inForm.lastName.value == "" && inForm.firstName.value == "") {
		alert("Please enter either the Registration number or Last and First names as the search criteria.");
		inForm.registrationNumber.focus();
		return false;
	}

	if (inForm.registrationNumber.value != "") {
		var isSpecialCharacters = isValid(inForm.registrationNumber.value, lower+upper+numbers);
		if (!isSpecialCharacters){
			alert("Please enter only Alpha-Numeric characters.");
			inForm.registrationNumber.value = "";
			inForm.registrationNumber.focus();
			return false;
		}
	}

	disableObjectAndSubmit(obj);
}

function validateComplaintFormSearchResults(obj) {
	var inForm = obj.forms[0];
	var radio = inForm.SelectedLicenseID;

	if (radio) {
	var flag = false;
	    if (radio.length) {
			for (var i = 0; i < radio.length; i++) {
				if (radio[i].checked) {
					flag = true;
					break;
				}
			}
	    }
	    else {
	    	if (radio.checked) {
				flag = true;
			}
	    }
		if (!flag) {
			alert("Please select one person from the results before continuing. Else click the 'None of the above' button.");
			return false;
		}
	}
	disableObjectAndSubmit(obj);
	return true;
}

function enableComplaintFormBrokerDetails(obj) {

	var inForm = obj.form;

	inForm.lastName.disabled = false;
	inForm.firstName.disabled = false;
	inForm.middleName.disabled = false;
	inForm.suffix.disabled = false;

	inForm.address.disabled = false;

	inForm.city.disabled = false;
	inForm.state.disabled = false;
	inForm.zipCode.disabled = false;

	inForm.registrationNumber.disabled = false;

	inForm.phone.disabled = false;
	inForm.fax.disabled = false;
	inForm.emailAddress.disabled = false;

	disableObjectAndSubmit(obj);

}

function validateComplaintFormBrokerDetails(obj) {

	var inForm = obj.form;


	if(inForm.lastName.value == "") {
		alert("Please enter the last name.");
		inForm.lastName.focus();
		return false;
	}

	if(inForm.firstName.value == "") {
		alert("Please enter the first name.");
		inForm.firstName.focus();
		return false;
	}

	/*if(inForm.address.value == "") {
		alert("Please enter the address.");
		inForm.address.focus();
		return false;
	}

	if(inForm.city.value == "") {
		alert("Please enter the city.");
		inForm.city.focus();
		return false;
	}

	if(inForm.state.value == "") {
		alert("Please enter the state.");
		inForm.state.focus();
		return false;
	}

	if(inForm.zipCode.value == "") {
		alert("Please enter the Zip Code.");
		inForm.state.focus();
		return false;
	}*/

	if(inForm.zipCode.value != "")
	{
		flag = validateZIPWithFiveDigits(inForm.zipCode);
		if(!flag)
		{
			inForm.zipCode.value= "";
			inForm.zipCode.focus();
			return false;
		}
	}

	if(inForm.phone.value != "")
	{
		flag = checkInternationalPhone(inForm.phone.value)
		if(!flag)
		{
			alert("Please enter a valid phone number");
			inForm.phone.value= "";
			inForm.phone.focus();
			return false;
		}
	}

	if(inForm.mobilephone.value != "")
	{
		flag = checkInternationalPhone(inForm.mobilephone.value)
		if(!flag)
		{
			alert("Please enter a valid phone number");
			inForm.mobilephone.value= "";
			inForm.mobilephone.focus();
			return false;
		}
	}

	if(inForm.fax.value != "")
	{
		flag = checkInternationalPhone(inForm.fax.value)
		if(!flag)
		{
			alert("Please enter a valid fax number");
			inForm.fax.value= "";
			inForm.fax.focus();
			return false;
		}
	}

	if(inForm.emailAddress.value != "")
	{
		var email = inForm.emailAddress.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(email)) {
			alert("Please enter a valid email address.");
			inForm.emailAddress.select();
			inForm.emailAddress.focus();
			return false;
		}
	}


	disableObjectAndSubmit(obj);
}


/*  Generic function written to limit the textarea characters to given maxLimit
	Author: Janardhana*/

function limitText(objTxtarea, limitNum) {

	var ID = (objTxtarea.id).substring(5);

	var templimitField = objTxtarea.id;

	//To decide whether the 6th letter of Textarea field name is String or Number
	if (isNaN (ID)){
	ID = 0;
	}

	var templimitCount = "countdown"+ID;

	var limitField = document.getElementById(templimitField);
	var limitCount = document.getElementById(templimitCount);

		limitCount.innerHTML = limitField.value.length;
		limitCount.value = limitField.value.length;

}

function limitTextForeclosure(objTxtarea, limitNum, countDisplayField) {

	var templimitField = objTxtarea.name;
	var templimitCount = countDisplayField;
	//alert(templimitCount);

	var limitField = document.getElementById(templimitField);
	var limitCount = document.getElementById(templimitCount);

		limitCount.innerHTML = limitField.value.length;
		limitCount.value = limitField.value.length;
}

function addEventsTable(btn, dateValue, eventValue, countValue) {


	//TODO :replace the children elements with w3c standards
	//btn.disabled = true;
	var eventstable = document.getElementById("eventsTable");

	var eventstableRowCount = document.getElementById("eventsTable").rows.length;
	var atPosition = eventstableRowCount - 2;

	var refRow = document.getElementById("eventRow");

	var newTR = eventstable.insertRow(atPosition);
	var td1, td2;
	//td1 = document.createElement("td");
	//newTR.appendChild(td1);

	td2 = document.createElement("td");
	td2.colSpan="5";
	newTR.appendChild(td2);
	td2.insertAdjacentHTML("AfterBegin",refRow.cells(1).innerHTML);

	if (document.getElementById("noOfEvents").value.length > 0) {
		document.getElementById("noOfEvents").value = parseInt(document.getElementById("noOfEvents").value) + 1;
	} else {
		document.getElementById("noOfEvents").value = 1;
	}
	//TODO: For the addition reason events -- Taking substrings and replacing the datRsn & date
	td2.children(0).rows(0).cells(1).children(0).name = "date" + document.getElementById("noOfEvents").value;
	td2.children(0).rows(1).cells(1).children(0).name = "event" + document.getElementById("noOfEvents").value;

	var tmpScriptInvoke = td2.children(0).rows(0).children(1).innerHTML;
	var tmpScriptInvoke1 = tmpScriptInvoke.substring(0,210);
	var tmpScriptInvoke2 = tmpScriptInvoke.substring(210,tmpScriptInvoke.length);
	tmpScriptInvoke1 = tmpScriptInvoke1.replace(/datRsn/g, "datRsn"+ document.getElementById("noOfEvents").value);
	tmpScriptInvoke1 = tmpScriptInvoke1.replace(/date/g, "date"+ document.getElementById("noOfEvents").value);
	td2.children(0).rows(0).children(1).innerHTML = tmpScriptInvoke1 + tmpScriptInvoke2;

	td2.children(0).rows(0).cells(1).children(0).id = td2.children(0).rows(0).cells(1).children(0).name;
	td2.children(0).rows(1).cells(1).children(0).id = td2.children(0).rows(1).cells(1).children(0).name;

	td2.children(0).rows(2).cells(1).children(0).name = "countdown" + document.getElementById("noOfEvents").value;
	td2.children(0).rows(2).cells(1).children(0).id = "countdown" + document.getElementById("noOfEvents").value;
	td2.children(0).rows(0).cells(1).children(0).value = dateValue;
	td2.children(0).rows(1).cells(1).children(0).value = eventValue;
	td2.children(0).rows(2).cells(1).children(0).innerHTML = countValue;

	document.getElementById("yes").checked = false;
}

function enableSubmitButton(btn) {
	btn.disabled = "";
}

function validateZIPCode(field)
{
	var valid = "0123456789";
	var hyphencount = 0;
	var zipContents = field.value;

	if (zipContents.length!=5 && isNumeric(zipContents))
	{
		alert("Please enter your 5 digit zip code");
		return false;
	}
	for (var i=0; i < zipContents.length; i++)
	{
		temp = "" + zipContents.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_ZIP_CODE]);
			return false;
		}
	}
	return true;
}

function validateRespondent(inForm)
{
	var flag;

	var doc = inForm.document;
	var sectionName = "respondentSection";
	var imageName = "image1";

	if(inForm.respondentLicenseName.selectedIndex == 0)
	{
		alert(sGlobalMessageArr[MSG_SELECT_LICENSE_NAME]);
		expandSection(doc,sectionName,imageName);
		inForm.respondentLicenseName.focus();
		return false;
	}
	if(trim(inForm.respondentFirstName.value) == "")
	{
		alert(sGlobalMessageArr[MSG_ENTER_FIRST_NAME]);
		inForm.respondentFirstName.value = "";
		expandSection(doc,sectionName,imageName);
		inForm.respondentFirstName.focus();
		return false;
	}

	if(trim(inForm.respondentLastName.value) == "")
	{
		alert(sGlobalMessageArr[MSG_ENTER_LAST_NAME]);
		inForm.respondentLastName.value = "";
		expandSection(doc,sectionName,imageName);
		inForm.respondentLastName.focus();
		return false;
	}

	if(trim(inForm.respondentBusinessZip.value) != "")
	{
		if(! validateZIPCode(inForm.respondentBusinessZip))
		{
			inForm.respondentBusinessZip.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentBusinessZip.focus();
			return false;
		}
	}

	if(trim(inForm.respondentBusinessPhone.value) != "")
	{
		if(! checkInternationalPhone(trim(inForm.respondentBusinessPhone.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
			inForm.respondentBusinessPhone.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentBusinessPhone.focus();
			return false;
		}
	}

	if(trim(inForm.respondentBusinessPhone.value) == "" && trim(inForm.respondentBusinessExtn.value) != "")
	{
		alert("Please enter a phone number");
		inForm.respondentBusinessPhone.value = "";
		expandSection(doc,sectionName,imageName);
		inForm.respondentBusinessPhone.focus();
		return false;
	}

	if(trim(inForm.respondentBusinessPhone.value) != "" && trim(inForm.respondentBusinessExtn.value) != "")
	{
		if(! isNumeric(trim(inForm.respondentBusinessExtn.value)))
		{
			alert("Please enter a valid Extension");
			inForm.respondentBusinessExtn.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentBusinessExtn.focus();
			return false;
		}
	}

	if(trim(inForm.respondentHomeZip.value) != "")
	{
		if(! validateZIPCode(inForm.respondentHomeZip))
		{
			inForm.respondentHomeZip.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentHomeZip.focus();
			return false;
		}
	}

	if(trim(inForm.respondentMobile.value) != "")
	{
		if(! checkInternationalPhone(trim(inForm.respondentMobile.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
			inForm.respondentMobile.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentMobile.focus();
			return false;
		}
	}

	if(trim(inForm.respondentHomePhone.value) != "")
	{
		if(! checkInternationalPhone(trim(inForm.respondentHomePhone.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
			inForm.respondentHomePhone.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentHomePhone.focus();
			return false;
		}
	}

	if(trim(inForm.respondentFax.value) != "")
	{
		if(! checkInternationalPhone(trim(inForm.respondentFax.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
			inForm.respondentFax.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentFax.focus();
			return false;
		}
	}

	if(trim(inForm.respondentEmail.value) != "")
	{
		if(! validateEmail(trim(inForm.respondentEmail.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_EMAIL_ADDRESS]);
			inForm.respondentEmail.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.respondentEmail.focus();
			return false;
		}
	}
	return true;
}

function validateComplainant(inForm)
{

	var doc = inForm.document;
	var sectionName = "complainantSection";
	var imageName = "image2";

	if(inForm.complainantType.selectedIndex == 0)
	{
		alert(sGlobalMessageArr[MSG_SELECT_COMPLAINANT_TYPE]);
		expandSection(doc,sectionName,imageName);
		inForm.complainantType.focus();
		return false;
	}

	if(trim(inForm.complainantFirstName.value) == "")
	{
		alert(sGlobalMessageArr[MSG_ENTER_FIRST_NAME]);
		inForm.complainantFirstName.value = "";
		expandSection(doc,sectionName,imageName);
		inForm.complainantFirstName.focus();
		return false;
	}

	if(trim(inForm.complainantLastName.value) == "")
	{
		alert(sGlobalMessageArr[MSG_ENTER_LAST_NAME]);
		inForm.complainantLastName.value = "";
		expandSection(doc,sectionName,imageName);
		inForm.complainantLastName.focus();
		return false;
	}

	if(trim(inForm.complainantBusinessZip.value) != "")
	{
		if(! validateZIPCode(inForm.complainantBusinessZip))
		{
			inForm.complainantBusinessZip.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.complainantBusinessZip.focus();
			return false;
		}
	}

	if(trim(inForm.complainantBusinessPhone.value) != "")
	{
		if(! checkInternationalPhone(trim(inForm.complainantBusinessPhone.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
			inForm.complainantBusinessPhone.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.complainantBusinessPhone.focus();
			return false;
		}
	}

	if(trim(inForm.complainantBusinessPhone.value) == "" && trim(inForm.complainantBusinessExtn.value) != "")
	{
		alert("Please enter a phone number");
		inForm.complainantBusinessPhone.value = "";
		expandSection(doc,sectionName,imageName);
		inForm.complainantBusinessPhone.focus();
		return false;
	}

	if(trim(inForm.complainantBusinessPhone.value) != "" && trim(inForm.complainantBusinessExtn.value) != "")
	{
		if(! isNumeric(trim(inForm.complainantBusinessExtn.value)))
		{
			alert("Please enter a valid Extension");
			inForm.complainantBusinessExtn.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.complainantBusinessExtn.focus();
			return false;
		}
	}

	if(trim(inForm.complainantMobile.value) != "")
	{
		if(! checkInternationalPhone(trim(inForm.complainantMobile.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
			inForm.complainantMobile.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.complainantMobile.focus();
			return false;
		}
	}

	if(trim(inForm.complainantFax.value) != "")
	{
		if(! checkInternationalPhone(trim(inForm.complainantFax.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
			inForm.complainantFax.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.complainantFax.focus();
			return false;
		}
	}

	if(trim(inForm.complainantEmail.value) != "")
	{
		if(! validateEmail(trim(inForm.complainantEmail.value)))
		{
			alert(sGlobalMessageArr[MSG_ENTER_VALID_EMAIL_ADDRESS]);
			inForm.complainantEmail.value = "";
			expandSection(doc,sectionName,imageName);
			inForm.complainantEmail.focus();
			return false;
		}
	}
	return true;
}

function validateAdditionalComplainants(inForm)
{
	var numberOfAdditionalComplainants = document.getElementsByName("addComplainantType").length - 1;

	var doc = inForm.document;
	var sectionName = "additionalcomplaintSection";
	var imageName = "image3";

	if(numberOfAdditionalComplainants >= 1)
	{
		for(var index = 0; index < numberOfAdditionalComplainants; index++)
		{
			if(document.getElementsByName("addComplainantType")[index].parentElement.parentElement.parentElement.parentElement.parentElement.style.display != "none")
			{
				if(document.getElementsByName("addComplainantType")[index].selectedIndex == 0)
				{

					alert(sGlobalMessageArr[MSG_SELECT_COMPLAINANT_TYPE]);
					expandSection(doc,sectionName,imageName);
					inForm.document.getElementsByName("addComplainantType")[index].focus();
					return false;
				}

				if(trim(inForm.addComplainantBusinessZip[index].value) != "")
				{
					if(! validateZIPCode(inForm.addComplainantBusinessZip[index]))
					{
						inForm.addComplainantBusinessZip[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.addComplainantBusinessZip[index].focus();
						return false;
					}
				}

				if(trim(inForm.addComplainantBusinessPhone[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.addComplainantBusinessPhone[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						inForm.addComplainantBusinessPhone[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.addComplainantBusinessPhone[index].focus();
						return false;
					}
				}

				if(trim(inForm.addComplainantBusinessPhone[index].value) == "" && trim(inForm.addComplainantBusinessExtn[index].value) != "")
				{
					alert("Please enter a phone number");
					inForm.addComplainantBusinessPhone[index].value = "";
					expandSection(doc,sectionName,imageName);
					inForm.addComplainantBusinessPhone[index].focus();
					return false;
				}

				if(trim(inForm.addComplainantBusinessPhone[index].value) != "" && trim(inForm.addComplainantBusinessExtn[index].value) != "")
				{
					if(! isNumeric(trim(inForm.addComplainantBusinessExtn[index].value)))
					{
						alert("Please enter a valid Extension");
						inForm.addComplainantBusinessExtn[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.addComplainantBusinessExtn[index].focus();
						return false;
					}
				}

				if(trim(inForm.addComplainantMobile[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.addComplainantMobile[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						inForm.addComplainantMobile[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.addComplainantMobile[index].focus();
						return false;
					}
				}

				if(trim(inForm.addComplainantFax[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.addComplainantFax[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						inForm.addComplainantFax[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.addComplainantFax[index].focus();
						return false;
					}
				}

				if(trim(inForm.addComplainantEmail[index].value) != "")
				{
					if(! validateEmail(trim(inForm.addComplainantEmail[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_EMAIL_ADDRESS]);
						inForm.addComplainantEmail[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.addComplainantEmail[index].focus();
						return false;
					}
				}
			}
		}
	}

	return true;
}

function validateWitnesses(inForm)
{
	var numberOfWitnessZip = document.getElementsByName("witnessBusinessZip").length - 1; //using this field to find number of witnesses

	var doc = inForm.document;
	var sectionName = "witnessSection";
	var imageName = "image4";

	var index = 0;

	if(inForm.witnessBusinessZip.length)
	{
		var numberOfWitnesses = inForm.witnessBusinessZip.length - 1;
		if(numberOfWitnesses >= 1)
		{
			for(index = 0; index < numberOfWitnesses; index++)
			{
				if(trim(inForm.witnessBusinessZip[index].value) != "")
				{
					if(! validateZIPCode(inForm.witnessBusinessZip[index]))
					{
						inForm.witnessBusinessZip[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.witnessBusinessZip[index].focus();
						return false;
					}
				}

				if(trim(inForm.witnessBusinessPhone[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.witnessBusinessPhone[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						inForm.witnessBusinessPhone[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.witnessBusinessPhone[index].focus();
						return false;
					}
				}

				if(trim(inForm.witnessBusinessPhone[index].value) == "" && trim(inForm.witnessBusinessExtn[index].value) != "")
				{
					alert("Please enter a phone number");
					inForm.witnessBusinessPhone[index].value = "";
					expandSection(doc,sectionName,imageName);
					inForm.witnessBusinessPhone[index].focus();
					return false;
				}

				if(trim(inForm.witnessBusinessPhone[index].value) != "" && trim(inForm.witnessBusinessExtn[index].value) != "")
				{
					if(! isNumeric(trim(inForm.witnessBusinessExtn[index].value)))
					{
						alert("Please enter a valid Extension");
						inForm.witnessBusinessExtn[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.witnessBusinessExtn[index].focus();
						return false;
					}
				}

				if(trim(inForm.witnessMobile[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.witnessMobile[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						inForm.witnessMobile[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.witnessMobile[index].focus();
						return false;
					}
				}

				if(trim(inForm.witnessFax[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.witnessFax[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						inForm.witnessFax[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.witnessFax[index].focus();
						return false;
					}
				}

				if(trim(inForm.witnessEmail[index].value) != "")
				{
					if(! validateEmail(trim(inForm.witnessEmail[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_EMAIL_ADDRESS]);
						inForm.witnessEmail[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.witnessEmail[index].focus();
						return false;
					}
				}
			}
		}
	}

	return true;
}

function validateAttorneys(inForm)
{
	var numberOfAttorneyZip = document.getElementsByName("attorneyBusinessZip").length - 1; //using this field to find number of witnesses

	var doc = inForm.document;
	var sectionName = "attorneySection";
	var imageName = "image5";
	var index = 0;

	if(inForm.attorneyBusinessZip.length)
	{
		var numberOfAttorneys = inForm.attorneyBusinessZip.length - 1;
		if(numberOfAttorneys >= 1)
		{
			for(index = 0; index < numberOfAttorneys; index++)
			{
				if(trim(inForm.attorneyBusinessZip[index].value) != "")
				{
					if(! validateZIPCode(inForm.attorneyBusinessZip[index]))
					{
						inForm.attorneyBusinessZip[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.attorneyBusinessZip[index].focus();
						return false;
					}
				}

				if(trim(inForm.attorneyBusinessPhone[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.attorneyBusinessPhone[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						inForm.attorneyBusinessPhone[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.attorneyBusinessPhone[index].focus();
						return false;
					}
				}

				if(trim(inForm.attorneyBusinessPhone[index].value) == "" && trim(inForm.attorneyBusinessExtn[index].value) != "")
				{
					alert("Please enter a phone number");
					inForm.attorneyBusinessPhone[index].value = "";
					expandSection(doc,sectionName,imageName);
					inForm.attorneyBusinessPhone[index].focus();
					return false;
				}

				if(trim(inForm.attorneyBusinessPhone[index].value) != "" && trim(inForm.attorneyBusinessExtn[index].value) != "")
				{
					if(! isNumeric(trim(inForm.attorneyBusinessExtn[index].value)))
					{
						alert("Please enter a valid Extension");
						inForm.attorneyBusinessExtn[index].value = "";
						expandSection(doc,sectionName,imageName);
						inForm.attorneyBusinessExtn[index].focus();
						return false;
					}
				}

				if(trim(inForm.attorneyMobile[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.attorneyMobile[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						expandSection(doc,sectionName,imageName);
						inForm.attorneyMobile[index].value = "";
						inForm.attorneyMobile[index].focus();
						return false;
					}
				}

				if(trim(inForm.attorneyFax[index].value) != "")
				{
					if(! checkInternationalPhone(trim(inForm.attorneyFax[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_PHONE_NUMBER]);
						expandSection(doc,sectionName,imageName);
						inForm.attorneyFax[index].value = "";
						inForm.attorneyFax[index].focus();
						return false;
					}
				}

				if(trim(inForm.attorneyEmail[index].value) != "")
				{
					if(! validateEmail(trim(inForm.attorneyEmail[index].value)))
					{
						alert(sGlobalMessageArr[MSG_ENTER_VALID_EMAIL_ADDRESS]);
						expandSection(doc,sectionName,imageName);
						inForm.attorneyEmail[index].value = "";
						inForm.attorneyEmail[index].focus();
						return false;
					}
				}
			}
		}
	}
	return true;
}

function validateAdminComplaintFormAttorneyInfo(obj) {

	var inForm = obj;
	var doc = inForm.document;
	var sectionName = "attorneySection";
	var imageName = "image5";

	if(inForm.attorneyRefId.length > 1)
	{
		for(i = 0; i < inForm.attorneyRefId.length -1; i++ )
		{
			var attorneyRefIdValue = inForm.attorneyRefId[i].value;
			if(inForm.attorneyFirstName[i].parentElement.parentElement.parentElement.parentElement.parentElement.style.display != "none")
			{
				if(inForm.attorneyFirstName[i].value == "") {
					alert("Please enter the attorney first name.");
					expandSection(doc,sectionName,imageName);
					inForm.attorneyFirstName[i].focus();
					return false;
				}

				if(inForm.attorneyLastName[i].value == "") {
					alert("Please enter the attorney last name.");
					expandSection(doc,sectionName,imageName);
					inForm.attorneyLastName[i].focus();
					return false;
				}

				var objArray1 = doc.getElementsByName('rbLawSuit'+attorneyRefIdValue);
				if (objArray1[0].checked == false && objArray1[1].checked == false) {
					alert("Please answer question 'a'. Attorney : "+ inForm.attorneyFirstName[i].value);
					expandSection(doc,sectionName,imageName);
					return false;
				}

				var objArray2 = doc.getElementsByName('rbLawSuitDismissed'+attorneyRefIdValue);
				if (objArray2[0].checked == false && objArray2[1].checked == false) {
					alert("Please answer question 'b'. Attorney : "+ inForm.attorneyFirstName[i].value);
					expandSection(doc,sectionName,imageName);
					return false;
				}

				var objArray3 = doc.getElementsByName('rbHasValidJudgement'+attorneyRefIdValue);
				if (objArray3[0].checked == false && objArray3[1].checked == false) {
					alert("Please answer question 'c'. Attorney : "+ inForm.attorneyFirstName[i].value);
					expandSection(doc,sectionName,imageName);
					return false;
				}

				var objArray4 = doc.getElementsByName('rbHasArbitrationParticipation'+attorneyRefIdValue);
				if (objArray4[0].checked == false && objArray4[1].checked == false) {
					alert("Please answer question 'd'. Attorney : "+ inForm.attorneyFirstName[i].value);
					expandSection(doc,sectionName,imageName);
					return false;
				}

				if ((objArray1[0].checked || objArray2[0].checked ||
					 objArray3[0].checked || objArray4[0].checked)
					&& (trim(inForm.moreInformation[i].value) == "")) {
					alert("Please answer question 'e'. Attorney : "+ inForm.attorneyFirstName[i].value);
					inForm.moreInformation[i].value = "";
					expandSection(doc,sectionName,imageName);
					inForm.moreInformation[i].focus();
					return false;
				}

				/* Function : Validating for textarea(More Information) text length before submitting
			       Author	: Janardhana
			    */
			    if (inForm.moreInformation[i].value !=null && inForm.moreInformation[i].value !="")
			    {
			    	if ((inForm.moreInformation[i].value).length > 4000){
			    	alert ("Number of characters for attorney exceeds the maximum allowed. Attorney : " +inForm.attorneyFirstName[i].value);
					expandSection(doc,sectionName,imageName);
			    	inForm.moreInformation[i].focus();
			    	return false;
			    	}
			    }
			}
			//Validation is completed
		}
	}
	return true;
}

function validateUpdateComplaintForm(obj)
{
	var inForm = obj.form;

	if(! validateRespondent(inForm))
	{
		return false;
	}

	if(! validateComplainant(inForm))
	{
		return false;
	}

	if(! validateAdditionalComplainants(inForm))
	{
		return false;
	}

	if(! validateWitnesses(inForm))
	{
		return false;
	}

	if(! validateAttorneys(inForm))
	{
		return false;
	}

	if(! validateAdminComplaintFormAttorneyInfo(inForm))
	{
		return false;
	}

	if(! validateForeclosureDetailsforViewEdit(inForm))
	{
		return false;
	}

	SelectAllFromList(inForm.selectedComplaintType);

	disableObjectAndSubmit(obj);
}

function cancelAddComplaint(inForm)
{
	if(confirm(sGlobalMessageArr[ MSG_CANCEL_ADD_COMPLAINT ]))
	{
		inForm.fromWhere.value = "createComplaint";
		var url = '/enforcement/SetUpEnforcementSearchComplaintForm.do';
 		inForm.action = url;
 		inForm.submit();
		return true;
	}
	else
	{
		return false;
	}
}

function cancelAddDisciplinaryFile(inForm)
{
	if(confirm(sGlobalMessageArr[ MSG_CANCEL_ADD_COMPLAINT ]))
	{
		inForm.fromWhere.value = "createDisciplinaryFile";
		var url = '/enforcement/SetUpViewMyDisciplinaryFilesForm.do?methodToCall=search';
 		inForm.action = url;
 		inForm.submit();
		return true;
	}
	else
	{
		return false;
	}
}

function validateAddDisciplinaryForm(obj)
{
	var inForm = obj.form;

	if(! validateRespondent(inForm))
	{
		return false;
	}

	disableObjectAndSubmit(obj);
}



function validateAddComplaintForm(obj)
{
	var inForm = obj.form;

	if(inForm.compliantReceivedDate.value == "")
	{
		alert(sGlobalMessageArr[MSG_ENTER_COMPLAINT_RECEIVED_DATE]);
		inForm.compliantReceivedDate.focus();
		return false;
	}

	if(!CompareDates(inForm.compliantReceivedDate,inForm.complaintEnteredDate))
	//if((inForm.compliantReceivedDate.value) > (inForm.complaintEnteredDate.value))
	{

		alert("The Received Date should be before or equal to current date.");
		inForm.compliantReceivedDate.focus();
		return;
	}



	if(! validateRespondent(inForm))
	{
		return false;
	}

	if(! validateComplainant(inForm))
	{
		return false;
	}

	if(! validateAdditionalComplainants(inForm))
	{
		return false;
	}

	if(! validateWitnesses(inForm))
	{
		return false;
	}

	if(! validateAttorneys(inForm))
	{
		return false;
	}

	if(! validateAdminComplaintFormAttorneyInfo(inForm))
	{
		return false;
	}

	if(! validateForeclosureDetails(inForm))
	{
		return false;
	}
	disableObjectAndSubmit(obj);
}

function validateForeclosureDetailsforViewEdit(inForm)
{
	if (inForm.foreclosureStatus[0].checked || inForm.foreclosureStatus[1].checked ||inForm.foreclosureStatus[2].checked)
	{
		if (inForm.foreclosureStatus[0].checked)
		{
			if (inForm.foreclosureStatus[0].value == inForm.allegationsLedToForeclosure.value)
			{
				var bitValue = getgetForeclosuresBitValue(inForm);
				if (bitValue==0)
				{
					alert (sGlobalMessageArr[MSG_SELECT_FORECLOSURE_FACTORS]);
					return false;
				}
				document.getElementById("foreclosureBitValue").value = bitValue;
			}
		}
	}
	else
	{
		alert (sGlobalMessageArr[MSG_SELECT_FORECLOSURE_STATUS]);
		inForm.foreclosureStatus[0].focus();
		return false;
	}

	return true;
}

function validateReviewComplaintForm(obj)
{
	var inForm = obj.form;

	if(inForm.compliantReceivedDate.value == "")
	{
		alert(sGlobalMessageArr[MSG_ENTER_COMPLAINT_RECEIVED_DATE]);
		inForm.compliantReceivedDate.focus();
		return false;
	}

	if(! validateRespondent(inForm))
	{
		return false;
	}

	if(! validateComplainant(inForm))
	{
		return false;
	}

	if(! validateAdditionalComplainants(inForm))
	{
		return false;
	}

	if(! validateWitnesses(inForm))
	{
		return false;
	}

	if(! validateAttorneys(inForm))
	{
		return false;
	}

	if(! validateForeclosureDetails(inForm))
	{
		return false;
	}
	disableObjectAndSubmit(obj);
}

function validateForeclosureDetails(inForm)
{
	if (inForm.foreclosureStatus[0].checked || inForm.foreclosureStatus[1].checked ||  inForm.foreclosureStatus[2].checked)
	{
		if (inForm.foreclosureStatus[0].checked)
		{
			if (inForm.foreclosureStatus[0].value == inForm.allegationsLedToForeclosure.value)
			{
				var bitValue = getgetForeclosuresBitValue(inForm);
				if (bitValue==0)
				{
					alert (sGlobalMessageArr[MSG_SELECT_FORECLOSURE_FACTORS]);
					return false;
				}
				document.getElementById("foreclosureBitValue").value = bitValue;
			}
		}
	}
	else
	{
		alert (sGlobalMessageArr[MSG_SELECT_FORECLOSURE_STATUS]);
		inForm.foreclosureStatus[0].focus();
		return false;
	}

	return true;
}

function validateComplaintFormReasonPage(obj) {

	var inForm = obj.form;



	/*var reasons = inForm.reasons;
	var reasonsListSize = inForm.reasons.length;
	var otherReasonSelected = false;

	var flag = false;
	for (var i = 0; i < reasonsListSize; i++) {
		if (reasons[i].checked) {
			flag = true;

			if (reasons[i].value == 1969) {
				otherReasonSelected = true;
				if (inForm.reasons[i].checked && inForm.otherReasonDescription.value == "") {
					alert("Please enter the reason for your complaint.");
					inForm.otherReasonDescription.focus();
					return false;
				}
			}
		}
	}

	if (!flag) {
		alert("Please select atleast one reason.");
		return false;
	}

	if (trim(inForm.otherReasonDescription.value) != "" && !otherReasonSelected) {
		alert("Please check the 'Other' option.");
		inForm.otherReasonDescription.value = "";
		inForm.otherReasonDescription.focus();
		return false;
	}*/

	/* Function : Validating for textarea's(Other reason and Events) text length before submitting
       Author	: Janardhana
    */
    if (inForm.complaintSummary.value !=null && inForm.complaintSummary.value !="")
    {
    	if ((inForm.complaintSummary.value).length > 4000){
    	alert ("Number of characters exceeds the maximum allowed.");
    	inForm.complaintSummary.focus();
    	return false;
    	}
    }
    else if (inForm.complaintSummary.value == "") //added by dilip, validating of Complaint summary
    {
    alert("Complaint Summary details are mandatory");
    inForm.complaintSummary.focus();
    return false;
    }

	var totalEvents = inForm.noOfEvents.value;

	for (i=1; i<=(totalEvents); i++){

	var eventField = "event"+i;
	var eventFieldObj = document.getElementById(eventField);

	 if (eventFieldObj.value !=null && eventFieldObj.value !="")
    	{
	    	if ((eventFieldObj.value).length > 4000){
	    	alert ("Number of characters exceeds the maximum allowed.");
	    	eventFieldObj.focus();
	    	return false;
	    	}
    	}
	}
	//Validation is completed

	var noOfEvents = inForm.noOfEvents.value;
	var count = 0;
	for (i=0;i<parseInt(noOfEvents);i++) {
		var dateValue = eval("inForm.date"+(i+1)+".value");

		//Date must not be older than 2 years
		if (dateValue != "") {
			dateObject=getDateObject(dateValue,"/");
			var today = new Date();
			var today = new Date(today.getYear(), today.getMonth(), today.getDate());
			var difference = Math.ceil((today.getTime()  - dateObject.getTime())/(1000*60*60*24));
			if (difference > 730) {
				alert("Date cannot be older than 2 years");
				eval("inForm.date"+(i+1)+".focus()");
				return false;
			}

			if (today.getTime()  < dateObject.getTime()) {
				alert("Future dates are not allowed.");
				return false;
			}
		}

		var eventValue = eval("inForm.event"+(i+1)+".value");
		if (trim(dateValue) != "" &&  trim(eventValue) == "") {
			alert("Please enter event details.");
			eval("inForm.event"+(i+1)+".focus()");
			return false;
		}

		if (trim(eventValue) != "" &&  trim(dateValue) == "") {
			alert("Please enter date details.");
			eval("inForm.date"+(i+1)+".focus()");
			return false;
		}

		if (dateValue == "" && eventValue == "") {
			count++;
		}
	}

	if (count == noOfEvents) {
		alert("Atleast one event detail is required to enter a complaint.");
		inForm.date1.focus();
		return false;
	}

	if (inForm.foreclosureComments.value !=null && inForm.foreclosureComments.value !="")
    {
    	if ((inForm.foreclosureComments.value).length > 500){
    	alert ("Number of characters exceeds the maximum allowed.");
    	inForm.foreclosureComments.focus();
    	return false;
    	}
    }

	if(inForm.radForclosureStatus){

		if (inForm.radForclosureStatus[0].checked || inForm.radForclosureStatus[1].checked){

			if (inForm.radForclosureStatus[0].checked){
			//alert(inForm.radForclosureStatus[0].value);
				if (inForm.radForclosureStatus[0].value == inForm.allegationsLedToForeclosure.value){
					var bitValue = getgetForeclosuresBitValue(inForm);
					//alert (bitValue);
					if (bitValue==0){
						alert ("You must select one of the 'If Yes, then choose one or more factors that caused the foreclosure' options");
						return false;
					}
					document.getElementById("foreclosureBitValue").value = bitValue;
					//alert(document.getElementById("foreclosureBitValue").value);
				}
			}

		}

		else {
		alert ("You must select one of the 'Have the allegations included in this complaint led to a foreclosure' options.");
		return false;
		}
	}
	disableObjectAndSubmit(obj);
}

function getgetForeclosuresBitValue(obj){

	var foreclosuresArr = new Array('appraisalFraud', 'lack', 'divorse', 'loss', 'incompetence', 'medical', 'lackmortgage', 'mortgageFraud', 'mortagageProduct', 'reFraud', 'financialHardship', 'other');

	var foreclosureBitValues = 0;

	for (i=0; i<foreclosuresArr.length; i++){

	  	if (document.getElementById(foreclosuresArr[i]).checked){

			//alert(document.getElementById(foreclosuresArr[i]).value);
			foreclosureBitValues = foreclosureBitValues + parseInt(document.getElementById(foreclosuresArr[i]).value);

		}
	}
	return foreclosureBitValues;
}

function enableDisableButtons(obj, value) {

	var inForm = obj.form;
 	if (value == 'yes'){

	document.getElementById("appraisalFraud").disabled = false;
	document.getElementById("lack").disabled = false;
	document.getElementById("divorse").disabled = false;
	document.getElementById("loss").disabled = false;
	document.getElementById("incompetence").disabled = false;
	document.getElementById("medical").disabled = false;
	document.getElementById("lackmortgage").disabled = false;
	document.getElementById("mortgageFraud").disabled = false;
	document.getElementById("mortagageProduct").disabled = false;
	document.getElementById("reFraud").disabled = false;
	document.getElementById("financialHardship").disabled = false;
	document.getElementById("other").disabled = false;
 	}

 	else if (value == 'no'){
		document.getElementById("appraisalFraud").disabled = true;
	document.getElementById("lack").disabled = true;
	document.getElementById("divorse").disabled = true;
	document.getElementById("loss").disabled = true;
	document.getElementById("incompetence").disabled = true;
	document.getElementById("medical").disabled = true;
	document.getElementById("lackmortgage").disabled = true;
	document.getElementById("mortgageFraud").disabled = true;
	document.getElementById("mortagageProduct").disabled = true;
	document.getElementById("reFraud").disabled = true;
	document.getElementById("financialHardship").disabled = true;
	document.getElementById("other").disabled = true;
 	}

}


function getDateObject(dateString,dateSeperator)
{
	//This function return a date object after accepting
	//a date string ans dateseparator as arguments
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;

	//extract month portion
	curPos=dateString.indexOf(sepChar);
	cMonth=dateString.substring(0,curPos);

	//extract day portion
	endPos=dateString.indexOf(sepChar,curPos+1);
	cDate=dateString.substring(curPos+1,endPos);

	//extract year portion
	curPos=endPos;
	endPos=curPos+5;
	cYear=curValue.substring(curPos+1,endPos);

	//Create Date Object
	dtObject=new Date(cYear,cMonth-1,cDate);

	return dtObject;
}


function validateComplaintFormWitnesses(obj) {

	var inForm = obj.form;
	var numberOfTables = inForm.lastName.length; // because there will be equal number of lastNames.

	if(!inForm.lastName[0]) {
		if(inForm.lastName.value == "") {
			alert("Please enter the last name.");
			inForm.lastName.focus();
			return false;
		}

		if(inForm.firstName.value == "") {
			alert("Please enter the first name.");
			inForm.firstName.focus();
			return false;
		}

		if(inForm.zipCode.value != "")
		{
			flag = validateZIP(inForm.zipCode);
			if(!flag)
			{
				inForm.zipCode.value= "";
				inForm.zipCode.focus();
				return false;
			}
		}

		if(inForm.phone.value != "")
		{
			flag = checkInternationalPhone(inForm.phone.value)
			if(!flag)
			{
				alert("Please enter a valid phone number");
				inForm.phone.value= "";
				inForm.phone.focus();
				return false;
			}
		}

		if(inForm.fax.value != "")
		{
			flag = checkInternationalPhone(inForm.fax.value)
			if(!flag)
			{
				alert("Please enter a valid fax number");
				inForm.fax.value= "";
				inForm.fax.focus();
				return false;
			}
		}

		if(inForm.emailAddress.value != "")
		{
			var email = inForm.emailAddress.value;
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (!filter.test(email)) {
				alert("Please enter a valid email address.");
				inForm.emailAddress.select();
				inForm.emailAddress.focus();
				return false;
			}
		}
	}

	if(numberOfTables >= 2) {
		for(var i = 0; i < numberOfTables; i++) {
			if(inForm.lastName[i].value == "") {
				alert("Please enter the last name.");
				inForm.lastName[i].focus();
				return false;
			}

			if(inForm.firstName[i].value == "") {
				alert("Please enter the first name.");
				inForm.firstName[i].focus();
				return false;
			}

			if(inForm.zipCode[i].value != "")
			{
				flag = validateZIP(inForm.zipCode[i]);
				if(!flag)
				{
					inForm.zipCode[i].value= "";
					inForm.zipCode[i].focus();
					return false;
				}
			}
			if(inForm.phone[i].value != "")
			{
				flag = checkInternationalPhone(inForm.phone[i].value)
				if(!flag)
				{
					alert("Please enter a valid phone number");
					inForm.phone[i].value= "";
					inForm.phone[i].focus();
					return false;
				}
			}

			if(inForm.fax[i].value != "")
			{
				flag = checkInternationalPhone(inForm.fax[i].value)
				if(!flag)
				{
					alert("Please enter a valid fax number");
					inForm.fax[i].value= "";
					inForm.fax[i].focus();
					return false;
				}
			}

			if(inForm.emailAddress[i].value != "")
			{
				var email = inForm.emailAddress[i].value;
				var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
				if (!filter.test(email)) {
					alert("Please enter a valid email address.");
					inForm.emailAddress[i].select();
					inForm.emailAddress[i].focus();
					return false;
				}
			}		}
	}

	disableObjectAndSubmit(obj);
}

function addWitnessTable(btn) {

	//alert("Adding another table");

	btn.disabled = true;
	var witnesstable = document.getElementById("witnessTable");

	var witnessTableRowCount = document.getElementById("witnessTable").rows.length;
	var atPosition = witnessTableRowCount - 3;

	var refRow = document.getElementById("witnessRow");

	if (atPosition < 0) atPosition = 0;
	var newTR = witnesstable.insertRow(atPosition);
	var td1, td2;
	td1 = document.createElement("td");
	newTR.appendChild(td1);

	var text = document.createTextNode("New Cell ");
	td2 = document.createElement("td");
	td2.setAttribute("width","100%");

	newTR.appendChild(td2);
	td2.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);

	document.getElementById("yes").checked = false;

	document.forms[0].noOfWitnesses.value = parseInt(document.forms[0].noOfWitnesses.value) + 1;
}

function validateComplaintFormAttorneyInfo(obj) {

	var inForm = obj.form;

	if(inForm.lastName.value == "") {
		alert("Please enter the last name.");
		inForm.lastName.focus();
		return false;
	}

	if(inForm.firstName.value == "") {
		alert("Please enter the first name.");
		inForm.firstName.focus();
		return false;
	}

	/*if(inForm.address.value == "") {
		alert("Please enter the address.");
		inForm.address.focus();
		return false;
	}

	if(inForm.city.value == "") {
		alert("Please enter the city.");
		inForm.city.focus();
		return false;
	}

	if(inForm.state.value == "") {
		alert("Please enter the state.");
		inForm.state.focus();
		return false;
	}

	if(inForm.zipCode.value == "") {
		alert("Please enter the zip code.");
		inForm.zipCode.focus();
		return false;
	}*/

	if(inForm.zipCode.value!="")
	{
		flag = validateZIPWithFiveDigits(inForm.zipCode);
		if(!flag)
		{
			inForm.zipCode.value= "";
			inForm.zipCode.focus();
			return false;
		}
	}

	var phone = inForm.phone.value;

	/*if(phone == "") {
		alert("Please enter the telephone number.");
		inForm.phone.focus();
		return false;
	}*/

	if(phone != "") {
		var isNumerals = isValid(phone, numbers);
		if (!isNumerals) {
			alert("Please enter only numeric characters for the telephone number.");
			inForm.phone.value = "";
			inForm.phone.focus();
			return false;
		}
	}

	if(phone != "" && phone.length != 10) {
		alert("Please enter the full telephone number.");
			inForm.phone.select();
			inForm.phone.focus();
			return false;
	}

	if(inForm.mobilephone.value != "")
	{
		flag = checkInternationalPhone(inForm.mobilephone.value)
		if(!flag)
		{
			alert("Please enter a valid phone number");
			inForm.mobilephone.value= "";
			inForm.mobilephone.focus();
			return false;
		}
	}

	if(inForm.fax.value != "" && inForm.fax.value.length != 10) {
		alert("Please enter the full fax number.");
		inForm.fax.focus();
		return false;
	}

	if(inForm.fax.value != "")
	{
		flag = checkInternationalPhone(inForm.fax.value)
		if(!flag)
		{
			alert("Please enter a valid fax number");
			inForm.fax.value= "";
			inForm.fax.focus();
			return false;
		}
	}

	var email = inForm.emailAddress.value;
	if (email != "") {
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(email)) {
			alert("Please enter a valid email address.");
			inForm.emailAddress.select();
			inForm.emailAddress.focus();
			return false;
		}
	}

	if (inForm.rbLawSuit[0].checked == false && inForm.rbLawSuit[1].checked == false) {
		alert("Please answer question 'a'.");
		return false;
	}

	if (inForm.rbLawSuitDismissed[0].checked == false && inForm.rbLawSuitDismissed[1].checked == false) {
		alert("Please answer question 'b'.");
		return false;
	}

	if (inForm.rbHasValidJudgement[0].checked == false && inForm.rbHasValidJudgement[1].checked == false) {
		alert("Please answer question 'c'.");
		return false;
	}

	if (inForm.rbHasArbitrationParticipation[0].checked == false && inForm.rbHasArbitrationParticipation[1].checked == false) {
		alert("Please answer question 'd'.");
		return false;
	}

	if ((inForm.rbLawSuit[0].checked || inForm.rbLawSuitDismissed[0].checked ||
		 inForm.rbHasValidJudgement[0].checked || inForm.rbHasArbitrationParticipation[0].checked)
		&& (trim(inForm.moreInformation.value) == "")) {
		alert("Please answer question 'e'.");
		inForm.moreInformation.value = "";
		inForm.moreInformation.focus();
		return false;
	}

	/* Function : Validating for textarea(More Information) text length before submitting
       Author	: Janardhana
    */
    if (inForm.moreInformation.value !=null && inForm.moreInformation.value !="")
    {
    	if ((inForm.moreInformation.value).length > 4000){
    	alert ("Number of characters exceeds the maximum allowed.");
    	inForm.moreInformation.focus();
    	return false;
    	}
    }
	//Validation is completed

	disableObjectAndSubmit(obj);
}

function addWitnessTableOnAdmin() {

	var witnesstable = document.getElementById("witnessDetailsTable");

	var witnessTableRowCount = document.getElementById("witnessDetailsTable").rows.length;
	var atPosition = witnessTableRowCount;
	//var atPosition = 0;

	var refRow = document.getElementById("witnessRow");

	var newTR = witnesstable.insertRow(atPosition);
	var td1, td2;
	td1 = document.createElement("td");
	newTR.appendChild(td1);

	td2 = document.createElement("td");
	td2.setAttribute("width","100%");

	newTR.appendChild(td2);
	td2.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);

	td2.children(1).rows(11).cells(0).children(0).value = "0";
	td2.children(1).rows(11).cells(0).children(1).value = "I";
}

function deleteWitnessRecord(obj)
{
	var inForm = obj.form;
	var witnessDetailsTableObj = document.getElementById("witnessDetailsTable");
	var deleteWitnessObj = document.getElementById("deleteWitness");

//	for(var i=0;i<witnessDetailsTableObj.rows.length;i++)
//	{
//		//alert(witnessDetailsTableObj.rows(0).cells(0).children(0).rows(13).cells(1).name);
//		//alert(witnessDetailsTableObj.rows(0).cells(0).children(0).rows(12).cells(1).children(0).name);
//		alert(witnessDetailsTableObj.rows(0).cells(1).children(1).rows(12).cells(1).children(0).checked);
//		if(witnessDetailsTableObj.rows(0).cells(1).children(1).rows(12).cells(1).children(0).checked)
//		{
////			alert(witnessDetailsTableObj.rows(0).cells(0).children(0).rows(12).cells(1).children(0).value);
//		}
//	}

	//alert(inForm.deleteWitness.length-1);
	if(inForm.deleteWitness.length)
	{
		for(var i=0;i<inForm.deleteWitness.length-1;i++)
		{
			//alert(inForm.deleteWitness[i].checked);
			if(inForm.deleteWitness[i].checked)
			{
				setDeleteOperationForWitnessRecord(inForm.deleteWitness[i]);
				disableTheDeletedWitness(inForm.deleteWitness[i]);
			}
		}
	}

}

function setDeleteOperationForWitnessRecord(obj)
{
	//alert(obj.parentElement.parentElement.parentElement.rows(11).cells(0).children(1).name)
	obj.parentElement.parentElement.parentElement.rows(11).cells(0).children(1).value = "D";

}
function disableTheDeletedWitness(obj)
{
	//alert(obj.parentElement.parentElement.parentElement.parentElement.id);
	//obj.parentElement.parentElement.parentElement.style.border = 1;
	obj.parentElement.parentElement.parentElement.parentElement.className = "";
	obj.parentElement.parentElement.parentElement.parentElement.style.display = "none";

}

function manageUpdateAndDeleteForWitness(obj)
{
	if(obj.parentElement.children(1).checked)
	{
		obj.parentElement.children(1).checked = false;
	}
	setUpdateOperation(obj.parentElement.children(1));
}
function setUpdateOperation(obj)
{
	//alert(obj.parentElement.parentElement.parentElement.rows(11).cells(0).children(1).name)

	if(obj.checked)
	{
		obj.parentElement.parentElement.parentElement.rows(11).cells(0).children(1).value = "U";

		//Enable first row
		obj.parentElement.parentElement.parentElement.rows(0).cells(1).children(0).disabled = false;
		obj.parentElement.parentElement.parentElement.rows(0).cells(2).children(0).disabled = false;
		obj.parentElement.parentElement.parentElement.rows(0).cells(3).children(0).disabled = false;
		obj.parentElement.parentElement.parentElement.rows(0).cells(4).children(0).disabled = false;

		//Enable second row
		obj.parentElement.parentElement.parentElement.rows(3).cells(1).children(0).disabled = false;

		//Enable third row
		obj.parentElement.parentElement.parentElement.rows(6).cells(1).children(0).disabled = false;
		obj.parentElement.parentElement.parentElement.rows(6).cells(2).children(0).disabled = false;
		obj.parentElement.parentElement.parentElement.rows(6).cells(3).children(0).disabled = false;

		//Enable forth row
		obj.parentElement.parentElement.parentElement.rows(9).cells(1).children(0).disabled = false;
		obj.parentElement.parentElement.parentElement.rows(9).cells(2).children(0).disabled = false;
		obj.parentElement.parentElement.parentElement.rows(9).cells(3).children(0).disabled = false;

		if(obj.parentElement.children(0).checked)
		{
			obj.parentElement.children(0).checked = false;
		}
	}
	else
	{
		obj.parentElement.parentElement.parentElement.rows(11).cells(0).children(1).value = "S";

//		alert(obj.parentElement.parentElement.parentElement.rows(0).cells(1).children(0).name);

		//Disable first row
		obj.parentElement.parentElement.parentElement.rows(0).cells(1).children(0).disabled = true;
		obj.parentElement.parentElement.parentElement.rows(0).cells(2).children(0).disabled = true;
		obj.parentElement.parentElement.parentElement.rows(0).cells(3).children(0).disabled = true;
		obj.parentElement.parentElement.parentElement.rows(0).cells(4).children(0).disabled = true;

		//Disable second row
		obj.parentElement.parentElement.parentElement.rows(3).cells(1).children(0).disabled = true;

		//Disable third row
		obj.parentElement.parentElement.parentElement.rows(6).cells(1).children(0).disabled = true;
		obj.parentElement.parentElement.parentElement.rows(6).cells(2).children(0).disabled = true;
		obj.parentElement.parentElement.parentElement.rows(6).cells(3).children(0).disabled = true;

		//Disable forth row
		obj.parentElement.parentElement.parentElement.rows(9).cells(1).children(0).disabled = true;
		obj.parentElement.parentElement.parentElement.rows(9).cells(2).children(0).disabled = true;
		obj.parentElement.parentElement.parentElement.rows(9).cells(3).children(0).disabled = true;
	}
}

function enableWitnessFeilds(obj)
{
	obj.parentElement.parentElement.parentElement.rows(0).cells(1).children(0).disabled = false;
	obj.parentElement.parentElement.parentElement.rows(0).cells(2).children(0).disabled = false;
	obj.parentElement.parentElement.parentElement.rows(0).cells(3).children(0).disabled = false;
	obj.parentElement.parentElement.parentElement.rows(0).cells(4).children(0).disabled = false;

	obj.parentElement.parentElement.parentElement.rows(3).cells(1).children(0).disabled = false;

	obj.parentElement.parentElement.parentElement.rows(6).cells(1).children(0).disabled = false;
	obj.parentElement.parentElement.parentElement.rows(6).cells(2).children(0).disabled = false;
	obj.parentElement.parentElement.parentElement.rows(6).cells(3).children(0).disabled = false;

	obj.parentElement.parentElement.parentElement.rows(9).cells(1).children(0).disabled = false;
	obj.parentElement.parentElement.parentElement.rows(9).cells(2).children(0).disabled = false;
}

function submitModifyRespondentHiddenForm()
{
	document.forms['hiddenFormForChangeRespondent'].submit();
}

function validateChangeRespondentDetails(inForm)
{

	var respondentLicenseNumbers = inForm.respondentLicenseNumbers.value;
	// Truncating the Final "," from the Input String
	respondentLicenseNumbers = respondentLicenseNumbers.substring(0,respondentLicenseNumbers.length-1);

	var inputRespondentLicenseNumbers = respondentLicenseNumbers.split(",");

	if(inForm.licensename != null && inForm.licensename.options[0].selected)
	{
			alert("License name is mandatory.");
			inForm.licensename.focus();
			return false;
	}
	if(inForm.licensenumber.value == "" && inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "" && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value for License Number and First Name / Last Name or Business Name.");
		inForm.licensenumber.focus();
		return false;
	}
	if((inForm.licenseefirstname.value == "" && inForm.licenseelastname.value == "")  && inForm.licenseebusinessname.value == "")
	{
	    alert("Please provide value either for First Name/Last Name or Business Name.");
		return false;
	}

	if(inForm.licenseezip.value!="")
	{
		if(!validateZIP(inForm.licenseezip))
		{
			inForm.licenseezip.focus();
			return false;
		}
	}

	document.getElementById("licenseefax").value = trim(document.getElementById("licenseefax").value);
	document.getElementById("licenseeemail").value = trim(document.getElementById("licenseeemail").value);

	if (!validatePhoneField(document.getElementById("licenseefax"), "fax number")) return false;
	if (!validateEmalField(document.getElementById("licenseeemail"), "email address")) return false;

	if(inForm.rdbSelectDetailType[0].checked)
		inForm.isCandidateOrbusiness.value = "candidate";
	else
		inForm.isCandidateOrbusiness.value = "business";

	inForm.SubmitButton.disabled=true;
	inForm.CancelButton.disabled=true;
	inForm.submit();
}

///////////////////////////////////////////// ADDED BY RISHABHJ


function addWitnessTableForAdminSite(obj) {

	var witnesstable = document.getElementById("witnessDetailsTable");

	var witnessTableRowCount = document.getElementById("witnessDetailsTable").rows.length;
	var atPosition = witnessTableRowCount;


	var refRow = document.getElementById("witnessRow");

	var newTR = witnesstable.insertRow(atPosition);
	newTR.id="newWitnessRow";
	newTR.name="newWitnessRow";
	var td1, td2;

	td2 = document.createElement("td");
	td2.setAttribute("width","100%");

	newTR.appendChild(td2);
	td2.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);

	var td1, td2;

	td2 = document.createElement("td");
	td2.setAttribute("width","100%");

	refRow.appendChild(td2);
}

function removeTable(obj)
{
	var removeThisTable = obj;

	if (removeThisTable) {

		var removeThisTableLength = removeThisTable.length;
		var z = new Array(100);
		var count = 0;
		if (removeThisTableLength >= 2) {
			var nonechecked = "";
			for (var i = 0; i < removeThisTableLength; i++) {
				if (removeThisTable[i].checked == true) {
					z[count] = removeThisTable[i];
					count++;
					nonechecked = "false";
				}
			}
			if(nonechecked == "")
			{
				alert(sGlobalMessageArr[ MSG_SELECT_WITNESS_TO_DELETE ]);
			}
		}
		else if (removeThisTableLength >= 1) {
			if (removeThisTable[0].checked == true) {
				z[count] = removeThisTable[0];
				count++;
			}
			else
			{
				alert(sGlobalMessageArr[ MSG_SELECT_WITNESS_TO_DELETE ]);
			}
		}
		else {
			if (removeThisTable.checked == true) {
				z[count] = removeThisTable;
				count++;
			}
			else
			{
				alert(sGlobalMessageArr[ MSG_SELECT_WITNESS_TO_DELETE ]);
			}
		}
		for (var i = 0; i < count; i ++) {
			var rowToDelete = z[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
			var parentOfRow = rowToDelete.parentElement;
			parentOfRow.removeChild(rowToDelete);
		}
	}
	else
	{
		alert(sGlobalMessageArr[ MSG_SELECT_WITNESS_TO_DELETE ]);
	}

	if(document.getElementById("addAttorney")){
	var addAttorneyButton = document.getElementById("addAttorney");
	addAttorneyButton.disabled="";
	}

}

function removeTableGeneric(inForm, obj)
{
	if(obj)
	{
		if(obj.length)
		{
			var nonechecked= "";
			for(i=0;i<obj.length;i++)
			{
				if(obj[i].checked)
				{
						if(obj[i].parentElement.children(1)!=null)
							setDeleteOperation(obj[i].parentElement.children(1));
						if(obj[i].parentElement.parentElement.parentElement.parentElement.parentElement.style.display == "")
							nonechecked = "false";
						obj[i].parentElement.parentElement.parentElement.parentElement.parentElement.style.display="none";

				}

			}
			if(nonechecked == "")
			{
				alert(sGlobalMessageArr[ MSG_SELECT_WITNESS_TO_DELETE ]);
			}
		}
		else
		{
			var nonechecked= "";
			if(obj.checked)
			{
					if(obj.parentElement.children(1)!=null)
							setDeleteOperation(obj.parentElement.children(1));
					if(obj[i].parentElement.parentElement.parentElement.parentElement.parentElement.style.display == "")
						nonechecked = "false";
					obj.parentElement.parentElement.parentElement.parentElement.parentElement.style.display="none";
			}
			if(nonechecked == "")
			{
				alert(sGlobalMessageArr[ MSG_SELECT_WITNESS_TO_DELETE ]);
			}
		}
	}
	else
	{
		alert(sGlobalMessageArr[ MSG_SELECT_WITNESS_TO_DELETE ]);
	}
}

function setDeleteOperation(obj)
{
	obj.value = 'D';
}
function removeLastWitnessTable(obj) {

	var removeThisTable = obj;

	if (removeThisTable) {

		var removeThisTableLength = removeThisTable.length;
		var z = new Array(100);
		var count = 0;
		if (removeThisTableLength >= 2) {
			for (var i = 0; i < removeThisTableLength; i++) {
				if (removeThisTable[i].checked == true) {
					z[count] = removeThisTable[i];
					count++;
				}
			}
		}
		else if (removeThisTableLength >= 1) {
			if (removeThisTable[0].checked == true) {
				z[count] = removeThisTable[0];
				count++;
			}
		}
		else {
			if (removeThisTable.checked == true) {
				z[count] = removeThisTable;
				count++;
			}
		}
		for (var i = 0; i < count; i ++) {
			var rowToDelete = z[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
			var parentOfRow = rowToDelete.parentElement;
			parentOfRow.removeChild(rowToDelete);
		}
	}
}


function StatusObject(enum1, list1)
{
    this.enum1 = enum1;
    this.list1 = list1;
}

function SubStatusObject(enum1, description1)
{
    this.enum1 = enum1;
    this.description1 = description1;
}

function populateValues(inForm)
{
	var statusSelected = inForm.status.value;
	var sub_status_list;
	var flag = false;


	for (var index = 0; index < StatusList.length; index++)
	{
		if (StatusList[index].enum1 == statusSelected)
		{
			if (StatusList[index].list1) {
				sub_status_list = StatusList[index].list1;
				flag = true;
				for (var jindex = 0; jindex < sub_status_list.length; jindex++)
				{
					inForm.substatus.options[jindex] = new Option(sub_status_list[jindex].description1, sub_status_list[jindex].enum1);
				}
			}
			else {
				flag = false;
			}
		}
	}
	if(flag) {
		inForm.substatus.disabled = false;
	}
	else {
		inForm.substatus.length = 0;
		inForm.substatus.options[0] = new Option("--------------------------------", "");
		inForm.substatus.disabled = true;
	}
}

function updateAttorneyOperationCheckBox(obj) {
	var inForm = obj;

	if (inForm.updateAttorney.checked) {
		inForm.attorneyOperation.value = "U";
		enableAttorneyTableForUpdateComplaintInAdminSite(inForm);
	}
	else {
		inForm.attorneyOperation.value = "S";
		disableAttorneyTableForUpdateComplaintInAdminSite(inForm);
	}

}

function enableAttorneyTableForUpdateComplaintInAdminSite(obj) {
	var inForm = obj;
	document.getElementsByName('attorneyFirstName')[0].readOnly = false;
	document.getElementsByName('attorneyMiddleName')[0].readOnly = false;
	document.getElementsByName('attorneyLastName')[0].readOnly = false;
	document.getElementsByName('attorneyBusinessName')[0].readOnly = false;
	document.getElementsByName('attorneyAddress1')[0].readOnly = false;
	document.getElementsByName('attorneyAddress2')[0].readOnly = false;
	document.getElementsByName('attorneyBusinessCity')[0].readOnly = false;
	document.getElementsByName('attorneyBusinessState')[0].disabled = false;
	document.getElementsByName('attorneyBusinessZip')[0].readOnly = false;
	document.getElementsByName('attorneyBusinessPhone')[0].readOnly = false;
	document.getElementsByName('attorneyBusinessExtn')[0].readOnly = false;
	document.getElementsByName('attorneyMobile')[0].readOnly = false;
	document.getElementsByName('attorneyEmail')[0].readOnly = false;
	document.getElementsByName('attorneyFax')[0].readOnly = false;
	inForm.rbLawSuit[0].disabled = "";
	inForm.rbLawSuit[1].disabled = "";
	inForm.rbLawSuitDismissed[0].disabled = "";
	inForm.rbLawSuitDismissed[1].disabled = "";
	inForm.rbHasValidJudgement[0].disabled = "";
	inForm.rbHasValidJudgement[1].disabled = "";
	inForm.rbHasArbitrationParticipation[0].disabled = "";
	inForm.rbHasArbitrationParticipation[1].disabled = "";
	inForm.moreInformation[0].disabled = false;
}

function disableAttorneyTableForUpdateComplaintInAdminSite(obj) {
	var inForm = obj;
	document.getElementsByName('attorneyFirstName')[0].readOnly = true;
	document.getElementsByName('attorneyMiddleName')[0].readOnly = true;
	document.getElementsByName('attorneyLastName')[0].readOnly = true;
	document.getElementsByName('attorneyBusinessName')[0].readOnly = true;
	document.getElementsByName('attorneyAddress1')[0].readOnly = true;
	document.getElementsByName('attorneyAddress2')[0].readOnly = true;
	document.getElementsByName('attorneyBusinessCity')[0].readOnly = true;
	document.getElementsByName('attorneyBusinessState')[0].disabled = true;
	document.getElementsByName('attorneyBusinessZip')[0].readOnly = true;
	document.getElementsByName('attorneyBusinessPhone')[0].readOnly = true;
	document.getElementsByName('attorneyBusinessExtn')[0].readOnly = true;
	document.getElementsByName('attorneyMobile')[0].readOnly = true;
	document.getElementsByName('attorneyEmail')[0].readOnly = true;
	document.getElementsByName('attorneyFax')[0].readOnly = true;
	inForm.rbLawSuit[0].disabled = "true";
	inForm.rbLawSuit[1].disabled = "true";
	inForm.rbLawSuitDismissed[0].disabled = "true";
	inForm.rbLawSuitDismissed[1].disabled = "true";
	inForm.rbHasValidJudgement[0].disabled = "true";
	inForm.rbHasValidJudgement[1].disabled = "true";
	inForm.rbHasArbitrationParticipation[0].disabled = "true";
	inForm.rbHasArbitrationParticipation[1].disabled = "true";
	inForm.moreInformation[0].disabled = true;
}


function addAttorneyTableOnUpdateComplaint() {

	document.getElementById("AttorneyDetailsForUpdate").style.display="";
	document.getElementById("AttorneyMoreInfo").style.display="";
	document.getElementById("AddAttorneyButton").disabled = true;
	document.getElementById("DeleteAttorneyButton").disabled = false;

	document.getElementById("attorneyOperation").value = "I";
	/*var attorneyrow = document.getElementById("attorneyDetailsRow");
	if (attorneyrow.cells.length == 0) {
		var refRow = document.getElementById("attorneyRow");
		td2 = document.createElement("td");
		td2.setAttribute("colspan","2");
		attorneyrow.appendChild(td2);
		td2.insertAdjacentHTML("AfterBegin",refRow.cells(0).innerHTML);
	} else {
		var hideThisRow = document.getElementById("attorneyDetailsRow");
		hideThisRow.style.display = "";
	}
	var addButton = document.getElementById("AddAttorneyButton");
	addButton.disabled = "true";
	*/
	enableAttorneyTableForUpdateComplaintInAdminSite(inForm);
}

function deleteAttorneyTableOnUpdateComplaint(obj) {

	document.getElementById("AttorneyDetailsForUpdate").style.display="none";
	document.getElementById("AttorneyMoreInfo").style.display="none";
	document.getElementById("AddAttorneyButton").disabled = false;
	document.getElementById("DeleteAttorneyButton").disabled = true;

	document.getElementById("attorneyOperation").value = "D";

	/*var inForm = obj;
	if (inForm.deleteAttorney.length > 0) {
		if (inForm.deleteAttorney[0].checked == true) {
			var hideThisRow = document.getElementById("attorneyDetailsRow");
			hideThisRow.style.display = "none";
			inForm.attorneyOperation[0].value = "D";
			var addButton = document.getElementById("AddAttorneyButton");
			addButton.disabled = "";
			inForm.deleteAttorney[0].checked = "";
		}
	*/

}
// ======================= END - RISHABH ============

function manageOtherReason(inForm)
{
	//alert(inForm.selectedComplaintType.length);
	var otherIsSelected = false;
	if(inForm.selectedComplaintType.length)
	{
		for(var i=0;i<inForm.selectedComplaintType.length;i++)
		{
//			alert(inForm.selectedComplaintType[i].value);
			if(inForm.selectedComplaintType[i].value == inForm.complaintTypeOther.value)
			{
				otherIsSelected = true;
				break;
			}
		}
	}
	if(otherIsSelected)
	{
		inForm.otherReasonDescription.readOnly = false;
	}
	else
	{
		inForm.otherReasonDescription.value = "";
		inForm.otherReasonDescription.readOnly = true;
	}
}

function manageSubStatus(obj)
{
	var inForm = obj.form;
	if(inForm.complaintReferredStatus.value == obj.value)
	{
		inForm.selectSubStatus.disabled = false;
		inForm.deselectSubStatus.disabled = false;
	}
	else
	{
		inForm.selectSubStatus.disabled = true;
		inForm.deselectSubStatus.disabled = true;
	}


	populateInvestigationSubStatusValues(inForm);
}

function populateInvestigationSubStatusValues(inForm)
{
	var statusSelected = inForm.status.value;
	var sub_status_list;
	var flag = false;


	for (var index = 0; index < StatusList.length; index++)
	{
		if (StatusList[index].enum1 == statusSelected)
		{
			if (StatusList[index].list1) {
				sub_status_list = StatusList[index].list1;
				flag = true;
				for (var jindex = 0; jindex < sub_status_list.length; jindex++)
				{
					inForm.complaintSubStatus.options[jindex] = new Option(sub_status_list[jindex].description1, sub_status_list[jindex].enum1);
				}
			}
			else {
				flag = false;
			}
		}
	}
	if(flag) {
		inForm.complaintSubStatus.disabled = false;
		inForm.selectedComplaintSubStatus.disabled = false;
	}
	else {
		inForm.complaintSubStatus.length = 0;
		inForm.complaintSubStatus.disabled = true;
		inForm.selectedComplaintSubStatus.length = 0;
		inForm.selectedComplaintSubStatus.disabled = true;

	}
}

function populateRespondentSubStatusValues(inForm)
{

	var statusSelected = inForm.respondentStatus.value;
//	alert("statusSelected = " + statusSelected);
	var sub_status_list;
	var flag = false;

//	alert(StatusList.length);
	for (var index = 0; index < StatusList.length; index++)
	{
		if (StatusList[index].enum1 == statusSelected)
		{
			if (StatusList[index].list1) {
				sub_status_list = StatusList[index].list1;
				flag = true;
				for (var jindex = 0; jindex < sub_status_list.length; jindex++)
				{
					inForm.respondentSubStatus.options[jindex] = new Option(sub_status_list[jindex].description1, sub_status_list[jindex].enum1);
				}
			}
			else {
				flag = false;
			}
		}
	}
	if(flag) {
		inForm.respondentSubStatus.disabled = false;
		inForm.selectedRespondentSubStatus.disabled = false;
		inForm.selectSubStatus.disabled = false;
		inForm.deselectSubStatus.disabled = false;
	}
	else {
		inForm.respondentSubStatus.length = 0;
		inForm.respondentSubStatus.disabled = true;
		inForm.selectedRespondentSubStatus.length = 0;
		inForm.selectedRespondentSubStatus.disabled = true;
	}
}

function manageRespondentSubStatus(obj)
{
	var inForm = obj.form;
	if(inForm.respondentReferredStatus.value == obj.value)
	{
		inForm.selectSubStatus.disabled = false;
		inForm.deselectSubStatus.disabled = false;
	}
	else
	{
		inForm.selectSubStatus.disabled = true;
		inForm.deselectSubStatus.disabled = true;
	}


	populateRespondentSubStatusValues(inForm);
}

function getMessageToDisplay(messageCode) {
	var messages=new Array()
	messages[0] = "Please enter the last name.";
	messages[1] = "Please enter the first name.";
	messages[2] = "Please enter the address.";
	messages[3] = "Please enter the city.";
	messages[4] = "Please enter the state.";
	messages[5] = "Please enter the zip code.";
	return messages[messageCode];
}


function validateComplaintStatusReportForm(obj)
{

	var inForm = obj.form;

	if(inForm.startDate.value == "")
	{
		alert("Please specify the Start Date");
		inForm.startDate.focus();
		return false;
	}

	if(inForm.endDate.value == "")
	{
		alert("Please specify the End Date");
		inForm.endDate.focus();
		return false;
	}

	if(inForm.startDate.value != "" && inForm.endDate.value != "")
	{
		if(checkDates(inForm.startDate.value, inForm.endDate.value) > 0)
		{
			alert("Start date cannot be later than End date");
			inForm.startDate.focus();
			return false;
		}
	}

	SelectAllFromList(inForm.selectedLicenseNames);
	SelectAllFromList(inForm.selectedLicenseLevels);
	SelectAllFromList(inForm.selectedComplaintStatus);
	SelectAllFromList(inForm.selectedComplaintTypes);
	SelectAllFromList(inForm.selectedPriorityCode);
	SelectAllFromList(inForm.selectedInvestigators);
	SelectAllFromList(inForm.selectedCounties);
	SelectAllFromList(inForm.selectedComplaintAdmins);
	SelectAllFromList(inForm.selectedStipulationTerms);


	getAllValuesAsCSVFromList(inForm,inForm.selectedLicenseNames,inForm.selectedLicenseNamesCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedLicenseLevels,inForm.selectedLicenseLevelsCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedComplaintStatus,inForm.selectedComplaintStatusCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedComplaintTypes,inForm.selectedComplaintTypesCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedPriorityCode,inForm.selectedPriorityCodeCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedInvestigators,inForm.selectedInvestigatorsCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedCounties,inForm.selectedCountiesCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedComplaintAdmins,inForm.selectedComplaintAdminsCSV);
	getAllValuesAsCSVFromList(inForm,inForm.selectedStipulationTerms,inForm.selectedStipulationTermsCSV);

	document.all.item("reportGenerate").checked = false;
	if(inForm.reportType.value == 'COMPLAINT_STATUS_REPORT'){
	document.all.item("Submit").disabled = true;
	}

	inForm.target = "_new";
	inForm.action = "/printcontent";
	inForm.submit();
	return true;

}

function getAllValuesAsCSVFromList(inForm,listBox,saveToObj)
{
	var listLength= listBox.length;
	var valCSV = "";
	if(listLength > 0)
	{
		for(var i = 0 ; i< listLength; i++)
		{
			valCSV = valCSV+listBox.options[i].text;
			if(i != listLength-1)
			{
				valCSV += ", ";
			}
		}
	}
	saveToObj.value = valCSV;
}

function enableButton(obj) {

	var inForm = obj;
	//inForm.Submit.disabled = false;
	if(inForm.reportGenerate.checked)
	{
		inForm.Submit.disabled = false;
	}
	else
	{
		inForm.Submit.disabled = true;
	}
	//document.all.item("Submit").disabled = false;
}

/*
 * Helper method for validateComplaintFormWitnessesForAdminSite
 */
function doMandatoryCheckForField(fieldObject, objectName ) {
	if(fieldObject.value == "") {
		alert("Please enter the " + objectName+ ".");
		fieldObject.focus();
		return false;
	}
	return true;
}

/*
 * Helper method for validateComplaintFormWitnessesForAdminSite
 */
function validateZipField(fieldObject) {
	if(fieldObject.value != "")
	{
		flag = validateZIP(fieldObject);
		if(!flag)
		{
			fieldObject.value= "";
			fieldObject.focus();
			return false;
		}
	}
	return true;
}

/*
 * Helper method for validateComplaintFormWitnessesForAdminSite
 */
function validatePhoneField(fieldObject, fieldObjectName) {
	if(fieldObject.value != "")
	{
		flag = checkInternationalPhone(fieldObject.value)
		if(!flag)
		{
			alert("Please enter a valid " + fieldObjectName);
			fieldObject.select();
			fieldObject.focus();
			return false;
		}
	}
	return true;
}

/*
 * Helper method for validateComplaintFormWitnessesForAdminSite
 */
function validateEmalField(fieldObject, fieldObjectName) {
	if(fieldObject.value != "")
	{
		var email = fieldObject.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(email)) {
			alert("Please enter a valid " + fieldObjectName + ".");
			fieldObject.select();
			fieldObject.focus();
			return false;
		}
	}
	return true;
}



/*
 * Author: Venkatesh
 * To Validate witnessForm for the Admin site
 */
function validateComplaintFormWitnessesForAdminSite(inForm) {

	/**************************************************
	 * Field Object Names of Witness Form to be given here.
	 **************************************************/
	var lastNameOnPage = "lastName";
	var firstNameOnPage = "firstName";
	var zipCodeOnPage = "zipCode";
	var phoneOnPage = "phone";
	//var faxOnPage = "fax";
	var emailAddressOnPage = "emailAddress";

	/**************************************************
	 * Field Object Names Declaration Over.
	 * Do not change anything after this line.
	 **************************************************/

	var lastName = eval("inForm." + lastNameOnPage);
	var firstName = eval("inForm." + firstNameOnPage);
	var zipCode = eval("inForm." + zipCodeOnPage);
	var phone = eval("inForm." + phoneOnPage);
	//var fax = eval("inForm." + faxOnPage);   	//Have commented fax number for now. If fax is added to the page, this comment may be removed.
	var emailAddress = eval("inForm." + emailAddressOnPage);
	var numberOfTables = 1;

	if (lastName[0]) numberOfTables = lastName.length;

	if(numberOfTables == 1) {

		lastName.value = trim(lastName.value);
		firstName.value = trim(firstName.value);
		zipCode.value = trim(zipCode.value);
		phone.value = trim(phone.value);
		//fax.value = trim(fax.value);
		emailAddress.value = trim(emailAddress.value);

		if (!doMandatoryCheckForField(lastName, "last name")) return false;
		if (!doMandatoryCheckForField(firstName, "first name")) return false;
		if (!validateZipField(zipCode)) return false;
		if (!validatePhoneField(phone, "phone number")) return false;
		//if (!validatePhoneField(fax, "fax number")) return false;
		if (!validateEmalField(emailAddress, "email address")) return false;


	}


	if(numberOfTables > 1) {
		for(var i = 0; i < numberOfTables; i++) {

			lastName[i].value = trim(lastName[i].value);
			firstName[i].value = trim(firstName[i].value);
			zipCode[i].value = trim(zipCode[i].value);
			phone[i].value = trim(phone[i].value);
			//fax[i].value = trim(fax[i].value);
			emailAddress[i].value = trim(emailAddress[i].value);

			if (!doMandatoryCheckForField(lastName[i], "last name")) return false;
			if (!doMandatoryCheckForField(firstName[i], "first name")) return false;
			if (!validateZipField(zipCode[i])) return false;
			if (!validatePhoneField(phone[i], "phone number")) return false;
			//if (!validatePhoneField(fax[i], "fax number")) return false;
			if (!validateEmalField(emailAddress[i], "email address")) return false;
		}
	}

	return true;
}

/*
 * Author: Venkatesh
 * To Validate witnessForm for the Admin site
 */
function validateComplaintFormWitnessesForAdminSiteUpdate(inForm) {



	/**************************************************
	 * Field Object Names of Witness Form to be given here.
	 **************************************************/
	var lastNameOnPage = "witnessLastName";
	var firstNameOnPage = "witnessFirstName";
	var zipCodeOnPage = "witnessZipCode";
	var phoneOnPage = "witnessPhone";
	//var faxOnPage = "fax";
	var emailAddressOnPage = "witnessEmailAddress";

	/**************************************************
	 * Field Object Names Declaration Over.
	 * Do not change anything after this line.
	 **************************************************/


	var lastName = eval("inForm." + lastNameOnPage);
	var firstName = eval("inForm." + firstNameOnPage);
	var zipCode = eval("inForm." + zipCodeOnPage);
	var phone = eval("inForm." + phoneOnPage);
	//var fax = eval("inForm." + faxOnPage);   	//Have commented fax number for now. If fax is added to the page, this comment may be removed.
	var emailAddress = eval("inForm." + emailAddressOnPage);

	var numberOfTables = 0;
	if (lastName[0]) numberOfTables = lastName.length;

	if(numberOfTables == 1) {

		//Trim Fields
		lastName.value = trim(lastName.value);
		firstName.value = trim(firstName.value);
		zipCode.value = trim(zipCode.value);
		phone.value = trim(phone.value);
		emailAddress.value = trim(emailAddress.value);

		if (!doMandatoryCheckForField(lastName, "last name")) return false;
		if (!doMandatoryCheckForField(firstName, "first name")) return false;
		if (!validateZipField(zipCode)) return false;
		if (!validatePhoneField(phone, "phone number")) return false;
		//if (!validatePhoneField(fax, "fax number")) return false;
		if (!validateEmalField(emailAddress, "email address")) return false;
	}


	if(numberOfTables > 1) {
		numberOfTables = numberOfTables -1;

		for(var i = 0; i < numberOfTables; i++) {

			obj = inForm.deleteWitness[i];

			if (obj.parentElement.parentElement.parentElement.parentElement.style.display != "none") {

				//Trim Fields
				lastName[i].value = trim(lastName[i].value);
				firstName[i].value = trim(firstName[i].value);
				zipCode[i].value = trim(zipCode[i].value);
				phone[i].value = trim(phone[i].value);
				emailAddress[i].value = trim(emailAddress[i].value);

				if (!doMandatoryCheckForField(lastName[i], "last name")) return false;
				if (!doMandatoryCheckForField(firstName[i], "first name")) return false;
				if (!validateZipField(zipCode[i])) return false;
				if (!validatePhoneField(phone[i], "phone number")) return false;
				//if (!validatePhoneField(fax[i], "fax number")) return false;
				if (!validateEmalField(emailAddress[i], "email address")) return false;
			}
		}
	}

	return true;
}

function sendCorrespondenceForComplaint(formObj)
{
	formObj.submit();
}

function adminSiteAddComplaint_enableDisableRemoveWitnessButton(inForm) {
	var blnDeleteChecked = false;
	var numberOfTables = 1;

	if (inForm.lastName.length)	numberOfTables = inForm.lastName.length;

	if (!inForm.deleteTable[0]) {
		if (inForm.deleteTable.checked) blnDeleteChecked = true;
	} else {
		for (i=0;i<numberOfTables;i++) {
			if (inForm.deleteTable[i].checked) blnDeleteChecked = true;
		}
	}

	if (blnDeleteChecked)
		inForm.removeWitness.disabled = false;
	else
		inForm.removeWitness.disabled = true;
}

function adminSiteAddComplaint_enableDisableRemoveAttorneyButton(inForm) {
	var blnDeleteChecked = false;
	var numberOfTables = 1;

	if (inForm.lastName.length)	numberOfTables = inForm.lastName.length;

	if (!inForm.deleteTable[0]) {
		if (inForm.deleteTable.checked) blnDeleteChecked = true;
	} else {
		for (i=0;i<numberOfTables;i++) {
			if (inForm.deleteTable[i].checked) blnDeleteChecked = true;
		}
	}

	if (blnDeleteChecked)
		inForm.removeWitness.disabled = false;
	else
		inForm.removeWitness.disabled = true;
}

function adminSiteAddComplaint_enableDisableRemoveAttorneyButton(inForm) {

	if (document.getElementById("AttorneyDetailsTable").style.display == "none") {
		inForm.removeAttorneyButton.disabled = false;
		inForm.addAttorneyButton.disabled = true;
		document.getElementById("AttorneyDetailsTable").style.display = "";
	} else {
		inForm.removeAttorneyButton.disabled = true;
		inForm.addAttorneyButton.disabled = false;
		document.getElementById("AttorneyDetailsTable").style.display = "none";
	}
}

function trimAttorneyFields(inForm) {
	inForm.attorneyLastName.value = trim(inForm.attorneyLastName.value);
	inForm.attorneyFirstName.value = trim(inForm.attorneyFirstName.value);
	inForm.attorneyAddress.value = trim(inForm.attorneyAddress.value);
	inForm.attorneyCity.value = trim(inForm.attorneyCity.value);
	inForm.attorneyState.value = trim(inForm.attorneyState.value);
	inForm.attorneyZipCode.value = trim(inForm.attorneyZipCode.value);
	inForm.attorneyPhone.value = trim(inForm.attorneyPhone.value);
	inForm.attorneyFax.value = trim(inForm.attorneyFax.value);
	inForm.attorneyEmailAddress.value = trim(inForm.attorneyEmailAddress.value);
}

function adminSiteAddComplaint_validateAttorney(inForm) {

	//if attorney is not visible, don't validate
	if (document.getElementById("AttorneyDetailsTable").style.display == "none") return true;

	trimAttorneyFields(inForm);

	if(inForm.attorneyLastName.value == "") {
		alert("Please enter the last name.");
		inForm.attorneyLastName.focus();
		return false;
	}

	if(inForm.attorneyFirstName.value == "") {
		alert("Please enter the first name.");
		inForm.attorneyFirstName.focus();
		return false;
	}

	if(inForm.attorneyAddress.value == "") {
		alert("Please enter the address.");
		inForm.attorneyAddress.focus();
		return false;
	}

	if(inForm.attorneyCity.value == "") {
		alert("Please enter the city.");
		inForm.attorneyCity.focus();
		return false;
	}

	if(inForm.attorneyState.value == "") {
		alert("Please enter the state.");
		inForm.attorneyState.focus();
		return false;
	}

	if(inForm.attorneyZipCode.value == "") {
		alert("Please enter the zip code.");
		inForm.attorneyZipCode.focus();
		return false;
	}

	if(inForm.attorneyZipCode != "")
	{
		flag = validateZIP(inForm.attorneyZipCode);
		if(!flag)
		{
			inForm.attorneyZipCode.value= "";
			inForm.attorneyZipCode.focus();
			return false;
		}
	}



	var phone = inForm.attorneyPhone.value;
	if(phone == "") {
		alert("Please enter the telephone number.");
		inForm.attorneyPhone.focus();
		return false;
	}

	if(phone != "") {
		var isNumerals = isValid(phone, numbers);
		if (!isNumerals) {
			alert("Please enter only numeric characters for the telephone number.");
			inForm.attorneyPhone.value = "";
			inForm.attorneyPhone.focus();
			return false;
		}
	}

	if(phone != "" && phone.length != 10) {
		alert("Please enter the full telephone number.");
			inForm.attorneyPhone.select();
			inForm.attorneyPhone.focus();
			return false;
	}


	if(inForm.attorneyFax.value != "" && inForm.attorneyFax.value.length != 10) {
		alert("Please enter the full fax number.");
		inForm.attorneyFax.focus();
		return false;
	}

	if(inForm.attorneyFax.value != "")
	{
		flag = checkInternationalPhone(inForm.attorneyFax.value)
		if(!flag)
		{
			alert("Please enter a valid fax number");
			inForm.attorneyFax.value= "";
			inForm.attorneyFax.focus();
			return false;
		}
	}

	var email = inForm.attorneyEmailAddress.value;
	if (email != "") {
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(email)) {
			alert("Please enter a valid email address.");
			inForm.attorneyEmailAddress.select();
			inForm.attorneyEmailAddress.focus();
			return false;
		}
	}

	if (inForm.rbLawSuit[0].checked == false && inForm.rbLawSuit[1].checked == false) {
		alert("Please answer question 'a'.");
		return false;
	}

	if (inForm.rbLawSuitDismissed[0].checked == false && inForm.rbLawSuitDismissed[1].checked == false) {
		alert("Please answer question 'b'.");
		return false;
	}

	if (inForm.rbHasValidJudgement[0].checked == false && inForm.rbHasValidJudgement[1].checked == false) {
		alert("Please answer question 'c'.");
		return false;
	}

	if (inForm.rbHasArbitrationParticipation[0].checked == false && inForm.rbHasArbitrationParticipation[1].checked == false) {
		alert("Please answer question 'd'.");
		return false;
	}

	if ((inForm.rbLawSuit[0].checked || inForm.rbLawSuitDismissed[0].checked ||
		 inForm.rbHasValidJudgement[0].checked || inForm.rbHasArbitrationParticipation[0].checked)
		&& (trim(inForm.moreInformation.value) == "")) {
		alert("Please answer question 'e'.");
		inForm.moreInformation.value = "";
		inForm.moreInformation.focus();
		return false;
	}

	/* Function : Validating for textarea(More Information) text length before submitting
       Author	: Janardhana
    */
    if (inForm.moreInformation.value !=null && inForm.moreInformation.value !="")
    {
    	if ((inForm.moreInformation.value).length > 4000){
    	alert ("Number of characters exceeds the maximum(4000) allowed.");
    	inForm.moreInformation.focus();
    	return false;
    	}
    }
	//Validation is completed

	return true;
}

function populateCountiesForState(inForm, stateObj, countyObj)
{
	var tmpCountyList = null;
    if (stateObj.value != "")
    {
        var stateName = stateObj;

        alert(stateName);

        for(i = 0; i < states.length; i++)
        {
            var tmpState = states[i];

            if(trim(stateName) == tmpState.stateName)
            {
				tmpCountyList = tmpState.countyList;
                if (tmpCountyList == null || tmpCountyList == "" || tmpCountyList.length == 0)
                {
				    countyObj.length = (0);
                    countyObj.options[0] = new Option("-- Select --","");
                    continue;
                }
                countyObj.length = (0);
                for(j = 0; j < tmpCountyList.length; j++)
                {
                    var county = tmpCountyList[j];
					countyObj.options[j] = new Option(county.name,county.name);
                }
            }
        }
    }
	else
	{

		   countyObj.length = 0;
           countyObj.options[0] = new Option("-- Select --","");
	}

}



function adminSiteUpdateComplaint_validateAttorney(inForm) {

	if (document.getElementById("AttorneyDetailsForUpdate").style.display=="none") return true;

	if(trim(inForm.lastName.value) == "") {
		alert("Please enter the last name.");
		inForm.lastName.select();
		inForm.lastName.focus();
		return false;
	}

	if(trim(inForm.firstName.value) == "") {
		alert("Please enter the first name.");
		inForm.firstName.select();
		inForm.firstName.focus();
		return false;
	}

	if(trim(inForm.address.value) == "") {
		alert("Please enter the address.");
		inForm.address.select();
		inForm.address.focus();
		return false;
	}

	if(trim(inForm.city.value) == "") {
		alert("Please enter the city.");
		inForm.city.select();
		inForm.city.focus();
		return false;
	}

	if(trim(inForm.state.value) == "") {
		alert("Please enter the state.");
		inForm.state.focus();
		return false;
	}

	if(trim(inForm.zipCode.value) == "") {
		alert("Please enter the zip code.");
		inForm.zipCode.select();
		inForm.zipCode.focus();
		return false;
	}

	if(inForm.zipCode != "")
	{
		flag = validateZIP(inForm.zipCode);
		if(!flag)
		{
			inForm.zipCode.value= "";
			inForm.zipCode.focus();
			return false;
		}
	}



	var phone = trim(inForm.phone.value);
	if(phone == "") {
		alert("Please enter the telephone number.");
		inForm.phone.select();
		inForm.phone.focus();
		return false;
	}

	if(phone != "") {
		var isNumerals = isValid(phone, numbers);
		if (!isNumerals) {
			alert("Please enter only numeric characters for the telephone number.");
			inForm.phone.select();
			inForm.phone.focus();
			return false;
		}
	}

	if(phone != "" && phone.length != 10) {
		alert("Please enter the full telephone number.");
			inForm.phone.select();
			inForm.phone.focus();
			return false;
	}


	if(trim(inForm.fax.value) != "" && trim(inForm.fax.value).length != 10) {
		alert("Please enter the full fax number.");
		inForm.fax.select();
		inForm.fax.focus();
		return false;
	}

	if(trim(inForm.fax.value) != "")
	{
		flag = checkInternationalPhone(trim(inForm.fax.value))
		if(!flag)
		{
			alert("Please enter a valid fax number");
			inForm.fax.select();
			inForm.fax.focus();
			return false;
		}
	}

	var email = trim(inForm.emailAddress.value);
	if (email != "") {
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(email)) {
			alert("Please enter a valid email address.");
			inForm.emailAddress.select();
			inForm.emailAddress.focus();
			return false;
		}
	}

	if (inForm.rbLawSuit[0].checked == false && inForm.rbLawSuit[1].checked == false) {
		alert("Please answer question 'a'.");
		return false;
	}

	if (inForm.rbLawSuitDismissed[0].checked == false && inForm.rbLawSuitDismissed[1].checked == false) {
		alert("Please answer question 'b'.");
		return false;
	}

	if (inForm.rbHasValidJudgement[0].checked == false && inForm.rbHasValidJudgement[1].checked == false) {
		alert("Please answer question 'c'.");
		return false;
	}

	if (inForm.rbHasArbitrationParticipation[0].checked == false && inForm.rbHasArbitrationParticipation[1].checked == false) {
		alert("Please answer question 'd'.");
		return false;
	}

	if ((inForm.rbLawSuit[0].checked || inForm.rbLawSuitDismissed[0].checked ||
		 inForm.rbHasValidJudgement[0].checked || inForm.rbHasArbitrationParticipation[0].checked)
		&& (trim(inForm.moreInformation.value) == "")) {
		alert("Please answer question 'e'.");
		inForm.moreInformation.select();
		inForm.moreInformation.focus();
		return false;
	}

	/* Function : Validating for textarea(More Information) text length before submitting
       Author	: Janardhana
    */
    if (inForm.moreInformation.value !=null && inForm.moreInformation.value !="")
    {
    	if ((inForm.moreInformation.value).length > 4000){
    	alert ("Number of characters exceeds the maximum(4000) allowed.");
    	inForm.moreInformation.focus();
    	return false;
    	}
    }
	//Validation is completed

	return true;
}

function validateUpdateInvestigation(obj)
{
	var inForm = obj.form;
	var doc = obj.form.document;
	if(! validateRespondent(inForm))
	{
		return false;
	}

	if(! validateComplainant(inForm))
	{
		return false;
	}

	if(! validateAdditionalComplainants(inForm))
	{
		return false;
	}

	if(! validateWitnesses(inForm))
	{
		return false;
	}

	if(! validateAttorneys(inForm))
	{
		return false;
	}

	if(! validateAdminComplaintFormAttorneyInfo(inForm))
	{
		return false;
	}

	if(! validateForeclosureDetailsforViewEdit(inForm))
	{
		return false;
	}

	SelectAllFromList(inForm.selectedComplaintType);
	disableObjectAndSubmit(obj);

	return false;
}
function validate4CheckAll(checkAllObj, chkObj, inForm)
{
    var selectAll = true;
    if(null != chkObj)
    {
        if(chkObj.length)
        {
            for(var i=0; i < chkObj.length; i++)
            {
                if(!chkObj[i].checked)
                {
                    selectAll = false;
                }
            }
        }
        else
        {
            if(!chkObj.checked)
            {
                selectAll = false;
            }
        }
    }
    if(selectAll)
        checkAllObj.checked = true;
    else
        checkAllObj.checked = false;

	//Code for enabling disabling delete button starts
	var bDisableDeleteButton = true;
	if(chkObj.length)
	{
		for (var i=0;i<chkObj.length;i++)
	       {
	           if(chkObj[i].checked)
	           {
				bDisableDeleteButton = false;
	           }
	       }
	}
	else
	{
		if(chkObj.checked)
	    {
			bDisableDeleteButton = false;
		}
	}
	inForm.deleteAlertButton.disabled = bDisableDeleteButton;
	//Code for enabling disabling delete button ends
}

function checkAllTests(inForm)
{
	if(null != inForm.alertDetailsId)
	{
		if(inForm.alertDetailsId.length)
		{
			var bFlag= false;

			if(inForm.checkall.checked)
			{
				bFlag = true;
			}
			for(var i=0; i < inForm.alertDetailsId.length; i++)
			{
				inForm.alertDetailsId[i].checked = bFlag;
			}
	 	}
		else
		{
			if(inForm.checkall.checked)
			{
				inForm.alertDetailsId.checked = true;
			}
			else
			{
				inForm.alertDetailsId.checked = false;
			}
		}

		//Code for enabling disabling delete button starts
		var bDisableDeleteButton = true;
		if(inForm.alertDetailsId.length)
		{
			for (var i=0;i<inForm.alertDetailsId.length;i++)
	        {
	            if(inForm.alertDetailsId[i].checked)
	            {
					bDisableDeleteButton = false;
	            }
	        }
		}
		else
		{
			if(inForm.alertDetailsId.checked)
	        {
				bDisableDeleteButton = false;
			}
		}
		inForm.deleteAlertButton.disabled = bDisableDeleteButton;
		//Code for enabling disabling delete button ends
	}
}

function deleteComplaintAlerts(inForm)
{
	var userAnswer = confirm(sGlobalMessageArr[ MSG_DELETE_ALERT ]);
	if(userAnswer == true)
	{
		inForm.methodToCall.value = 'delete';
		inForm.deleteAlertButton.disabled="true";
		inForm.submit();
	}
}

function doAlertsCancel(obj)
{
	var inForm = obj.form;
	inForm.action = '/enforcement/SetUpViewMyComplaintsForm.do?methodToCall=search';
	inForm.submit();
}

function complaintPopUp(auditLogId, auditType)
{
    var width=790;
    var height=600;


	var auditID = auditLogId;
	var url = '/enforcement/showAuditLog.do?Id='+auditID+'&auditType='+auditType;
	window.open(url, null, ' left = 100, top = 100, height=' + height + ',width=' + width+ ',scrollbars=yes,status=no');
}

	function expandSection(doc,sectionName,imageName)
{
if(doc.getElementById(imageName))
	{
	doc.getElementById(imageName).src=doc.forms[0].collapseImage.value;
	doc.getElementById(imageName).alt="Hide Details";
	}
if(doc.getElementById(sectionName))
	{
	doc.getElementById(sectionName).style.display = "";
	}

}

function doInvestigationCancel(obj)
{
	var inForm = obj.form;
	inForm.action = '/enforcement/SetUpViewMyComplaintsForm.do?methodToCall=search';
	inForm.submit();
}

function showLicenseDetails(obj,licenseId){

	var inForm = obj;
	inForm.action = '/licenseprocessing/showIndividualLicenseeDetails.do?licenseId='+licenseId;
	inForm.submit();

}

function populateComplaintTypeListBox(inForm)
{
	if(document.forms[0].respondentLicenseName.value=="1")
	{
		if(document.forms[0].complaintTypeForRE)
		{
		document.forms[0].complaintTypeForRE.style.display="";
		document.forms[0].complaintTypeForAP.style.display="none";
		document.forms[0].complaintTypeForMB.style.display="none";
		document.forms[0].complaintTypeForLMB.style.display="none";
		document.forms[0].complaintType.style.display="none";
		document.forms[0].fromObj.value="complaintTypeForRE";
		}

	}
	else if(document.forms[0].respondentLicenseName.value=="2")
	{
		if(document.forms[0].complaintTypeForAP)
		{
			document.forms[0].complaintTypeForAP.style.display="";
			document.forms[0].complaintTypeForRE.style.display="none";
			document.forms[0].complaintTypeForMB.style.display="none";
			document.forms[0].complaintTypeForLMB.style.display="none";
			document.forms[0].complaintType.style.display="none";
			document.forms[0].fromObj.value="complaintTypeForAP";
		}
	}
	else if(document.forms[0].respondentLicenseName.value=="4")
	{
		if(document.forms[0].complaintTypeForMB)
		{
			document.forms[0].complaintTypeForMB.style.display="";
			document.forms[0].complaintTypeForRE.style.display="none";
			document.forms[0].complaintTypeForAP.style.display="none";
			document.forms[0].complaintTypeForLMB.style.display="none";
			document.forms[0].complaintType.style.display="none";
			document.forms[0].fromObj.value="complaintTypeForMB";
		}
	}
	else if(document.forms[0].respondentLicenseName.value=="5")
	{
		if(document.forms[0].complaintTypeForLMB)
		{
			document.forms[0].complaintTypeForLMB.style.display="";
			document.forms[0].complaintTypeForRE.style.display="none";
			document.forms[0].complaintTypeForAP.style.display="none";
			document.forms[0].complaintTypeForMB.style.display="none";
			document.forms[0].complaintType.style.display="none";
			document.forms[0].fromObj.value="complaintTypeForLMB";
		}
	}
	else
	{
		if(document.forms[0].complaintTypeForMB)
		{
			document.forms[0].complaintType.style.display="";
			document.forms[0].complaintTypeForRE.style.display="none";
			document.forms[0].complaintTypeForAP.style.display="none";
			document.forms[0].complaintTypeForMB.style.display="none";
			document.forms[0].complaintTypeForLMB.style.display="none";
			document.forms[0].fromObj.value="complaintType";
		}
	}
}


function limitTextGeneric(limitField,limitNum) {
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	}

}

function limitTextWithCount(limitField,limitcount,limitNum)
 {
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	}
	else
	{
		//limitcount.value=limitField.value.length
		limitcount.innerHTML = limitField.value.length;
		limitcount.value = limitField.value.length;
	}

}



function deleteStipulationRecord(inForm)
{
if(inForm.removeTermOfStipulation[0]){

for(i=document.getElementById("termsOfStipulationDetails").rows.length-1;i>=0;i--)
{
if(inForm.removeTermOfStipulation[i].checked)
	{
if(inForm.termsOfStipulationId[i].value !="" && inForm.termsOfStipulationOperation[i].value!="D" )
		{
inForm.termsOfStipulationOperation[i].value="D";
document.getElementById("termsOfStipulationDetails").rows(i).style.display = "none";
		}
else
	{
document.getElementById("termsOfStipulationDetails").deleteRow(i);
}
}
}
}
}
function enableDisablePrintAndRemoveButton(inForm)
{
	var selectedDocumentCount = 0;
	var existingDocumentDetails = "";
	for(i=document.all.documentAttachementDetails.rows.length-3;i>=0;i--)
	{
		if(inForm.chkDocumentAttachment[i].checked)
		{
			selectedDocumentCount++;
		}
	}
	if(selectedDocumentCount==1)
	{
		for(i=document.all.documentAttachementDetails.rows.length-3;i>=0;i--)
		{
			if(inForm.chkDocumentAttachment[i].checked)
			{
				var existingDocumentAttachementDetails = inForm.chkDocumentAttachment[i].value;

				if(existingDocumentAttachementDetails!="")
				{
					document.all.PrintDocument.disabled = false;
				}
			}
		}
	}
	else
	{
		document.all.PrintDocument.disabled = true;
	}

	if(selectedDocumentCount>=1)
	{
		document.all.RemoveDocument.disabled = false;
	}
	else
	{
		document.all.RemoveDocument.disabled = true;
	}
}

function launchDocumentDisplayPopUpWithPrinting(inForm)
{
	for(i=document.all.documentAttachementDetails.rows.length-3;i>=0;i--)
	{
		if(inForm.chkDocumentAttachment[i].checked)
		{
			var documentDisplayAttributesArray=inForm.chkDocumentAttachment[i].value.split(",");
			var a = window.open('/servlet/documentcontentdisplay?documentId='+documentDisplayAttributesArray[0]+'&complaintId='+documentDisplayAttributesArray[1]+'&accountId='+documentDisplayAttributesArray[2],'null','');
			a.print();
		}
	}
}

function launchStipulationDocumentDisplayPopUpWithPrinting(inForm)
{
	for(i=document.all.documentAttachementDetails.rows.length-3;i>=0;i--)
	{
		if(inForm.chkDocumentAttachment[i].checked)
		{
			var documentDisplayAttributesArray=inForm.chkDocumentAttachment[i].value.split(",");
			var a = window.open('/servlet/documentcontentdisplay?documentId='+documentDisplayAttributesArray[0]+'&complaintId='+documentDisplayAttributesArray[1]+'&accountId='+documentDisplayAttributesArray[2]+'&stipulationId='+documentDisplayAttributesArray[3]+'&isStipulationDocument='+documentDisplayAttributesArray[4],'null','');
			a.print();
		}
	}
}
function appraisalFraudToggle(countStartValue)
{
	appraisalFraudToggle.count = ++appraisalFraudToggle.count || countStartValue;
	if(appraisalFraudToggle.count % 2 == 0)	document.getElementById('appraisalFraud').checked=false; else document.getElementById('appraisalFraud').checked=true;
}
function lackToggle(countStartValue)
{
	lackToggle.count = ++lackToggle.count || countStartValue;
	if(lackToggle.count % 2 == 0)	document.getElementById('lack').checked=false; else document.getElementById('lack').checked=true;
}
function divorseToggle(countStartValue)
{
	divorseToggle.count = ++divorseToggle.count || countStartValue;
	if(divorseToggle.count % 2 == 0)	document.getElementById('divorse').checked=false; else document.getElementById('divorse').checked=true;
}
function lossToggle(countStartValue)
{
	lossToggle.count = ++lossToggle.count || countStartValue;
	if(lossToggle.count % 2 == 0)	document.getElementById('loss').checked=false; else document.getElementById('loss').checked=true;
}
function incompetenceToggle(countStartValue)
{
	incompetenceToggle.count = ++incompetenceToggle.count || countStartValue;
	if(incompetenceToggle.count % 2 == 0)	document.getElementById('incompetence').checked=false; else document.getElementById('incompetence').checked=true;
}
function medicalToggle(countStartValue)
{
	medicalToggle.count = ++medicalToggle.count || countStartValue;
	if(medicalToggle.count % 2 == 0)	document.getElementById('medical').checked=false; else document.getElementById('medical').checked=true;
}
function lackmortgageToggle(countStartValue)
{
	lackmortgageToggle.count = ++lackmortgageToggle.count || countStartValue;
	if(lackmortgageToggle.count % 2 == 0)	document.getElementById('lackmortgage').checked=false; else document.getElementById('lackmortgage').checked=true;
}
function mortgageFraudToggle(countStartValue)
{
	mortgageFraudToggle.count = ++mortgageFraudToggle.count || countStartValue;
	if(mortgageFraudToggle.count % 2 == 0)	document.getElementById('mortgageFraud').checked=false; else document.getElementById('mortgageFraud').checked=true;
}
function mortagageProductToggle(countStartValue)
{
	mortagageProductToggle.count = ++mortagageProductToggle.count || countStartValue;
	if(mortagageProductToggle.count % 2 == 0)	document.getElementById('mortagageProduct').checked=false; else document.getElementById('mortagageProduct').checked=true;
}
function reFraudToggle(countStartValue)
{
	reFraudToggle.count = ++reFraudToggle.count || countStartValue;
	if(reFraudToggle.count % 2 == 0)	document.getElementById('reFraud').checked=false; else document.getElementById('reFraud').checked=true;
}
function financialHardshipToggle(countStartValue)
{
	financialHardshipToggle.count = ++financialHardshipToggle.count || countStartValue;
	if(financialHardshipToggle.count % 2 == 0)	document.getElementById('financialHardship').checked=false; else document.getElementById('financialHardship').checked=true;
}
function otherToggle(countStartValue)
{
	otherToggle.count = ++otherToggle.count || countStartValue;
	if(otherToggle.count % 2 == 0)	document.getElementById('other').checked=false; else document.getElementById('other').checked=true;
}


// Function to compare the dates
function CompareDates(date1, date2)

{
   var str1  = date1.value;

   var str2  = date2.value;

   var mon1   = parseInt(str1.substring(0,2),10);

   var dt1  = parseInt(str1.substring(3,5),10);

   var yr1   = parseInt(str1.substring(6,10),10);

   var mon2   = parseInt(str2.substring(0,2),10);

   var dt2  = parseInt(str2.substring(3,5),10);

   var yr2   = parseInt(str2.substring(6,10),10);

   var date1 = new Date(yr1, mon1, dt1);

   var date2 = new Date(yr2, mon2, dt2);

   if(date2 < date1)

   {
      return false;
   }

   else
   {
	return true;
   }

}