// vc_id = "$Id: ppMapIframeControl.js 9260 2006-06-09 00:14:53Z robert $"
// JavaScript Document
var agt = navigator.userAgent.toLowerCase();
if (agt.indexOf("webkit") != -1) {
	var safari = 1;
} else {
	var safari = 0;
}

function doNothing() {
	return;
}
function changeSectionTab( tabID, formName ) {
	if ((tabID == 'ppMap') || (tabID == 'ppAerial')) {
		document.getElementById("ppMap").className = '';
		document.getElementById("ppAerial").className = '';
	
		document.getElementById(tabID).className = 'current';
	
	
		if (tabID == 'ppAerial') {
			window.ppLeftFrame.document.forms[ formName ].mapConnectionProduct.value = "aerial";
			window.ppLeftFrame.document.forms[ formName ].submit( );
		} else if (tabID == 'ppMap') {
			window.ppLeftFrame.document.forms[ formName ].mapConnectionProduct.value = "rmims";
			window.ppLeftFrame.document.forms[ formName ].submit( );
        }
	}
	
	if ((tabID == 'ppSearchForm') || (tabID == 'ppListingDetail') || (tabID == 'ppListingCart')) {
		document.getElementById("ppSearchForm").className = '';
		document.getElementById("ppListingDetail").className = '';
		//document.getElementById("ppListingCart").className = '';
	
		document.getElementById(tabID).className = 'current';
		
		if (tabID == 'ppSearchForm') {
			document.getElementById('ppListingDetailiFrame').style.display = 'none';
			//document.getElementById('ppShoppingCartHolder').style.display = 'none';
			document.getElementById('ppSearchFormContainer').style.display = 'block';
		} else if (tabID == 'ppListingDetail') {
			document.getElementById('ppListingDetailiFrame').style.display = 'block';
			//document.getElementById('ppShoppingCartHolder').style.display = 'none';
			document.getElementById('ppSearchFormContainer').style.display = 'none';
		} else if (tabID == 'ppListingCart') {
			document.getElementById('ppListingDetailiFrame').style.display = 'none';
			//document.getElementById('ppShoppingCartHolder').style.display = 'block';
			document.getElementById('ppSearchFormContainer').style.display = 'none';
		}
	}
}

function showCartDetail(currentID,html,totalItems) {
	var divLayer = document.getElementById(currentID);
	var divFloatLayer = document.getElementById('ppDetail_' + currentID);
	var divContentHolder = document.getElementById('content_' + currentID);
	var divFloatingLayer = document.getElementById('ppDetail_' + currentID);
	var posTop = divLayer.offsetTop;
	var posLeft = divLayer.offsetLeft;
	var loopCount = 1;
	
	for ( var i = 1; i < totalItems; i++ ) {
		//alert('rtListingInfo' + loopCount);
		document.getElementById('ppDetail_rtListingInfo' + loopCount).style.display = 'none';
		loopCount = loopCount + 1;
	}
	
	divContentHolder.style.visibility = 'hidden';
	divFloatingLayer.style.display = 'block';
	divFloatingLayer.style.position = 'absolute';
	divFloatingLayer.style.backgroundColor = '#ffffff';
	divFloatingLayer.style.padding = '5px';
	divFloatingLayer.style.top = posTop + 'px';
}

function hideCartAll(totalItems) {
	var loopCount = 1;
	
	for ( var i = 1; i < totalItems; i++ ) {
		//alert('rtListingInfo' + loopCount);
		document.getElementById('ppDetail_rtListingInfo' + loopCount).style.display = 'none';
		document.getElementById('content_rtListingInfo' + loopCount).style.visibility = 'visible';
		loopCount = loopCount + 1;
	}
}

// method to update the property criteria on the map
// @param form name of the map
// @query string of criteria to be added. 
//  an ampersand will be used to concat the form action
//  with the query strings, since the form action itself contains query 
//  string info.
function changePropertyCriteria( formName, criteria ) {
	resetSearchFormCheckBoxes();
	if (safari) {
    	var form = document.getElementById('ppLeftInlineFrame').document.forms[ formName ];
	} else {
		
		var form = window.parent['ppLeftFrame'].document.forms[ formName ];
	}
    form.action = form.action + "&" + criteria;
    form.submit( );
}

function viewDetails(listingID) {
	alert(listingID);
}

function removeFromShoppingCart(listingID) {
	window.parent.ppShoppingCartIframe.location = 'index.cfm?fuseaction=listing.ppShoppingCartDetails&listingToRemove=' + listingID;
}

function calcWidth(frameID,scrollWidth) {
	document.getElementById(frameID).width = scrollWidth + 'px';
}

function calcHeight(frameID,scrollHeight) {
	//alert(frameID + "|" + scrollHeight);
	var scrollHeight = parseInt(scrollHeight);
	//alert(scrollHeight);
	document.getElementById(frameID).style.height = scrollHeight + 'px';
	//alert(document.getElementById(frameID).height);
}

function resetSearchFormCheckBoxes() {
	if (safari) {
		for (j = 0; j < document.getElementById('ppLeftInlineFrame').document.forms['searchListingForm'].elements.length; j++) {
			document.getElementById('ppLeftInlineFrame').document.forms['searchListingForm'].elements[j].checked = false;
		}
	} else {
		for (j = 0; j < window.parent['ppLeftFrame'].document.forms['searchListingForm'].elements.length; j++) {
			window.parent['ppLeftFrame'].document.forms['searchListingForm'].elements[j].checked = false;
		}
	}
}









