function topicClickedTopic(id)
{
	var oElement = document.getElementById('relTopic'+ id);
	if (oElement.style.display == 'none') { oElement.style.display = ''; } else { oElement.style.display = 'none'; }
}//topicClickedTopic


function delRow(id)
{
	theFile = eval("document.getElementById('property" + id+"')");
	theFile.outerHTML = "<input type='file' onKeyDown='return false;' onDragStart='return false;' onKeyPress='return false;' name='property" + id + "' maxlength='200' class='formElement'>"
	return;
}// delRow


function delete_clicked(id)
{
	document.getElementById('file_span'+ id).innerHTML = 'N/A';
	if (document.frmForm1.delFiles.value != "") { document.frmForm1.delFiles.value += ","; } 
	eval("document.frmForm1.id_property" + id + ".value = -1")
}//delete_clicked


function avatar_clicked(theAction)
{
	if (theAction == 'delete') {
		document.frmForm1.avatar.value = "delete"
		document.getElementById("avatar_span").innerHTML = ""
	}
	if (theAction == 'clear') {
		document.getElementById("avatar_file").outerHTML = "<input type='file' onKeyDown='return false;' onDragStart='return false;' onKeyPress='return false;' name='avatar_file' maxlength='200' class='formElement'>"
	}
}//avatar_clicked


function preview()
{
	//	window.open('blank.asp','_Preview','top=100,left=100,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=480');
}//preview


function salChange()
{
	if (document.createElement) {
		if (frmForm1.title.value == "Other") {	
			var preName = getInput("Enter New Salutation:", "", "");
			if (preName != null) {
				var oOption = document.createElement("OPTION");
				document.frmForm1.title.options.add(oOption);
				oOption.innerText = preName;
				oOption.value = preName;
				document.frmForm1.title.selectedIndex = frmForm1.title.options.length-1;
			} else {
				document.frmForm1.title.selectedIndex = 0;
			}//if
		}//if
	}//if
}//salChange


function monthChanged()
{
	if (document.createElement && document.appendChild && document.removeChild) {
		if (!document.frmForm1 && !document.frmForm1.birthMonth) { return; }
		
		var iMonth = parseInt(document.frmForm1.birthMonth.value);
		var iNumDays = 31;
		
		if ((iMonth == 1) || (iMonth == 3) || (iMonth == 5) || (iMonth == 7) || (iMonth == 8) || (iMonth == 10) || (iMonth == 12)) {
			iNumDays = 31;
		} else if (iMonth == 2) {
			iNumDays = 29;
		} else {
			iNumDays = 30;
		}//if
	
		if (parseInt(iMonthChangedNumDays) == parseInt(iNumDays)) { return; }
		
		var oDay = document.getElementById('birthDay_obj');
		if (oDay) {
			if (parseInt(iMonthChangedNumDays) > parseInt(iNumDays)) {
				for (var i = parseInt(iMonthChangedNumDays); i > parseInt(iNumDays); i--) {
					if (parseInt(oDay.value) == i) { oDay.selectedIndex = 0; }
					oDay.removeChild(oDay.options[i]);
				}//for
			} else {
				for (var i = parseInt(iMonthChangedNumDays+1); i <= parseInt(iNumDays); i++) {
					var oOption = document.createElement("OPTION"); var oOptionLabel = document.createTextNode(i); oOption.setAttribute('value', i);
					oOption.appendChild(oOptionLabel); oDay.appendChild(oOption);
				}//for
			}//if
		}//if
		iMonthChangedNumDays = iNumDays;
	}//if
}//monthChanged


function calChange(strid)
{
	var objCal, objElement;
	objCal = eval('document.all.property'+ strid +'_obj');
	objElement = eval('document.all.property'+ strid);
	objElement.value = objCal.day +'/'+ objCal.month +'/'+ objCal.year;
	dynHiddenCheck(strid,-1);
	dynValueCheck(strid,-1);
}//calChange


function calChange2(strid, strky)
{
	var objElement;
	objElement = eval('document.frmForm1.property'+ strid);
	objElementD = eval('document.frmForm1.property'+ strid +'_day');
	objElementM = eval('document.frmForm1.property'+ strid +'_month');
	objElementY = eval('document.frmForm1.property'+ strid +'_year');
	objElement.value = objElementD.options[objElementD.selectedIndex].value +'/'+ objElementM.options[objElementM.selectedIndex].value +'/'+ objElementY.options[objElementY.selectedIndex].value
	if ((objElementD.options[objElementD.selectedIndex].value != 0) && (objElementM.options[objElementM.selectedIndex].value != 0) && (objElementY.options[objElementY.selectedIndex].value != 0)) {
		if (!chkdate(objElement.value)) {
			alert("The following field is not valid: Date");
			objElement = eval('document.frmForm1.property'+ strid +'_day');
			objElement.focus();
			return false; 
		}// if
	}// if 
	dynHiddenCheck(strid,-1);
	dynValueCheck(strid,-1);
}//calChange2


function chkdate(strDate) {
	//var strDatestyle = "US"; //United States date style
	var strDatestyle = "EU";  //European date style
	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intday;
	var intMonth;
	var intYear;
	var booFound = false;
	var strSeparatorArray = new Array("-"," ","/",".");
	var intElementNr;
	var err = 0;
	var strMonthArray = new Array(12);
	strMonthArray[0] = "Jan";
	strMonthArray[1] = "Feb";
	strMonthArray[2] = "Mar";
	strMonthArray[3] = "Apr";
	strMonthArray[4] = "May";
	strMonthArray[5] = "Jun";
	strMonthArray[6] = "Jul";
	strMonthArray[7] = "Aug";
	strMonthArray[8] = "Sep";
	strMonthArray[9] = "Oct";
	strMonthArray[10] = "Nov";
	strMonthArray[11] = "Dec";
	
	if (strDate.length < 1) {
		return true;
	}
	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
		if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
			if (strDateArray.length != 3) {
				err = 1;
				return false;
			}
			else {
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				strYear = strDateArray[2];
			}
		booFound = true;
		}
	}
	if (booFound == false) {
		if (strDate.length>5) {
		strDay = strDate.substr(0, 2);
		strMonth = strDate.substr(2, 2);
		strYear = strDate.substr(4);
	   }
	}
	if (strYear.length == 2) {
		strYear = '20' + strYear;
	}
	// US style
	if (strDatestyle == "US") {
	strTemp = strDay;
	strDay = strMonth;
	strMonth = strTemp;
	}
	intday = parseInt(strDay, 10);
	if (isNaN(intday)) {
	err = 2;
	return false;
	}
	intMonth = parseInt(strMonth, 10);
	if (isNaN(intMonth)) {
	for (i = 0;i<12;i++) {
	if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
	intMonth = i+1;
	strMonth = strMonthArray[i];
	i = 12;
	   }
	}
	if (isNaN(intMonth)) {
	err = 3;
	return false;
	   }
	}
	intYear = parseInt(strYear, 10);
	if (isNaN(intYear)) {
	err = 4;
	return false;
	}
	if (intMonth>12 || intMonth<1) {
	err = 5;
	return false;
	}
	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
	err = 6;
	return false;
	}
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
	err = 7;
	return false;
	}
	if (intMonth == 2) {
	if (intday < 1) {
	err = 8;
	return false;
	}
	if (LeapYear(intYear) == true) {
	if (intday > 29) {
	err = 9;
	return false;
	}
	}
	else {
	if (intday > 28) {
	err = 10;
	return false;
	}
	}
	}
	return true;
}//chkdate


function LeapYear(intYear) {
	if (intYear % 100 == 0) {
		if (intYear % 400 == 0) { return true; }
	}
	else {
		if ((intYear % 4) == 0) { return true; }
	}
	return false;
}//LeapYear