function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
var section, opacity = 0, opacity2 = 1, opacity3 = 100, switched, coverval, one, two, three, four, five;
var Showroom = {
	initialize: function() {

		var pageSize = getPageSize();
		document.getElementById("cover").style.height = pageSize[1] + "px";
		
//		alert(pageSize[1]);

		if('function' == typeof window.smoothScroll) {
			smoothScroll(500);
		}

		one = document.getElementById("one");
		two = document.getElementById("two");
		three = document.getElementById("three");
		four = document.getElementById("four");
		five = document.getElementById("five");

		switched = 0;

		one.onmouseover = Showroom.cover;
		two.onmouseover = Showroom.cover;
		three.onmouseover = Showroom.cover;
		four.onmouseover = Showroom.cover;
		five.onmouseover = Showroom.cover;

		p1 = new Image();
		p1.src = "/showroom/projectone.png";
		p2 = new Image();
		p2.src = "/showroom/projecttwo.png";
		p3 = new Image();
		p3.src = "/showroom/projectthree.png";
		p4 = new Image();
		p4.src = "/showroom/projectfour.png";
		p5 = new Image();
		p5.src = "/showroom/projectfive.png";
		p6 = new Image();
		p6.src = "/showroom/freeman1.jpg";
		p7 = new Image();
		p7.src = "/showroom/abraham1.jpg";
		p8 = new Image();
		p8.src = "/showroom/queensridge-p.jpg";
		p9 = new Image();
//		p9.src = "/showroom/projectfour.jpg";
		p0 = new Image();
//		p0.src = "/showroom/projectfive.jpg";
	},
	cover: function() {
		one.onmouseout = Showroom.cover;
		two.onmouseout = Showroom.cover;
		three.onmouseout = Showroom.cover;
		four.onmouseout = Showroom.cover;
		five.onmouseout = Showroom.cover;

		if(switched == 0) {
			switched = 1;
			section = this.id;
			content = document.getElementById("projectcontent");
			content.style.filter = "alpha(opacity=20)";
			switch(section) {
				case "one":
					content.innerHTML = '<img src="/showroom/projectone.png" width="400" height="76" style="position: absolute; right: 394px; top: 80px;" /><img src="/showroom/freeman1.jpg" width="356" height="266" style="position: absolute; right: 480px; top: 145px;" />';
					break;
				case "two":
					content.innerHTML = '<img src="/showroom/projecttwo.png" width="400" height="76" style="position: absolute; right: 398px; top: 206px;" /><img src="/showroom/abraham1.jpg" width="358" height="282" style="position: absolute; right: 484px; top: 271px;" />';
					break;
				case "three":
					content.innerHTML = '<img src="/showroom/projectthree.png" width="400" height="76" style="position: absolute; right: 342px; top: 326px;" /><img src="/showroom/queensridge-p.jpg" width="356" height="328" style="position: absolute; right: 428px; top: 391px;" />';
					break;
				case "four":
					content.innerHTML = '<img src="/showroom/projectfour.png" width="400" height="76" style="position: absolute; right: 221px; top: 406px;" />';//<img src="/showroom/rancho1.jpg" width="356" height="266" style="position: absolute; right: 480px; top: 145px;" />';
					break;
				case "five":
					content.innerHTML = '<img src="/showroom/projectfive.png" width="400" height="76" style="position: absolute; right: 75px; top: 414px;" />';//<img src="/showroom/rancho1.jpg" width="356" height="266" style="position: absolute; right: 480px; top: 145px;" />';
					break;
			}
		} else {
			switched = 0;
		}
		coverval = setInterval("Showroom.zoom()", 50);
	},
	zoom: function() {

		if(switched == 1 && opacity != 8) {
			if(opacity == 0) {
				opacity2 = 0.5;
				opacity3 = 50;
			} else {
				opacity2 = 0;
				opacity3 = 0;
			}
			opacity += 2;
		} else if(switched == 0 && opacity != 0) {
			opacity -= 2;
			if(opacity == 0) {
				opacity2 = 1;
				opacity3 = 100;
			} else if(opacity == 2) {
				opacity2 = 0.2;
				opacity3 = 30;
			} else if(opacity == 4) {
				opacity2 = 0.1;
				opacity3 = 10;
			}
		}

		divs = document.getElementsByTagName("div");
		for(var i = 0; i < divs.length; i++) {
			if(divs[i].className.indexOf("link") != -1) {
				divs[i].style.opacity = opacity2;
				divs[i].style.filter = "alpha(opacity=" + opacity3 + ")";
			}
		}

		document.getElementById("cover").style.display = "block";
		document.getElementById("cover").style.opacity = "0." + opacity;
		document.getElementById("cover").style.MozOpacity = "0." + opacity;
		document.getElementById("cover").style.filter = "alpha(opacity=" + opacity + "0)";
		document.getElementById("projectcontent").style.display = "block";
		document.getElementById("projectcontent").style.opacity = "0." + opacity;
		document.getElementById("projectcontent").style.MozOpacity = "0." + opacity;
		document.getElementById("projectcontent").style.filter = "alpha(opacity=" + opacity + "0)";
		
		if(opacity >= 8) {
			switched = 1;
			clearInterval(coverval);
		}
		if(opacity <= 0) {
			document.getElementById("projectcontent").style.display = "none";
			document.getElementById("cover").style.display = "none";
			switched = 0;
			clearInterval(coverval);
		}
	}
}
window.onload = Showroom.initialize;