function isNumber( value ){
	return isFinite( (value * 1.0) );
}

function doTheChange(whichImage){
  //$("body")[0].style.background = "#28687c url('themes/greenvest/images/background/" + whichImage + ".jpg') no-repeat fixed top center"; 
  $("body")[0].style.background = "#ffffff url('/staging/themes/greenvest/images/background/" + whichImage + ".jpg') no-repeat scroll top center"; 
  $("#animal")[0].style.backgroundImage = "url('/staging/themes/greenvest/images/animals/" + whichImage + ".png')"; 
  $("#front-main")[0].style.background = "#ffffff url('/staging/themes/greenvest/images/panoramic/" + whichImage + ".jpg') no-repeat scroll top center";
  $("#right_bar")[0].style.background = "url('/staging/themes/greenvest/images/panoramic/" + whichImage + "b.jpg') no-repeat scroll top center";
}
function changeBGImage(whichImage){
	if (isNumber(whichImage)){
    
	if ($.preload){
	
	
    	$.preload([
		//bug: loads the images but they get loaded again above!
		/*"/staging/themes/greenvest/images/background/" + whichImage + ".jpg",
  		"/staging/themes/greenvest/images/animals/" + whichImage + ".png",
  		"/staging/themes/greenvest/images/panoramic/" + whichImage + ".jpg",
  		"/staging/themes/greenvest/images/panoramic/" + whichImage + "b.jpg"*/
		], 
      {
        onFinish: function(){doTheChange(whichImage)}
      });
	  
    } else {
      doTheChange(whichImage)
    }
	} else {
		$("body")[0].style.backgroundImage = ""; 
		$("#animal")[0].style.backgroundImage = ""; 
		if($("#front-main")[0]) $("#front-main")[0].style.backgroundImage = "";
		if($("#right_bar")[0]) $("#right_bar")[0].style.backgroundImage = "";
	}
}