<!--
function clearField(theText) {
	if (theText.value == theText.defaultValue) {
		theText.value = ""
	}
}

function charCount(part, num) {
	numChars = document.getElementById(num+"_"+part).value.length;
	outputElem = document.getElementById(part+"_"+num);
	
	outputElem.innerHTML = numChars;
	
	if (part == 'headline' && numChars > 25) { outputElem.style.color = "#ff0000"; }
	else if (part == 'line1' && numChars > 35) { outputElem.style.color = "#ff0000"; }
	else if (part == 'line2' && numChars > 35) { outputElem.style.color = "#ff0000"; }
	else if (part == 'display' && numChars > 35) { outputElem.style.color = "#ff0000"; }
	else if (part == 'destination' && numChars > 1024) { outputElem.style.color = "#ff0000"; }
	else { document.getElementById(part+"_"+num).style.color = "#0e1215"; }
}

function validateForm(form) {
	// check to make sure a campaign name was entered
	if (document.inputForm.campaignName.value == document.inputForm.campaignName.defaultValue || document.inputForm.campaignName.value == '') {
		alert("Error: You must give your campaign a name");
		return false;
	}
	
	// check to make sure at least one keyword match type was selected
	if (document.inputForm.elements['matchTypes[]'][0].checked == false && document.inputForm.elements['matchTypes[]'][1].checked == false && document.inputForm.elements['matchTypes[]'][2].checked == false) { 
		alert("Error: You must choose at least one keyword match type");
		return false;
	}
	
	// check to make sure a custom ad group name was entered if checked
	if ((document.inputForm.groupName.value == document.inputForm.groupName.defaultValue || document.inputForm.groupName.value == '') && document.inputForm.grouping[3].checked == true) {
		alert("Error: You chose a single custom ad group but you didn't give it a name");
		return false;
	}
	
	// check all ads to make sure they are complete
	for (x=1; x<=6; x++) {
		if ((
		 document.getElementById(x+'_headline').value != '' ||  
		 document.getElementById(x+'_line1').value != '' || 
		 document.getElementById(x+'_line2').value != '' ||  
		 document.getElementById(x+'_display').value != '' || 
		 document.getElementById(x+'_destination').value != ''
		) && (
		 document.getElementById(x+'_headline').value == '' ||  
		 document.getElementById(x+'_line1').value == '' || 
		 document.getElementById(x+'_line2').value == '' ||  
		 document.getElementById(x+'_display').value == '' || 
		 document.getElementById(x+'_destination').value == ''
		))
		{
			alert("Error: Ad #"+x+" is incomplete");
			return false;
		}	
	}
	
}

function groupMode(mode) {
	if (mode == 'all') {
		document.getElementById('groupByExpansion').style.display = 'block';
		document.getElementById('groupByFinal').style.display = 'block';
	}
	if (mode == 'limit') {
		document.getElementById('groupByExpansion').style.display = 'none';
		document.getElementById('groupByFinal').style.display = 'none';
		if (document.inputForm.grouping[1].checked == true || document.inputForm.grouping[2].checked == true) {
			document.inputForm.grouping[0].checked = true;
		}
	}
}

function branch(mode) {
	if (mode == 'enable') {
		document.inputForm.branchKeywords.disabled = false;	
		document.inputForm.branchKeywords.style.background = '#ffffff';
		document.inputForm.branchKeywords.style.color = '#0e1215';
	}
	if (mode == 'disable') {
		document.inputForm.branchKeywords.disabled = true;
		document.inputForm.branchKeywords.style.background = '#f1f1f1';
		document.inputForm.branchKeywords.style.color = '#88939b';
	}
}

function base(mode) {
	if (mode == 'root') {
		document.getElementById('root-base').style.display = 'block';
		document.getElementById('branch-base').style.display = 'none';
		document.getElementById('base-unavail').style.display = 'none';
		document.inputForm.branchBase[1].checked = true;
		if (document.inputForm.mixing[3].checked == true || document.inputForm.mixing[3].checked == true) { base('none'); }
	}
	if (mode == 'branch') {
		document.getElementById('root-base').style.display = 'none';
		document.getElementById('branch-base').style.display = 'block';
		document.getElementById('base-unavail').style.display = 'none';
		document.inputForm.rootBase[1].checked = true;
	}
	if (mode == 'both') {
		document.getElementById('root-base').style.display = 'block';
		document.getElementById('branch-base').style.display = 'block';
		document.getElementById('base-unavail').style.display = 'none';
	}
	if (mode == 'none') {
		document.getElementById('root-base').style.display = 'none';
		document.getElementById('branch-base').style.display = 'none';
		document.getElementById('base-unavail').style.display = 'block';
		document.inputForm.rootBase[1].checked = true;
		document.inputForm.branchBase[1].checked = true;
	}
}
//-->
