// JavaScript Document
var htmlHeight;
var windowHeight;
var strPicCode;

function mySwapFunc(strNewImage, strImageID) {
		document.getElementById(strImageID).src = 'images/' + strNewImage;
}

function getdocumentheight() {
	htmlHeight = document.documentElement.scrollHeight;
	windowHeight = document.documentElement.clientHeight;
	var footerElement = new getObj('footer');
	if (windowHeight < htmlHeight || htmlHeight < 440)
		{
			var num = document.documentElement.scrollHeight + 10;
			if (windowHeight != 0) { // this avoids the Safari bug
				footerElement.style.top = num + 'px';
				return false;
			}
		} else {
			footerElement.style.bottom = '0px';
		}
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function reSizeMe() {
	var browserName=navigator.appName;
	if (browserName=="Microsoft Internet Explorer") {
		window.onresize = '';
		setTimeout("refreshMyWindow()",10);
	} else {
		refreshMyWindow();
	}
}

function refreshMyWindow() {
	var sURL = unescape(window.location.pathname);
	window.location.href = sURL;
}

function openNewWindow(strPicID){
	window.open('imageView.htm?' + strPicID, "myImage", "height=400,width=533,resizable=0");
}

function getImage(){
	var sURL = window.location.href;
	
	var strCode = Right(sURL, 2);
	var strType = '';
	if (Left(strCode, 1) == 'D') {
		strType = 'deck';
	} 
	if (Left(strCode, 1) == 'P') {
		strType = 'pool';
	} 
	if (Left(strCode, 1) == 'S') {
		strType = 'stairs';
	} 
	if (Left(strCode, 1) == 'G') {
		strType = 'pergolas';
	} 
	if (Left(strCode, 1) == 'B') {
		strType = 'balconies';
	}
	document.getElementById('display_image').src = 'images/' + strType + '/full_size/' + Right(strCode, 1) + '.jpg';
}
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
