/*
 * jqBookmark - a jquery Bookmark script
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt.
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to calisza@gmail.com so we can send you a copy immediately.
 *

$(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){
			$("a.jqbookmark").attr("rel","sidebar");
		} 
	}

	$("a.jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.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) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}
	
	});
});
 */
ATBookmarkApp = function () {
	var isIEmac = false; /*@cc_on @if(@_jscript&&!(@_win32||@_win16)&& (@_jscript_version<5.5)) isIEmac=true; @end @*/
	var isMSIE = (-[1,]) ? false : true;
	var cjHref = location.href;

	function hotKeys() {
		var ua = navigator.userAgent.toLowerCase();
		var str = '';
		var isWebkit = (ua.indexOf('webkit') != - 1);
		var isMac = (ua.indexOf('mac') != - 1);
		if (ua.indexOf('konqueror') != - 1) {
			str = 'CTRL + B'; // Konqueror
		} else if (window.home || isWebkit || isIEmac || isMac) {
			str = (isMac ? 'Command/Cmd' : 'CTRL') + ' + D'; // Netscape, Safari, iCab, IE5/Mac
		}
		return ((str) ? 'Your browser does not support this action - press ' + str + ' to bookmark this page manually.' : str);
	}

	function isIE8() {
		var rv = -1;
		if (navigator.appName == 'Microsoft Internet Explorer') {
			var ua = navigator.userAgent;
			var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
			if (re.exec(ua) != null) {
				rv = parseFloat(RegExp.$1);
			}
		}
		if (rv > - 1) {
			if (rv >= 8.0) {
				return true;
			}
		}
		return false;
	}

function addBookmark(a) {
		cjTitle = "A " + document.getElementById("title").innerHTML + " cocktail from the Baboon Saloon!";
		try {
			if (typeof a == "object" && a.tagName.toLowerCase() == "a") {
				a.style.cursor = 'pointer';
				if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) {
					window.sidebar.addPanel(cjTitle, cjHref, ""); // Gecko
					return false;   
				} else if (window.external) {
					if (isIE8()) {
						window.external.AddToFavoritesBar(cjHref, cjTitle); // IE 8                    
					} else {
						window.external.AddFavorite(cjHref, cjTitle); // IE <=7
					}
					return false;
				} else if (window.opera) {
					a.href = cjHref;
					a.title = cjTitle;
					a.rel = 'sidebar'; // Opera 7+
					return true;
				} else {
					alert(hotKeys());
				}
			} else {
				throw "Error occured.\r\nNote, only a tagname is allowed!";
			}
		} catch (err) {
			alert(err);
		}
	}
	return {
			addBookmark : addBookmark
	}
}()
;

