<!--


function numericValidation(from, e)
{
	if(window.event) // IE
		keynum = e.keyCode;
	else if(e.which) // Netscape/Firefox/Opera
		keynum = e.which;

	if (from == 'phone')
	{
		if ((keynum == 43) || (keynum == 45) || (keynum == 8))
			return true;
		else
		{
			if ((keynum >= 48) && (keynum <= 57))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
	else
	{
		if ((keynum < 48) || (keynum > 57)) // only numbers are valid
		{
			if ((keynum != 46) && (keynum != 8))// if decimal key
			{
				return false;
			}
		}
	}
}

function resetMenus()
{
	document.getElementById(itemMenu1[0]).selected = true;
	document.getElementById(itemMenu2[0]).selected = true;
	document.getElementById(itemMenu3[0]).selected = true;
	document.getElementById(itemMenu4[0]).selected = true;
	document.getElementById(itemMenu5[0]).selected = true;
	document.getElementById(itemMenu6[0]).selected = true;
	document.getElementById(itemMenu7[0]).selected = true;
}

function checkPurchasePrice()
{
	val1 = parseInt(document.getElementById('constructionCost').value);
	val2 = parseInt(document.getElementById('purchasePrice').value);
	if (val1 >= val2){
		alert("Construction cost MUST be less than the Purchase Price.");
	}
	
}

function capValidate(){
	var isError = false;
	var errorMsgText = "<ul class='errorList'>";
	var dots = '<li>';
	if (document.getElementById('constructionCost').disabled == false){ // not disabled
		if ((document.getElementById('buildDate').value != "Pre 1985") || (document.getElementById('buildingDateValue').value != "01/01/1985")){
			if (isRequired(document.getElementById('constructionCost').value)){
				isError = true;
				errorMsgText += dots+"Please enter the Construction Cost </li>";
				document.getElementById('constructionCostSpan').style.color = "#FF0000";
			} else {
				if (isNaN(document.getElementById('constructionCost').value)){ // not a number
					errorMsgText += dots+"Please enter your Construction Cost As a Numerical Value</li>";
					document.getElementById('constructionCostSpan').style.color = "#FF0000";
				} else {
					document.getElementById('constructionCostSpan').style.color = "#78A7D5";
				}
			}
		}
	}
	
	if (!isError) {
//		ShowHideTheRow('blahrow1123');
//		ShowHideTheRow('blahrow11232');
//		ShowHideTheRow('pne');
//		ShowHideTheRow('pne2');
		// hide the button
	//	document.getElementById('capOK').style.visibility = "hidden";
//document.getElementById('fxRow').style.visibility= "visible";
//		ShowHideTheRow('selectFX');
//		ShowHideTheRow('enterFX');
        //scrollTo(0,document.body.scrollHeight);
	} else {
//		firstSwap();
		popSizedWin("error.php?error=" + errorMsgText, 500, 500);
	}
}
function checkForm()
{
	allOk = true;
	errorMsgText = "<ul class='errorList'>";
	numIterations = document.getElementById('rowCounter').value;

	for (i = 0; i < numIterations; i++)
	{
		if (itemArray[i] == 1)
		{
			if (document.getElementById('isUser' + i).value == 1)
			{
				if ((document.getElementById('userValue' + i).value == null) || (document.getElementById('userValue' + i).value.length == 0))
				{
					errorMsgText += "<li>Please Enter a Valid Cost for <b>"+thePlantItems[i][2]+"</b></li>";
					allOk = false;
				} 
			} else
			{
				if ((document.getElementById('value' + i).value == null) || (document.getElementById('value'+ i).value.length == 0))
				{
					errorMsgText += "<li>Please Enter a Valid Original Value for <b>"+thePlantItems[i][2]+"</b></li>";
					allOk = false;
				} 
			}
						
			if ((document.getElementById('qtyCount' + i).value == null) || (document.getElementById('qtyCount' + i).value.length == 0))
			{
				errorMsgText += "<li>Please Enter a Quantity Value for <b>"+thePlantItems[i][2]+"</b></li>";
				allOk = false;
			} 
			
			if ((document.getElementById('date' + i).value == null) || (document.getElementById('date' + i).value.length == 0))
			{
				errorMsgText += "<li>Invalid Date Value for <b>"+thePlantItems[i][2]+"</b></li>";
				allOk = false;
			} 
			
			if ((document.getElementById('pRate' + i).value == null) || (document.getElementById('pRate' + i).value.length == 0))
			{
				errorMsgText += "<li>Please Enter a Valid Rate for <b>"+thePlantItems[i][2]+"</b></li>";
				allOk = false;
			} 
		}
	}
	errorMsgText += "</ul>";

	if (allOk)
	{
		//Hack to cater for firefox not being able to post form vars that aren't on the bottom layer
		bottomVars = '';
		for (i = 0; i < document.getElementById('rowCounter').value; i++)
		{
			if (document.getElementById('itemID' + i))
				bottomVars += '<input type="hidden" name="itemID' + i + '" id="itemID' + i + '" value="' + document.getElementById('itemID' + i).value + '">\n';

			if (document.getElementById('itemDesc' + i))
				bottomVars += '<input type="hidden" name="itemDesc' + i + '" id="itemDesc' + i + '" value="' + document.getElementById('itemDesc' + i).value + '">\n';

			if (document.getElementById('qtyCount' + i))
				bottomVars += '<input type="hidden" name="qtyCount' + i + '" id="qtyCount' + i + '" value="' + document.getElementById('qtyCount' + i).value + '">\n';

			if (document.getElementById('qtyType' + i))
				bottomVars += '<input type="hidden" name="qtyType' + i + '" id="qtyType' + i + '" value="' + document.getElementById('qtyType' + i).value + '">\n';

			if (document.getElementById('value' + i))
				bottomVars += '<input type="hidden" name="value' + i + '" id="value' + i + '" value="' + document.getElementById('value' + i).value + '">\n';

			if (document.getElementById('isUser' + i))
				bottomVars += '<input type="hidden" name="isUser' + i + '" id="isUser' + i + '" value="' + document.getElementById('isUser' + i).value + '">\n';

			if (document.getElementById('userValue' + i))
				bottomVars += '<input type="hidden" name="userValue' + i + '" id="userValue' + i + '" value="' + document.getElementById('userValue' + i).value + '">\n';

			if (document.getElementById('date' + i))
				bottomVars += '<input type="hidden" name="date' + i + '" id="date' + i + '" value="' + document.getElementById('date' + i).value + '">\n';

			if (document.getElementById('dRate' + i))
				bottomVars += '<input type="hidden" name="dRate' + i + '" id="dRate' + i + '" value="' + document.getElementById('dRate' + i).value + '">\n';

			if (document.getElementById('pRate' + i))
				bottomVars += '<input type="hidden" name="pRate' + i + '" id="pRate' + i + '" value="' + document.getElementById('pRate' + i).value + '">\n\n';
		}
		//alert(bottomVars);
		document.getElementById('jsvars').innerHTML = bottomVars;
		document.getElementById('taxFrm').submit();
	} else
	{
		popSizedWin("error.php?error=" + errorMsgText, 500, 500);
	}
	
}

function checkRow(id, menuID){
	var errorMsgText = "<ul class='errorList'>";
	var dots = '<li>';
	var allOk = true;
	// ***************************************
	// DYNAMIC ROWS FIELD VALIDATION
	// ***************************************
	if (id == 1){
		if (isRequired(document.getElementById('settleDate').value)){ // no settlement date entered
			allOk = false;
			errorMsgText += "<li>Please enter the property settlement Date</li>";
			resetMenus();
			document.getElementById('settleSpan').style.color = "#FF0000";
		} else {
			errorMsgText = "<ul class='errorList'>";
			document.getElementById('settleSpan').style.color = "#78A7D5";
		}
	} else {
		if (isRequired(document.getElementById('buildDate').value)){
			allOk = false;
			errorMsgText += "<li>Please enter the property Building Date</li>";
			document.getElementById('buildingSpan').style.color = "#FF0000";
			resetMenus();
		} else {
			document.getElementById('buildingSpan').style.color = "#78A7D5";
			
		}
	}	
	if (rowCount > 1){
		if (document.getElementById('itemDesc' + eval(rowCount - 1)).value != null) {
			if (document.getElementById('itemDesc' + eval(rowCount - 1)).value.length == 0){
				errorMsgText += "<li>Invalid Item Description Value</li>";
				allOk = false;
			} 
		} 
		if ((document.getElementById('pRate' + eval(rowCount - 1)).value == null) || (document.getElementById('pRate' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Invalid Rate Value</li>";
			allOk = false;
		}
		
		if ((document.getElementById('value' + eval(rowCount - 1)).value == null) || (document.getElementById('value' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Please Enter a Valid Original Value</li>";
			allOk = false;
		} 
		
		if ((document.getElementById('qtyCount' + eval(rowCount - 1)).value == null) || (document.getElementById('qtyCount' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Please Enter a Quantity Value</li>";
			allOk = false;
		} 
		
		if ((document.getElementById('date' + eval(rowCount - 1)).value == null) || (document.getElementById('date' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Invalid Date Value</li>";
			allOk = false;
		} 
		
	
		if (allOk) {
			if (id == '1'){
				addNewRow(menuID);
			} else {
				addNewOtherRow();
			}
		} else {
			popSizedWin("error.php?error=" + errorMsgText, 500, 500);
		}
	} else {
		
		if (allOk) {
			if (id == '1'){
				addNewRow(menuID);
			} else {
				addNewOtherRow();
			}
		} else {
//			firstSwap();
			popSizedWin("error.php?error=" + errorMsgText, 500, 500);
		}
	}
	resetMenus();
}

function checkRow2(id, menuID, pos, itemID){
//alert("sd " + itemID);
	var errorMsgText = "<ul class='errorList'>";
	var dots = '<li>';
	var allOk = true;
	// ***************************************
	// DYNAMIC ROWS FIELD VALIDATION
	// ***************************************
	if (id == 1){
		if (isRequired(document.getElementById('settleDate').value)){ // no settlement date entered
			allOk = false;
			errorMsgText += "<li>Please enter the property settlement Date</li>";
			resetMenus();
			document.getElementById('settleSpan').style.color = "#FF0000";
		} else {
			errorMsgText = "<ul class='errorList'>";
			document.getElementById('settleSpan').style.color = "#78A7D5";
		}
	} else {
		if (isRequired(document.getElementById('buildDate').value)){
			allOk = false;
			errorMsgText += "<li>Please enter the property Building Date</li>";
			document.getElementById('buildingSpan').style.color = "#FF0000";
			resetMenus();
		} else {
			document.getElementById('buildingSpan').style.color = "#78A7D5";
			
		}
	}	
	if (rowCount > 1){
		if (document.getElementById('itemDesc' + eval(rowCount - 1)).value != null) {
			if (document.getElementById('itemDesc' + eval(rowCount - 1)).value.length == 0){
				errorMsgText += "<li>Invalid Item Description Value</li>";
				allOk = false;
			}
		} 
		if ((document.getElementById('pRate' + eval(rowCount - 1)).value == null) || (document.getElementById('pRate' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Invalid Rate Value</li>";
			allOk = false;
		} 
		if ((document.getElementById('value' + eval(rowCount - 1)).value == null) || (document.getElementById('value' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Please Enter a Valid Original Value</li>";
			allOk = false;
		} 
		
		if ((document.getElementById('qtyCount' + eval(rowCount - 1)).value == null) || (document.getElementById('qtyCount' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Please Enter a Quantity Value</li>";
			allOk = false;
		} 
		
		if ((document.getElementById('date' + eval(rowCount - 1)).value == null) || (document.getElementById('date' + eval(rowCount - 1)).value.length == 0)){
			errorMsgText += "<li>Invalid Date Value</li>";
			allOk = false;
		} 
		
		if (allOk) {
			if (id == '1'){
				addNewRow2(menuID, pos, itemID);
			} else {
				addNewOtherRow();
			}
		} else {
			popSizedWin("error.php?error=" + errorMsgText, 500, 500);
		}
	} else {
		
		if (allOk) {
			if (id == '1'){
				addNewRow2(menuID, pos, itemID);
			} else {
				addNewOtherRow();
			}
		} else {
			//firstSwap();
			popSizedWin("error.php?error=" + errorMsgText, 500, 500);
		}
	}
	

	resetMenus();
}

function popSizedWin(uri, winWidth, winHeight)
{
	thePopSizedWin = window.open(uri, '', 'scrollbars=yes,resizable=yes,width=' + winWidth + ',height=' + winHeight + ',left=50,top=50');

	if (navigator.appName == "Netscape")
	{
		thePopSizedWin.focus();
	}
}

function checkFormToSubmit(optionID){
	errorMsgText = "<ul class='errorList'>";
	isError = false;
	dots = '<li>';

//	HideTheRow('StoreError');
//	HideTheRow('errorOccured');
	document.getElementById('typeSpan').style.color = "#78A7D5";
	document.getElementById('stampSpan').style.color = "#78A7D5";
//	document.getElementById('legalSpan').style.color = "#78A7D5";
	document.getElementById('houseSpan').style.color = "#78A7D5";
	document.getElementById('mobileNSpan').style.color = "#78A7D5";
	document.getElementById('buildTypeSpan').style.color = "#78A7D5";
	document.getElementById('pre85Span').style.color = "#78A7D5";
	document.getElementById('conveyingSpan').style.color = "#78A7D5";

	if (document.getElementById('aboutUs2').value == ""){ // no value inputted
		document.getElementById('aboutUs').value = document.getElementById('aboutUsSelect').value;
	} else {
		document.getElementById('aboutUs').value = document.getElementById('aboutUs2').value;
	}

	if (isRequired(document.getElementById('aboutUs').value)){
		isError = true;
		errorMsgText += dots+"Please enter the details where you heard about us</li>";
		document.getElementById('aboutUsSpan').style.color = "#FF0000";
	} else {
		document.getElementById('aboutUsSpan').style.color = "#78A7D5";
	}

	// ***************************************
	// PROPERTY FIELD VALIDATION
	// ***************************************
	if (isRequired(document.getElementById('addy').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Address</li>";
		document.getElementById('addySpan').style.color = "#FF0000";
	} else {
		document.getElementById('addySpan').style.color = "#78A7D5";
	}

	if (isRequired(document.getElementById('suburb').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Suburb</li>";
		document.getElementById('suburbSpan').style.color = "#FF0000";
	} else {
		document.getElementById('suburbSpan').style.color = "#78A7D5";
	}

	if (isRequired(document.getElementById('state').value)){
		isError = true;
		errorMsgText += dots+"Please select a State</li>";
		document.getElementById('stateSpan').style.color = "#FF0000";
	} else {
		document.getElementById('stateSpan').style.color = "#78A7D5";
	}

	if (isRequired(document.getElementById('pCode').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Post Code</li>";
		document.getElementById('pCodeSpan').style.color = "#FF0000";
	} else {
		if (isNaN(document.getElementById('pCode').value)){ // not a number
			errorMsgText += dots+"Please enter your Post Code As a Numerical Value</li>";
			document.getElementById('pCodeSpan').style.color = "#FF0000";
		} else if ((document.getElementById('pCode').value.length < 4) || (document.getElementById('pCode').value.length > 4)) {  
		// check length of the home number must be 4 digits for post code 
			isError = true;
			errorMsgText += dots+"Please enter the Property Post Code</li>";
			document.getElementById('pCodeSpan').style.color = "#FF0000";
		} else {
			document.getElementById('pCodeSpan').style.color = "#78A7D5";
		}
	} 
	
	if (isRequired(document.getElementById('settleDate2').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Acquisition Date</li>";
		document.getElementById('settleSpan2').style.color = "#FF0000";
	} else {
		acqDate = document.getElementById('settleDate2').value;
		acqDay = parseInt(acqDate.substring(0,2), 10);
		acqMonth = parseInt(acqDate.substring(3,5), 10);
		acqYear = parseInt(acqDate.substring(6,10), 10);
		
		settDate = document.getElementById('settleDate').value;
		setDay = parseInt(settDate.substring(0,2), 10);
		settMonth = parseInt(settDate.substring(3,5), 10);
		settYear = parseInt(settDate.substring(6,10), 10);

		if ((acqYear > settYear) || ((acqYear == settYear) && (acqMonth > settMonth)) || ((acqYear == settYear) && (acqMonth == settMonth) && (acqDay >= setDay))){
			isError = true;
			errorMsgText += dots+"Property Acquisition Date must be less than Settlement Date</li>";
			document.getElementById('settleSpan2').style.color = "#FF0000";
		} else {
			document.getElementById('settleSpan2').style.color = "#78A7D5";
		}
	}

	if (isRequired(document.getElementById('settleDate').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Settlement Date</li>";
		document.getElementById('settleSpan').style.color = "#FF0000";
	} else {
		document.getElementById('settleSpan').style.color = "#78A7D5";
	}
	
	if (isRequired(document.getElementById('buildDate').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Construction End Date</li>";
		document.getElementById('buildingSpan2').style.color = "#FF0000";
	} else {
		document.getElementById('buildingSpan2').style.color = "#78A7D5";
	}
	

	if (isRequired(document.getElementById('buildDate2').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Construction Start Date</li>";
		document.getElementById('buildingSpan').style.color = "#FF0000";
	} else {
		bstartDate = document.getElementById('buildDate2').value;
		bstartDay = parseInt(bstartDate.substring(0,2), 10);
		bstartMonth = parseInt(bstartDate.substring(3,5), 10);
		bstartYear = parseInt(bstartDate.substring(6,10), 10);
		
		bendDate = document.getElementById('buildDate').value;
		bendDay = parseInt(bendDate.substring(0,2), 10);
		bendMonth = parseInt(bendDate.substring(3,5), 10);
		bendYear = parseInt(bendDate.substring(6,10), 10);

		if ((bstartYear > bendYear) || ((bstartYear == bendYear) && (bstartMonth == bendMonth) && (bstartDay >= bendDay)) || ((bstartYear == bendYear) && (bstartMonth > bendMonth))){
			isError = true;
			errorMsgText += dots+"Property construction start date must be less than construction end date</li>";
			document.getElementById('buildingSpan').style.color = "#FF0000";
		} else {
			document.getElementById('buildingSpan').style.color = "#78A7D5";
		}
	}




	// ***************************************
	// TOTAL CAPITAL EXPENDITURE FIELD VALIDATION
	// ***************************************
	if (isRequired(document.getElementById('purchasePrice').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Purchase Price</li>";
		document.getElementById('purchaseSpan').style.color = "#FF0000";
	} else {
		if (isNaN(document.getElementById('purchasePrice').value)){ // not a number
			errorMsgText += dots+"Please enter your Purchase Price As a Numerical Value</li>";
			document.getElementById('purchaseSpan').style.color = "#FF0000";
		} else {
			document.getElementById('purchaseSpan').style.color = "#78A7D5";
		}
	}

	if (isRequired(document.getElementById('land').value)){
		isError = true;
		errorMsgText += dots+"Please enter the Property Land Cost</li>";
		document.getElementById('landSpan').style.color = "#FF0000";
	} else {
		if (isNaN(document.getElementById('land').value)){ // not a number
			errorMsgText += dots+"Please enter your Land Cost As a Numerical Value</li>";
			document.getElementById('landSpan').style.color = "#FF0000";
		} else {
			document.getElementById('landSpan').style.color = "#78A7D5";
		}
	}

	if (document.getElementById('constructionCostExist').checked == false){
		if (document.getElementById('constructionCost').disabled == false){
			if (isRequired(document.getElementById('constructionCost').value)){
				isError = true;
				errorMsgText += dots+"Please enter the Construction Cost</li>";
				document.getElementById('constructionCostSpan').style.color = "#FF0000";
			} else {
				document.getElementById('constructionCostSpan').style.color = "#78A7D5";
			}
		}
	} else {
		if (isRequired(document.getElementById('floorArea').value)){ 
			isError = true;
			errorMsgText += dots+"Please enter the Property Floor Area</li>";
			document.getElementById('floorSpan').style.color = "#FF0000";
		} else {
			document.getElementById('floorSpan').style.color = "#78A7D5";
		}
	}
	
	// ***************************************
	// CONTACT INFORMATION FIELD VALIDATION
	// ***************************************

	var firstName = document.getElementById('fname').value;
	var surName = document.getElementById('lname').value;
	if ((isRequired(firstName)) || (firstName.substring(firstName.length - 1) == " "))
	{
		isError = true;
		errorMsgText += dots+"Please enter your Firstname ensuring there are no leading or trailing spaces</li>";
		document.getElementById('firstnameSpan').style.color = "#FF0000";
	} else {
		document.getElementById('firstnameSpan').style.color = "#78A7D5";
	}
	
	if ((isRequired(surName)) || (surName.substring(surName.length - 1) == " "))
	{
		isError = true;
		errorMsgText += dots+"Please enter your Lastname ensuring there are no leading or trailing spaces</li>";
		document.getElementById('lastnameSpan').style.color = "#FF0000";
	} else {
		document.getElementById('lastnameSpan').style.color = "#78A7D5";
	}
/*	
	if (isRequired(document.taxFrm.homePre.value)){
		isError = true;
		errorMsgText += dots+"Please enter your Area Code</li>";
		document.getElementById('homeNSpan').style.color = "#FF0000";
	} else {
		if (document.taxFrm.homePre.value.length < 2){
			isError = true;
			errorMsgText += dots+"Please enter a <b>2 Digit</b> Area Code</li>";
			document.getElementById('homeNSpan').style.color = "#FF0000";
		} else {
			document.getElementById('homeNSpan').style.color = "#78A7D5";
		}
	}
	*/
	if (isRequired(document.getElementById('homeN').value)){
		isError = true;
		errorMsgText += dots+"Please enter your Home Number</li>";
		document.getElementById('homeNSpan').style.color = "#FF0000";
	} else {
/*		if (document.taxFrm.homeN.value.length < 12){
			isError = true;
			errorMsgText += dots+"Please enter an <b>8 Digit</b> Home Number</li>";
			document.getElementById('homeNSpan').style.color = "#FF0000";
		} else {*/
			document.getElementById('homeNSpan').style.color = "#78A7D5";
	//	}
	}
	
	if (document.getElementById('mobileN').value.length > 0){ // if there's something there
		if (document.getElementById('mobileN').value.length < 10){
			isError = true;
			errorMsgText += dots+"Please enter a <b>10 Digit</b> Mobile Number</li>";
			document.getElementById('mobileNSpan').style.color = "#FF0000";
		} else {
			document.getElementById('mobileNSpan').style.color = "#78A7D5";
		}
	}
	
	if (isRequired(document.getElementById('email').value)){
		isError = true;
		errorMsgText += dots+"Please enter your Email Address</li>";
		document.getElementById('emailSpan').style.color = "#FF0000";
	} else {
		if (!isEmail(document.getElementById('email').value)){
			isError = true;
			errorMsgText += dots+"Please Enter a Valid Email Address</li>";
			document.getElementById('emailSpan').style.color = "#FF0000";
		} else {
			document.getElementById('emailSpan').style.color = "#78A7D5";
		}
	}
	

	
	if (optionID == 2){
	
		if (document.getElementById('constructionCost').disabled == false){ // not disabled
			if (((document.getElementById('buildDate').value != "Pre 1985") || (document.getElementById('buildingDateValue').value != "01/01/1985")) && (document.getElementById('constructionCost').disabled == false)){
				if (isRequired(document.getElementById('constructionCost').value)){
					isError = true;
					errorMsgText += dots+"Please enter the Construction Cost</li>";
					document.getElementById('constructionCostSpan').style.color = "#FF0000";
				} else {
					if (isNaN(document.getElementById('constructionCost').value)){ // not a number
						errorMsgText += dots+"Please enter your Construction Cost As a Numerical Value</li>";
						document.getElementById('constructionCostSpan').style.color = "#FF0000";
					} else {
						val1 = parseInt(document.getElementById('constructionCost').value);
						val2 = parseInt(document.getElementById('purchasePrice').value);
						if (val1 >= val2){
							errorMsgText += dots+"Construction cost MUST be less than Purchase Price.</li>";
							document.getElementById('constructionCostSpan').style.color = "#FF0000";
						} else {
							document.getElementById('constructionCostSpan').style.color = "#78A7D5";
						}
					}
				}
			}
		}
		// ***************************************
		// DYNAMIC ROW FIELD VALIDATION
		// ***************************************
		if (rowCount < 2){ // no rows created yet
			isError = true;
			errorMsgText += dots+"No items have been added for the schedule. <br>Please Insert your Property items.<br>Use The Drop down menu located in the Floating Helper on the right hand side</li>";
		} else { 			// rows have been created
	
			i = 1;
			while (i < rowCount){
				if (isRequired(document.getElementById('itemDesc' + i).value)){
					isError = true;
					errorMsgText += dots+"Please Enter the Description for Item <B>"+ i +"</B></li>";
					document.getElementById('itemDesc' + eval(i)).style.border = 'solid rgb(163,23,49) 2px';
				} else {
					document.getElementById('itemDesc' + eval(i)).style.border = 'solid rgb(165,172,178) 1px';
				}
				if (isRequired(document.getElementById('pRate' + i).value)){
					isError = true;
					errorMsgText += dots+"Please Enter the Decpreciation Rate for Item <B>"+ i +"</B></li>";
					document.getElementById('pRate' + eval(i)).style.border = 'solid rgb(163,23,49) 2px';
				} else {
					document.getElementById('pRate' + eval(i)).style.border = 'solid rgb(165,172,178) 1px';
				}
				
				if (document.getElementById('isUser' + i).value == 1){
					if (isRequired(document.getElementById('userValue' + eval(i)).value)){
						isError = true;
						errorMsgText += dots+"Please Enter the Cost for Item <B>"+ i +"</B></li>";
						document.getElementById('userValue' + eval(i)).style.border = 'solid rgb(163,23,49) 2px';
					} else {
						document.getElementById('userValue' + eval(i)).style.border = 'solid rgb(165,172,178) 1px';
					}
				} else {
					if (isRequired(document.getElementById('value' + eval(i)).value)){
						isError = true;
						errorMsgText += dots+"Please Enter the Original Cost for Item <B>"+ i +"</B></li>";
						document.getElementById('value' + eval(i)).style.border = 'solid rgb(163,23,49) 2px';
					} else {
						document.getElementById('value' + eval(i)).style.border = 'solid rgb(165,172,178) 1px';
					}
				}
								
				if (isRequired(document.getElementById('qtyCount' + eval(i)).value)){
					isError = true;
					errorMsgText += dots+"Please Enter the Quantity for Item <B>"+ i +"</B></li>";
					document.getElementById('qtyCount' + eval(i)).style.border = 'solid rgb(163,23,49) 2px';
				} else {
					document.getElementById('qtyCount' + eval(i)).style.border = 'solid rgb(165,172,178) 1px';
				}
				
				document.getElementById('date' + eval(i)).style.border = 'solid rgb(165,172,178) 1px';
				
				i++;
			}
		}
	}
	val1 = parseInt(document.getElementById('constructionCost').value);
	val2 = parseInt(document.getElementById('purchasePrice').value);
	if (val1 >= val2){
		isError = true;
		errorMsgText += dots+"Construction cost MUST be less than Purchase Price.</li>";
		document.getElementById('constructionCostSpan').style.color = "#FF0000";
	} else {
		document.getElementById('constructionCostSpan').style.color = "#78A7D5";
	}
	
	if (isError){
		popSizedWin("error.php?error=" + errorMsgText, 500, 500);
		return false;
	} else {
	
	// ***************************************
	// CHECK IF CONSTRUCTION END IS LESS THAN EQUAL TO SETTLEMENT DATE
	// ***************************************
	
		settDate = document.getElementById('settleDate').value;
		setDay = parseInt(settDate.substring(0,2), 10);
		settMonth = parseInt(settDate.substring(3,5), 10);
		settYear = parseInt(settDate.substring(6,10), 10);

		bendDate = document.getElementById('buildDate').value;
		bendDay = parseInt(bendDate.substring(0,2), 10);
		bendMonth = parseInt(bendDate.substring(3,5), 10);
		bendYear = parseInt(bendDate.substring(6,10), 10);

		if ((bendYear > settYear) || ((bendYear == settYear) && (bendMonth > settMonth)) || ((bendYear == settYear) && (bendMonth == settMonth) && (bendDay > setDay))){
			var errorMsgText = dots+"Construction End Date must NOT be after Settlement Date</li>";
			document.getElementById('settleSpan').style.color = "#FF0000";
			document.getElementById('buildingSpan2').style.color = "#FF0000";
			popSizedWin("error.php?error=" + errorMsgText, 500, 500);
			return false;
		} else {
			document.getElementById('settleSpan').style.color = "#78A7D5";
			document.getElementById('buildingSpan2').style.color = "#FF0000";
			return true;
		}
		

		// everything is ok
		//taxFrm.rowCounter.value = rowCount;
		
	}
}

function isRequired(str)
{
	if (str == "") return true;
	else return false;
}

function isEmail(src)
{
	if (src.indexOf(" ") > 0)
		return false;
	else
	{
		if (src.indexOf("@") > 0)
		{
			var domain = src.substring(src.indexOf("@"));
			if (domain.indexOf(".") > 0)
			{
				return true;
			}
			else
				return false;
		}
		else
			return false;
	}


//	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]+[\.]{1}[\\w]+[\.]?[\\w]+$";
 //    var regex = new RegExp(emailReg);
  //   if (regex.test(src)) return true;
//	 else return false;
}
  
function HideTheRow(therow)
	{ 
//	var objRow = document.getElementById(therow);
//	objRow.style.display = 'none';  
}
	
function ShowTheRow(therow)
	{ 
	//var objRow = document.getElementById(therow);
//	objRow.style.display = '';  
}

-->
