// validation routines for site submitter editor
function seValidateFields(){
	try {
		var rc = true;
		if ( rc ) {
			rc = seValidateSpecialFields();
		}
		if ( rc ) {
			rc = seValidateEnhancedFields();
		}
		// Do basic last as it contains the T&C check.
		if ( rc ) {
			rc = seValidateBasicFields();
		}
		return(rc);
		
	} catch(e) {
		alert("Error in validation script seValidateFields():" + e.message + '/' + e.name);
		return(false);
	}
}

function seValidateBasicFields()
{
	// divBasicAdDetails - Basic area fields master div
	try {
		var x,y;
		var adTypeSelectorId;
		var rc = true;
		var step = 0;
		var pat = '';
		var doBirthDateTest = false;
		var doStateTest = false;
		var adjFactor = 0;
		var msg;
		var words = new Array('');
		var form = 'frmSed';
		var thmbMinHeight;
		var thmbMaxHeight;
		var thmbMinWidth;
		var thmbMaxWidth;
		
		// ad type - radAdType - pulldown menu
		step = 1;
		adTypeSelectorId = 'radAdType';
		x = tcGetValFromList(adTypeSelectorId, adjFactor);
		if ( ! x ) {
			msg = 'Please select the Ad Type that best suits your ad.';
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);		
		}
		
		// title - theTitle - text field
		step = 2;
		x = Trim(tcGetVal('theTitle'));
		tcSetVal('theTitle', x);
		//alert('title found is [' + x + ']');
		if ( ! x || ! x.length ) {
			msg = 'Please correct the Short Ad Title or Brief Description field. Fill it in with something meaningful related to your ad.';
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		// title - test title for min number of words
		pat = /\s+/;
		words = x.split(pat);
		// alert('Title has ' + words.length + ' words');
		if ( words.length < 3 ) {
			msg = 'Please correct the Short Ad Title or Brief Description field. Fill it in with something meaningful related to your ad. At least 3 meaningful words are required.';
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		// title - test for html tags
		x = tcGetVal('theTitle');
		pat = /\<|\>/;
		if ( x.match(pat) ){
			msg = "HTML Markup tags (<>) are not allowed in the 'Short Ad Title' field. Please remove all tags.";
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		
		// desc - desc - text field
		x = Trim(tcGetVal('desc'));
		tcSetVal('desc', x);
		pat = /\<|\>/;
		if ( x.match(pat) ){
			msg = "HTML Markup tags (<>) are not allowed in the 'Description Overview' field. Please remove all tags.";
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		if ( x.length < 25 ){
			msg = 'Please enter a meaningful description for your ad into the Description Overview field.';
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		if ( x.length < 25 ){
			msg = 'Please enter a meaningful description for your ad into the Description Overview field.';
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		if ( x.length > 255){
			msg = 'The Description Overview entered too long. Please limit the entry to 255 characters.';
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		pat = /\s+/;
		words = x.split(pat);
		if ( words.length < 10 ) {
			msg = 'Please correct the Description Overview field. Fill it in with something meaningful related to your ad. At least 10 meaningful words are required.';
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		
		// content - ad_content - text field
		x = Trim(tcGetVal('ad_content'));
		tcSetVal('ad_content', x);
		x = tcGetVal('ad_content'); // get trimmed version
		pat = /<b>|<\/b>/ig;
		x = x.replace( pat, '');
		pat = /<i>|<\/i>/ig;
		x = x.replace( pat, '');
		pat = /\<|\>/; //check for any remaining offending tags now.
		if ( x.match(pat) ){
			msg = "Only limited HTML tags are allowed in the 'Your Ad Content' field of the Basic Ad Details section. ";
			msg = msg + 'Please remove all other (<>) oriented markup or HTML tags. ';
			msg = msg + 'Allowed HTML Tags: Bold <b></b><i></i> .';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		if ( x.length < 50 ){
			msg = "Please enter a meaningful description for your ad into the 'Your Ad Content' field.";
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		if ( x.length > 5000){
			msg = "The 'Your Ad Content' entered is too long. Please limit the entry to 5000 characters.";
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		pat = /\s+/;
		words = x.split(pat);
		if ( words.length < 20 ) {
			msg = "Please correct the 'Your Ad Content' field. Fill it in with something meaningful related to your ad. At least 20 meaningful words are required.";
			msg = msg + ' The field is in the Basic Ad Details section.';
			alert(msg);
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
			return(false);	
		}
		
		// keyword 0 - kw0 - text field
		x = Trim(tcGetVal('kw0'));
		tcSetVal('kw0', x);
		if ( x.length ) {		
			pat = /\<|\>/;
			if ( x.match(pat) ){
				msg = "HTML Markup tags (<>) are not allowed in the 'Keyword Pattern *' fields. Please remove all tags in the keyword fields.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			if ( x.length < 5 ){
				msg = "Keyword 1 is too short. Please enter a meaningful keyword or keyword pair for the Keyword Pattern 1 field (5 character minimum).";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			pat = /\s+/;
			words = x.split(pat);
			if ( words.length > 3 ) {
				msg = "Please correct the 'Keyword Pattern 1' field. Up to 3 words are allowed. You entered " + words.length + " words.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt();
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
		}
		
		// keyword 1 - kw0 - text field
		x = Trim(tcGetVal('kw1'));
		tcSetVal('kw1', x);
		if ( x.length ) {
			pat = /\<|\>/;
			if ( x.match(pat) ){
				msg = "HTML Markup tags (<>) are not allowed in the 'Keyword Pattern *' fields. Please remove all tags in the keyword fields.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			if ( x.length < 5 ){
				msg = "Keyword 2 is too short. Please enter a meaningful keyword or keyword pair for the Keyword Pattern 2 field (5 character minimum).";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			pat = /\s+/;
			words = x.split(pat);
			if ( words.length > 3 ) {
				msg = "Please correct the 'Keyword Pattern 2' field. Up to 3 words are allowed. You entered " + words.length + " words.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt();
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
		}
		
		// keyword 2 - kw0 - text field
		x = Trim(tcGetVal('kw2'));
		tcSetVal('kw2', x);
		if ( x.length ) {
			pat = /\<|\>/;
			if ( x.match(pat) ){
				msg = "HTML Markup tags (<>) are not allowed in the 'Keyword Pattern *' fields. Please remove all tags in the keyword fields.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			if ( x.length < 5 ){
				msg = "Keyword 3 is too short. Please enter a meaningful keyword or keyword pair for the Keyword Pattern 3 field (5 character minimum).";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			pat = /\s+/;
			words = x.split(pat);
			if ( words.length > 3 ) {
				msg = "Please correct the 'Keyword Pattern 3' field. Up to 3 words are allowed. You entered " + words.length + " words.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt();
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
		}
		
		// keyword 3 - kw0 - text field
		x = Trim(tcGetVal('kw3'));
		tcSetVal('kw3', x);
		if ( x.length ) {
			pat = /\<|\>/;
			if ( x.match(pat) ){
				msg = "HTML Markup tags (<>) are not allowed in the 'Keyword Pattern *' fields. Please remove all tags in the keyword fields.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			if ( x.length < 5 ){
				msg = "Keyword 4 is too short. Please enter a meaningful keyword or keyword pair for the Keyword Pattern 4 field (5 character minimum).";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			pat = /\s+/;
			words = x.split(pat);
			if ( words.length > 3 ) {
				msg = "Please correct the 'Keyword Pattern 4' field. Up to 3 words are allowed. You entered " + words.length + " words.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt();
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
		}
		
		// keyword 4 - kw0 - text field
		x = Trim(tcGetVal('kw4'));
		tcSetVal('kw4', x);
		if ( x.length ) {
			pat = /\<|\>/;
			if ( x.match(pat) ){
				msg = "HTML Markup tags (<>) are not allowed in the 'Keyword Pattern *' fields. Please remove all tags in the keyword fields.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			if ( x.length < 5 ){
				msg = "Keyword 5 is too short. Please enter a meaningful keyword or keyword pair for the Keyword Pattern 5 field (5 character minimum).";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt(); 
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
			pat = /\s+/;
			words = x.split(pat);
			if ( words.length > 3 ) {
				msg = "Please correct the 'Keyword Pattern 5' field. Up to 3 words are allowed. You entered " + words.length + " words.";
				msg = msg + ' The field is in the Basic Ad Details section.';
				alert(msg);
				sedShowBasicDetailsAlt();
				tcJumpToAnchor('#anchKeywords');
				return(false);	
			}
		}
		
		// url - theUrl - text field
		step = 30;
		pat = /http:\/\//;
		x = Trim(tcGetVal('theUrl'));
		tcSetVal('theUrl', x);
		if ( x != 'http://' ) {
			if ( ! seValidateURL(x) ) {
				alert("Please correct the Target URL field. Fill it in with a valid URL to your ad or site or leave it as 'http://' indicating to us to use a default ad page we will generate for you. The URL must begin with http://");
				sedShowBasicDetailsAlt();
				document.location.href="#anchorTargetUrl";
				return(false);	
			}
		}
		
		/* 
		// Image Radio Buttons
		// radImageOption1 - radio button set of 2
		// radImageOption2 - radio button set of 2
		// radImageOption3 - radio button set of 2
		// Divs: divImageOption1, divImageOption2, divImageOption3
		// Div::divImageOption1:
		//   bnnrurl - text field <or>
		//   bnnrcode - text field
		//   menBannerType - select menu
		// Div::divImageOption2:
		//   thumburl - text field
		//   txtThmbWdth - text field
		//   txtThmbHght - text field
		// Div::divImageOption3:
		//   txtPictureUrl - text field
		*/
		x = tcIntVal(tcGetRadioButtonValue(form, 'radImageOption1'));
		if ( x ) {
			//alert('radio image option 1 is: ' + x);
			// validate banner URL or Javascript
			x = Trim(tcGetVal('bnnrurl'));
			tcSetVal('bnnrurl', x);
			if ( x && ! seValidateImageURL(x) ) {
				alert("Please correct the Banner URL field. Fill it in with a valid URL that shows the appropriate banner image. when entered into a browser. The file type must end in .jpg, .jpeg, .gif, .bmp. or .png");
				sedShowBasicDetailsAlt();
				tcShowDiv('divImageOption1');
				document.location.href="#anchorBannerUrl";
				return(false);	
			}
			// Check to see if they at least enter banner url or code
			if ( ! x ) {
				x = Trim(tcGetVal('bnnrcode'));
				tcSetVal('bnnrcode', x);
				if ( ! x ) {
					alert("Please enter either a valid the Banner URL or fill in the banner code with valid HTML or Javascript markup.");
					sedShowBasicDetailsAlt();
					tcShowDiv('divImageOption1');
					document.location.href="#anchorBannerUrl";
					return(false);	
				}
			}
		}
		
		// Image option 2
		x = tcIntVal(tcGetRadioButtonValue(form, 'radImageOption2'));
		if ( x ) {
			//alert('radio image option 2 is: ' + x);
			x = tcGetVal('thumburl');
			if ( !  seValidateImageURL(x) ) {
				alert("Please correct the Thumbnail Image URL field. Fill it in with a valid URL that shows the appropriate banner image. when entered into a browser. The URL must end in .jpg, .gif, .bmp, or .png and be a valid image.");
				sedShowBasicDetailsAlt();
				tcShowDiv('divImageOption2');
				document.location.href="#anchImageOption2";
				return(false);	
			}
			// Now test the thumbnail image dimensions
			x = tcIntVal(Trim(tcGetVal('txtThmbWdth')));
			thmbMinWidth = parseInt(tcGetVal('txtThmbMinWidth'));
			thmbMaxWidth = parseInt(tcGetVal('txtThmbMaxWidth'));
			isNaN(x) ? x=thmbMinWidth : 1;
			tcSetVal('txtThmbWdth', x);
			if ( ! x ) {
				alert("Please enter an integer number value for the 'Width' of the thumbnail url image given in pixels. The typical range is 250 to 480.");
				sedShowBasicDetailsAlt();
				tcShowDiv('divImageOption2');
				document.location.href="#anchImageOption2";
				return(false);	
			}
			
			x = tcIntVal(Trim(tcGetVal('txtThmbHght')));
			thmbMinHeight = parseInt(tcGetVal('txtThmbMinHeight'));
			thmbMaxHeight = parseInt(tcGetVal('txtThmbMaxHeight'));
			isNaN(x) ? x=thmbMinHeight : 1;
			tcSetVal('txtThmbHght', x);
			if ( ! x ) {
				alert("Please enter an integer number value for the 'Height' of the thumbnail url image given in pixels. The typical range is 250 to 480.");
				sedShowBasicDetailsAlt();
				tcShowDiv('divImageOption2');
				document.location.href="#anchImageOption2";
				return(false);	
			}
		}
		
		// Image option 3
		x = tcIntVal(tcGetRadioButtonValue(form, 'radImageOption3'));
		if ( x ) {
			//alert('radio image option 3 is: ' + x);
			x = tcGetVal('txtPictureUrl');
			if ( ! seValidateImageURL(x) ) {
				alert("Please correct the Detailed Picture URL field. Fill it in with a valid URL that shows an appropriate image when entered into a browser. The URL must end in .jpg, .gif, .bmp, or .png and be a valid image.");
				sedShowBasicDetailsAlt();
				tcShowDiv('divImageOption3');
				document.location.href="#anchImageOption3";
				return(false);	
			}
		}
		
		// Born Month - txtBornMonth - text field
		// Born Day - txtBornDay - text field
		// Born Year - txtBornYear - text field
		// Test only certain ad types
		adTypeSelectorId = 'radAdType';
		x = tcGetValFromList(adTypeSelectorId, adjFactor);
		
		// Classifieds range: 30-49
		if (30 <= x && x <= 49) {
			doBirthDateTest = true;
			doStateTest = true;
		}
		
		// Personal ad range: 70-79
		if ( 70 <= x && x <= 79) {
			doBirthDateTest = true;
			doStateTest = true;
		}
		
		if ( doBirthDateTest ) {
			// Validate Born Date Time
			// txtBornYear
			step = 'Year Born Test';
			x = Trim(tcGetVal('txtBornYear'));
			tcSetVal('txtBornYear', x);
			if ( ! x || ! isUnsignedInteger(x) || x <= 1900 || x > 1991 || x.length != 4) {
				sedShowBasicDetailsAlt();
				tcShowDiv('divDateBornHelp');
				alert("Please correct the year born or year item was produced field. Enter only 4 numbers for the year in YYYY format.");
				document.location.href="#dateborn";
				return(false);
			}
	
			// txtBornMonth
			step = 'Month Born Test';
			x = Trim(tcGetVal('txtBornMonth'));
			tcSetVal('txtBornMonth', x);
			if ( ! x || ! isUnsignedInteger(x) || x < 1 || x > 12 || x.length != 2) {
				sedShowBasicDetailsAlt();
				tcShowDiv('divDateBornHelp');
				alert("Please correct the month born field. Enter two numbers between 01 and 12 for the month of year in MM format.");
				document.location.href="#dateborn";
				return(false);
			}
	
			// txtBornDay
			step = 'Day Born Test';
			x = Trim(tcGetVal('txtBornDay'));
			tcSetVal('txtBornDay', x);
			if ( ! x || ! isUnsignedInteger(x) || x < 1 || x > 31 || x.length != 2) {
				sedShowBasicDetailsAlt();
				tcShowDiv('divDateBornHelp');
				alert("Please correct the day born field. Enter two numbers between 01 and 31 for the day of month in DD format.");
				document.location.href="#dateborn";
				return(false);
			}
			
			// txtBornHour
			step = 'Hour Test';
			x = Trim(tcGetVal('txtBornHour'));
			tcSetVal('txtBornHour', x);
			if ( ! x || ! isUnsignedInteger(x) || x < 0 || x > 23 || x.length != 2) {
				sedShowBasicDetailsAlt();
				tcShowDiv('divDateBornHelp');
				alert("Please correct the 'Hour born' field. Enter two numbers between 00 and 23 (military time) in HH format.");
				document.location.href="#dateborn";
				return(false);
			}
		}
		
		if ( doStateTest ) {	
			step = 'State Test';
			x = Trim(tcGetVal('txtState'));
			tcSetVal('txtState', x);
			if ( ! x || x.length < 2) {
				sedShowBasicDetailsAlt();
				tcShowDiv('divStateSelector');
				alert("Please select your State or Province.");
				document.location.href="#anchStateSel1";
				return(false);
			}
		}
		
		// Ensure terms are accepted - chk_terms_and_conditions
		x = tcGetDomObj('chk_terms_and_conditions').checked;
		if ( ! x ) {
			alert("You must check the checkbox next to 'Save My Ad Details' indicating you accept the site terms and conditions and other legal guidelines before submitting your ad.");
			sedShowBasicDetailsAlt();
			document.location.href="#anchorTermsConditions";
			return(false);
		}
		
		// State selectors - see site_editor.js for routines.
		// selStateSelector1
		// selStateSelector2
		
		// on failure show the basic section
		if ( ! rc ) {
			sedShowBasicDetailsAlt(); 
			tcJumpToAnchor('#sedBasicFields');
		}
		return(rc);
		
	} catch(e) {
		alert("Error in validation script seValidateBasicFields():" + e.message + '/' + e.name);
		return(false);
	}
}

function seValidateEmail(email) {
  try {
    var rc = true;
	var pat = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z0-9]{2,6})$/;
    if ( ! email.match(pat) ) {
      rc = false;
    }
	return(rc);
  } catch(e) {
    alert("Error occurred in function seValidateEmail(): " + e.name + "/" + e.message);
  } 
}

/* validate an open ended URL that can contain subdirs: ex: http://domain_dom.com/subdir/stuff... */
function seValidateURL(url) {
  try {
	var pat;
    var rc = true;
	url = url.toLowerCase();
	pat = /^http:\/\/[a-z0-9_\-\.\/]*(\.[a-z]{2,6}).*$/;  // loose for now.
    if ( ! url.match(pat) ) {
      rc = false;
    }
	return(rc);
  } catch(e) {
    alert("Error occurred in function seValidateURL(): " + e.name + "/" + e.message);
  } 
}

function seValidateImageURL(url) {
  try {
	var pat;
    var rc = true;
	// Allow gif, jpg, png, bmp
	url = url.toLowerCase();
	if ( seValidateURL(url) ) {
		pat = /^http:\/\/.*\.(jpg|jpeg|gif|bmp|png)$/;
		if ( ! url.match(pat) ){
		  rc = false;
		}
	} else {
		rc = false;
	}
	return(rc);
  } catch(e) {
    alert("Error occurred in function seValidateImageURL(): " + e.name + "/" + e.message);
  } 
}

// Scans for lt and gt tags - if found returns true.
function seContainsMarkup(s){
	try {
		var rc = false;
		var pat = /\<|\>/;
		if ( s.match(pat) ){
			rc = true; // tags found
		}
		return(rc);
	} catch(e) {
    	alert("Error occurred in function seScanForHtml(): " + e.name + "/" + e.message);
	}
}

function seValidateEnhancedFields(){
	// Major Div: divEnhAdDetails
	try {
		var rc = true;
		var x;
		var pat;
		var step = 0;
		
		// txtMapUrl
		step = 1;
		x = tcGetVal('txtMapUrl');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please enter a valid Map URL that does not contain markup tags. It must start with http://');
			return(false);
		}
		step = 2;
		if ( x && ! seValidateURL(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please enter a valid Map URL that does not contain markup tags. It must start with http://');
			return(false);
		}
		
		// txtGalaxy
		step = 3;
		x = tcGetVal('txtGalaxy');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Galaxy field. Markup is not allowed.');
			return(false);
		}
		
		// txtPlanet
		step = 4;
		x = tcGetVal('txtPlanet');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Planet field. Markup is not allowed.');
			return(false);
		}
		
		// txtHemis
		step = 5;
		x = tcGetVal('txtHemis');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Hemisphere field. Markup is not allowed.');
			return(false);
		}
		
		// txtContinent
		step = 6;
		x = tcGetVal('txtContinent');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Continent field. Markup is not allowed.');
			return(false);
		}
		
		// txtCountry
		step = 7;
		x = tcGetVal('txtCountry');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Country field. Markup is not allowed.');
			return(false);
		}
		
		// txtRegion
		step = 8;
		x = tcGetVal('txtRegion');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Region field. Markup is not allowed.');
			return(false);
		}
		
		// txtState
		step = 9;
		x = tcGetVal('txtState');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the State field. Markup is not allowed.');
			return(false);
		}
		
		// txtDistrict
		step = 10;
		x = tcGetVal('txtDistrict');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the District field. Markup is not allowed.');
			return(false);
		}
		
		// txtCounty
		step = 11;
		x = tcGetVal('txtCounty');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the County field. Markup is not allowed.');
			return(false);
		}
		
		// txtCity
		step = 12;
		x = tcGetVal('txtCity');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the City field. Markup is not allowed.');
			return(false);
		}
		
		// txtTown
		step = 13;
		x = tcGetVal('txtTown');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Town field. Markup is not allowed.');
			return(false);
		}
		
		// txtSubdiv
		step = 14;
		x = tcGetVal('txtSubdiv');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Sub-Division field. Markup is not allowed.');
			return(false);
		}
		
		// txtComplex
		step = 15;
		x = tcGetVal('txtComplex');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert("Please remove all markup tags from the 'Project, Complex, or Building' field. Markup is not allowed.");
			return(false);
		}
		
		// txtAddress1
		step = 16;
		x = tcGetVal('txtAddress1');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Address 1 field. Markup is not allowed.');
			return(false);
		}
		
		// txtAddress2
		step = 17;
		x = tcGetVal('txtAddress2');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Address 2 field. Markup is not allowed.');
			return(false);
		}
		
		// txtCntryCd
		step = 18;
		x = tcGetVal('txtCntryCd');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Country Code field. Markup is not allowed.');
			return(false);
		}
		
		// txtAreaCd
		step = 19;
		x = tcGetVal('txtAreaCd');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Area Code field. Markup is not allowed.');
			return(false);
		}
		
		// txtZipCd
		step = 20;
		x = tcGetVal('txtZipCd');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Zip Code field. Markup is not allowed.');
			return(false);
		}
		
		// txtPhnNum
		step = 21;
		x = tcGetVal('txtPhnNum');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Phone Number field. Markup is not allowed.');
			return(false);
		}
		
		// txtLngTd
		step = 22;
		x = tcGetVal('txtLngTd');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Longitude field. Markup is not allowed.');
			return(false);
		}
		
		// txtLatTd
		step = 23;
		x = tcGetVal('txtLatTd');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Latitude field. Markup is not allowed.');
			return(false);
		}
		
		// txtTmZnDelta
		step = 24;
		x = tcGetVal('txtTmZnDelta');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Time Zone field. Markup is not allowed.');
			return(false);
		}
		
		// txtLang
		step = 25;
		x = tcGetVal('txtLang');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Language field. Markup is not allowed.');
			return(false);
		}
		
		// txtRelig
		step = 26;
		x = tcGetVal('txtRelig');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Religion field. Markup is not allowed.');
			return(false);
		}
		
		// category - select menu
		// altcat - select menu
		
		// txtmetainfo
		step = 29;
		x = tcGetVal('txtmetainfo');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Ad Metadata field. Markup is not allowed. Enter keywords separated by spaces or commas.');
			return(false);
		}
		
		// menPropagate - select menu
		// admode - select menu
		
		// display_url - text field
		step = 32;
		x = tcGetVal('display_url');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Short URL field. Markup is not allowed. Enter a well formed URL starting with http://');
			return(false);
		}
				
		// override_url - text field
		step = 33;
		x = tcGetVal('override_url');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Alternate Target URL field. Markup is not allowed. Enter a well formed URL starting with http://');
			return(false);
		}
		step = 34;
		if ( x && ! seValidateURL(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please enter a valid Alternate Target URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtOrg
		step = 35;
		x = tcGetVal('txtOrg');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Club or Org Name field. Markup is not allowed.');
			return(false);
		}
		
		// txtPriceFound
		step = 36;
		x = tcGetVal('txtPriceFound');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the Retail Price Found field. Markup is not allowed.');
			return(false);
		}
		
		// txtUpcCode
		step = 37;
		x = tcGetVal('txtUpcCode');
		if ( seContainsMarkup(x) ){
			sedShowEnhDetails();
			tcJumpToAnchor('#AdvancedSiteEditor');
			alert('Please remove all markup tags from the UPC Code field. Markup is not allowed.');
			return(false);
		}

		return(rc); // all pass
		
	} catch(e) {
		alert("Error in validation script seValidateEnhancedFields() at step:" + step + '/' + e.message + '/' + e.name);
		return(false);
	}
}

function seValidateSpecialFields(){
	// Main Div: divSpecialAdDetails
	try {
		var rc = true;
		var x;
		var pat;
		var step = 0;
		
		// menTrgAudience - select menu
		step = 1;
		
		// txtMinAge
		step = 2;
		x = tcGetVal('txtMinAge');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Minimum Age field. Markup is not allowed.');
			return(false);
		}
		
		// txtMaxAge
		step = 3;
		x = tcGetVal('txtMaxAge');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Maximum Age field. Markup is not allowed.');
			return(false);
		}
		
		// txtStkSym
		step = 4;
		x = tcGetVal('txtStkSym');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Stock Market Symbol field. Markup is not allowed.');
			return(false);
		}
		
		// txtSICCd
		step = 5;
		x = tcGetVal('txtSICCd');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Standard Industry Code field. Markup is not allowed.');
			return(false);
		}
		
		// txtCmpSize
		step = 6;
		x = tcGetVal('txtCmpSize');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Company size field. Markup is not allowed.');
			return(false);
		}
		
		// txtCmpRev
		step = 7;
		x = tcGetVal('txtCmpRev');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Company Revenue field. Markup is not allowed.');
			return(false);
		}
		
		// txtSrtHr
		step = 8;
		x = tcGetVal('txtSrtHr');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Start Hour field. Markup is not allowed.');
			return(false);
		}
		
		// txtEndHr
		step = 9;
		x = tcGetVal('txtEndHr');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the End Hour field. Markup is not allowed.');
			return(false);
		}
		
		// txtRewards
		step = 10;
		x = tcGetVal('txtRewards');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Customer Rewards field. Markup is not allowed.');
			return(false);
		}
		
		// txtAudUrl
		step = 11;
		x = tcGetVal('txtAudUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Audio Presentation URL field. Markup is not allowed.');
			return(false);
		}
		step = 12;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Audio Presentation URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtPrezUrl
		step = 13;
		x = tcGetVal('txtPrezUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Multimedia Presentation URL field. Markup is not allowed.');
			return(false);
		}
		step = 14;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Multimedia Presentation URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtVideoUrl
		step = 15;
		x = tcGetVal('txtVideoUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Video Presentation URL field. Markup is not allowed.');
			return(false);
		}
		step = 16;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Video Presentation URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtVRcontrollers
		step = 17;
		x = tcGetVal('txtVRcontrollers');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Virtual Reality Controllers field. Markup tags <> are not allowed.');
			return(false);
		}
		
		// txtAppUrl
		step = 18;
		x = tcGetVal('txtAppUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the on-line applications / demo or access URL field. Markup is not allowed.');
			return(false);
		}
		step = 19;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid on-line applications / demo or access URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtForumUrl
		step = 20;
		x = tcGetVal('txtForumUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Forum URL field. Markup is not allowed.');
			return(false);
		}
		step = 21;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Forum URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtRssUrl
		step = 22;
		x = tcGetVal('txtRssUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the RSS Feed URL field. Markup is not allowed.');
			return(false);
		}
		step = 23;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid RSS Feed URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtBlogUrl
		step = 24;
		x = tcGetVal('txtBlogUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Blog URL field. Markup is not allowed.');
			return(false);
		}
		step = 25;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Blog URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtPubdomUrl
		step = 26;
		x = tcGetVal('txtPubdomUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Free Public Domain Content URL field. Markup is not allowed.');
			return(false);
		}
		step = 27;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Free Public Domain Content URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtSurveyUrl
		step = 28;
		x = tcGetVal('txtSurveyUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Paid Survey URL field. Markup is not allowed.');
			return(false);
		}
		step = 29;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Paid Survey URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtContestUrl
		step = 30;
		x = tcGetVal('txtContestUrl');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Public Contests URL field. Markup is not allowed.');
			return(false);
		}
		step = 31;
		if ( x && ! seValidateURL(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please enter a valid Public Contests URL that does not contain <> markup tags. Enter a well formed URL starting with http://');
			return(false);
		}
		
		// txtVirtPlnPasswd
		step = 32;
		x = tcGetVal('txtVirtPlnPasswd');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Virtual Plane Password field. Markup is not allowed.');
			return(false);
		}
		
		// txtVirtPlane
		step = 33;
		x = tcGetVal('txtVirtPlane');
		if ( seContainsMarkup(x) ){
			sedShowSpecialDetails();
			tcJumpToAnchor('#anchSpecialAdDetails');
			alert('Please remove all markup tags from the Custom Virtual Plane Name field. Markup is not allowed.');
			return(false);
		}
		
		// on fail, show the enhanced ad details
		if ( ! rc ) {
			sedShowSpecialDetails() 
			tcJumpToAnchor('#anchSpecialAdDetails');
		}
		return(rc);
		
	} catch(e) {
		alert("Error in validation script seValidateSpecialFields() at step:" + step + '/' + e.message + '/' + e.name);
		return(false);
	}
}
