function changeEditState(ping, state) {
	$('edit_ping_' + ping).style.backgroundImage = 'url(../images/edit_state_' + state + '.gif)';
}

function checkLinkForm(element) {
	if (element.value == "custom") {
		$('custom_link').update('<label for="custom_link">Custom Link</label><br/><input id="ping_email" name="custom_link" size="30" type="text" />');
	} else {
		$('custom_link').update('');
	}
}

function RemovePingBatch(pings) {
	var i = 0;
	while(pings[i]) {
		if ($('remove_ping_' + pings[i]).checked) {
			DeletePing(pings[i], i);
			pings[i] = false;
		}
		i++;
	}
}

function DeletePing(pID){
		new Ajax.Request('/ping/destroy/' + pID, {
			asynchronous:true, 
			evalScripts:true,
			onSuccess:function(request){
				new Effect.Fade('ping_' + pID);
			},
			 onFailure: function(transport){ 
				/*alert("Network error: could not establish a connection. Please try again."); */
			}			
		}); 
	return false;
}

function toggle_select_all(toggle_box) {
	var check = $(toggle_box).checked
	var i = 0;
	$$('input').each( function(the_input) {
		if ($(the_input).type == "checkbox") {
			$(the_input).checked = check;
			if (i != 0) {
				if (check) {
					$(the_input).parentNode.parentNode.style.backgroundColor = "#ffffcc";
				} else {
					$(the_input).parentNode.parentNode.style.backgroundColor = "#fff";
				}
			}
			i++;
		}
	});
}

function highlight_row(row_id) {
	if ($('remove_ping_' + row_id).checked) {
		$('ping_' + row_id).style.backgroundColor = "#ffffcc";
	} else {
		$('ping_' + row_id).style.backgroundColor = "#fff";
	}
}