/**
 * @author Michael.Howlett
 * requires 'runbOnLoad.js' for image width and height
 */
 

			
 $(document).ready(function(){ 

	if(!($.browser.msie && $.browser.version=="6.0"))
	{
		$('.difr').each(function(){
			var item = $(this);
			
			item.parent().hover(function(){

								var imgSrc = $(this).find('img').attr('src');
								imgSrc = imgSrc.replace('000000','FFFFFF');
								$(this).find('img').attr('src',imgSrc);
							},
							function()
							{							
								var imgSrc = $(this).find('img').attr('src');
								imgSrc = imgSrc.replace('FFFFFF','000000');
								$(this).find('img').attr('src',imgSrc);
							}
						);
		});


		//$('#difr-highlight a').css("background-colour", "#000000");

	}
	
	
	function rgbToHex(rgb) {
		var rgbvals = /rgb\((.+),(.+),(.+)\)/i.exec(rgb);
		var rval = parseInt(rgbvals[1]);
		var gval = parseInt(rgbvals[2]);
		var bval = parseInt(rgbvals[3]);
		
		return '#' + (	getRGBzeros(rval.toString(16)) +	getRGBzeros(gval.toString(16)) +	getRGBzeros(bval.toString(16))	).toUpperCase();
	
	} 

	function getRGBzeros(sColourVal){
	if(sColourVal.length < 2){
	    sColourVal = "0"+sColourVal;
	    }
	return sColourVal;
	}
	
	//$('#nav').css("visibility", "visible");
});

function fnCompressString(strIn){

//was using hashing, found it was overkill - oliver

    strIn = removeAll(strIn," ");
    strIn = removeAll(strIn,".");
    strIn = removeAll(strIn,":");
    strIn = removeAll(strIn,"&copy;");
    strIn = removeAll(strIn,";");
    strIn = removeAll(strIn,"#");
    strIn = removeAll(strIn,"?");
    strIn = removeAll(strIn,"%20");
    strIn = removeAll(strIn,"©");
    strIn = removeAll(strIn,"&");
    return strIn;    
}

function removeAll(strIn, reStr){
    var strReturn = "";
    strArr = strIn.split(reStr);
    for(var i = 0;i<strArr.length;i++)
    {
       strReturn = strReturn + strArr[i].replace(reStr,"");
    }
    return strReturn;
}

function ascii_value (c)
{
	// restrict input to a single character
	c = c . charAt (0);

	// loop through all possible ASCII values
	var i;
	for (i = 0; i < 256; ++ i)
	{
		// convert i into a 2-digit hex string
		var h = i . toString (16);
		if (h . length == 1)
			h = "0" + h;

		// insert a % character into the string
		h = "%" + h;

		// determine the character represented by the escape code
		h = unescape (h);

		// if the characters match, we've found the ASCII value
		if (h == c)
			break;
	}
	return i;
}


