//method to "show" or "hide" an element on a page by it's ID and the type of display desired
function showHide(id, displayType) {
	if (displayType == "none") {
		$(id).style.display = "none";
	} else if (displayType == "block") {
		$(id).style.display = "block";
	}
	
	//otherwise leave as is
}

//method to "hide" an element on a page by it's ID
function hide(id) {
	showHide(id, "none");
}

//method to "show" an element on a page by it's ID
function show(id) {
	showHide(id, "block");
}


function validate() {

	var showMessage = new Boolean(false);

	//array of validation message bullet points
	var errorMessageComponents = new Array(
	"validation",
	"stateIDVal",
	"tccIDVal"
	);

	//set 'em all to hidden at the start of validation
	for(i = 0; i < errorMessageComponents.length; i++) {
		hide(errorMessageComponents[i]);
	}

	if($('stateID').value == "") {
		show("stateIDVal");
		showMessage = true;
	}

	if($('tccID').value == "") {
		show("tccIDVal");
		showMessage = true;
	}


	//Did you find validation errors?  If so, show the messages and reposition the window
	if(showMessage == true) {
		show("validation");
		if($("applicationValidation") != null) {			
			hide("applicationValidation");
		}		
		return false;

	} else {
		//valid
		return true;
	}

	return false;

}

function confirmOrDeclineRenewal() {
	if ($("yesAutoRenew").checked == true) {
		openConfirmRenewal();
	} else {
		declineAnnualRenewal();
	}
}

function openConfirmRenewal() {
	show("autoRenewMessage");
}

function declineAnnualRenewal() {
	hide("autoRenewMessage");
	$("yesAutoRenew").checked = false;
}

var confirmation = false;

function confirmMe() {
	return confirmation;
}