function tag_url()
{
    var FoundErrors = '';
    var enterURL   = prompt("Enter the complete link of the url", "http://");
    var enterTITLE = prompt("Enter the title of the webpage", "Name of web page");
    if (!enterURL)
    {
        FoundErrors += " " + error_no_url;
    }
    if (!enterTITLE)
    {
        FoundErrors += " " + error_no_title;
    }
    if (FoundErrors)
    {
        alert("Error!"+FoundErrors);
        return;
    }
    var ToAdd = "<a href="+enterURL+" target=_blank class=main>"+enterTITLE+"</a>";
    document.picker.contents.value+=ToAdd;
	document.picker.contents.focus();
}
function tag_email()
{
    var emailAddress = prompt("Enter the email address","");
	 var enterName= prompt("Enter the name of contact", "Name of contact");
    if (!emailAddress) { alert(error_no_email); return; }
    var ToAdd = "<a href=mailto:"+emailAddress+">"+enterName+"</a>";
    document.picker.contents.value+=ToAdd;
	document.picker.contents.focus();
}
function addHTMLtoText(sTag) {
    seltext = (document.all)? document.selection.createRange() : document.getSelection();
    var selit = (document.all)? document.selection.createRange().text : document.getSelection();
    if (selit.length > 0){
         if (seltext) {
              switch (sTag) {
                   case 'B': case 'I': case 'U' :
                        seltext.text = simpleFormat(selit, sTag);
                   break;
                   case 'OL': case 'UL': 
                        seltext.text = listFormat(selit, sTag);
                   break;
                   case 'LEFT': case 'CENTER': case 'RIGHT':
                        seltext.text = paragraphFormat(selit, sTag);
                   break;
              }
              window.focus()
         }
    }
}

function simpleFormat(sText, sTag) {
    return '<' + sTag + '>' + sText + '</' + sTag + '>';
}

function listFormat(sText, sTag) {
    var selit = '';
    var listItems = sText.split('\r\n');
    for (i = 0; i < listItems.length; i++) {
         selit += '<LI>' + listItems[i] + '</LI>\n';
    }
    return '<' + sTag + '>\n' + selit + '</' + sTag + '>';
}

function paragraphFormat(sText, sTag) {
    return '<P align="' + sTag + '">' + sText + '</P>'
}

function DoDelete(dL)
{
	if(confirm ("Are you sure you want to delete this item?"))
	{
		window.location=dL;	
	}

	
}
