// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level WHITESPACE_ONLY
// ==/ClosureCompiler==

// we check to see if we are the top window
if ( top != self )
{
top.location.href = unescape(window.location.pathname);
}
function rollChange (styleSheetName) {
window.event.srcElement.className = styleSheetName;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}


function MM_displayStatusMsg(msgStr) { //v1.0
status=msgStr;
document.MM_returnValue = true;
}


function sendmail(a) {
if(a=="technical"){
b="technical"}
else
{b="enquiries"
}
var addr = "mailto:";
addr=addr+b+String.fromCharCode(64);
addr=addr+"rshygiene";
addr=addr+".co.uk";

window.location = addr;
}


function Kill() {
clearInterval(clockID);

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function Change(obj,colour){
if(obj.style.backgroundColor == "#fbd023" || obj.style.backgroundColor == "rgb(251, 208, 35)"){
//do nothing
}
else
{
obj.style.backgroundColor = colour;
}
}
function LoadImage() {
var ver 				= getInternetExplorerVersion();
var IEFilter 			= "";
if(ver>-1)IEFilter 		= "filter:alpha(opacity=0);"
GLOBALAllValidImages 	= GLOBALAllImages.split(",");

//This does not show each image once until they are all shown before refreshing the list
var whichImage 	= Math.floor(Math.random()*(GLOBALAllValidImages.length));

var imageNumber = GLOBALAllValidImages[whichImage];

document.getElementById("imageLoader").innerHTML	= "<img id=\"FF\" src=\""+GLOBALImagePath+imageNumber+"\" onerror=\"RandomiseImage()\" onabort=\"RandomiseImage()\">";

document.getElementById("Image").innerHTML 		=  "<div id=\"Slides\" class=\"Slides\" style=\"background-image: url("
+ GLOBALImagePath+imageNumber
+ "); width:240px; height:240px; left:0px; top:0px;\">"
+ "<img src=\"" + GLOBALImagePath + imageNumber +"\" style=\"-moz-opacity:0;opacity:0;" + IEFilter + "\" id=\"Blend\" onerror=\"RandomiseImage()\" onabort=\"RandomiseImage()\" >"
+ "</div>";

BlendImage('Blend', GLOBALImagePath+imageNumber, 15);
RandomImageTimer(7);
}

function RandomiseImage(theImage,PositionInArray) {
GLOBALAllValidImages 	= GLOBALAllImages.split(",");
//This does not show each image once until they are all shown before refreshing the list
var whichImage 	= Math.floor(Math.random()*(GLOBALAllValidImages.length));

var imageNumber = GLOBALAllValidImages[whichImage];

document.getElementById("imageLoader").innerHTML 	= "<img id=\"FF\" src=\""+GLOBALImagePath+imageNumber+"\" onerror=\"RandomiseImage()\" onabort=\"RandomiseImage()\">";

BlendImage('Blend', GLOBALImagePath+imageNumber, 15);

}

var RandomClockID = null;
function RandomImageTimer(Seconds){
RandomImageKill();
var Con 		= 1000*Seconds;
RandomClockID 	= setInterval("RandomiseImage()",Con);
}

function RandomImageKill() {
//alert(RandomClockID)
clearInterval(RandomClockID);
}
function BlendImage(imageid, imagefile, millisec) {
var speed = millisec;
var timer = 0;
//set the current image as background
document.getElementById("Slides").style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
//make image transparent
ChangeOpac(0, imageid);
//make new image
document.getElementById(imageid).src = imagefile;
//fade in image
for(i=0; i<51; i++) {
setTimeout("ChangeOpac(" + i + ",'" + imageid + "')",(timer*speed));
timer++;
timer++;
}
}

function ChangeOpac(opacity, id){
var ver 				= getInternetExplorerVersion();
var object 				= document.getElementById(id).style;
object.opacity 			= ((opacity*2)/100);
object.MozOpacity		= ((opacity*2)/100);
object.KhtmlOpacity 	= ((opacity*2)/100);
//if it is IE
if(ver > -1){
object.filter 	= "alpha(opacity=" + (opacity*2) + ")";
}
}

function getInternetExplorerVersion(){
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
var rv = -1; // Return value assumes failure
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 );
}
return rv;
}
