function javascriptConfirmDelete(urltosendontoifyes)
// used to confirm a delete action - the user gets a prompt and they can click 'cancel' to stop the deletion from happening
{
	if (confirm("Are you sure you want to delete this?"))
	// they are sure - forward the user on to the delete URL
		document.location = urltosendontoifyes;
}

//////////////////////////

function JavascriptDropDownDiv(divid)
// slide down the div with this id
{
	if ($("#"+divid).is(":hidden"))
		$("#"+divid).slideDown("slow");
	
	else 
		$("#"+divid).slideUp("slow");
}

//////////////////////////

function javascriptSetSelectedTabStandard()
// used in the create campaign wizard, the value of selectedtab is either 'standard' or 'advanced'
{
	document.getElementById('theselectedtab').value = 'standard';
	// set the value of a hidden form input that the "process" page can get the value of to know which set of values
	// to use - the "standard" or the "advanced" ones, if the same input can be entered into either
}

function javascriptSetSelectedTabAdvanced()
// used in the create campaign wizard, the value of selectedtab is either 'standard' or 'advanced'
{
	document.getElementById('theselectedtab').value = 'advanced';
	// set the value of a hidden form input that the "process" page can get the value of to know which set of values
	// to use - the "standard" or the "advanced" ones, if the same input can be entered into either
}

//////////////////////////

function javascriptUpdateInputField(inputfieldid,outputfieldid)
// copies the contents of the "input" field (the one being changed) to the "output" field (the mirror copy)
// so that when switch tabs don't lose all of the existing input if the same field is in both the standard and advanced
// tab sections. This happens "onkeyup", so updates after each key press
{
	var valuetocopyacross = document.getElementById(inputfieldid).value;
	// the "input" value
	
	document.getElementById(outputfieldid).value = valuetocopyacross;
	// simply copy the value across into the new field
}

function javascriptUpdateSelect(inputfieldid,outputfieldid)
// copies the value selected in the "input" select menu to the "output" select menu
{
	var valuetocopyacross = document.getElementById(inputfieldid).selectedIndex;
	// the "input" value
	
	document.getElementById(outputfieldid).selectedIndex = valuetocopyacross;
	// simply copy the value across into the new field to select it. NOTE have to add 1 to the index since the
	// index value starts at 0, not 1
}

function javascriptToggleDivDisplay(divid)
{
	var currentstate = document.getElementById(divid).style.display;
	
	if (currentstate == 'block')
		document.getElementById(divid).style.display = 'none';
	
	else
		document.getElementById(divid).style.display = 'block';
}

////////////////////////////////////

// on stage 9 of the wizard ...
function javascriptSendMyselfACopyOfEmailFromStage9(inputidholdingaddresstosendto,dividtoshowresponsein)
{
	var addresstosendto = document.getElementById(inputidholdingaddresstosendto).value;
	
	$(dividtoshowresponsein).load("sendacopyoftheemail_fromstage9.php?emailaddresstosendcopyto="+addresstosendto);
}

/////////////////////////////////////

$(document).ready(function(){
	// jQuery rollover effect ...
	$(".change_opacity_on_hover").hover(function(){
		$(this).fadeTo("fast", 0.75);
		// set the opacity to 75% on hover
		},function(){
		$(this).fadeTo("fast", 1.0);
		// set the opacity back to 100% (normal) when take mouse away
	});
})

////////////////////////////////////////

function JavascriptToggleFieldActive(field_id)
// toggles this form field between enabled and disabled
{
	if (document.getElementById(field_id).disabled == false)
		document.getElementById(field_id).disabled = true;
	
	else
		document.getElementById(field_id).disabled = false;
}

