/* This first part is a conditional server check */

// Get the host name
var host = window.location.host;
// Get the path name
var path = window.location.pathname;


// Get the index of the string "blue"
// We're checking to see if we're on
// the test server or live server
var index = host.indexOf("blue");

if (index != -1) {
 // If the index is not -1, we're on blue-iceberg server
 var thisdir = 'http://' + window.location.host + '/yale80/public_html/';
} else {
 // If not, we're on the live server
 var thisdir = 'http://' + window.location.host + '/';
}


// This is a constant
var thisurl = 'http://' + window.location.host + window.location.pathname;




/* This function confirms that the user wants to delete an article */

function confirmDelete(type,id,title)
{

 var response = confirm('Are you sure you want to DELETE ' + title + '?');
 
 //var delurl = thisdir + page +'?action=delete&id=' + id;
 var delurl = thisurl + '?action=delete&type=' + type + '&id=' + id;
 
 if (response == true)
 {
  //For Debugging:
  //alert(delurl);
  window.location.href = delurl;
 }
 
} // Close Function


function styleText(style,formname,fieldname) {

    if (document.selection && document.selection.createRange) {
     
        // the Internet Explorer 4.0x code
        var str = document.selection.createRange().text;
        
        if (document.selection.createRange().parentElement().tagName != 'TEXTAREA') {
            return false;
        }
        
        if (str=='' || !str) alert('Please, select some text first!');
  
        if (style=="heading") {
            document.selection.createRange().text = "[h]" + str + "[/h]";
        } else if (style=="bold") {
            document.selection.createRange().text = "[b]" + str + "[/b]";
        } else if (style=="italic") {
            document.selection.createRange().text = "[i]" + str + "[/i]";
        } else if (style=="link") {
            document.selection.createRange().text = "[link=http://EnterWebsiteURLHere]" + str + "[/link]";
        } else if (style=="email") {
            document.selection.createRange().text = "[email=EnterEmailAddressHere]" + str + "[/email]";
        }
  
    } else {
        alert("Sorry, this function does not work on your browser.\nPlease use Internet Explorer on Windows");
    
/*
        if (style=="heading") {
            str = "[h]Enter Heading Here[/h]";
        } else if (style=="bold") {
            str = "[b]Enter Bold Text Here[/b]";
        } else if (style=="italic") {
            str = "[i]Enter Italic Text Here[/i]";
        } else if (style=="link") {
            str = "[link=http://EnterWebsiteURLHere]Enter Website Label Here[/link]";
        } else if (style=="email") {
            str = "[email=EnterEmailAddressHere]Enter Email Label Here[/link]";
        }
        
        var isForm=document.forms[formname];
        if (isForm) {
            var input=document.forms[formname].elements[fieldname];
            input.value=input.value+str;
        }
*/
    }

}