

function addContent(text, form, element) {
	var content = document.forms[form][element].value;
	var temp    = content +''+ text;

	document.forms[form][element].value = temp;
}




function addHref(form, element, displayValue, defaultValue) {
	var linkURL  = prompt('Enter the '+ displayValue +' in full', defaultValue);
	var linkText = prompt('Enter the name of the link [this is how it will appear on the page]');

	var target   = '';

	if ( displayValue == 'URL' ) {
		var check = confirm('Should this open in a new window?');
		if ( check == true ) {
			target = ' target="new"';
		}
	}

	var linkCode = '<a href="'+linkURL+'"'+ target +'>'+linkText+'</a>';

	addContent(linkCode, form, element)
}




function addEmail(form, element) {
	addHref(form, element, 'email address', 'mailto:')
}


function addURL(form, element) {
	addHref(form, element, 'URL', 'http://')
}



function addList(form, element){
	alert("After you click OK, you will be presented with a prompt, add list items by entering text then clicking OK, when you do not wish to add any more, click cancel");
	listitem = null;
	listcontent="";
	do{

		if(listitem != null && listitem!=""){
			listcontent+="\t<li>"+listitem+"</li>\n";
		}
		listitem = prompt("Enter another Item:");

	} while(listitem != "" && listitem != null);	
	
	return listcontent;

}

function addOrderedList(form, element){

	listContent = addList(form, element);
	if(listContent!=false){
		fullListContent = "<ol>\n"+listContent+"</ol>\n";
		addContent(fullListContent, form, element);
	}

}

function addUnorderedList(form, element){

	listContent = addList(form, element);
	if(listContent!=false){
		fullListContent = "<ul>\n"+listContent+"</ul>\n";
		addContent(fullListContent, form, element);
	}

}

function addBold(form,element){
	
	content = prompt("Enter the text to be made Bold");
	if(content != null){
		addContent("<b>"+content+"</b>", form, element);
	}

}


function addItalic(form,element){
		
	content = prompt("Enter the text to be Italicised");
	if(content != null){
		addContent("<i>"+content+"</i>", form, element);
	}

}


function addUnderline(form,element){
	
	content = prompt("Enter the text to be Underlined");
	if(content != null){
		addContent("<u>"+content+"</u>", form, element);
	}

}

function confirmDelete(url, name) {
	var check = confirm('Are you sure you want to delete ['+ name +']?');
	if (check == true) {
		this.location = url;
	}
}

function addMiniText(text,fielditem){
    var currtext=document.forms['addForm'][fielditem].value;
    var newtest=currtext+""+text;
    document.forms['addForm'][fielditem].value=newtest;
}
