﻿// JScript File

function shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
}
function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function bookmarkMe(myUrl, myTitle)
{
        if(window.sidebar)
        {
               //******************************//
               // Firefox is used
               // We can just prompt the user
               // to add a regular bookmark...
                //******************************//

               alert('Please press CTRL+D to bookmark this page!');

               //******************************//
               // ... or we can add a 'sidebar' bookmark.
               // To do it, use the line below,
               // instead of the line above:
               //******************************//

               // window.sidebar.addPanel(myTitle, myUrl, '');

               //******************************//
               // In the second case, you can
               // give the visitor additional information.
               // to do it, uncomment the lines below
               //******************************//

               // var msg = "Firefox has just added the bookmark ";
               // msg += "that will open in the sidebar by default.\n";
               // msg += "If you want it to open in the main window instead, ";
               // msg += "please go to Bookmarks, right-click the recently ";
               // msg += "added bookmark, choose 'Properties' and uncheck the ";
               // msg += "'load this bookmark in the sidebar' option.\n\n";
               // msg += "Sorry, this in unavoidable with Firefox so far.";
               // alert(msg);
        }
        else if(window.opera && window.print)
        {
               //******************************//
               // Opera is used
               //******************************//

               var bkmark = document.createElement('a');
               bkmark.setAttribute('rel','sidebar');
               bkmark.setAttribute('href', myUrl);
               bkmark.setAttribute('title', myTitle);
               bkmark.click();
        }
        else if(document.all)
        {
               //******************************//
               // Most probably IE, but even if it's not,
               // we don't want an error to pop up
               // so we use the try-catch structure
               //******************************//

               try
               {
                       window.external.AddFavorite(myUrl, myTitle);
               }
               catch(e)
               {
                       //******************************//
                       // oops! not IE. Prompt user for action.
                       //******************************//

                       var msg = "Sorry, your browser doesn't allow scripts ";
                       msg += "to add bookmarks.\n";
                       msg += "Please use your browser's keyboard shortcut ";
                       msg += "(most commonly CTRL+D) to add a bookmark.";
                       alert(msg);
               }
        }
}
