
function addTabs(allTabs){
	if (document.getElementById){
		var i = 0, allTabsLength = allTabs.length;
		if (! document.getElementById('tab0') && document.getElementById('tab0Page')){
		var oCell, oRow, oDiv, oText;
			for (i = 0; i < allTabsLength; i++){
				oRow = document.getElementById('tabs');
				oCell = oRow.insertCell(-1);
				oDiv = (document.createElementNS) ? document.createElementNS("http://www.w3.org/1999/xhtml","div") : document.createElement("div");
				oDiv.className = 'offTab';
				oDiv.id = 'tab' + i;
				oText = document.createTextNode(allTabs[i]);
				oDiv.appendChild(oText);
				oDiv.onclick =	function(){
							setActiveTab(this.id, allTabs);
						}
				if (allTabs[i] != "") oCell.appendChild(oDiv);
			}
			oCell = oRow.insertCell(-1);
			var attrClass = (document.all) ? "className" : "class";
			oCell.setAttribute(attrClass, "emptyTabArea");
			oText = document.createTextNode("\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0"); //create unicode non-breaking space
			oCell.appendChild(oText);
			oCell.style.width = "100%";
			if (document.getElementById('tab0')) setActiveTab('tab0', allTabs);
		}
	}
}
function setActiveTab(tabID, allTabs){
	if (document.getElementById){
		var i = 0, allTabsLength = allTabs.length;
		for (; i < allTabsLength; i++){
			if (tabID == 'tab' + i){
				setAttr(tabID, "class", "onTab");
				setStyle(tabID + 'Page', "display", "block");
			} else {
				setAttr("tab" + i, "class", "offTab");
				setStyle("tab" + i + 'Page', "display", "none");
			}
		}
	}
}
function setStyle(el, attr, newValue){
	if (document.getElementById || document.all){
		var elNode = false;
		if (document.getElementById) elNode = "document.getElementById";
		else if (document.all) elNode = "document.all";
		if (elNode){
			isNode = (eval(elNode + "('" + el + "')")) ? 1 : 0;
			if (isNode) eval(elNode + "('" + el + "').style." + attr + " = '" + newValue + "'");
		}
	}
}
function getActiveTab(tabName, numTabs){
	if (document.getElementById){
		var i = 0;
		for (; i < numTabs; i++){
			if (document.getElementById(tabName + i) && document.getElementById(tabName + i).className == 'onTab')
				return i;
		}
	}
	return false;
}
function addPropertyType(oForm, propertyTypes){
	if (document.getElementById){
		if (oForm.lastChild.nodeName.toLowerCase() == 'input' && oForm.lastChild.name == 'propertyType') oForm.removeChild(oForm.lastChild);
		var oInput = (document.createElementNS) ? document.createElementNS("http://www.w3.org/1999/xhtml","input") : document.createElement("input");
		oInput.type = 'hidden';
		oInput.name = 'propertyType';
		var tabIndex = getActiveTab('tab', propertyTypes.length);
		oInput.value = propertyTypes[tabIndex];
		oForm.appendChild(oInput);
	} else {
		var isConfirmed = confirm('Your browser does not support this type of search. Please download and install a standards-compliant browser like Mozilla Firefox.');
		if (isConfirmed) window.location = 'http://www.mozilla.com/';
		return false;
	}
}

function openMlsDetailed(uri, title){
	if (navigator.platform.indexOf("Mac") != -1){
		var newWin = window.open(uri,'','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=yes,fullscreen=no,dependent=no,width=950,height=660');
		if (newWin) newWin.focus();
	} else {
		var title = (title != '') ? title : '';
		var height = (getBodyHeight() < 660) ? getBodyHeight() - 50 : 660;
		dialogWin = new Window({
			className: "dialog",
			title: title,
			url: uri,
			width:950,
			height: height,
			zIndex: 99999,
			resizable: true,
			showEffect:Effect.BlindDown,
			hideEffect: Effect.SwitchOff,
			draggable:true,
			wiredDrag: true,
			constraint: {top:0, right:0, bottom:0, left:0}
		});
		dialogWin.showCenter(true);
	}
}
