function minHeight(objectID, minHeight) {	
	if (document.getElementById) {
		var c_height = document.getElementById(objectID).offsetHeight;
		
		if (c_height < minHeight) {
			document.getElementById(objectID).style.height = minHeight + 'px';
		}
	}
}
function setHeights() {
	var l = document.getElementById("left").offsetHeight;
	var r = document.getElementById("right").offsetHeight;

	if (l > r) minHeight("content", (l - 160));
	else if (r > l) minHeight("left", r);
}
function openProductPhotoGallery() {
	var rows = document.getElementById("photoBox").getElementsByTagName("tr");
	for(i = 0; i < rows.length; i++) {
		if (rows[i].style.display == "none") rows[i].style.display = "block";
	}
	document.getElementById("photoLink").innerHTML = '<a href="#" onclick="closeProductPhotoGallery();return false;">close</a>';	
	setHeights();
}
function closeProductPhotoGallery() {
	var rows = document.getElementById("photoBox").getElementsByTagName("tr");
	for(i = 0; i < rows.length; i++) {
		if (rows[i].className == "photoThumb") rows[i].style.display = "none";
	}
	document.getElementById("photoLink").innerHTML = '<a href="#" onclick="openProductPhotoGallery();return false;">view all photos</a>';	
	setHeights();
}
function sendFriendEmail() {
	var n = document.getElementById("send-name").value;
	var e = document.getElementById("send-email").value;
	var fn = document.getElementById("send-friend-name").value;
	var fe = document.getElementById("send-friend-email").value;	
	var m = document.getElementById("send-msg").value;
	xajax_sendFriendEmail(n, e, fn, fe, m);
}
function showMortgageCalculator() {
	if (document.getElementById("calc-overlay").style.display != 'block') {
		document.getElementById("calc-overlay").style.display = "block";
		var arrayPageSize = getPageSize();
		document.getElementById("calc-overlay").style.height = arrayPageSize[1] + 'px';
		document.getElementById("calc-overlay").onclick = function() {
			//closeShadow();
		}
		document.getElementById("calc-alert-window-frame").style.marginTop = '100px';
		document.getElementById("calc-alert-window-frame").style.display = 'block';	
	}	
}
function floor(number) {
	return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}
function dosum() {
	var mi = document.temps.IR.value / 1200;
	var base = 1;
	var mbase = 1 + mi;
	for (i=0; i<document.temps.YR.value * 12; i++) {
		base = base * mbase
	}
	document.temps.PI.value = floor(document.temps.LA.value * mi / ( 1 - (1/base)))
	document.temps.MT.value = floor(document.temps.AT.value / 12)
	document.temps.MI.value = floor(document.temps.AI.value / 12)
	var dasum = document.temps.LA.value * mi / ( 1 - (1/base)) +
		document.temps.AT.value / 12 + 

		document.temps.AI.value / 12;

	  document.temps.MP.value = floor(dasum);

	}
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;
}
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
function newsletterSignUp() {
	document.getElementById("newsletter-msg").innerHTML = cart_progress_bar; 
	document.getElementById("newsletter-msg").style.display = 'block';
	xajax_newsletterSignUp(document.getElementById("newsletter-name").value, document.getElementById("newsletter-email").value);
}
