$(document).ready(function() {
	//document.getElementById('slideshow').src = randomSlide();
	//$('#slideshow').fadeIn(500);
	loadImage();
	$("#house-button").click(function(){loadImage();});
	
	$("li:not(.on).subnav a").mouseover(function() {
		$("li.on ul").hide();
	});
	
	$("li.subnav a").mouseout(function() {
		$("li.on ul").show();
	});
	
	$(".thumbnails a").click(function(e) {
		e.preventDefault();
		var filename = $(this).attr("href");
		$(".big-image").attr({ src: filename});
	});
	

});

var current_image = null;
var randomnumber = null;
//var randomnumber = Math.floor(Math.random()*14);

function fadeInSlide(next_image) {
	document.getElementById('slideshow').src = next_image.src;
	$('#slideshow').fadeIn(500);
}

function loadImage() {
	$('#slideshow').fadeOut(500,function() {
		var next_image = new Image();
		$('#slideshow').attr('src','images/spacer.gif');
		$('#slideshow').load(fadeInSlide(next_image));
		$('#slideshow').attr('src',randomSlide());
	});
}

function randomSlide() {
	randomnumber = Math.ceil(Math.random()*13);
	slidesrc="images/slideshow/"+randomnumber+".jpg";
	if(randomnumber==current_image) {
		return randomSlide();
	} else {
		current_image = randomnumber;
		return slidesrc;
	}
}

// IE6 HOVER CODE
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace
        (" over", "");
   }
   }
  }
 }
}
window.onload=startList;

