


function validateChores() {
	var isValidate=false;
	for (i=0;i<20;i++) {
		if ((document.getElementById("hidden_task_" + i).value) == '1') {
			isValidate=true;
		}  
	}

	for (i=0;i<8;i++) {
		var txtBox = document.getElementById("txtchkCTask_" + i);
		var ct = "";
		if (txtBox) { 
			ct = txtBox.value;
		}
		if (ct.indexOf("Custom Chore") < 0 && ct != '') {
			isValidate=true;
		}  
	}
	
	return isValidate;
}

function submitSignupChoreChart(postToUrl, openNewWindow) {
	if(validateChores()) {
		var url = postToUrl; 
		url += "&taskIds=";
		for (i=0;i<20;i++) {
			if ((document.getElementById("hidden_task_" + i).value) == '1') {
				url += document.getElementById("t_" + i).value + ",";
			}  
		}
		url += "&";
		for (i=0;i<8;i++) {
			var txtBox = document.getElementById("txtchkCTask_" + i);
			var customTask = "";
			if (txtBox) {
				customTask = txtBox.value;
			}			
			if (customTask != '' && customTask.indexOf("Custom ") <0 ) {
				url += "cust_" + i + "=" + document.getElementById("txtchkCTask_" + i).value + "&";
			}  
		}
		if (openNewWindow) {
			window.open(url);
		} else {	
			window.location.href = url;
		}
		return true;
	} else {
		alert('Please select at least one task to create your chart.');
		return false;
	}
}

function setTaskCheckValue(id) {
	if ( document.getElementById("hidden_task_" + id).value == 0) {
		document.getElementById("hidden_task_" + id).value = 1;
	} else {
		document.getElementById("hidden_task_" + id).value = 0;
	}
}

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}