
// set up hovers and replace headings links etc on doc ready
$(document).ready(function(){
	
	
	/*	
	var fOptions = {};
	
	fOptions.selector = "strong";
	fOptions.size = "15"; // text size, in 
	fOptions.color = "#D78E02"; // main text colour, can be with or without hash
	fOptions.font = ""; //font name
	fOptions.bgc = "#fff"; // used for aliasing halo
	*/
	
	
	
});



//Function to get hex format a rgb colour

function rgb2hex(rgb) {
    //generates the hex-digits for a colour.
    function hex(x) {
            hexDigits = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8","9", "A", "B", "C", "D", "E", "F");
            return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
    }
    return hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
} 
			

// removes html text element and replaces with an image tag
function loadImageHeader(options){
	
	
	
	
	
	items = $(options.selector);
	
	items.each(function(){
		txtString = $(this).html();
		width = $(this).innerWidth();
		txtString = escape(txtString);
		if (txtString.length > 0) {
			$(this).after("<img style='display:block' class='blocked' src='http://services.daydream.pt/typography/type.php?color=" + options.color +"&text=" + txtString +"&size=" + options.size +"&bwidth="+width+"&font="+options.font+"&bgc="+ options.bgc +"'>").remove();
		}
	});
}

// Reads text from inside HTML tag and puts image inside, without removing
function loadImageLink(options){		
	
	items = $(options.selector);
	items.each(function(){
	
		txtString = $(this).html();
		width = $(this).innerWidth();
		txtString = escape(txtString);
		if (txtString.length > 0) {
			$(this).html("<img style='display:block' class='blocked' src='http://services.daydream.pt/typography/type.php?color=" + options.color +"&text=" + txtString +"&size=" + options.size +"&bwidth="+width+"&font="+options.font+"&bgc="+ options.bgc +"'>");
		}
	});
}

