/*<![CDATA[*/
// BROWSER DETECT SCRIPT

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function setIFrameHeight() {
	if (BrowserDetect.browser == "Explorer") {
		if (document.getElementById("whiteBgTopBlock")) {
			document.getElementById("whiteBgTopBlock").style.width = String($(window).width() - 286) + "px";
		}
		if (document.getElementById("whiteBgRow2TopBlock")) {
			document.getElementById("whiteBgRow2TopBlock").style.width = String($(window).width() - 256) + "px";
		}
		if (document.getElementById("whiteBg")) {
			document.getElementById("whiteBg").style.overflow = "scroll";
			document.getElementById("whiteBg").style.width =  String($(window).width() - 322) + "px";
			document.getElementById("whiteBg").style.height = String($(window).height() - 96) + "px";
		}
		if (document.getElementById("contentHolderDiv")) {
			document.getElementById("contentHolderDiv").style.width = String($(window).width() - 272) + "px";
			document.getElementById("contentHolderDiv").style.height = String($(window).height() - 72) + "px";
		}
		// this div is only displayed when there is an Cevado IDX iFrame being used
		if (document.getElementById("cevadoIFrame")) {
			document.getElementById("cevadoIFrame").style.width = String($(window).width() - 277) + "px";
			document.getElementById("cevadoIFrame").style.height = String($(window).height() - 140) + "px";
		}
	} else if (BrowserDetect.browser == "Firefox") {
		if (document.getElementById("whiteBgTopBlock")) {
			document.getElementById("whiteBgTopBlock").style.width = String($(window).width() - 277) + "px";
		}
		if (document.getElementById("whiteBgRow2TopBlock")) {
			document.getElementById("whiteBgRow2TopBlock").style.width = String($(window).width() - 257) + "px";
		}
		if (document.getElementById("whiteBg")) {
			document.getElementById("whiteBg").style.width =  String($(window).width() - 323) + "px";
			document.getElementById("whiteBg").style.height = String($(window).height() - 97) + "px";
		}
		if (document.getElementById("contentHolderDiv")) {
			document.getElementById("contentHolderDiv").style.width = String($(window).width() - 272) + "px";
			document.getElementById("contentHolderDiv").style.height = String($(window).height() - 72) + "px";
		}
		// this div is only displayed when there is an Cevado IDX iFrame being used
		if (document.getElementById("cevadoIFrame")) {
			document.getElementById("cevadoIFrame").style.width = (window.innerWidth - 277) + "px";
			document.getElementById("cevadoIFrame").style.height = (window.innerHeight - 140) + "px";
		}
	} else {
		if (document.getElementById("whiteBgTopBlock")) {
			document.getElementById("whiteBgTopBlock").style.width = String($(window).width() - 292) + "px";
		}
		if (document.getElementById("whiteBgRow2TopBlock")) {
			document.getElementById("whiteBgRow2TopBlock").style.width = String($(window).width() - 272) + "px";
		}
		if (document.getElementById("whiteBg")) {
			document.getElementById("whiteBg").style.width =  String($(window).width() - 322) + "px";
			document.getElementById("whiteBg").style.height = String($(window).height() - 97) + "px";
		}
		if (document.getElementById("contentHolderDiv")) {
			document.getElementById("contentHolderDiv").style.width = String($(window).width() - 272) + "px";
			document.getElementById("contentHolderDiv").style.height = String($(window).height() - 72) + "px";
		}
		// this div is only displayed when there is an Cevado IDX iFrame being used
		if (document.getElementById("cevadoIFrame")) {
			document.getElementById("cevadoIFrame").style.width = (window.innerWidth - 277) + "px";
			document.getElementById("cevadoIFrame").style.height = (window.innerHeight - 140) + "px";
		}
	}
}

function setIFrameContent(page) {
	document.getElementById("cevadoIFrame").src = page;
}

function subNavOver(navItem) {
	if (BrowserDetect.browser == "Explorer") {
		navItem.childNodes[0].style.backgroundPosition = "0px -9px";
		navItem.childNodes[0].style.cursor = "hand";
		navItem.style.cursor = "hand";
	} else {
		navItem.childNodes[1].style.backgroundPosition = "0px -9px";
		navItem.childNodes[1].style.cursor = "hand";
	}
}

function subNavOut(navItem) {
	if (BrowserDetect.browser == "Explorer") {
		navItem.childNodes[0].style.backgroundPosition = "0px 0px";
		navItem.childNodes[0].style.cursor = "default";
		navItem.style.cursor = "default";
	} else {
		navItem.childNodes[1].style.backgroundPosition = "0px 0px";
		navItem.childNodes[1].style.cursor = "default";
	}
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num);// + '.' + cents);
}

function calculateRebateBuying() {
	document.getElementById("theirPrice").innerHTML = formatCurrency( document.getElementById("homePrice").value );
	
	document.getElementById("theirSixPercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .06 );
	document.getElementById("ourSixPercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .06 );
	
	document.getElementById("theirListingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .03 );
	document.getElementById("ourListingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .03 );
	
	document.getElementById("theirSellingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .03 );
	document.getElementById("ourSellingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .015 );
	
	document.getElementById("theirRebate").innerHTML = formatCurrency( document.getElementById("homePrice").value * 0 );
	var rebateValue = document.getElementById("homePrice").value * .015;
	if (document.getElementById("homePrice").value <= 266667) {
		//rebateValue = document.getElementById("homePrice").value * .03 - 4000;
	}
	document.getElementById("ourRebate").innerHTML = "<b>" + formatCurrency( rebateValue ) + "</b>*";
	
}

function calculateRebateSelling() {
	document.getElementById("theirPrice").innerHTML = formatCurrency( document.getElementById("homePrice").value );
	
	document.getElementById("theirSixPercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .06 );
	document.getElementById("ourSixPercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .045 );
	
	document.getElementById("theirListingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .03 );
	document.getElementById("ourListingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .03 );
	
	document.getElementById("theirSellingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .03 );
	document.getElementById("ourSellingThreePercent").innerHTML = formatCurrency( document.getElementById("homePrice").value * .015 );
	
	document.getElementById("theirRebate").innerHTML = formatCurrency( document.getElementById("homePrice").value * 0 );
	var rebateValue = document.getElementById("homePrice").value * .015;
	if (document.getElementById("homePrice").value <= 266667) {
		//rebateValue = document.getElementById("homePrice").value * .03 - 4000;
	}
	document.getElementById("ourRebate").innerHTML = "<b>" + formatCurrency( rebateValue ) + "</b>*";
	
}


var phone = "()- 0123456789";
var numb = "0123456789";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
function res(t,v) {
	var w = "";
	for (i=0; i < t.value.length; i++) {
	x = t.value.charAt(i);
	if (v.indexOf(x,0) != -1)
	w += x;
	}
	t.value = w;
}
/*]]>*/







