var thisPage = function() {
	var private_var;
	function private_method() {
		// do stuff here
	}
	return {

		showExtraLinks : function(ulRootObj, brand) {
			// first, make our <ul> active
			css.addClassName(ulRootObj, 'active');

			// now activate appropriate links
			var arrLi = ulRootObj.getElementsByTagName('li');
			for (var i = 0; i < arrLi.length; i++) {
				//console.log(arrLi[i].id);
				if (css.hasClassName(arrLi[i], 'linkCompareTrim') || css.hasClassName(arrLi[i], 'linkCompareGM')) {
					//console.log(arrLi[i].id.indexOf('_'+brand+'_'));
					var years = document.getElementById('polkTrimsActionForm').sYear;
					var year = years.options[years.selectedIndex].value;
					$('startLinkCompareTrim').set('styles', {'display': 'none'});
					$('startLinkCompareGM').set('styles', {'display': 'none'});
					if (arrLi[i].id.indexOf('_'+brand+'_') != -1 && arrLi[i].id.indexOf('_'+year+'_') != -1) {
						css.addClassName(arrLi[i], 'active');
					} else {
						css.removeClassName(arrLi[i], 'active');
					}
				}
			}


		},
		validateForm : function(form) {
				if (form.sYear.value == 'Select Year') {
					alert("Please use the drop-down boxes to select a vehicle.");
					return false;
				}

				if (form.sBrand.value == 'Select Model') {
					alert("Please use the drop-down boxes to select a vehicle.");
					return false;
				}

				if (form.sSubBrand.value == 'Select Configuration') {
					alert("Please use the drop-down boxes to select a vehicle.");
					return false;
				}

				if (form.sTrim.value == 'Select Trim') {
					alert("Please use the drop-down boxes to select a vehicle.");
					return false;
				}


				form.anchorVehicleYear.value = form.sYear.value;
				form.modelID.value = form.sBrand.value;
				form.configID.value = form.sSubBrand.value;
				form.anchorVehicleID.value = form.sTrim.value;

				return true;
		}
	};
}();

// when dom is ready
$(document).addEvent('domready', function() {

	// when user changes brand menu
	$('sBrand').addEvent('change', function() {
		//console.log("change");
		//console.log(this.value);
		thisPage.showExtraLinks($('pCompareLinks'), this.value);
		/*
		if (this.value == 'Select Model') {
			css.removeClassName($('pCompareLinks'), 'active');
		} else {
			thisPage.showExtraLinks($('pCompareLinks'), this.value);
		}
*/
	});

});

function validateLinkCompare(type,url){
	var result = true;
	if(type.contains('Trim')){
		if($('sYear').get('value').contains('Select a Year') || $('sBrand').get('value').contains('Select a Model')){
			alert("Please use the dropdowns to select a year and model.");
			result = false;
		}
	}
	if(type.contains('GM')){
		if($('sYear').get('value').contains('Select a Year') || $('sBrand').get('value').contains('Select a Model') || $('sSubBrand').get('value').contains('Select a Configuration') || $('sTrim').get('value').contains('Select a Trim')){
			alert("Please use the dropdowns to select a vehicle trim.");
			result = false;
		}
	}
	if(result) window.location = url;
}