//	CSS Browser Selector v0.3.4 (Sep 29, 2009)
//	Rafael Lima (http://rafael.adm.br)
//	http://rafael.adm.br/css_browser_selector
//	License: http://creativecommons.org/licenses/by/2.5/
//	Contributors: http://rafael.adm.br/css_browser_selector#contributors

/*

<style type="text/css">
.ie .example {background-color: yellow}
.ie7 .example {background-color: orange}
.gecko .example {background-color: gray}
.win.gecko .example {background-color: red}
.linux.gecko .example {background-color: pink}
.opera .example {background-color: green}
.konqueror .example {background-color: blue}
.webkit .example {background-color: black}
.chrome .example {background-color: cyan}
.example {width: 100px; height: 100px;}
.no_js {display: block}
.has_js {display: none}
.js .no_js {display: none}
.js .has_js {display: block}
</style>

*/

function css_browser_selector(u){
	var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; 

css_browser_selector(navigator.userAgent);



//Amend the number below and add a new array item. Also need to amend the number in the Home page template code 
function getRandom(nums){
	var ranNum= Math.round(Math.random()*nums);
	return ranNum;
}

// Create an array to hold the names of all images.
var numberOfImages = 5;
var image = new Array(numberOfImages);
var path = "/absugar/media/AB-Sugar/Images/Home-Image-Loop/";
image[0]=path+"homeImage1.jpg";
image[1]=path+"homeImage2.jpg";
image[2]=path+"homeImage3.jpg";
image[3]=path+"homeImage4.jpg";
image[4]=path+"homeImage5.jpg";


setRollOvers();	
function setRollOvers(){
	$(function() {
		$('.rollover').hover(function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		}, function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		});
	});						
}


jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
