
window.onload = function() {
	setCanvasPosition();
}
window.onresize = function() {
	setCanvasPosition();
}


function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}


function setCanvasPosition() {

	var windowWidth = getWindowWidth();
	var windowHeight = getWindowHeight();
        var contentWidth = 900;
        var canvasHeight = document.getElementById('canvas').scrollHeight;

        document.getElementById('canvas').style.left = (Math.abs((windowWidth-contentWidth)/2)) + 'px';
        
        if (canvasHeight < windowHeight) {
        	document.getElementById('canvas').style.height = windowHeight + 'px';
        	document.getElementById('bg-left').style.height = windowHeight + 'px';
        	document.getElementById('bg-right').style.height = windowHeight + 'px';
        } else {
        	document.getElementById('bg-left').style.height = canvasHeight + 'px';
        	document.getElementById('bg-right').style.height = canvasHeight + 'px';
        }

}


function validateContactForm() {

  var vbCRLF = String.fromCharCode(13,10);
  var incomplete = 0, msg = "";

  if (document.contactForm.name.value == "") {
    incomplete = 1;
    msg = "Please type your first and last name." + vbCRLF;
  }
  if (document.contactForm.phone.value == "") {
    incomplete = 1;
    msg += "Please type your phone #." + vbCRLF;
  }
  if (document.contactForm.email.value == "" || document.contactForm.email.value.indexOf("@")==-1 || document.contactForm.email.value.indexOf(".")==-1 ) {
    incomplete = 1;
    msg += "Please type a valid email address." + vbCRLF;
  }
  if (incomplete == 1) {
    alert(msg);
  }
  else {
    document.contactForm.submit();
  }

}


function validateLeasingForm() {

  var vbCRLF = String.fromCharCode(13,10);
  var incomplete = 0, msg = "";

  if (document.leasingForm.firstName.value == "") {
    incomplete = 1;
    msg = "Please type your first name." + vbCRLF;
  }
  if (document.leasingForm.lastName.value == "") {
    incomplete = 1;
    msg += "Please type your last name." + vbCRLF;
  }
  if (document.leasingForm.phone.value == "") {
    incomplete = 1;
    msg += "Please type your phone #." + vbCRLF;
  }
  if (document.leasingForm.email.value == "" || document.leasingForm.email.value.indexOf("@")==-1 || document.leasingForm.email.value.indexOf(".")==-1 ) {
    incomplete = 1;
    msg += "Please type a valid email address." + vbCRLF;
  }
  if (document.leasingForm.birth.value == "") {
    incomplete = 1;
    msg += "Please type your date of birth." + vbCRLF;
  }
  if (incomplete == 1) {
    alert(msg);
  }
  else {
    document.leasingForm.submit();
  }

}


function validateUpdatesForm() {

  var vbCRLF = String.fromCharCode(13,10);
  var incomplete = 0, msg = "";

  if (document.updatesForm.email.value == "" || document.updatesForm.email.value.indexOf("@")==-1 || document.updatesForm.email.value.indexOf(".")==-1 ) {
    incomplete = 1;
    msg = "Please type a valid email address." + vbCRLF;
  }
  if (incomplete == 1) {
    alert(msg);
  }
  else {
    document.updatesForm.submit();
  }

}


function sameAsAbove() {

  document.leasingForm.fName.value = document.leasingForm.mName.value;
  document.leasingForm.fOccupation.value = document.leasingForm.mOccupation.value;
  document.leasingForm.fAddress.value = document.leasingForm.mAddress.value;
  document.leasingForm.fCity.value = document.leasingForm.mCity.value;
  document.leasingForm.fState.value = document.leasingForm.mState.value;
  document.leasingForm.fZip.value = document.leasingForm.mZip.value;
  document.leasingForm.fHomePhone.value = document.leasingForm.mHomePhone.value;
  document.leasingForm.fWorkPhone.value = document.leasingForm.mWorkPhone.value;

}


function runFlash(width, height, src, align) {
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' +width+ '" height="' +height+ '" align="' +align+ '">\n');
  document.write('<param name="movie" value="' +src+ '" />\n');
  document.write('<param name="quality" value="high" />\n');
  document.write('<embed src="' +src+ '" quality="high" align="' +align+ '" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' +width+ '" height="' +height+ '">\n');
  document.write('</embed>\n');
  document.write('</object>\n');
}


function popUp(URL, width, height) {
  var windowWidth = getWindowWidth();
  var windowHeight = getWindowHeight();
  var posX = (windowWidth - width)/2;
  var posY = (windowHeight - height)/2;
  window.open(URL, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+',left='+posX+',top='+posY+'');
}




