// Show user a confirm dialog
function confirmDeletion(which,id,page,label,vars){
	var input_box=confirm("Are you sure you want to delete this "+label+"?");
	if (input_box==true){
		if(vars)
		 	window.location = page+"&d"+which+"="+id;
		else
			window.location = page+"?d"+which+"="+id;
	} else {
		//do nothing
	}
}

// Mask an email address
function maskEmail(user,site,message){
	document.write('<a href=\"mailto:'+ user + '@' + site + '\">'); 
	document.write(message+'</a>');
}

// Force a maximum length on a textarea or other input
function forceMaxLength(obj, maxlength){
	if (obj.value.length > maxlength)
		obj.value = obj.value.substring(0,maxlength)
}

// This functions like 'placeholder'
function checkInput(obj, value, fontColor){
	if(fontColor==undefined) fontColor = '#000000';
	if(obj.value == ""){
		obj.value = value;
		obj.style.color = '#999999';
	} else if(obj.value == value){
		obj.value = "";
		obj.style.color = fontColor;
	}
}

// Regex to wrap a URL with an <a> tag
function replaceURLWithHTMLLinks(text){
	var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
	return text.replace(exp,"<a href='$1' target='_blank'>$1</a>"); 
}



