// Preload the gallery images

// Birchwood
var bw1 = new Image(575,450); bw1.src = "images/photo-gallery/bw1.jpg";
var bw2 = new Image(575,450); bw2.src = "images/photo-gallery/bw2.jpg";

// Beachwood
var beach1 = new Image(575,450); beach1.src = "images/photo-gallery/beach1.jpg";
var beach2 = new Image(575,450); beach2.src = "images/photo-gallery/beach2.jpg";
var beach3 = new Image(575,450); beach3.src = "images/photo-gallery/beach3.jpg";

// Custom build home
var cb1 = new Image(575,450); cb1.src = "images/photo-gallery/cb1.jpg";
var cb2 = new Image(575,450); cb2.src = "images/photo-gallery/cb2.jpg";

// Okanogan home
var ok1 = new Image(575,450); ok1.src = "images/photo-gallery/ok1.jpg";
var ok2 = new Image(575,450); ok2.src = "images/photo-gallery/ok2.jpg";
var ok3 = new Image(575,450); ok3.src = "images/photo-gallery/ok3.jpg";

// Rupert Home
var rh1 = new Image(575,450); rh1.src = "images/photo-gallery/rh1.jpg";
var rh2 = new Image(575,450); rh2.src = "images/photo-gallery/rh2.jpg";
var rh3 = new Image(575,450); rh3.src = "images/photo-gallery/rh3.jpg";
var rh4 = new Image(575,450); rh4.src = "images/photo-gallery/rh4.jpg";
var rh5 = new Image(575,450); rh5.src = "images/photo-gallery/rh5.jpg";
var rh6 = new Image(575,450); rh6.src = "images/photo-gallery/rh6.jpg";
var rh7 = new Image(575,450); rh7.src = "images/photo-gallery/rh7.jpg";
var rh8 = new Image(575,450); rh8.src = "images/photo-gallery/rh8.jpg";
var rh9 = new Image(575,450); rh9.src = "images/photo-gallery/rh9.jpg";
var rh10 = new Image(575,450); rh10.src = "images/photo-gallery/rh10.jpg";
var rh11 = new Image(575,450); rh11.src = "images/photo-gallery/rh11.jpg";
var rh12 = new Image(575,450); rh12.src = "images/photo-gallery/rh12.jpg";

// Rundle
var rm1 = new Image(575,450); rm1.src = "images/photo-gallery/rm1.jpg";
var rm2 = new Image(575,450); rm2.src = "images/photo-gallery/rm2.jpg";
var rm3 = new Image(575,450); rm3.src = "images/photo-gallery/rm3.jpg";


// Amazingly Lightweight Function for Corss Fade Comes From here:
// http://brainerror.net/scripts/javascript/blendtrans/

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //set the current image as background
    document.getElementById(divid).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 <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
}