
function changepic( idname, type )
{
    pagelink = "../dyno/mediapopup.html?MediaType=" + type
        + "&type=" + idname;
    winstatus=window.open(pagelink,"Select Picture","scrollbars,width=500,height=300,resizable",false);
}

function clearpic() 
{
    document.inputform.MainPicture.value = "";
    document.inputform.ThePicture.value = "";
}

function makegenerallink() {

    // ask for a link address
    linkaddress = prompt("Enter the address of the page you want to link.","http://");
    if ( linkaddress === null ) {
        return;
    }
    // ask for a link page name
    linkpagename = prompt("Enter the name of the page you are linking.\n "+
               "Example: if you are linking to http://www.google.com/ "+
               "you might use the name 'Search Engine'", "");
    // or just use LINK DESCRIPTION if they dont specify
    if ( linkpagename === null ) {
        linkpagename = 'LINK DESCRIPTION';
    }

    // ask what color, green or orange
    linkcolor = prompt("What color should the link be?\n"+
		       "(valid colors are 'green' or 'orange')","orange");

    thelinktoinsert = '<a href="'
                    + linkaddress + '"'
                    + ' class="' + linkcolor + '"'
                    + '>' 
		    + linkpagename
                    + '</a>';

    window.document.maineditform.sometext.value =
         window.document.maineditform.sometext.value + " " + thelinktoinsert;

}

function mediapopup( thelink ) {
    winstatus=window.open(thelink,"","resizable,width=150,height=150");
}


//
//  Safe way to get the object.  
//  Most browsers will usually work with the first one
//
function getElement( id ) {
    if (document.getElementById) {
        return (document.getElementById(id));
    } else if (document.all) {
        return (document.all[id]);
    } else {
        alert (" Unable to add text: Message-001 ");
    }
}

//
// add the given textToAdd to the textarea specified by "id"
//
function perform_update()
{
    document.topicform.little_update.value = 'Y';
    document.topicform.submit();
}

//
// add the given textToAdd to the textarea specified by "id"
//
function dynoInsert(id, textToAdd )
{
    // get the current textarea
    theTextArea = getElement( id );

    tagStart = "";
    tagEnd = "";
    fontSelect = getElement( "messageFont" );
    fontClass = fontSelect.value;
    if (fontClass == "quickbold") {
        tagStart = '<b>';
        tagEnd = '</b>';
    } else if (fontClass == "quickitalic") {
        tagStart = '<i>';
        tagEnd = '</i>';
    } else if (fontClass == "superscript") {
        tagStart = '<sup>';
        tagEnd = '</sup>';
    } else if (fontClass == "verysmall") {
        tagStart = '<font size="-3">';
        tagEnd = '</font>';
    } else if ( (fontClass != "") && (fontClass != "plain") ) {
        tagEnd = '</span>';
        tagStart = '<span class="' + fontClass + '">';
    }

    theTextArea.value = theTextArea.value + ' ' 
                           + tagStart + textToAdd + tagEnd;
}


//
//  dynamic way to add "special" text to a textarea
//  (the textarea is specified by "id")
//
function dynoText( id, boxId ) {
    // Get the text from the little text box
    textToAdd = getElement( boxId );
    // check if empty
    if ( textToAdd.value == "" )
    {
	errorMessage = "You must specify what text to add";
	alert(errorMessage);
	textToAdd.focus();
    }
    else
    {
        //alert( "you would add [" + textToAdd.value + "] to textarea " + id );
        dynoInsert( id, textToAdd.value );
    }
}

//
// if we want to delete a topic 
//
function delete_topic( topicnumber, topicname ) {
    if ( confirm( "Are you sure you want to delete:\n    " + 
	topicname + " (topic #" + topicnumber + ") ?" )   ) {
        document.topicform.topictodelete.value = topicnumber;
        document.topicform.submit();
    } else {
        alert (" Topic was not deleted ");
    }
}

function popupstarter( tipnumber )
{
    thelink = "./conversationstarter.html?tip=" + tipnumber;
    winstatus=window.open(thelink,"","scrollbars,resizable,width=448,height=300");
}

function popuptip( tipnumber, topic )
{
    thelink = "../tips.html?tip=" + tipnumber + "&topic=" + topic;
    winstatus=window.open(thelink,"","scrollbars,resizable,width=448,height=300");
}

function popupvideo( videofile )
{
    thelink = "/issues/video.html?vid=" + videofile;
    winstatus=window.open(thelink,"","resizable,width=350,height=300");
}

function popuptranscript( transcriptfile )
{
    thelink = "/issues/transcript.html?transcript=" + transcriptfile;
    winstatus=window.open(thelink,"","scrollbars,resizable,width=350,height=300");
}

//
// if we want to delete a tip 
//
function delete_tip( tipnumber, tipname ) {
    if ( confirm( "Are you sure you want to delete:\n    " + 
	tipname + " (tip #" + tipnumber + ") ?" )   ) {
        document.tipform.tiptodelete.value = tipnumber;
        document.tipform.submit();
    } else {
        alert (" Tip was not deleted ");
    }
}

//
// if we want to delete an additional content 
//
function delete_content( contentnumber, contentname ) {
    //alert ( contentnumber );
    //alert ( contentname  );
    if ( confirm( "Are you sure you want to delete:\n    " + 
	contentname + " (content #" + contentnumber + ") ?" )   ) {
        document.addcontentform.contenttodelete.value = contentnumber;
        document.addcontentform.submit();
    } else {
        alert (" Additional content was not deleted ");
    }
}

//
// if we want to delete a news item
//
function delete_news( newsnumber, newsname ) {
    //alert ( newsnumber );
    //alert ( newsname  );
    if ( confirm( "Are you sure you want to delete:\n    " + 
	newsname + " (news #" + newsnumber + ") ?" )   ) {
        document.newseditform.newstodelete.value = newsnumber;
        document.newseditform.submit();
    } else {
        alert (" Additional news was not deleted ");
    }
}



//
// if we want to delete a multimedia item
//
function delete_media( medianumber, mediadescription ) {
    //alert ( medianumber );
    //alert ( mediadescription  );
    if ( confirm( "Are you sure you want to delete:\n    " + 
	mediadescription + " (media #" + medianumber + ") ?" )   ) {
        document.mediaform.mediatodelete.value = medianumber;
        document.mediaform.submit();
    } else {
        alert (" Specified Multimeda was not deleted ");
    }
}

//
// 
//
function order_changed()
{
    document.topicform.order_update.value = 'true';
}

function setClass(whattext,whatstyle)
{
    var littletextstyle = getElement( whattext ).style;
    if (('bodybold'==whatstyle)||('quickbold'==whatstyle)) {
        littletextstyle.fontWeight = 'bold';
        littletextstyle.fontStyle = 'normal';
        littletextstyle.fontSize = '12';
    } else if ('bodybolditalic'==whatstyle) {
        littletextstyle.fontWeight = 'bold';
        littletextstyle.fontStyle = 'italic';
        littletextstyle.fontSize = '12';
    } else if (('bodyitalic'==whatstyle)||('quickitalic'==whatstyle)) {
        littletextstyle.fontWeight = 'normal';
        littletextstyle.fontStyle = 'italic';
        littletextstyle.fontSize = '12';
    } else if ('headline'==whatstyle) {
        littletextstyle.fontWeight = 'normal';
        littletextstyle.fontStyle = 'normal';
        littletextstyle.fontSize = '14';
    } else if ('headlinebold'==whatstyle) {
        littletextstyle.fontWeight = 'bold';
        littletextstyle.fontStyle = 'normal';
        littletextstyle.fontSize = '14';
    } else if ('plain'==whatstyle) {
        littletextstyle.fontWeight = 'normal';
        littletextstyle.fontStyle = 'normal';
        littletextstyle.fontSize = '12';
    } else if ('superscript'==whatstyle) {
        littletextstyle.fontWeight = 'normal';
        littletextstyle.fontStyle = 'normal';
        littletextstyle.fontSize = '10';
    } else if ('verysmall'==whatstyle) {
        littletextstyle.fontWeight = 'normal';
        littletextstyle.fontStyle = 'normal';
        littletextstyle.fontSize = '9';
    }
}



