﻿// Standard Blue Diesel library of javascript functions
// version: 1.0
// date: 08-12-2008

// function to print a web page
// example: <a href=javascript:printpage()>Print this page</a>
function printpage() {
    window.print();
}

// function to add page as a favorite
// example: <a href=javascript:addfav(url,title)>Add to favorites</a>
function addfavold(url,title) {
	if (window.sidebar) { // Mozilla Firefox Bookmark		
	    window.sidebar.addPanel(title, url,"");	
	} else if( window.external ) { // IE Favorite		
	        window.external.AddFavorite( url, title); 
	    } else if(window.opera && window.print) { // Opera Hotlist
		    return true; 
	    }
	}

// function to add page as a favorite
// example: <a href=javascript:addfav(url,title)>Add to favorites</a>
function addfav(url, title) {
    var ua=navigator.userAgent.toLowerCase();
    var isKonq=(ua.indexOf('konqueror')!=-1);
    var isSafari=(ua.indexOf('webkit')!=-1);
    var isMac=(ua.indexOf('mac')!=-1);
    var buttonStr=isMac?'Command/Cmd':'CTRL';

    if(window.external && (!document.createTextNode ||
      (typeof(window.external.AddFavorite)=='unknown'))) {
        // IE4/Win generates an error when you
        // execute "typeof(window.external.AddFavorite)"
        // In IE7 the page must be from a web server, not directly from a local 
        // file system, otherwise, you will get a permission denied error.
        window.external.AddFavorite(url, title); // IE/Win
    } else if(isKonq) {
      alert('You need to press CTRL + B to bookmark our site.');
    } else if(window.opera) {
      void(0); // do nothing here (Opera 7+)
    } else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab
      alert('You need to press '+buttonStr+' + D to bookmark our site.');
    } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0
      alert('You need to press Command/Cmd + D to bookmark our site.');    
    } else {
      alert('In order to bookmark this site you need to do so manually '+
        'through your browser.');
    }

}
// function to add page to digg
// example: <a href=javascript:adddigg(url)>Digg this</a>
function adddigg(url) {
    location.href='http://digg.com/submit?url=' + encodeURIComponent(url) ;
}

// function to email a page link
// example: <a href=javascript:sentto(subject,url)>Email this page</a>
function sendto(subject,url) {

}