function checkRemoveGroup() {
	var checkedItem = false;
	//alert(document.forms[0].removeHierarchy.length);
	if(!document.forms[0].removeHierarchy.length) {
		if (document.forms[0].removeHierarchy.checked == true) {
			checkedItem = true;
		}
	}
	else {
		for (var i = 0; i < document.forms[0].removeHierarchy.length; i++) {
			if (document.forms[0].removeHierarchy[i].checked == true) {
				checkedItem = true;
				break;
			}
		}
	}

	if (!checkedItem) {
		alert('Please select a hierarchy to remove.');
		return false;
	} else {
		return areYouSure();
	}
}

function areYouSure() {
   return confirm("Are you sure you want to delete this?");
}

function changeAction(url) {
	document.forms[0].target = "_self";
	document.forms[0].action = url;
	document.forms[0].submit();
}
function changeActionCF(url) {
	document.CFForm_1.target = "_self";
	document.CFForm_1.action = url;
	document.CFForm_1.submit();
}

function changeActionValidate(url) {
	document.CFForm_1.target = "_self";
	document.CFForm_1.action = url;
	if ( _CF_checkCFForm_1(document.CFForm_1) ) {
		document.CFForm_1.submit();
	}
	else {
		return false;
	}
}

function submitUserDetailForm() {
	if ( validateEmail() ) {
		if ( _CF_checkuserForm(document.userForm) ) {
			document.userForm.submit();
		}
		else {
			return false;
		}
	}
}

function changeActionBlank(url) {
	document.forms[0].target = "_blank";
	document.forms[0].action = url;
	document.forms[0].submit();
}


function validForm() {
			
			if (document.forms[0].password.value != document.forms[0].c_password.value) {
				alert("Entered passwords did not match.")
				document.forms[0].password.focus();
				return false;
			}
			return true;
		}
		
function mustSelect(url) {
			
	if (document.forms[0].r_id.value < 1) {
		alert("You must select a revenue type.")
		return false;
		}
	else {
		changeAction(url);
		return true;
		}
	}
		

function validateEmail() {

		txt=document.forms[0].email.value;
		txt=txt.toLowerCase();
		regex= /\S/g;
		//checkspace = form[0].email;
		checkspace = document.forms[0].email.value.replace(regex,"");
		if(checkspace != ""){alert("I'm sorry. The email address you supplied seems wrong. Please check for blank spaces within the address.");return false;}
		
		if(txt=="")
		{
		alert("Please provide an email address.");
		return false;
		}
				
		if (txt.indexOf("@") <= 0)
		{
		alert("I'm sorry. The email address you supplied seems wrong. Please"
		+" check the prefix and '@' sign.");
		return false;
		}
		
		if ((txt.indexOf(".com")<3)&&(txt.indexOf(".org")<3)
			&&(txt.indexOf(".gov")<3)&&(txt.indexOf(".net")<3)
			&&(txt.indexOf(".mil")<3)&&(txt.indexOf(".edu")<3)
			&&(txt.indexOf(".ca")<3)&&(txt.indexOf(".uk")<3)
			&&(txt.indexOf(".de")<3)&&(txt.indexOf(".jp")<3)
			&&(txt.indexOf(".fr")<3)&&(txt.indexOf(".za")<3)
			&&(txt.indexOf(".lu")<3)&&(txt.indexOf(".bm")<3))
		{
		alert("I'm sorry. The email address you supplied seems wrong. Please"
		+" check the suffix for accuracy. (It should include a "
		+".com, .edu, .net, .org, .gov)");
		return false;
	  	}
		
		return true;
	}

	
function mustSelectGroup()
	{
		
		if (document.forms[0].groupID.options[document.forms[0].groupID.selectedIndex].value == "") {
				alert("You must select a group.")
				document.forms[0].groupID.focus();
				return false;
			}
		
		if (document.forms[0].searchType[0].checked)
			{
				if (document.forms[0].reportMonth.options[document.forms[0].reportMonth.selectedIndex].value == "")
				{
					alert("You must select a month period.")
					document.forms[0].reportMonth.focus();
					return false;
				}
				
				if (document.forms[0].reportDay.options[document.forms[0].reportDay.selectedIndex].value == "")
				{
					alert("You must select a day period.")
					document.forms[0].reportDay.focus();
					return false;
				}
			}
		else if (document.forms[0].searchType[1].checked)
			{
				if (document.forms[0].qtrRange.options[document.forms[0].qtrRange.selectedIndex].value == "")
				{
					alert("You must select a report period quarter.")
					document.forms[0].qtrRange.focus();
					return false;
				}
			}
		else
			{
				alert("You must select a report search type.")
				return false;
			}
			
		if (document.forms[0].qtrYear.options[document.forms[0].qtrYear.selectedIndex].value == "")
		{
			alert("You must select a report period year.")
			document.forms[0].qtrYear.focus();
			return false;
		}			
						
			if (document.forms[0].compareReport.checked)
			{

				if (document.forms[0].searchType[0].checked)
					{
						if (document.forms[0].c_reportMonth.options[document.forms[0].c_reportMonth.selectedIndex].value == "")
						{
							alert("You must select a comparison month period.")
							document.forms[0].c_reportMonth.focus();
							return false;
						}
						
						if (document.forms[0].c_reportDay.options[document.forms[0].c_reportDay.selectedIndex].value == "")
						{
							alert("You must select a comparison day period.")
							document.forms[0].c_reportDay.focus();
							return false;
						}
					}
				else if (document.forms[0].searchType[1].checked)
					{
						if (document.forms[0].c_qtrRange.options[document.forms[0].c_qtrRange.selectedIndex].value == "")
						{
							alert("You must select a comparison report period quarter.")
							document.forms[0].c_qtrRange.focus();
							return false;
						}
					}
		
				if (document.forms[0].c_qtrYear.options[document.forms[0].c_qtrYear.selectedIndex].value == "")
				{
					alert("You must select a comparison report period year.")
					document.forms[0].c_qtrYear.focus();
					return false;
				}
			
				return true;
			}
			
		return true;
	}
	
function mustSelectGroup2()
	{
		
		if (document.forms[0].groupID.options[document.forms[0].groupID.selectedIndex].value == "") {
				alert("You must select a  group.")
				document.forms[0].groupID.focus();
				return false;
			}
		
		if (document.forms[0].searchType[0].checked)
			{
				if (document.forms[0].reportMonth.options[document.forms[0].reportMonth.selectedIndex].value == "")
				{
					alert("You must select a month period.")
					document.forms[0].reportMonth.focus();
					return false;
				}
				
				if (document.forms[0].reportDay.options[document.forms[0].reportDay.selectedIndex].value == "")
				{
					alert("You must select a day period.")
					document.forms[0].reportDay.focus();
					return false;
				}
			}
		else if (document.forms[0].searchType[1].checked)
			{
				if (document.forms[0].qtrRange.options[document.forms[0].qtrRange.selectedIndex].value == "")
				{
					alert("You must select a report period quarter.")
					document.forms[0].qtrRange.focus();
					return false;
				}
			}
		else
			{
				alert("You must select a report search type.")
				return false;
			}
			
		if (document.forms[0].qtrYear.options[document.forms[0].qtrYear.selectedIndex].value == "")
		{
			alert("You must select a report period year 2.")
			document.forms[0].qtrYear.focus();
			return false;
		}
		
		if (document.forms[0].c_qtrYear.options[document.forms[0].c_qtrYear.selectedIndex].value == "")
		{
			alert("You must select a report period year 1.")
			document.forms[0].qtrYear.focus();
			return false;
		}
				
		return true;
	}


function mustSelectGroup3()
	{
		
		if (document.forms[0].groupID.options[document.forms[0].groupID.selectedIndex].value == "") 
		{
				alert("You must select a major group.")
				document.forms[0].groupID.focus();
				return false;
			}
		if (document.forms[0].qtrYear2.options[document.forms[0].qtrYear2.selectedIndex].value == "")
		{
			alert("You must select a report period year 2.")
			document.forms[0].qtrYear2.focus();
			return false;
		}
		
		if (document.forms[0].qtrYear1.options[document.forms[0].qtrYear1.selectedIndex].value == "")
		{
			alert("You must select a report period year 1.")
			document.forms[0].qtrYear1.focus();
			return false;
		}
		if (document.forms[0].qtrWeek.options[document.forms[0].qtrWeek.selectedIndex].value == "") 
		{
				alert("You must select a week.")
				document.forms[0].qtrWeek.focus();
				return false;
			}
	
		return true;
	}


	

function logMustSelect() {
			
			if (document.forms[0].fromDate.value == "") {
				alert("You must select a valid from date.")
				return false;
			}
			if (document.forms[0].toDate.value == "") {
				alert("You must select a valid to date.")
				return false;
			}
			return true;
		}

function checkHierarchy() {

		if (document.forms[0].r_id.options[document.forms[0].r_id.selectedIndex].value == "")
		{
			alert("You must select a region.");
			document.forms[0].r_id.focus();
			return false;
		}
		
		if (document.forms[0].m_id.options[document.forms[0].m_id.selectedIndex].value == "")
		{
			alert("You must select a market.");
			document.forms[0].m_id.focus();
			return false;
		}
		
		if (document.forms[0].s_id.options[document.forms[0].s_id.selectedIndex].value == "")
		{
			alert("You must select a station.");
			document.forms[0].s_id.focus();
			return false;
		}
		
		return true;
	}

	function validateReport1Selection()
	{
		
		if (document.forms[0].groupID.options[document.forms[0].groupID.selectedIndex].value == "") {
				alert("You must select a group.")
				document.forms[0].groupID.focus();
				return false;
			}
		
		if (document.forms[0].searchType[0].checked)
			{
				if (document.forms[0].reportMonth1.options[document.forms[0].reportMonth1.selectedIndex].value == "")
				{
					alert("You must select a month period.")
					document.forms[0].reportMonth1.focus();
					return false;
				}
				
				if (document.forms[0].reportDay1.options[document.forms[0].reportDay1.selectedIndex].value == "")
				{
					alert("You must select a day period.")
					document.forms[0].reportDay1.focus();
					return false;
				}
			}
		else if (document.forms[0].searchType[1].checked)
			{
				if (document.forms[0].reportQtr1.options[document.forms[0].reportQtr1.selectedIndex].value == "")
				{
					alert("You must select a report period quarter.")
					document.forms[0].reportQtr1.focus();
					return false;
				}
			}
		else
			{
				alert("You must select a report search type.")
				return false;
			}
			
		if (document.forms[0].reportYear1.options[document.forms[0].reportYear1.selectedIndex].value == "")
		{
			alert("You must select a report period year.")
			document.forms[0].reportYear1.focus();
			return false;
		}			
						
			if (document.forms[0].reportCompare.checked)
			{

				if (document.forms[0].searchType[0].checked)
					{
						if (document.forms[0].reportMonth2.options[document.forms[0].reportMonth2.selectedIndex].value == "")
						{
							alert("You must select a comparison month period.")
							document.forms[0].reportMonth2.focus();
							return false;
						}
						
						if (document.forms[0].reportDay2.options[document.forms[0].reportDay2.selectedIndex].value == "")
						{
							alert("You must select a comparison day period.")
							document.forms[0].reportDay2.focus();
							return false;
						}
					}
				else if (document.forms[0].searchType[1].checked)
					{
						if (document.forms[0].reportQtr2.options[document.forms[0].reportQtr2.selectedIndex].value == "")
						{
							alert("You must select a comparison report period quarter.")
							document.forms[0].reportQtr2.focus();
							return false;
						}
					}
		
				if (document.forms[0].reportYear2.options[document.forms[0].reportYear2.selectedIndex].value == "")
				{
					alert("You must select a comparison report period year.")
					document.forms[0].reportYear2.focus();
					return false;
				}
			
				return true;
			}
			
		return true;
	}

	function validateReport4Selection()
	{
		
	if (document.forms[0].groupID.options[document.forms[0].groupID.selectedIndex].value == "")
		{
		alert("You must select a group.")
		document.forms[0].groupID.focus();
		return false;
		}
		
	if (document.forms[0].reportMonth1.options[document.forms[0].reportMonth1.selectedIndex].value == "")
		{
		alert("You must select a data entry month.")
		document.forms[0].reportMonth1.focus();
		return false;
		}
				
	if (document.forms[0].reportDay1.options[document.forms[0].reportDay1.selectedIndex].value == "")
		{
		alert("You must select a data entry day.")
		document.forms[0].reportDay1.focus();
		return false;
		}

	if (document.forms[0].reportYear1.options[document.forms[0].reportYear1.selectedIndex].value == "")
		{
		alert("You must select a data entry year.")
		document.forms[0].reportYear1.focus();
		return false;
		}			

	if (document.forms[0].reportQtr1.options[document.forms[0].reportQtr1.selectedIndex].value == "")
		{
		alert("You must select a report period quarter.")
		document.forms[0].reportQtr1.focus();
		return false;
		}
			
	if (document.forms[0].reportFirstYear1.options[document.forms[0].reportFirstYear1.selectedIndex].value == "")
		{
		alert("You must select a report period year.")
		document.forms[0].reportFirstYear1.focus();
		return false;
		}			
						
	if (document.forms[0].reportMonth2.options[document.forms[0].reportMonth2.selectedIndex].value == "")
		{
		alert("You must select a data entry month.")
		document.forms[0].reportMonth2.focus();
		return false;
		}
				
	if (document.forms[0].reportDay2.options[document.forms[0].reportDay2.selectedIndex].value == "")
		{
		alert("You must select a data entry day.")
		document.forms[0].reportDay2.focus();
		return false;
		}

	if (document.forms[0].reportYear2.options[document.forms[0].reportYear2.selectedIndex].value == "")
		{
		alert("You must select a data entry year.")
		document.forms[0].reportYear2.focus();
		return false;
		}			

	if (document.forms[0].reportQtr2.options[document.forms[0].reportQtr2.selectedIndex].value == "")
		{
		alert("You must select a report period quarter.")
		document.forms[0].reportQtr2.focus();
		return false;
		}
			
	if (document.forms[0].reportFirstYear2.options[document.forms[0].reportFirstYear2.selectedIndex].value == "")
		{
		alert("You must select a report period year.")
		document.forms[0].reportFirstYear2.focus();
		return false;
		}			
						
	
		return true;
	}

