﻿
//Converts supplied string to a hex value if required
function RGB2Hex(style)
{
    if(style.indexOf('rgb') > -1)
    {
        var decToHex="";
        var arr = new Array();
        var numStr = new String();

        numStr = style.toString().match("([\\d]+[\\s]*,[\\s]*[\\d]+[\\s]*,[\\s]*[\\d]+)")[0];

        arr = numStr.split(",");

        for(var i=0;i<3;i++)
        {
        var hexArray = new Array( "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" );

        var code1 = Math.floor(arr[i] / 16);
        var code2 = arr[i] - code1 * 16;

        decToHex += hexArray[code1];
        decToHex += hexArray[code2];
        }

        return "#" + decToHex;
    }
    else
    {
        return style;
    }
}

function addToFavourites()
{
	title = document.title;
	url = location.href;

	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
		var link = document.createElement('a');
		link.setAttribute('rel','sidebar');
		link.setAttribute('href',url);
		link.setAttribute('title',title);
		link.click();
		// return true;
	} else {
                  // Safari and others
                  alert('This function is not supported in your web browser. Please press Ctrl-D/Command-D to bookmark this page.');
         }

}