
function confirmDelete(param) {
	var user_input = confirm("Are you sure you want to DELETE " + param + " ?");
	return user_input;
}

function confirmDelete_Address(obj, param) {
	if (confirmDelete(param)) {
		//alert(obj.form);
		obj.form.submit();
	}
}

function confirmActiveChange(element, param) {
	if (element.checked) {
		var user_input = confirm("Are you sure you want to mark " + param + " ACTIVE?");
		if ( ! user_input) {
			element.checked = false;
		}
	} else {
		var user_input = confirm("Are you sure you want to mark " + param + " INACTIVE?");
		if ( ! user_input) {
			element.checked = true;
		}
	}
}

function confirmDeactivate(param) {
	var user_input = confirm("Are you sure you want to mark " + param + " INACTIVE?");
	return user_input;
}

function confirmReactivate(param) {
	var user_input = confirm("Are you sure you want to mark " + param + " ACTIVE?");
	return user_input;
}

function confirmSendRecurringTestMessage(element, index, subject) {
	var the_form = element.form;
	var text_field_name = 'test_address[' + index + ']'; 
	if (the_form.elements[text_field_name].value == '') {
		alert('You did not enter an email address to receive the test message');
	} else if ( confirm('Are you sure you want to send a test email for "' + subject + '"?') ) {
		the_form.task.value = 'send_recurring_test';
		the_form.test_index.value = index;
		the_form.submit();
	}
}

function submitMLform(p_task) {
	var the_form = document.forms['the_form'];
	the_form.task.value = p_task; 
	the_form.submit();
}

function toggleCheckbox(element) {
	var theForm = element.form, z = 0;
	for(z=0; z<theForm.length; z++) {
		if (theForm[z].type == 'checkbox' && theForm[z].name != 'selectall1' && theForm[z].name != 'selectall2') {
			if (theForm[z].checked) {
				theForm[z].checked = false;
			} else {
				theForm[z].checked = true;
			}
		}
	}
}

/*======================================================
//	BEGIN NAV TOOGLE CODE
======================================================*/
function initMainMenu(){
	var limit = sub_menu_ids.length;
	for(var x=0; x<limit; x++){
		var index_str = sub_menu_ids[x];
		sub_menu_nodes[index_str] = document.getElementById( sub_menu_ids[x] );
		sub_menu_nodes[index_str].style.display = 'none';
		
	}	
}

function toggleNav(ulID){
	if(sub_menu_nodes[ulID].style.display == 'none'){
		sub_menu_nodes[ulID].style.display = 'block';
	} else {
		sub_menu_nodes[ulID].style.display = 'none';	
	}
	//var ul_node = document.getElementById(ulID);
	//alert(ul_node);
	//alert(sub_menu_nodes[ulID].style.display);
}

/*======================================================
//	END NAV TOOGLE CODE
======================================================*/

function changeRecurringTimimg(timimg_menu, day_id) {
	var day_node = document.getElementById(day_id);
	
	//alert(timimg_menu.value);
	// if the timing selected is "on"
	if (timimg_menu.value == 1) {
		//alert('hide days');
		day_node.style.visibility = 'hidden';
		day_node.selectedIndex = 0;
	} else {
		day_node.style.visibility = 'visible';
	}
}