var errorText;
var errors = false;

function ConfirmDelete(pItem)
{
	var response = confirm("CAUTION: You are about to delete this " + pItem + "! Doing so will prevent other members from seeing it, and will also delete any associated hotlist entries and / or comments and ratings for this " + pItem + ". This is not reversible. Are you sure you'd like to proceed?");

	if (response)
		return true;
	else
		return false;
}

function ddlChanged(type, selector, loControl, hiControl)
{
	//var selIndex  = document.Form1.ddlPriceOpt.selectedIndex;
	//var selText = document.Form1.ddlPriceOpt.options[selIndex].text;
	
	var selIndex  = document.getElementById(selector).selectedIndex;
	var selText = document.getElementById(selector).options[selIndex].text;

	if (selText == 'Is Between')
	{
		//selectedIndex
		if (type == 'txt')
		{
			document.getElementById(loControl).disabled = false;
			document.getElementById(hiControl).disabled = false;
			if (document.getElementById(loControl).value == 'n/a')
				document.getElementById(loControl).value = '';
			if (document.getElementById(hiControl).value == 'n/a')
				document.getElementById(hiControl).value = '';
		}
		else
		{
			document.getElementById(loControl).disabled = false;
			document.getElementById(hiControl).disabled = false;
			if (document.getElementById(loControl).selectedIndex == 0)
				document.getElementById(loControl).selectedIndex = 1;
			if (document.getElementById(hiControl).selectedIndex == 0)
				document.getElementById(hiControl).selectedIndex = 1;
		}
	}
	else if (selText == 'Any')
	{
		document.getElementById(loControl).disabled = true;
		document.getElementById(hiControl).disabled = true;
		
		
		if (type == 'txt')
		{
			document.getElementById(loControl).value = 'n/a';
			document.getElementById(hiControl).value = 'n/a';
		}
		else
		{
			document.getElementById(loControl).selectedIndex = 0;
			document.getElementById(hiControl).selectedIndex = 0;
		}
	}
	else
	{
		document.getElementById(loControl).disabled = false;
		document.getElementById(hiControl).disabled = true;
		
		if (type == 'txt')
		{
			if (document.getElementById(loControl).value == 'n/a')
				document.getElementById(loControl).value = '';
			document.getElementById(hiControl).value = 'n/a';
		}
		else
		{
			if (document.getElementById(loControl).selectedIndex == 0)
				document.getElementById(loControl).selectedIndex = 1;
			document.getElementById(hiControl).selectedIndex = 0;
		}
	}
}

function resetControls()
{
	document.getElementById('txtPriceLo').disabled = true;
	document.getElementById('txtPriceLo').disabled = true;
	document.getElementById('txtMileageLo').disabled = true;
	document.getElementById('txtMileageHi').disabled = true;
	document.getElementById('ddlYearLo').disabled = true;
	document.getElementById('ddlYearHi').disabled = true;
	document.getElementById('ddlDisplacementLo').disabled = true;
	document.getElementById('ddlDisplacementHi').disabled = true;
	
	document.getElementById('txtPriceLo').value = 'n/a';
	document.getElementById('txtPriceHi').value = 'n/a';
	document.getElementById('txtMileageLo').value = 'n/a';
	document.getElementById('txtMileageHi').value = 'n/a';

	document.getElementById('ddlYearLo').selectedIndex = 0;
	document.getElementById('ddlYearHi').selectedIndex = 0;
	document.getElementById('ddlDisplacementLo').selectedIndex = 0;
	document.getElementById('ddlDisplacementHi').selectedIndex = 0;
}


function ddlMaxPrizeChanged()
{
	var selIndex  = document.Form1.ddlMaxPrizeOpt.selectedIndex;
	
	if (selIndex > 0)
	{
		document.getElementById("txtMaxPrize").disabled = false;
	}
	else
	{
		document.getElementById("txtMaxPrize").disabled = true;
		document.getElementById("txtMaxPrize").value = '0';
	}
}

function ddlEntryFeeChanged()
{
	var selIndex  = document.Form1.ddlEntryFeeOpt.selectedIndex;

	if (selIndex > 0)
	{
		document.getElementById("txtEntryFee").disabled = false;
	}
	else
	{
		document.getElementById("txtEntryFee").disabled = true;
		document.getElementById("txtEntryFee").value = '0';
	}
}

function ValidateDDL(pControl, pLabel, pErrStr)
{
	var selIndex  = document.getElementById(pControl).selectedIndex;
	var selText = document.getElementById(pControl).options[selIndex].text;
	
	if (selText == 'Select')
	{
		var objWarningText = document.getElementById("lblWarning");

		errorText = document.createTextNode(pErrStr);
		objWarningText.appendChild(errorText);
		objWarningText.appendChild(document.createElement("br"));
		document.getElementById(pLabel).style.backgroundColor = "Red";
		document.getElementById(pLabel).style.color = "White";
		
		errors = true;
	}
	else
	{
		if(document.getElementById(pLabel).style.backgroundColor != "Red")
		{
			document.getElementById(pLabel).style.color = "DarkOrange";
			document.getElementById(pLabel).style.backgroundColor = "";
		}
	}
}


function CheckRequired(pControl, pLabel, pErrStr)
{
	var objWarningText = document.getElementById("lblWarning");

	if (document.getElementById(pControl).value == "")
	{
		// don't try to pass only the control name here... sometimes
		// we need to add "(use 0 if necessary)" after it...
		errorText = document.createTextNode(pErrStr);
		
		objWarningText.appendChild(errorText);
		objWarningText.appendChild(document.createElement("br"));
		document.getElementById(pLabel).style.backgroundColor = "Red";
		document.getElementById(pLabel).style.color = "White";
		
		errors = true;
	}
	else
	{
		if(document.getElementById(pLabel).style.backgroundColor != "Red")
			document.getElementById(pLabel).style.color = "DarkOrange";
			document.getElementById(pLabel).style.backgroundColor = "";
	}
}

function ValidateDate(pControl, pLabel, pErrStr)
{
	if (document.getElementById(pControl).value != "")
	{
		var objWarningText = document.getElementById("lblWarning");
		
		var regExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
		var regExp2 = /[.-]/;
		if (regExp.test(document.getElementById(pControl).value) == false || regExp2.test(document.getElementById(pControl).value) == true)
		{
			errorText = document.createTextNode(pErrStr);
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			document.getElementById(pLabel).style.color = "DarkOrange";
			
			errors = true;
		}
		else
		{
			if(document.getElementById(pLabel).style.color != "DarkOrange")
				document.getElementById(pLabel).style.color = "black";
		}
	}
}

function ValidateEmail(pControl, pLabel, pErrStr)
{
	if (document.getElementById(pControl).value != "")
	{
		var objWarningText = document.getElementById("lblWarning");
		
		var regExp = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		if (regExp.test(document.getElementById(pControl).value) == false)
		{
			errorText = document.createTextNode(pErrStr);
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			document.getElementById(pLabel).style.color = "DarkOrange";
			
			errors = true;
		}
		else
		{
			if(document.getElementById(pLabel).style.backgroundColor != "Red")
				document.getElementById(pLabel).style.color = "DarkOrange";
				document.getElementById(pLabel).style.backgroundColor = "";
		}
	}
}

function ValidateURL(pControl, pLabel, pErrStr)
{
	if (document.getElementById(pControl).value != "" && document.getElementById(pControl).value != "http://")
	{
		var objWarningText = document.getElementById("lblWarning");
		
		var regExp = /(http|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
		if (regExp.test(document.getElementById(pControl).value) == false)
		{
			errorText = document.createTextNode(pErrStr);
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			document.getElementById(pLabel).style.color = "DarkOrange";
			
			errors = true;
		}
		else
		{
			if(document.getElementById(pLabel).style.color != "DarkOrange")
				document.getElementById(pLabel).style.color = "black";
		}
	}
}


function ValidatePassword(pControl, pLabel)
{
	if (document.getElementById(pControl).value != "" && document.getElementById(pControl).value != "http://")
	{
		var objWarningText = document.getElementById("lblWarning");

		// check length
		if (document.getElementById(pControl).value.length > 10)
		{
			errorText = document.createTextNode("Password is too long.");
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			document.getElementById(pLabel).style.color = "DarkOrange";
			
			errors = true;
		}
		
		// test for spaces
		var regExp = /\s+/;
		if (regExp.test(document.getElementById(pControl).value) == true)
		{
			errorText = document.createTextNode("Password cannot contain space characters.");
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			document.getElementById(pLabel).style.color = "DarkOrange";
			
			errors = true;
		}
		else
		{
			if(document.getElementById(pLabel).style.backgroundColor != "Red")
				document.getElementById(pLabel).style.color = "DarkOrange";
				document.getElementById(pLabel).style.backgroundColor = "";
		}
	}
}


function CheckLength(pControl, pLabel, pLen)
{
	if (document.getElementById(pControl).value != "")
	{
		var objWarningText = document.getElementById("lblWarning");

		// check length
		if (document.getElementById(pControl).value.length > pLen)
		{
			errorText = document.createTextNode(document.getElementById(pLabel).childNodes[0].data + " Too long (currently " + document.getElementById(pControl).value.length + ").");
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			document.getElementById(pLabel).style.backgroundColor = "Red";
			document.getElementById(pLabel).style.color = "White";
			
			errors = true;
		}
		else
		{
			if(document.getElementById(pLabel).style.backgroundColor != "Red")
			{
				document.getElementById(pLabel).style.color = "DarkOrange";
				document.getElementById(pLabel).style.backgroundColor = "";
			}
		}
	}
}


function StripNasties(pControl, pLabel, pErrStr)
{
	if (document.getElementById(pControl).value != "")
	{
		var objWarningText = document.getElementById("lblWarning");
		
		var regExp = /[;|\|<|>]| drop |drop | alter |alter/;
		if (regExp.test(document.getElementById(pControl).value) == true)
		{
			errorText = document.createTextNode(pErrStr + " contains invalid characters. (; \ < > drop alter)");
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			document.getElementById(pLabel).style.backgroundColor = "Red";
			document.getElementById(pLabel).style.color = "White";

			errors = true;
		}
		else
		{
			if(document.getElementById(pLabel).style.backgroundColor != "Red")
			{
				document.getElementById(pLabel).style.color = "DarkOrange";
				document.getElementById(pLabel).style.backgroundColor = "";
			}
		}
	}
}


function Encode(pControl)
{
	if (document.getElementById(pControl).value != "")
	{
		var strValue = encodeURIComponent(document.getElementById(pControl).value);
	}
}

function Decode(pControl)
{
	if (document.getElementById(pControl).value != "")
	{
		var strValue = encodeURIComponent(document.getElementById(pControl).value);
		strValue = decodeURIComponent(strValue);
	}
}


function CheckDigits(pControl, pLabel, pErrStr)
{
	if (document.getElementById(pControl).value != "")
	{
		var objWarningText = document.getElementById("lblWarning");

		var regExp = /\D/;
		if (regExp.test(document.getElementById(pControl).value) == true)
		{
			errorText = document.createTextNode(pErrStr + " must be digits only.");
			objWarningText.appendChild(errorText);
			objWarningText.appendChild(document.createElement("br"));
			
			
			document.getElementById(pLabel).style.backgroundColor = "Red";
			document.getElementById(pLabel).style.color = "White";
			
			errors = true;
		}
		else
		{
			if(document.getElementById(pLabel).style.backgroundColor != "Red")
			{
				document.getElementById(pLabel).style.color = "DarkOrange";
				document.getElementById(pLabel).style.backgroundColor = "";
			}
		}
	}
}

function ValidateSearchForm(pType)
{	
	errors = false;

	// clear out any old errors first
	var objWarningText = document.getElementById("lblWarning");
	while (objWarningText.hasChildNodes())
		objWarningText.removeChild(objWarningText.lastChild);

	// add a line break before any errors
	//objWarningText.appendChild(document.createElement("br"));

	if (pType == 'advanced')
		StripNasties("txtAlias", "lblAlias", "Posted By");

	var selIndex  = document.Form1.ddlStartDate.selectedIndex;
	
	// only validate dates if > 0 since otherwise it's text 'n/a'
	if (selIndex > 0)
	{
		CheckRequired("txtStartDateLo", "lblStartDate", "Start Date 1 is required.");
		ValidateDate("txtStartDateLo", "lblStartDate", "Start Date 1 invalid (use mm/dd/yyyy).");
	}
	
	if (selIndex == 4)
	{
		CheckRequired("txtStartDateHi", "lblStartDate", "Start Date 2 is required.");
		ValidateDate("txtStartDateHi", "lblStartDate", "Start Date 2 invalid (use mm/dd/yyyy).");
	}

	CheckRequired("txtMaxPrize", "lblMaxPrize", "Max Prize is required. (0 if necessary)");
	CheckDigits("txtMaxPrize", "lblMaxPrize", "Max Prize");
	CheckRequired("txtEntryFee", "lblEntryFee", "Entry Fee is required. (0 if necessary)");
	CheckDigits("txtEntryFee", "lblEntryFee", "Entry Fee");
	CheckDigits("txtAge", "lblAge", "Contestant Age");

	if (pType == 'advanced')
	{

		// make sure at least one media type is checked
		var selIndex  = document.Form1.ddlMediaSelector.selectedIndex;

		if (selIndex > 0)
		{
			var i;
			var bSuccess = false;
			
			for (i = 0;  i < 7; i++)
			{
				if (document.getElementById("cblCoverage_" + i).checked == true)
					bSuccess = true;
			}
			
			// if we didn't find one checkbox selected....
			if (bSuccess != true)
			{
				errorText = document.createTextNode("Please select at least 1 Media Coverage checkbox or reset the Media Coverage selector to Any Media Coverage.");
				objWarningText.appendChild(errorText);
				objWarningText.appendChild(document.createElement("br"));
				document.getElementById("lblMediaCoverage").style.color = "red";
				errors = true;
			}
			else
			{
				if (document.getElementById("lblMediaCoverage").style.color != "red")
					document.getElementById("lblMediaCoverage").style.color = "black";
			}
		}
	}

	if (errors)
	{
		alert("The form is incomplete. Please review the red text at the top of the page.");
		return false;
	}
}

function ValidatePersonalInfoForm(pType)
{	
	try
	{	
		errors = false;

		// clear out any old errors first
		var objWarningText = document.getElementById("lblWarning");
		while (objWarningText.hasChildNodes())
			objWarningText.removeChild(objWarningText.lastChild);

		// add a line break before any errors
		objWarningText.appendChild(document.createElement("br"));
		
		if (pType == "add")
		{
			//StripNasties("Personal_info1_txtReferProfile", "Personal_info1_lblReferProfile", "Referrer's User Name");
			CheckRequired("Personal_info1_txtSubscriptionID", "Personal_info1_lblSubscriptionID", "Subscription ID is required.");
			StripNasties("Personal_info1_txtSubscriptionID", "Personal_info1_lblSubscriptionID", "Subscription ID");			
			//CheckDigits("Personal_info1_txtSubscriptionID", "Personal_info1_lblSubscriptionID", "Subscription ID");
		}
		
		// age
	    CheckRequired("Personal_info1_txtAge", "Personal_info1_lblAge", "Age is required. (0 if necessary)");
	    CheckDigits("Personal_info1_txtAge", "Personal_info1_lblAge", "Age");

		// alias
	    CheckRequired("Personal_info1_txtAlias", "Personal_info1_lblAlias", "Screen Name is required.");
	    //StripNasties("Personal_info1_txtAlias", "Personal_info1_lblAlias", "Screen Name");

	    // password
	    CheckRequired("Personal_info1_txtPassword", "Personal_info1_lblPassword", "Password is required.");
	    StripNasties("Personal_info1_txtPassword", "Personal_info1_lblPassword", "Password");
	    ValidatePassword("Personal_info1_txtPassword", "Personal_info1_lblPassword");
	    
		// company
	    //StripNasties("Personal_info1_txtCompany", "Personal_info1_lblCompany", "Company");

		// fname
	    CheckRequired("Personal_info1_txtFname", "Personal_info1_lblFname", "First Name is required.");
	    //StripNasties("Personal_info1_txtFname", "Personal_info1_lblFname", "First Name");

		// lname
	    CheckRequired("Personal_info1_txtLname", "Personal_info1_lblLname", "Last Name is required.");
	    //StripNasties("Personal_info1_txtLname", "Personal_info1_lblLname", "Last Name");

	    // address1
	    CheckRequired("Personal_info1_txtAddress1", "Personal_info1_lblAddress1", "Address is required.");
	    //StripNasties("Personal_info1_txtAddress1", "Personal_info1_lblAddress1", "Address");
	    	    
	    // city
	    CheckRequired("Personal_info1_txtCity", "Personal_info1_lblCity", "City is required.");
	    //StripNasties("Personal_info1_txtCity", "Personal_info1_lblCity", "City");
	    
	    // metro
	    ValidateDDL("Personal_info1_ddlMetro", "Personal_info1_lblMetro", "Please select the nearest Metro Area.");

	    // state
		var selIndex  = document.getElementById("Personal_info1_ddlCountry").selectedIndex;
		var selText = document.getElementById("Personal_info1_ddlCountry").options[selIndex].text;
		
		if (selText == "United States" || selText == "Canada")
		{
			ValidateDDL("Personal_info1_ddlState", "Personal_info1_lblState", "State or Province is required.");
	    }
	    else
	    {
			document.getElementById("Personal_info1_lblState").style.color = "DarkOrange";
	    }
	    
	    // zip
	    CheckRequired("Personal_info1_txtZip", "Personal_info1_lblZip", "Zip or Postal Code is required.");
	    StripNasties("Personal_info1_txtZip", "Personal_info1_lblZip", "Zip");
	  	    
	    // country
	    ValidateDDL("Personal_info1_ddlCountry", "Personal_info1_lblCountry", "Please select your Country.");
      
		// phone1
	    CheckRequired("Personal_info1_txtPhone1", "Personal_info1_lblPhone1", "Phone is required.");
	    StripNasties("Personal_info1_txtPhone1", "Personal_info1_lblPhone1", "Phone");

		// email
	    CheckRequired("Personal_info1_txtEmail", "Personal_info1_lblEmail", "Email is required.");
	    //StripNasties("Personal_info1_txtEmail", "Personal_info1_lblEmail", "Email");
		ValidateEmail("Personal_info1_txtEmail", "Personal_info1_lblEmail", "Email Address is invalid.")
		
		// descr
	    //StripNasties("Personal_info1_txtDescription", "Personal_info1_lblDescription", "Description");
		CheckLength("Personal_info1_txtDescription", "Personal_info1_lblDescription", 256);
	    //Encode("Personal_info1_txtDescription");

		if (errors)
		{
			alert("The form is incomplete. Please review the red text at the top of the page.");
			return false;
		}
		else
		{
			if (pType == "add")
				location.replace("success.aspx");
			else
				location.replace("settings.aspx");
		}
	}
	catch (ex)
	{
		alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
	}
}


function ValidateNewComment(pType, pTitleName, pTextName, pLen)
{	
	try
	{	
		errors = false;

		// clear out any old errors first
		var objWarningText = document.getElementById("lblWarning");
		while (objWarningText.hasChildNodes())
			objWarningText.removeChild(objWarningText.lastChild);

		// add a line break before any errors
		//objWarningText.appendChild(document.createElement("br"));
		
		// alias
	    CheckRequired("txtTitle", "lblTitle", pTitleName + " is required.");
	    StripNasties("txtTitle", "lblTitle", pTitleName);
		CheckLength("txtTitle", "lblTitle", 50);

		// descr
	    CheckRequired("txtComments", "lblComments", pTextName + " is required.");
	    if (pType != 'help_item')
	    {
			StripNasties("txtComments", "lblComments", pTextName);
		}
		CheckLength("txtComments", "lblComments", pLen);

		if (errors)
		{
			alert("The form is incomplete. Please review the red text at the top of the page.");
			return false;
		}
		else
		{
			return true;
		}
	}
	catch (ex)
	{
		alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
	}
}




function ValidateMessage()
{	
	try
	{	
		errors = false;

		// clear out any old errors first
		var objWarningText = document.getElementById("lblWarning");
		while (objWarningText.hasChildNodes())
			objWarningText.removeChild(objWarningText.lastChild);

		// start with black labels
		document.getElementById("lblReplyAddress").style.color = "black";
		document.getElementById("lblSubject").style.color = "black";
		document.getElementById("lblMessage").style.color = "black";

		// add a line break before any errors
		//objWarningText.appendChild(document.createElement("br"));
		
		// email
	    CheckRequired("txtReplyAddress", "lblReplyAddress", "Reply Address is required.");
	    StripNasties("txtReplyAddress", "lblReplyAddress", "Reply Address");
		ValidateEmail("txtReplyAddress", "lblReplyAddress", "Reply Address is invalid.")

		// subject
	    CheckRequired("txtSubject", "lblSubject", "Subject is required.");
	    StripNasties("txtSubject", "lblSubject", "Subject");

		// descr
	    CheckRequired("txtMessage", "lblMessage", "Message is required.");
		StripNasties("txtMessage", "lblMessage", "Message");

		if (errors)
		{
			alert("The form is incomplete. Please review the red text at the top of the page.");
			return false;
		}
		else
		{
			return true;
		}
	}
	catch (ex)
	{
		alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
	}
}


function ValidateNewAd()
{	
	try
	{	
		errors = false;

		// clear out any old errors first
		var objWarningText = document.getElementById("lblWarning");
		while (objWarningText.hasChildNodes())
			objWarningText.removeChild(objWarningText.lastChild);

		// add a line break before any errors
		objWarningText.appendChild(document.createElement("br"));

		objWarningText.style.backgroundColor = "Red";
		objWarningText.style.color = "White";

	    CheckRequired("txtTimesViewed", "lblTimesViewed", "Times Viewed is required (0 if necessary).");
	    
	    ValidateDDL("ddlAdType", "lblAdType", "Please make a selection for Ad Type.");
	    ValidateDDL("ddlCycleType", "lblCycleType", "Please make a selection for Cycle Type.");
	    
	    ValidateDDL("ddlStreetLegal", "lblStreetLegal", "Please make a selection for Street Legal.");
	    ValidateDDL("ddlYear", "lblYear", "Please make a selection for Year.");
	    ValidateDDL("ddlMake", "lblMake", "Please make a selection for Make.");
	    ValidateDDL("ddlModel", "lblModel", "Please make a selection for Model.");
	    CheckRequired("txtPrice", "lblPrice", "Price is required. (0 if necessary)");
	    CheckDigits("txtPrice", "lblPrice", "Price");

	    ValidateDDL("ddlDisplacement", "lblDisplacement", "Please make a selection for Displacement.");
	    ValidateDDL("ddlCylinders", "lblCylinders", "Please make a selection for Cylinders.");
	    ValidateDDL("ddlStroke", "lblStroke", "Please make a selection for Stroke.");
	    ValidateDDL("ddlDriveTrain", "lblDriveTrain", "Please make a selection for Drive Train.");

	    CheckRequired("txtMileage", "lblMileage", "Mileage is required. (0 if necessary)");
	    CheckDigits("txtMileage", "lblMileage", "Mileage");
 	    ValidateDDL("ddlCondition", "lblCondition", "Please make a selection for Condition.");
	    ValidateDDL("ddlCrashDamage", "lblCrashDamage", "Please make a selection for Crash Damage.");
	    ValidateDDL("ddlTireCondition", "lblTireCondition", "Please make a selection for Tire Condition.");
	    ValidateDDL("ddlTitleStatus", "lblTitleStatus", "Please make a selection for Title Status.");

 	    ValidateDDL("ddlColor", "lblColor", "Please make a selection for Color.");
	    ValidateDDL("ddlPaintType", "lblPaintType", "Please make a selection for Paint Type.");
	    ValidateDDL("ddlModifications", "lblModifications", "Please make a selection for Modifications.");

		// descr
	    CheckRequired("txtDescription", "lblDescription", "Description is required.");
	    StripNasties("txtDescription", "lblDescription", "Description");
		CheckLength("txtDescription", "lblDescription", 1000);
      			    /*
		*/

		if (errors)
		{
			alert("The form is incomplete. Please review the red text at the top of the page.");
			return false;
		}
		else
		{
			return true;
		}
	}
	catch (ex)
	{
		alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
	}
}