// $History: Library.js $
// 
// *****************  Version 3  *****************
// User: Ultraman     Date: 3/25/00    Time: 2:37p
// Updated in $/Web/coccc
// - Added scrolling functions to Library.js
// 
// *****************  Version 2  *****************
// User: Ultraman     Date: 3/25/00    Time: 2:33p
// Updated in $/Web/coccc
// - Added Library.js and common.css
// 
// *****************  Version 1  *****************
// User: Ultraman     Date: 3/25/00    Time: 2:23p
// Created in $/Web/coccc

function openFullScreen(strURL)
{
    //Check browser 
    var isNav = (navigator.appName == "Netscape") ? 1 : 0;
    var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;

    //Check Platform 
    var isMac = (navigator.platform.indexOf("Mac") > -1) ? 1 : 0;
    var isWin = (navigator.platform.indexOf("Win") > -1) ? 1 : 0;

    //Set global window options 
    var opts = "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,copyhistory=no,menubar=no"

    //Set platform and browser specific options 
    if (isNav) {
        //Navigator windows have outerWidth and outerHeight properties 
        //use these to set window size to the available screen height and width 
        opts = opts + ",outerWidth=" + screen.availWidth + ",outerHeight=" + screen.availHeight + ",screenX=0,screenY=0";
    }
    else if (isIE) {
        //IE has a "full-screen" option which can be used by placing "fullscreen=yes" here 
        opts = opts + ",left=0,top=0";

        //To size the window (rather than open in fullscreen mode) we need to know the padding 
        //i.e. the space taken by the title bar and window edges. These values are subtracted 
        //from the available screen width and height (different for Macs). If the new window 
        //is opened with toolbars, status bar, etc. the values here should be changed to 
        //compensate for the new features. 
        if (isMac) {
            //this uses a value of 13 for the extra width and 32 for the extra height 
            opts = opts + ",width=" + (screen.availWidth - 13) + ",height=" + (screen.availHeight - 32);
        }
        else if (isWin) {
            //this uses a value of 12 for the extra width and 25 for the extra height 
            opts = opts + ",width=" + (screen.availWidth - 12) + ",height=" + (screen.availHeight - 25);
        }
        else {
            opts = opts + ",width=" + screen.availWidth + ",height=" + screen.availHeight;
        }
    }
    else {
        return;
    }

    //Open a new window 
    var newWin = window.open(strURL, "newwindow", opts);
    newWin.focus();
    //Move to 0,0 (javascript 1.2) 
    if (parseInt(navigator.appVersion) >= 4) {
        newWin.moveTo(0, 0);
    }
}

function showLink(strURL, strTitle, strImage)
{
    document.write("<img width='18' height='18' border='0' SRC='images/" + strImage + "'> ");
    document.write("<a href='" + strURL + "' target='_blank' onMouseOver=\"window.status='" + strTitle + "';return true\"");
    document.write("onMouseOut=\"window.status='';return true\">" + strTitle + "</a>");
}

function showWWWLink(strURL, strTitle)
{
    var strImage = "globe.png";
    showLink(strURL, strTitle, strImage);
}

function showImageLink(strURL, strTitle)
{
    var strImage = "photo_icon.png";
    showLink(strURL, strTitle, strImage);
}

function showPDFLink(strURL, strTitle)
{
    var strImage = "pdf.gif";
    showLink(strURL, strTitle, strImage);
}

function showDOCLink(strURL, strTitle)
{
    var strImage = "worddoc.png";
    showLink(strURL, strTitle, strImage);
}

function showXLSLink(strURL, strTitle)
{
    var strImage = "xls.gif";
    showLink(strURL, strTitle, strImage);
}

function showNewsletterQuickButton(strURL, strTitle, blnNewDoc)
{
    if (blnNewDoc) {
        document.write("<img width='19' height='18' border='0' SRC='images/newdoc.gif' alt='New' text='New'> ");
    } else {
        document.write("<img width='19' height='18' border='0' SRC='images/doc.gif'> ");
    }
    document.write("<a href='" + strURL + "' target='_blank' onMouseOver=\"window.status='" + strTitle + "';return true\"");
    document.write("onMouseOut=\"window.status='';return true\">");
    document.write(strTitle + "</a>");
}

function postMemberName(strName, strEmail, strTitle)
{
    document.write("<tr><td class='box' width='500'>");
    document.write("<b>&nbsp;" + strTitle + "</b></td>");
    document.write("<td class='box'>&nbsp;" + strName + "</td>");
//    document.write("<td class='box'>&nbsp;");
//    showHyperlinkName(strEmail, strEmail);
    document.write("</td></tr>");
}

function postMemberNameScrolling(strName, strEmail, strTitle)
{
    document.write("<tr><td class='box'>");
    document.write("<b>&nbsp;" + strTitle + "</b></td>");
    document.write("<td class='box'>&nbsp;" + strName + "</td>");
    document.write("<td class='box'>&nbsp;");
    showHyperlinkNameScrolling(strEmail, strEmail);
    document.write("</td></tr>");
}

function showHyperlinkName(strName, strEmail)
{
    if (strEmail.length > 0) {
        document.write("<img border='0' width='18' height='13' src='images/email18x13.gif'>&nbsp;<a href='mailto:" + strEmail + "?subject=COCCC General Inquiries' title='Send E-mail to " + strName + "' onMouseOver=\"window.status='Send E-mail to "
        + strName + "';return true\" onMouseOut=\"window.status='';return true\">");
    }
    document.write(strName);
    if (strEmail.length > 0) {
        document.write("</a>");
    }
}

function showHyperlinkNameScrolling(strName, strEmail)
{
    if (strEmail.length > 0) {
        document.write("<img border='0' width='18' height='13' src='images/email18x13.gif'>&nbsp;<a href='mailto:" + strEmail + "?subject=Comments for COCCC Website' title='Send E-mail to " + strName + "' onMouseOver=\"startScrolling();return true\"");
        document.write("onMouseOut=\"stopScrolling();window.status='';return true\">");
    }
    document.write(strName);
    if (strEmail.length > 0) {
        document.write("</a>");
    }
}

function showLastModified()
{
    mod_date = new Date(document.lastModified);
    which_month = mod_date.getMonth();                // returns 0 thru 11
    which_date = mod_date.getDate();                 // returns 1 thru 31
    which_year = mod_date.getYear();                 // returns 2 digit year if < 2000
    which_month++;
    if (which_month < 10) {
        which_month = "0" + which_month
    }

    if (which_date < 10) {
        which_date = "0" + which_date
    }

    if (which_year < 1000) {
        which_year += 2000;                            // ensure 4 digit year
    }

    last_mod = which_month + "/" + which_date + "/" + which_year

    //   document.write("<h6>Last revision: " + last_mod + "</h6>");
}

var posMsg = 1;
var ID1_scrollOut = 0;
var ID1_scrollIn = 0;
var ID2_scrollOut = 0;
var ID2_scrollIn = 0;
var Message = "Send your comments regarding this website to Jack Lee";

function startScrolling()
{
    posMsg = 1;
    scrollIn();
}

function stopScrolling()
{
    if (ID1_scrollOut) {
        clearTimeout(ID1_scrollOut);
    }

    if (ID1_scrollIn) {
        clearTimeout(ID1_scrollIn);
    }

    if (ID2_scrollOut) {
        clearTimeout(ID2_scrollOut);
    }

    if (ID2_scrollIn) {
        clearTimeout(ID2_scrollIn);
    }
}

function scrollIn()
{
    window.status = Message.substring(0, posMsg);
    if (posMsg >= Message.length) {
        posMsg = 1;
        ID1_scrollOut = window.setTimeout("scrollOut()", 2000);
    }
    else {
        posMsg++;
        ID1_scrollIn = window.setTimeout("scrollIn()", 50);
    }
}

function scrollOut()
{
    window.status = Message.substring(posMsg, Message.length);
    if (posMsg >= Message.length) {
        posMsg = 1;
        ID2_scrollIn = window.setTimeout("scrollIn()", 100);
    }
    else {
        posMsg++;
        ID2_scrollOut = window.setTimeout("scrollOut()", 50);
    }
}

