function CyberSlider( strContainerId, bIsVertical, iLowBound, iHighBound, iStartAt,
strBgImage, iBgWidth, iBgHeight, strAdditionalStyleCommands,
strFgImage, iFgWidth, iFgHeight,
onMoveCompleteCb, onMoveCb )
{
this.pContainer = document.getElementById(strContainerId);
if( !this.pContainer ) {
throw( new TypeError("Container ID must exist, could not create slider object") );
}
this.pContainer.style.float = "left";
this.pContainer.style.margin = "0";
this.pContainer.style.width = iBgWidth;
this.pContainer.style.height = iBgHeight;
var strPointerId = strContainerId+'_pointer';
var strTrackId = strContainerId+'_track';
var strContents = '<div id="'+strTrackId+'" style="height:'+iBgHeight+'px;width:'+iBgWidth+'px;background:url('+strBgImage+');position:relative;'+strAdditionalStyleCommands+'">' +
' <div id="'+strPointerId+'" style="background:url('+strFgImage+');width:'+iFgWidth+'px; height:'+iFgHeight+'px;position:relative;"></div>' +
'</div>';
this.pContainer.innerHTML = strContents;
this.pTrack = document.getElementById(strTrackId);
if( !this.pTrack ) {
throw( new TypeError("Could not create new slider track.") );
}
this.pTrack.strContainerId = strContainerId;
this.pTrack.bIsVertical = bIsVertical;
this.pTrack.iLowBound = iLowBound;
this.pTrack.iHighBound = iHighBound;
this.pTrack.iStartAt = iStartAt;
this.pTrack.strBgImage = strBgImage;
this.pTrack.iBgWidth = iBgWidth;
this.pTrack.iBgHeight = iBgHeight;
this.pTrack.strFgImage = strFgImage;
this.pTrack.iFgWidth = iFgWidth;
this.pTrack.iFgHeight = iFgHeight;
this.pTrack.onMoveComplete = onMoveCompleteCb;
this.pTrack.onMove = onMoveCb;
this.pTrack.pMyself = this;
this.pTrack.iDistance = (bIsVertical ? (iBgHeight-iFgHeight) : (iBgWidth-iFgWidth));
this.pTrack.xMax = 0;
this.pTrack.yMax = 0;
this.pTrack.xMin = 0;
this.pTrack.yMin = 0;
this.pTrack.bInDrag = false;
this.pTrack.iNumElements = iHighBound - iLowBound;
this.pTrack.fValue = iStartAt;
this.pTrack.iEffectiveBound= 0;
this.pTrack.scale = ((this.pTrack.iHighBound - this.pTrack.iLowBound) / this.pTrack.iDistance);
if (this.pTrack.bIsVertical) {
this.pTrack.iEffectiveBound = iHighBound;
this.pTrack.xMax = 0;
this.pTrack.yMax = this.pTrack.iDistance;
this.pTrack.scale = -this.pTrack.scale;
} else {
this.pTrack.iEffectiveBound = iLowBound;
this.pTrack.xMax = this.pTrack.iDistance;
this.pTrack.yMax = 0;
}
this.pTrack.pPointer = document.getElementById(strPointerId);
if( !this.pTrack.pPointer ) {
throw( new TypeError("Could not create new slider pointer.") );
}
this.pTrack.pPointer.pTrack = this.pTrack;
this.pTrack.pPointer.startOffsetX = 0;
this.pTrack.pPointer.startOffsetY = 0;
this.pTrack.pPointer.onmousedown = cyberSliderHandleOnMouseDown;
this.pTrack.onclick = cyberSliderHandleTrackOnClick;
this.SetValue = function(fValue) {
if( fValue > this.pTrack.iHighBound ) fValue = this.pTrack.iHighBound;
if( fValue < this.pTrack.iLowBound ) fValue = this.pTrack.iLowBound;
var sliderPos = (fValue - this.pTrack.iEffectiveBound) / this.pTrack.scale;
this.pTrack.fValue = fValue;
if (this.pTrack.bIsVertical) {
this.getSetObjectTop(this.pTrack.pPointer, Math.round(sliderPos));
} else {
this.getSetObjectLeft(this.pTrack.pPointer, Math.round(sliderPos));
}
if( this.pTrack.onMoveComplete ) {
this.pTrack.onMoveComplete( this );
}
};
this.GetValue = function() {
return this.pTrack.fValue;
};
this.Destroy = function() {
if (document.removeEventListener) {
document.removeEventListener('mousemove', cyberSliderHandleOnMouseMove, false);
document.removeEventListener('mouseup', cyberSliderHandleOnMouseUp, false);
} else if (document.detachEvent) {
document.detachEvent('onmousemove', cyberSliderHandleOnMouseMove);
document.detachEvent('onmouseup', cyberSliderHandleOnMouseUp);
}
this.pTrack.pPointer.onmousedown = null;
this.pTrack.onclick = null;
this.pContainer.innerHTML = '';
};
this.getSetObjectLeft = function(objElement, pos) {
if (objElement.style && (typeof(objElement.style.left) == 'string')) {
if (typeof(pos) == 'number') {
objElement.style.left = pos + 'px';
} else {
pos = parseInt(objElement.style.left);
if (isNaN(pos)) {
pos = 0;
}
}
} else if (objElement.style && objElement.style.pixelLeft) {
if ( typeof(pos) == 'number') {
objElement.style.pixelLeft = pos;
} else {
pos = objElement.style.pixelLeft;
}
}
return pos;
}
this.findPosY = function(obj)
{
var curtop = 0;
if (document.getElementById || document.all) {
if( !obj.offsetParent ){
curtop += obj.offsetTop;
}
while (obj.offsetParent) {
curtop += obj.offsetTop;
obj = obj.offsetParent;
}
} else if (document.layers)
curtop += obj.y;
return curtop;
}
this.findPosX = function(obj)
{
var curleft = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curleft += obj.offsetLeft;
obj = obj.offsetParent;
}
} else if (document.layers)
curleft += obj.x;
return curleft;
}
this.getSetObjectTop = function(objElement, pos)
{
if (objElement.style && (typeof(objElement.style.top) == 'string')) {
if (typeof(pos) == 'number') {
objElement.style.top = pos + 'px';
} else {
pos = parseInt(objElement.style.top);
if (isNaN(pos)) pos = 0;
}
} else if (objElement.style && objElement.style.pixelTop) {
if (typeof(pos) == 'number') objElement.style.pixelTop = pos;
else pos = objElement.style.pixelTop;
}
return pos;
}
this.HandleTrackOnClick = function(objEvent) {
var iPosX = 0;
var iPosY = 0;
if ( objEvent.pageX ) {
iPosX = objEvent.pageX;
} else {
if ( objEvent.clientX ) {
iPosX = objEvent.clientX + (document.body.scrollLeft?document.body.scrollLeft:0);
}
}
if ( objEvent.pageY ) {
iPosY = objEvent.pageY;
} else {
if ( objEvent.clientY ) {
iPosY = objEvent.clientY + (document.body.scrollTop?document.body.scrollTop:0);
}
}
var x = iPosX - this.findPosX(this.pTrack);
var y = iPosY - this.findPosY(this.pTrack);
if (x > this.pTrack.xMax) x = this.pTrack.xMax;
if (x < this.pTrack.xMin) x = this.pTrack.xMin;
if (y > this.pTrack.yMax) y = this.pTrack.yMax;
if (y < this.pTrack.yMin) y = this.pTrack.yMin;
this.getSetObjectLeft(this.pTrack.pPointer, x);
this.getSetObjectTop(this.pTrack.pPointer, y);
var sliderVal = x + y;
var sliderPos = (this.pTrack.iDistance / this.pTrack.iNumElements ) * Math.round(this.pTrack.iNumElements * sliderVal / this.pTrack.iDistance);
var v = Math.round( (sliderPos * this.pTrack.scale + this.pTrack.iEffectiveBound) );
this.pTrack.fValue = v;
if( this.pTrack.onMoveComplete ) {
this.pTrack.onMoveComplete( this );
}
}
this.HandleOnMouseDown = function(objEvent) {
this.pTrack.pPointer.startOffsetX = this.getSetObjectLeft(this.pTrack.pPointer) - objEvent.screenX;
this.pTrack.pPointer.startOffsetY = this.getSetObjectTop(this.pTrack.pPointer) - objEvent.screenY;
this.pTrack.bInDrag = true;
if( window.addEventListener ) {
document.addEventListener('mousemove', cyberSliderHandleOnMouseMove, false);
document.addEventListener('mouseup', cyberSliderHandleOnMouseUp, false);
} else {
document.attachEvent('onmouseup', cyberSliderHandleOnMouseUp);
document.attachEvent('onmousemove', cyberSliderHandleOnMouseMove);
}
return false
};
this.HandleOnMouseMove = function(objEvent) {
if (this.pTrack.bInDrag) {
var x = this.pTrack.pPointer.startOffsetX + objEvent.screenX;
var y = this.pTrack.pPointer.startOffsetY + objEvent.screenY;
if (x > this.pTrack.xMax) x = this.pTrack.xMax;
if (x < this.pTrack.xMin) x = this.pTrack.xMin;
if (y > this.pTrack.yMax) y = this.pTrack.yMax;
if (y < this.pTrack.yMin) y = this.pTrack.yMin;
this.getSetObjectLeft(this.pTrack.pPointer, x);
this.getSetObjectTop(this.pTrack.pPointer, y);
var sliderVal = x + y;
var sliderPos = (this.pTrack.iDistance / this.pTrack.iNumElements ) * Math.round(this.pTrack.iNumElements * sliderVal / this.pTrack.iDistance);
var v = Math.round( (sliderPos * this.pTrack.scale + this.pTrack.iEffectiveBound) );
this.pTrack.fValue = v;
if( this.pTrack.onMove ) {
this.pTrack.onMove( this );
}
return false;
}
return;
}
this.HandleOnMouseUp = function(objEvent) {
if (this.pTrack.bInDrag) {
var v = (this.pTrack.fValue) ? this.pTrack.fValue : 0;
var pos = (v - this.pTrack.iEffectiveBound)/(this.pTrack.scale);
if (this.pTrack.yMax == 0) {
pos = (pos > this.pTrack.xMax) ? this.pTrack.xMax : pos;
pos = (pos < 0) ? 0 : pos;
this.getSetObjectLeft(this.pTrack.pPointer, pos);
}
if (this.pTrack.xMax == 0) {
pos = (pos > this.pTrack.yMax) ? this.pTrack.yMax : pos;
pos = (pos < 0) ? 0 : pos;
this.getSetObjectTop(this.pTrack.pPointer, pos);
}
if (document.removeEventListener) {
document.removeEventListener('mousemove', cyberSliderHandleOnMouseMove, false);
document.removeEventListener('mouseup', cyberSliderHandleOnMouseUp, false);
} else if (document.detachEvent) {
document.detachEvent('onmousemove', cyberSliderHandleOnMouseMove);
document.detachEvent('onmouseup', cyberSliderHandleOnMouseUp);
}
}
this.pTrack.bInDrag = false;
this.SetValue( this.pTrack.fValue );
}
this.SetValue( iStartAt );
}
var g_pCurrentMovingPointer = null;
function cyberSliderHandleOnMouseDown( objEvent )
{
if (!objEvent) objEvent = window.event;
var pPointer = (objEvent.target) ? objEvent.target : objEvent.srcElement;
if( pPointer && pPointer.pTrack ) {
g_pCurrentMovingPointer = pPointer;
return pPointer.pTrack.pMyself.HandleOnMouseDown( objEvent );
}
}
function cyberSliderHandleOnMouseMove( objEvent )
{
if (!objEvent) objEvent = window.event;
var pPointer = g_pCurrentMovingPointer;
if( pPointer && pPointer.pTrack ) {
return pPointer.pTrack.pMyself.HandleOnMouseMove( objEvent );
}
}
function cyberSliderHandleOnMouseUp( objEvent )
{
if (!objEvent) objEvent = window.event;
var pPointer = g_pCurrentMovingPointer;
if( pPointer && pPointer.pTrack ) {
return pPointer.pTrack.pMyself.HandleOnMouseUp( objEvent );
}
}
function cyberSliderHandleTrackOnClick( objEvent )
{
if (!objEvent) objEvent = window.event;
var pTrack = (objEvent.target) ? objEvent.target : objEvent.srcElement;
if( pTrack && pTrack.pMyself ) {
return pTrack.pMyself.HandleTrackOnClick( objEvent );
}
}
function CyberDualSlider( strContainerId, bIsVertical, iLowBound, iHighBound, iStartLowAt, iStartHighAt,
strBgImage, iBgWidth, iBgHeight, strAdditionalStyleCommands,
strFgLowImage, strFgHighImage, iFgWidth, iFgHeight,
onMoveCompleteCb, onMoveCb )
{
this.pContainer = document.getElementById(strContainerId);
if( !this.pContainer ) {
throw( new TypeError("Container ID must exist, could not create slider object") );
}
this.pContainer.style.float = "left";
this.pContainer.style.margin = "0";
this.pContainer.style.width = iBgWidth;
this.pContainer.style.height = iBgHeight;
var strLowPointerId = strContainerId+'_lowpointer';
var strHighPointerId = strContainerId+'_highpointer';
var strTrackId = strContainerId+'_track';
var strContents = '<div id="'+strTrackId+'" style="height:'+iBgHeight+'px;width:'+iBgWidth+'px;background:url('+strBgImage+');position:relative;'+strAdditionalStyleCommands+'">' +
' <div id="'+strLowPointerId+'" style="background:url('+strFgLowImage+');width:'+iFgWidth+'px; height:'+iFgHeight+'px;position:absolute;"></div>' +
' <div id="'+strHighPointerId+'" style="background:url('+strFgHighImage+');width:'+iFgWidth+'px; height:'+iFgHeight+'px;position:absolute;"></div>' +
'</div>';
this.pContainer.innerHTML = strContents;
this.pTrack = document.getElementById(strTrackId);
if( !this.pTrack ) {
throw( new TypeError("Could not create new slider track.") );
}
this.pTrack.strContainerId = strContainerId;
this.pTrack.bIsVertical = bIsVertical;
this.pTrack.iLowBound = iLowBound;
this.pTrack.iHighBound = iHighBound;
this.pTrack.iStartLowAt = iStartLowAt;
this.pTrack.iStartHighAt = iStartHighAt;
this.pTrack.strBgImage = strBgImage;
this.pTrack.iBgWidth = iBgWidth;
this.pTrack.iBgHeight = iBgHeight;
this.pTrack.iFgWidth = iFgWidth;
this.pTrack.iFgHeight = iFgHeight;
this.pTrack.onMoveComplete = onMoveCompleteCb;
this.pTrack.onMove = onMoveCb;
this.pTrack.pMyself = this;
this.pTrack.iDistance = (bIsVertical ? (iBgHeight-iFgHeight) : (iBgWidth-iFgWidth));
this.pTrack.xMax = 0;
this.pTrack.yMax = 0;
this.pTrack.xMin = 0;
this.pTrack.yMin = 0;
this.pTrack.bInDrag = false;
this.pTrack.iNumElements = iHighBound - iLowBound;
this.pTrack.fLowValue = iStartLowAt;
this.pTrack.fHighValue = iStartHighAt;
this.pTrack.iEffectiveBound= 0;
this.pTrack.scale = ((this.pTrack.iHighBound - this.pTrack.iLowBound) / this.pTrack.iDistance);
if (this.pTrack.bIsVertical) {
this.pTrack.iEffectiveBound = iHighBound;
this.pTrack.xMax = 0
this.pTrack.yMax = this.pTrack.iDistance;
this.pTrack.scale = -this.pTrack.scale;
} else {
this.pTrack.iEffectiveBound = iLowBound;
this.pTrack.xMax = this.pTrack.iDistance;
this.pTrack.yMax = 0;
}
this.pTrack.pLowPointer = document.getElementById(strLowPointerId);
if( !this.pTrack.pLowPointer ) {
throw( new TypeError("Could not create new low slider pointer.") );
}
this.pTrack.pHighPointer = document.getElementById(strHighPointerId);
if( !this.pTrack.pHighPointer ) {
throw( new TypeError("Could not create new high slider pointer.") );
}
this.pTrack.pLowPointer.pTrack = this.pTrack;
this.pTrack.pHighPointer.pTrack = this.pTrack;
this.pTrack.pLowPointer.startOffsetX = 0;
this.pTrack.pLowPointer.startOffsetY = 0;
this.pTrack.pLowPointer.iHiLoInd = 0;
this.pTrack.pHighPointer.startOffsetX = 0;
this.pTrack.pHighPointer.startOffsetY = 0;
this.pTrack.pHighPointer.iHiLoInd = 1;
this.pTrack.pLowPointer.onmousedown = cyberDualSliderHandleOnMouseDown;
this.pTrack.pHighPointer.onmousedown = cyberDualSliderHandleOnMouseDown;
this.pTrack.onclick = cyberDualSliderHandleTrackOnClick;
this.SetValues = function(fLowValue, fHighValue, bCallCallback) {
if( fLowValue > fHighValue ) {
var fTemp = fLowValue;
fLowValue = fHighValue;
fHighValue = fTemp;
}
if( fLowValue > this.pTrack.iHighBound ) fLowValue = this.pTrack.iHighBound;
if( fLowValue < this.pTrack.iLowBound ) fLowValue = this.pTrack.iLowBound;
if( fHighValue > this.pTrack.iHighBound ) fHighValue = this.pTrack.iHighBound;
if( fHighValue < this.pTrack.iLowBound ) fHighValue = this.pTrack.iLowBound;
this.pTrack.fLowValue = fLowValue;
this.pTrack.fHighValue = fHighValue;
var sliderLowPos = (fLowValue - this.pTrack.iEffectiveBound) / this.pTrack.scale;
var sliderHighPos = (fHighValue - this.pTrack.iEffectiveBound) / this.pTrack.scale;
if (this.pTrack.bIsVertical) {
this.getSetObjectTop(this.pTrack.pLowPointer, Math.round(sliderLowPos));
this.getSetObjectTop(this.pTrack.pHighPointer, Math.round(sliderHighPos));
} else {
this.getSetObjectLeft(this.pTrack.pLowPointer, Math.round(sliderLowPos));
this.getSetObjectLeft(this.pTrack.pHighPointer, Math.round(sliderHighPos));
}
if( bCallCallback && this.pTrack.onMoveComplete ) {
this.pTrack.onMoveComplete( this );
}
};
this.GetLowValue = function() {
return (this.pTrack.fLowValue);
};
this.GetHighValue = function() {
return (this.pTrack.fHighValue);
};
this.Destroy = function() {
if (document.removeEventListener) {
document.removeEventListener('mousemove', cyberDualSliderHandleOnMouseMove, false);
document.removeEventListener('mouseup', cyberDualSliderHandleOnMouseUp, false);
} else if (document.detachEvent) {
document.detachEvent('onmousemove', cyberDualSliderHandleOnMouseMove);
document.detachEvent('onmouseup', cyberDualSliderHandleOnMouseUp);
}
this.pTrack.pLowPointer.onmousedown = null;
this.pTrack.pHighPointer.onmousedown = null;
this.pTrack.onclick = null;
this.pContainer.innerHTML = '';
};
this.getSetObjectLeft = function(objElement, pos)
{
if (objElement.style && (typeof(objElement.style.left) == 'string')) {
if (typeof(pos) == 'number') {
objElement.style.left = pos + 'px';
} else {
pos = parseInt(objElement.style.left);
if (isNaN(pos)) pos = 0;
}
}
else if (objElement.style && objElement.style.pixelLeft) {
if (typeof(pos) == 'number') objElement.style.pixelLeft = pos;
else pos = objElement.style.pixelLeft;
}
return pos;
}
this.findPosY = function(obj)
{
var curtop = 0;
if (document.getElementById || document.all) {
if( !obj.offsetParent ){
curtop += obj.offsetTop;
}
while (obj.offsetParent) {
curtop += obj.offsetTop;
obj = obj.offsetParent;
}
} else if (document.layers)
curtop += obj.y;
return curtop;
}
this.findPosX = function(obj)
{
var curleft = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curleft += obj.offsetLeft;
obj = obj.offsetParent;
}
} else if (document.layers)
curleft += obj.x;
return curleft;
}
this.getSetObjectTop = function(objElement, pos)
{
if (objElement.style && (typeof(objElement.style.top) == 'string')) {
if (typeof(pos) == 'number') {
objElement.style.top = pos + 'px';
} else {
pos = parseInt(objElement.style.top);
if (isNaN(pos)) pos = 0;
}
} else if (objElement.style && objElement.style.pixelTop) {
if (typeof(pos) == 'number') objElement.style.pixelTop = pos;
else pos = objElement.style.pixelTop;
}
return pos;
}
this.HandleTrackOnClick = function(objEvent) {
var iPosX = 0;
var iPosY = 0;
if ( objEvent.pageX ) {
iPosX = objEvent.pageX;
} else {
if ( objEvent.clientX ) {
iPosX = objEvent.clientX + (document.body.scrollLeft?document.body.scrollLeft:0);
}
}
if ( objEvent.pageY ) {
iPosY = objEvent.pageY;
} else {
if ( objEvent.clientY ) {
iPosY = objEvent.clientY + (document.body.scrollTop?document.body.scrollTop:0);
}
}
var x = iPosX - this.findPosX(this.pTrack);
var y = iPosY - this.findPosY(this.pTrack);
if (x > this.pTrack.xMax) x = this.pTrack.xMax;
if (x < this.pTrack.xMin) x = this.pTrack.xMin;
if (y > this.pTrack.yMax) y = this.pTrack.yMax;
if (y < this.pTrack.yMin) y = this.pTrack.yMin;
var sliderVal = x + y;
var sliderPos = (this.pTrack.iDistance / this.pTrack.iNumElements ) * Math.round(this.pTrack.iNumElements * sliderVal / this.pTrack.iDistance);
var v = Math.round( (sliderPos * this.pTrack.scale + this.pTrack.iEffectiveBound) );
if( v > this.pTrack.fHighValue ) {
this.getSetObjectLeft(this.pTrack.pHighPointer, x);
this.getSetObjectTop(this.pTrack.pHighPointer, y);
this.pTrack.fHighValue = v;
} else {
this.getSetObjectLeft(this.pTrack.pLowPointer, x);
this.getSetObjectTop(this.pTrack.pLowPointer, y);
this.pTrack.fLowValue = v;
}
if( this.pTrack.onMoveComplete ) {
this.pTrack.onMoveComplete( this );
}
}
this.HandleOnMouseDown = function(objEvent) {
if( g_pCurrentMovingPointer ) {
g_pCurrentMovingPointer.startOffsetX = this.getSetObjectLeft(g_pCurrentMovingPointer) - objEvent.screenX;
g_pCurrentMovingPointer.startOffsetY = this.getSetObjectTop(g_pCurrentMovingPointer) - objEvent.screenY;
this.pTrack.bInDrag = true;
if( window.addEventListener ) {
document.addEventListener('mousemove', cyberDualSliderHandleOnMouseMove, false);
document.addEventListener('mouseup', cyberDualSliderHandleOnMouseUp, false);
} else {
document.attachEvent('onmouseup', cyberDualSliderHandleOnMouseUp);
document.attachEvent('onmousemove', cyberDualSliderHandleOnMouseMove);
}
}
return false
};
this.HandleOnMouseMove = function(objEvent) {
if (this.pTrack.bInDrag && g_pCurrentMovingPointer) {
var x = g_pCurrentMovingPointer.startOffsetX + objEvent.screenX;
var y = g_pCurrentMovingPointer.startOffsetY + objEvent.screenY;
if (x > this.pTrack.xMax) x = this.pTrack.xMax;
if (x < this.pTrack.xMin) x = this.pTrack.xMin;
if (y > this.pTrack.yMax) y = this.pTrack.yMax;
if (y < this.pTrack.yMin) y = this.pTrack.yMin;
var sliderVal = x + y;
var sliderPos = (this.pTrack.iDistance / this.pTrack.iNumElements ) * Math.round(this.pTrack.iNumElements * sliderVal / this.pTrack.iDistance);
var v = Math.round( (sliderPos * this.pTrack.scale + this.pTrack.iEffectiveBound) );
if( g_pCurrentMovingPointer.iHiLoInd ) {
if( v < this.pTrack.fLowValue ) {
return;
}
this.pTrack.fHighValue = v;
} else {
if( v > this.pTrack.fHighValue ) {
return;
}
this.pTrack.fLowValue = v;
}
this.getSetObjectLeft(g_pCurrentMovingPointer, x);
this.getSetObjectTop(g_pCurrentMovingPointer, y);
if( this.pTrack.onMove ) {
this.pTrack.onMove( this );
}
return false;
}
return;
}
this.HandleOnMouseUp = function(objEvent) {
if (this.pTrack.bInDrag && g_pCurrentMovingPointer) {
var v = null;
if( g_pCurrentMovingPointer.iHiLoInd ) {
v = (this.pTrack.fHighValue) ? this.pTrack.fHighValue : 0;
} else {
v = (this.pTrack.fLowValue) ? this.pTrack.fLowValue : 0;
}
var pos = (v - this.pTrack.iEffectiveBound)/(this.pTrack.scale);
if (this.pTrack.yMax == 0) {
pos = (pos > this.pTrack.xMax) ? this.pTrack.xMax : pos;
pos = (pos < 0) ? 0 : pos;
if( g_pCurrentMovingPointer ) {
var iMyPos = this.findPosX(g_pCurrentMovingPointer);
if( g_pCurrentMovingPointer.iHiLoInd ) {
var iLowPos = this.findPosX(this.pTrack.pLowPointer);
if( iMyPos <= iLowPos ) {
pos += (this.pTrack.iFgWidth/2);
}
} else {
var iHiPos = this.findPosX(this.pTrack.pHighPointer);
if( iMyPos >= iHiPos ) {
pos -= (this.pTrack.iFgWidth/2);
}
}
this.getSetObjectLeft(g_pCurrentMovingPointer, pos);
}
}
if (this.pTrack.xMax == 0) {
pos = (pos > this.pTrack.yMax) ? this.pTrack.yMax : pos;
pos = (pos < 0) ? 0 : pos;
if( g_pCurrentMovingPointer ) {
var iMyPos = this.findPosY(g_pCurrentMovingPointer);
if( g_pCurrentMovingPointer.iHiLoInd ) {
var iLowPos = this.findPosY(this.pTrack.pLowPointer);
if( iMyPos >= iLowPos ) {
pos -= (this.pTrack.iFgHeight/2);
}
} else {
var iHiPos = this.findPosY(this.pTrack.pHighPointer);
if( iMyPos <= iHiPos ) {
pos += (this.pTrack.iFgHeight/2);
}
}
this.getSetObjectTop(g_pCurrentMovingPointer, pos);
}
}
if (document.removeEventListener) {
document.removeEventListener('mousemove', cyberDualSliderHandleOnMouseMove, false);
document.removeEventListener('mouseup', cyberDualSliderHandleOnMouseUp, false);
} else if (document.detachEvent) {
document.detachEvent('onmousemove', cyberDualSliderHandleOnMouseMove);
document.detachEvent('onmouseup', cyberDualSliderHandleOnMouseUp);
}
}
this.pTrack.bInDrag = false;
this.SetValues( this.pTrack.fLowValue, this.pTrack.fHighValue, true );
}
this.SetValues( iStartLowAt, iStartHighAt, false );
}
var g_pCurrentMovingPointer = null;
function cyberDualSliderHandleOnMouseDown( objEvent )
{
if (!objEvent) objEvent = window.event;
var pPointer = (objEvent.target) ? objEvent.target : objEvent.srcElement;
if( pPointer && pPointer.pTrack ) {
g_pCurrentMovingPointer = pPointer;
return pPointer.pTrack.pMyself.HandleOnMouseDown( objEvent );
}
}
function cyberDualSliderHandleOnMouseMove( objEvent )
{
if (!objEvent) objEvent = window.event;
var pPointer = g_pCurrentMovingPointer;
if( pPointer && pPointer.pTrack ) {
return pPointer.pTrack.pMyself.HandleOnMouseMove( objEvent );
}
}
function cyberDualSliderHandleOnMouseUp( objEvent )
{
if (!objEvent) objEvent = window.event;
var pPointer = g_pCurrentMovingPointer;
if( pPointer && pPointer.pTrack ) {
return pPointer.pTrack.pMyself.HandleOnMouseUp( objEvent );
}
}
function cyberDualSliderHandleTrackOnClick( objEvent )
{
if (!objEvent) objEvent = window.event;
var pTrack = (objEvent.target) ? objEvent.target : objEvent.srcElement;
if( pTrack && pTrack.pMyself ) {
return pTrack.pMyself.HandleTrackOnClick( objEvent );
}
}
var AJAXQUEUE_STATUS_PREPPING = 0;
var AJAXQUEUE_STATUS_QUEUED = 1;
var AJAXQUEUE_STATUS_PROCESSING = 2;
var AJAXQUEUE_STATUS_SENT = 3;
var AJAXQUEUE_STATUS_COMPLETE = 4;
var AJAXQUEUE_STATUS_ERROR = 5;
var AJAXQUEUE_STATUS_CANCELLED = 6;
function AjaxQueue() {
this.bDoCleanup = true;
this.iAjaxCallInterval = 250;
this.iIntervalId = 0;
this.bIntervalStarted = false;
this.locks = new Object;
this.calls = new Object;
this.strLastCall = null;
this.iIteration = 0;
this.errorHandler = null;
this.RegisterErrorHandler = function( pFunction ) {
this.errorHandler = pFunction;
}
this.schedule = function(strName, strUrl, fCallback, bInterrupt, bPriority) {
if (this.calls[strName] != undefined) {
this.destroyCall(strName);
}
var bReturn = true;
var queueItem = new AjaxQueueCall(strUrl);
queueItem.callback = fCallback;
queueItem.priority = (bPriority == true) ? true : false;
if (bInterrupt == true) {
this.purgeAllCalls();
}
this.calls[strName] = queueItem;
this.calls[strName].state = AJAXQUEUE_STATUS_PREPPING;
try {
this.calls[strName].xmlObject = this.getNewXMLObject();
this.calls[strName].xmlObject.onreadystatechange = function() { onReadyStateChangeHelper( strName, strUrl ); }
} catch (e) {
if( this.errorHandler ) {
this.errorHandler( e );
} else {
alert("AjaxQueue Scheduling Failed for ["+strName+"]: "+e.message);
}
bRetrun = false;
}
this.calls[strName].state = AJAXQUEUE_STATUS_QUEUED;
return bReturn;
}
this.isLocked = function(strLock) {
if (strLock != undefined) {
if (this.locks[strLock] != undefined) {
return this.locks[strLock].state;
} else {
return false;
}
} else {
for (var i in this.locks) {
if (this.locks[i].state == true) {
return true;
}
}
return false;
}
}
this.registerLock = function(strLockName) {
var lock = new AjaxQueueLock(strLockName);
this.locks[strLockName] = lock;
return;
}
this.unregisterLock = function(strLockName) {
try{
delete this.locks[strLockName];
} catch (e) {
}
return;
}
this.engageLock = function(strLockName) {
return this.changeLockState(strLockName, true);
}
this.disengageLock = function(strLockName) {
return this.changeLockState(strLockName, false);
}
this.changeLockState = function(strLockName, bState) {
try {
this.locks[strLockName].state = bState;
} catch (e) {
if( this.errorHandler ) {
this.errorHandler( e );
} else {
alert("AjaxQueue: cannot change lock ["+strLockName+"]: " + e.message);
}
}
return;
}
this.destroyCall = function(strName) {
if (this.calls[strName] != undefined) {
this.calls[strName].state = AJAXQUEUE_STATUS_CANCELLED;
this.abortCall(strName);
if (this.bDoCleanup == true) {
this.purgeCall(strName);
}
}
}
this.purgeCall = function(strName) {
try {
delete this.calls[strName];
} catch (e) {
}
return;
}
this.abortCall = function(strName) {
this.calls[strName].xmlObject.abort();
return;
}
this.purgeAllCalls = function() {
for (var i in this.calls) {
this.destroyCall(i);
}
if (this.bDoCleanup == true) {
this.calls = new Object;
}
}
this.getNewXMLObject = function() {
var newAjaxObj = null;
try {
if (window.XMLHttpRequest) {
newAjaxObj = new XMLHttpRequest();
} else {
newAjaxObj = new ActiveXObject("Microsoft.XMLHTTP");
}
if (newAjaxObj == undefined || newAjaxObj == null) {
alert("This website requires that your browser support AJAX. Please update your browser, or use the accesible site links at the bottom of the page to continue.");
}
} catch (e) {
alert("This website requires that your browser support AJAX. Please update your browser, or use the accesible site links at the bottom of the page to continue.");
}
return newAjaxObj;
}
this.doAjaxHandling = function() {
var strCall = this.getNextPriorityOpenCall();
if (strCall == null) {
strCall = this.getNextOpenCall();
}
this.strLastCall = strCall;
this.iIteration++;
if (strCall != null) {
if (this.isLocked() == true && this.calls[strCall].priority == false) {
this.strLastCall = "skip! " + this.isLocked() + " " + this.calls[strCall].priority;
return;
}
this.calls[strCall].state = AJAXQUEUE_STATUS_PROCESSING;
try {
var queueItem = this.calls[strCall];
queueItem.xmlObject.open("GET", queueItem.url, true);
queueItem.xmlObject.send("");
} catch (e) {
queueItem.state = AJAXQUEUE_STATUS_ERROR;
if( this.errorHandler ) {
this.errorHandler( e );
} else {
alert("AjaxQueue: Could not act on ["+strCall+"]:" + e.message);
}
}
}
this.cleanUpCalls();
}
this.getNextOpenCall = function() {
for (var i in this.calls) {
if (this.calls[i].state == AJAXQUEUE_STATUS_QUEUED) {
return i;
}
}
return null;
}
this.getNextPriorityOpenCall = function() {
for (var i in this.calls) {
if (this.calls[i].state == AJAXQUEUE_STATUS_QUEUED && this.calls[i].priority == true) {
return i;
}
}
return null;
}
this.cleanUpCalls = function() {
if (this.bDoCleanup == true) {
for (var i in this.calls) {
if (this.calls[i].state > AJAXQUEUE_STATUS_SENT) {
this.destroyCall(i);
}
}
return;
}
}
this.IsAjaxCapable = function() {
var tmp = this.getNewXMLObject();
if( tmp == undefined || tmp == null ) {
return false;
}
tmp = null;
return true;
}
}
function onReadyStateChangeHelper( strName, strUrl )
{
if( g_AjaxQueue.calls[strName] ) {
if( g_AjaxQueue.calls[strName].state != AJAXQUEUE_STATUS_PROCESSING ) {
return;
}
if (g_AjaxQueue.calls[strName].xmlObject.readyState == 4 ) {
if( g_AjaxQueue.calls[strName].xmlObject.status && g_AjaxQueue.calls[strName].xmlObject.status == 200) {
try {
g_AjaxQueue.calls[strName].callback(g_AjaxQueue.calls[strName].xmlObject);
g_AjaxQueue.calls[strName].state = AJAXQUEUE_STATUS_COMPLETE;
} catch (e) {
g_AjaxQueue.calls[strName].state = AJAXQUEUE_STATUS_ERROR;
if( this.errorHandler ) {
this.errorHandler( e );
} else {
alert("AjaxQueue: callback for ["+strName+"] failed: "+e.message);
}
}
} else if (g_AjaxQueue.calls[strName].xmlObject.status == 404) {
g_AjaxQueue.calls[strName].state = AJAXQUEUE_STATUS_ERROR;
if( this.errorHandler ) {
var e = new Error("404: Page not found, " + strUrl );
this.errorHandler( e );
} else {
alert("AjaxQueue Call Failed for ["+ strName +"]: [" + strUrl + "] Does Not Exist!");
}
} else if (g_AjaxQueue.calls[strName].xmlObject.status == 500) {
g_AjaxQueue.calls[strName].state = AJAXQUEUE_STATUS_ERROR;
if( this.errorHandler ) {
var e = new Error("500: Internal server error, " + strUrl );
this.errorHandler( e );
} else {
alert("AjaxQueue Call Failed for ["+ strName +"]: [" + strUrl + "] Server Error!");
}
}
}
}
}
function AjaxQueueCall(strUrl) {
this.url = strUrl;
this.xmlObject = null;
this.state = AJAXQUEUE_STATUS_PREPPING;
this.callback = null;
this.priority = 0;
}
function AjaxQueueLock(strLockName) {
this.name = strLockName;
this.state = false;
}
function AjaxGetNodeValue(obj, tag)
{
if( obj ) {
var pElement = obj.getElementsByTagName(tag);
if( pElement && pElement[0] ) {
if( pElement[0].firstChild ) {
return pElement[0].firstChild.nodeValue;
}
}
}
return "";
}
g_AjaxQueue = new AjaxQueue();
g_bAjaxEnabled = g_AjaxQueue.IsAjaxCapable();
function fireAjaxQueue() {
if (g_AjaxQueue.bIntervalStarted == false) {
g_AjaxQueue.iIntervalId = setInterval(function(){g_AjaxQueue.doAjaxHandling();}, g_AjaxQueue.iAjaxCallInterval);
g_AjaxQueue.bIntervalStarted == true;
}
}
RfgQueueCommand("fireAjaxQueue();");
var g_strRedirectLegalDisclaimer = "You have selected a link to a website that is not owned or maintained by Coldwell Banker Real Estate Corporation. Different terms of use and privacy policies will apply.";
function ClearDefault(pField, strDefault){
if( pField && pField.value == strDefault ){
pField.value = '';
pField.style.color = '#222';
}
}
function FallBackPopup( strUrl, iWidth, iHeight )
{
wind=window.open(strUrl,'','width='+iWidth+',height='+iHeight+',resizable=yes,scrollbars=yes,status=yes');
if ( wind ) return false;
return true;
}
function EmptyIfEnter(pField)
{
if ( pField ) {
if ( pField.value )
if ( pField.value.length > 5 )
if ( pField.value.indexOf("Enter ") >= 0 || pField.value.indexOf("Entre ") >= 0 || pField.value.indexOf("Introduzca") >= 0 )
pField.value = '';
}
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if ( endstr == -1 )
endstr = document.cookie.length;
return(unescape(document.cookie.substring(offset, endstr)));
}
function FixCookieDate (date) {
var base = new Date(0);
var skew = base.getTime();
date.setTime (date.getTime() - skew);
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while ( i < clen ) {
var j = i + alen;
if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j));
i = document.cookie.indexOf(" ", i) + 1;
if ( i == 0 ) break;
}
return(null);
}
function SetCookie (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
if ( GetCookie(name) ) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
function UrlDecode(strEncodeString)
{
var lsRegExp = /\+/g;
return unescape(String(strEncodeString).replace(lsRegExp, " "));
}
QueryString.keys = new Array();
QueryString.values = new Array();
function QueryString(key) {
var value = null;
for (var i=0;i<QueryString.keys.length;i++) {
if (QueryString.keys[i]==key) {
value = QueryString.values[i];
break;
}
}
return value;
}
function QueryString_Parse() {
QueryString.keys = new Array();
QueryString.values = new Array();
var query = window.location.search.substring(1);
var pairs = query.split("&");
for (var i=0;i<pairs.length;i++) {
var pos = pairs[i].indexOf('=');
if (pos >= 0) {
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
QueryString.keys[QueryString.keys.length] = argname;
QueryString.values[QueryString.values.length] = value;
}
}
}
function SavedQueryString_Parse( strUrl ) {
QueryString.keys = new Array();
QueryString.values = new Array();
if ( strUrl == null ) return;
var query = '';
var qpos = strUrl.indexOf('?');
if( qpos > 0 ){
query = strUrl.substring(qpos+1);
} else {
query = strUrl;
}
var pairs = query.split("&"); for (var i=0;i<pairs.length;i++) {
var pos = pairs[i].indexOf('=');
if (pos >= 0) {
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
QueryString.keys[QueryString.keys.length] = argname;
QueryString.values[QueryString.values.length] = value;
}
}
}
function moneyFormat(input) {
var dollars = Math.floor(input);
var tmp = new String(input);
for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) {
if ( tmp.charAt(decimalAt)=="." )
break;
}
var cents = "" + Math.round(input * 100);
cents = cents.substring(cents.length-2, cents.length)
dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;
if ( cents == "0" )
cents = "00";
return(dollars + "." + cents);
}
function PhoneFormat(strPhone) {
var bFormatted = false;
strPhone = strPhone.toString();
if( strPhone.indexOf('(') > -1 ) bFormatted = true;
if( (strPhone.length > 9) && !bFormatted) {
strFormatted = '(';
strFormatted += strPhone.substring(0, 3);
strFormatted += ') ';
strFormatted += strPhone.substring(3, 6);
strFormatted += '-';
strFormatted += strPhone.substring(6, 10);
if( strPhone.length > 10 ) {
strFormatted += ' x';
strFormatted += strPhone.substring(10, strPhone.length);
}
return strFormatted;
}
return strPhone;
}
function FormatExternalUrlWithLink(strUrl) {
var strLink = '';
strUrl = strUrl.toString();
if( strUrl.length > 0 ) {
var strFqUrl;
var strDisplay;
var iProtocolAt = strUrl.indexOf('://');
if( iProtocolAt > 0 ) {
strFqUrl = strUrl;
strDisplay = strUrl.substring(iProtocolAt + 3);
} else {
strDisplay = strUrl;
strFqUrl = 'http://' + strUrl;
}
var iDirectoryAt = strDisplay.indexOf('/');
if( iDirectoryAt > 0 ) {
strDisplay = strDisplay.substring(0, iDirectoryAt);
}
strLink = '<a href="'+strFqUrl+'" target="_external">' + strDisplay + '</a>';
}
return strLink;
}
function FormatEmailWithLink(strEmail) {
var strLink = '';
strEmail = strEmail.toString();
if( strEmail.length > 0 ) {
var iProtocolAt = strEmail.indexOf('@');
if( iProtocolAt > 0 ) {
strLink = '<a href="mailto:'+strEmail+'">' + strEmail + '</a>';
}
}
return strLink;
}
function IfLinkNotInCbcNetworkForceConfirmation()
{
var strServerName;
if( document.getElementsByTagName ) {
var aTags = document.getElementsByTagName('a');
var iAnchorCount = aTags.length;
for (var i=0; i < iAnchorCount; i++) {
if (! aTags[i].getAttribute('donotaddlegaldisclaimer')) {
if (aTags[i].href) {
strServerName = getServerName(aTags[i].getAttribute('href'));
if (strServerName.length > 0) {
if (!isValidCbcServer(strServerName)) {
aTags[i].onclick = function () { return confirm(g_strRedirectLegalDisclaimer); };
}
}
}
}
}
}
}
function getServerName(strValue)
{
var strServerName;
var iParmLocation;
strServerName = strValue.toLowerCase();
iParmLocation = strServerName.indexOf("?");
if (iParmLocation >= 0) {
strServerName = strServerName.substring(0,iParmLocation);
}
if (strServerName.indexOf("http") == 0) {
iParmLocation = strServerName.indexOf("https://");
if (iParmLocation >= 0) {
strServerName = strServerName.substring((iParmLocation+8),strServerName.length);
}
iParmLocation = strServerName.indexOf("http://");
if (iParmLocation >= 0) {
strServerName = strServerName.substring((iParmLocation+7),strServerName.length);
}
iParmLocation = strServerName.indexOf("/");
if (iParmLocation >= 0) {
strServerName = strServerName.substring(0,iParmLocation);
}
} else {
strServerName = "";
}
return strServerName;
}
function isValidCbcServer(strServerName)
{
var CurrentServer = document.location.host.toLowerCase();
if( strServerName.indexOf(".coldwellbankercommercial.com") >= 0 ){
return true;
}
if( strServerName == "coldwellbankercommercial.com" ){
return true;
}
if( strServerName.indexOf(".realogy.com") >= 0 ){
return true;
}
if( strServerName.indexOf(".instantclientaccess.com") >= 0 ){
return true;
}
if( strServerName == "instantclientaccess.com" ){
return true;
}
if( strServerName == CurrentServer ){
return true;
}
return false;
}
function RestorePreviousFormFill( pForm, strCookieName )
{
if( !pForm || !strCookieName ){
return;
}
SavedQueryString_Parse( GetCookie(strCookieName) );
var iNumElements = pForm.elements.length;
for( var i=0; i < iNumElements; i++ ){
if(pForm.elements[i].type == 'select-one' ) {
var strLast = UrlDecode(QueryString( pForm.elements[i].name ));
if( strLast ) {
for( var j=0; j<pForm.elements[i].length; j++ ){
if( pForm.elements[i][j].value == strLast ){
pForm.elements[i][j].selected = true;
}
}
}
} else if(pForm.elements[i].type == 'text' ) {
var strLast = UrlDecode(QueryString( pForm.elements[i].name ));
if( strLast && strLast != 'null' ){
pForm.elements[i].value = strLast;
}
}
}
QueryString_Parse();
for( var i=0; i < iNumElements; i++ ){
if(pForm.elements[i].type == 'select-one' ) {
var strLast = UrlDecode(QueryString( pForm.elements[i].name ));
if( strLast && strLast.length > 0) {
for( var j=0; j<pForm.elements[i].length; j++ ){
if( pForm.elements[i][j].value == strLast ){
pForm.elements[i][j].selected = true;
}
}
}
} else if(pForm.elements[i].type == 'text' ) {
var strLast = UrlDecode(QueryString( pForm.elements[i].name ));
if( strLast && strLast != 'null' && strLast.length > 0 ){
pForm.elements[i].value = strLast;
}
}
}
}
function CbcImgQuickSwap( pPhotoToSwap, strSrcId, strNewPhoto, strCaption, strLargeFileUrl )
{
var bReturn = true;
if( !pPhotoToSwap ) return;
if ( pPhotoToSwap ) {
if ( pPhotoToSwap.src ) {
pPhotoToSwap.src = strNewPhoto;
bReturn = false;
}
var pLPE = document.getElementById( strSrcId );
if( pLPE ) {
if ( strLargeFileUrl ) {
pLPE.value = strLargeFileUrl;
}
}
}
if( document.getElementById ) {
var pCaption = document.getElementById('photocaption');
if( pCaption ) {
pCaption.innerHTML = strCaption;
}
}
return bReturn;
}
function ShowLargePhotoUrl( strUrl, strCaptionId )
{
var strCaption = '';
var pCaption = document.getElementById(strCaptionId);
if( pCaption ) {
strCaption = pCaption.innerHTML;
}
if( strUrl != '' ) {
var pWinPop = window.open('', 'largeImage', 'width=760,height=540,resizeable=yes');
if( pWinPop ) {
pWinPop.document.write('<html><head><title>Image</title>');
pWinPop.document.write('</head><body>');
pWinPop.document.write('<p align=center><img src="'+strUrl+'"></p><p align=center>');
pWinPop.document.write(strCaption + '</p><p align=center>');
pWinPop.document.write('<a href="Javascript:window.close()">Close Window</a></p>');
pWinPop.document.write(' </body></html>');
setTimeout( function(){ fitWinToPic(pWinPop); }, 1000 );
}
}
}
function fitWinToPic( pWinHandle )
{
if( pWinHandle ) {
if( document.images[0].complete ) {
var NS = (navigator.appName=="Netscape")?true:false;
var iWidth = (NS)?pWinHandle.innerWidth:pWinHandle.document.body.clientWidth;
var iHeight = (NS)?pWinHandle.innerHeight:pWinHandle.document.body.clientHeight;
var iThisWidth = (NS)?window.innerWidth:document.body.clientWidth;
var iThisHeight = (NS)?window.innerHeight:document.body.clientHeight;
if( iWidth > iThisWidth ) iWidth = iThisWidth + 20;
if( iHeight > iThisHeight ) iHeight = iThisHeight + 100;
if( pWinHandle.document.images[0].width > iThisWidth ) pWinHandle.document.images[0].width = iThisWidth - 30;
else if( pWinHandle.document.images[0].height > iThisHeight) pWinHandle.document.images[0].height = iThisHeight - 30;
iWidth = (pWinHandle.document.images[0].width - iWidth) + 20;
iHeight = (pWinHandle.document.images[0].height - iHeight) + 100;
if( (iWidth > 0) || (iHeight > 0) ) {
pWinHandle.resizeBy(iWidth, iHeight);
pWinHandle.focus();
}
} else if ( pWinHandle.document.images[0] ) {
setTimeout( function(){ fitWinToPic(pWinPop); }, 250 );
}
}
}
var g_strRfgClientSupportUrl = '/RfgClientSupportFiles';
var g_pZoomSlider = null;
var g_strAreaMapObjId = 'RFGMAPDIV_1';
var g_bInDragEvent = false;
var g_bInClickEvent = false;
var g_iLastPosX = -1;
var g_iLastPosY = -1;
var g_iPolySeq = 0;
var g_iPolyPointSeq = 0;
var g_polyDrawDynamicLine = null;
var g_polyDrawFillColor = new VEColor(241, 244, 81, 0.25); var g_polyDrawEdgeColor = new VEColor(241, 244, 81, 0.90); var g_polyDrawEdgeWidth = 3;
var g_polyFinishedFillColor = new VEColor(51, 153, 255, 0.15); var g_polyFinishedEdgeColor = new VEColor(17, 5, 125, 0.90); var g_polyFinishedEdgeWidth = 3;
var g_SearchByMapDisplay = false;
var g_PolygonDrawMode = false;
var g_aPolygonDrawPoints = new Array();
var g_MapHelpOpen = false;
var g_Orientation = ["North", "East", "South", "West"];
var g_OrientationCurrent = 0;
var g_iMiniDetailsId = '';
var g_iMAPINITSIZE = 66;
var g_iMAPTIMEINC = 4;
var g_iMAPSIZEADD = 100;
var g_iRSSTHRESHOLD = 10;
try{
if( !alt_map ) {
RfgQueueCommand(escape("RfgCreateMap('RFGMAPDIV_1', 'HybridVE', false, 38.6437, -98.8235, 4, false, true );"));
RfgQueueCommand(escape("g_pAreaMap = RfgGetMapById('RFGMAPDIV_1');"));
RfgQueueCommand(escape("g_pAreaMap.AttachEvent('onendzoom', checkZoom);"));
RfgQueueCommand(escape("document.getElementById('loading').style.visibility = 'hidden';"));
RfgQueueCommand(escape("SetupMapDashboard('RFGMAPDIV_1');"));
RfgQueueCommand(escape("RfgAttachMapEvent( 'RFGMAPDIV_1', Events.ONCHANGEVIEW, SynchronizeZoomSlider );"));
RfgQueueCommand(escape("SetBirdseyeButton();"));
}
}catch( e ){
RfgQueueCommand(escape("RfgCreateMap('RFGMAPDIV_1', 'HybridVE', false, 38.6437, -98.8235, 4, false, true );"));
RfgQueueCommand(escape("g_pAreaMap = RfgGetMapById('RFGMAPDIV_1');"));
RfgQueueCommand(escape("g_pAreaMap.AttachEvent('onendzoom', checkZoom);"));
RfgQueueCommand(escape("document.getElementById('loading').style.visibility = 'hidden';"));
RfgQueueCommand(escape("SetupMapDashboard('RFGMAPDIV_1');"));
RfgQueueCommand(escape("RfgAttachMapEvent( 'RFGMAPDIV_1', Events.ONCHANGEVIEW, SynchronizeZoomSlider );"));
RfgQueueCommand(escape("SetBirdseyeButton();"));
}
function AddOfficePushPin(iCbcOfficeId, latitude, longitude, strName, strCity, mapId){
var strHover = '<span class="proptype">'+ strName +'</span><br />'+ strCity;
var strIcon = '/images/pushpins/propforsale.gif';
if( mapId ) {
AddPushPin(mapId, iCbcOfficeId, parseFloat(latitude), parseFloat(longitude), strHover, strIcon, 'property' );
}else{
AddPushPin('RFGMAPDIV_1', iCbcOfficeId, parseFloat(latitude), parseFloat(longitude), strHover, strIcon, 'property' );
}
}
function AddPropertyPushPin(iCbcListingId, latitude, longitude, strType, strPrice, aSelectedListings, mapId, strContent){
var strIcon;
if( strContent!=null && strContent!="" ) {
var strHover = strContent;
}else{
var strHover = '<span class="proptype">'+ strType +'</span><br />'+ strPrice;
}
if( !aSelectedListings || aSelectedListings.length<1 ) {
aSelectedListings = new Array();
var strCookie = GetCookie("PropCompare");
if( strCookie ){
var aCompare = strCookie.split("|");
for( var i = 0; i < aCompare.length; i++) {
var aProperty = aCompare[i].split('*');
aSelectedListings.push(aProperty[0]);
}
}
}
if( strType.indexOf('Lease') > -1 ) strIcon = '/images/pushpins/propforlease.gif'; else strIcon = '/images/pushpins/propforsale.gif';
for(var j = 0; j < aSelectedListings.length; j++ ) {
if(aSelectedListings[j] == iCbcListingId) {
strIcon = '/images/pushpins/selectedprop.gif';
}
}
if( mapId ) {
AddPushPin(mapId, iCbcListingId, parseFloat(latitude), parseFloat(longitude), strHover, strIcon, 'property' );
}else{
AddPushPin('RFGMAPDIV_1', iCbcListingId, parseFloat(latitude), parseFloat(longitude), strHover, strIcon, 'property' );
}
}
function AddPushPin(strMapId, pinId, fLatitude, fLongitude, strContents, strIcon, type ){
if( fLatitude == 0 && fLongitude == 0 ) return;
if( strIcon == '' ) strIcon = null;
var pMap = g_pRfgMapContainer[strMapId];
if( pMap ) {
try{
g_iPushPinSeq++;
var location = new VELatLong( fLatitude, fLongitude );
var pin = new VEPushpin(("" + pinId), location, strIcon);
if( strMapId=='RFGMAPDIV_3D' ) {
RfgAddPushPin(strMapId, fLatitude, fLongitude, "", strContents, strIcon);
}else{
pMap.AddPushpin(pin);
}
element = document.getElementById(("" + pinId));
if( element ) {
element.onmouseover = function(){
handlePushpinMouseover( pinId, strContents )
};
element.onmouseout = function(){
var pDiv = document.getElementById('RfgMapHoverDiv');
if( pDiv ) {
pDiv.style.display='none';
g_bRfgSearchTipVisible = false;
g_bRfgSearchTipCurrentId = "";
}
};
if( type == 'property' ) {
element.onclick = function(){
showMiniPropertyDetails( pinId );
};
}
}
} catch( xE ){
if( g_bShowErrorInformation ) {
alert( xE.message );
}
}
}
}
function getElementsByClassName(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
}
function EnableBirdseyeIfAvailable() {
if( g_pAreaMap ) {
try {
if( g_pAreaMap.IsBirdseyeAvailable() ) {
g_pAreaMap.SetMapStyle("ObliqueVE");
}
} catch (e) {
}
}
}
function SetBirdseyeButton(){
if( g_pAreaMap ) {
var button = document.getElementById("birdseye_view");
if( g_pAreaMap.IsBirdseyeAvailable() ) {
button.style.backgroundImage = "url(/images/mapcontrols/large_but.gif)";
button.style.backgroundRepeat = "no-repeat";
}else{
if( button.className.search(/off/g)==-1 ) {
button.style.backgroundImage = "url(/images/mapcontrols/large_but_off.gif)";
button.style.backgroundRepeat = "no-repeat";
}
}
}
}
function DelayedEnableBirdseyeIfAvailable() {
setTimeout(EnableBirdseyeIfAvailable, 1000);
}
function SetRssStatusMessage( strMessage )
{
if( document.getElementById ) {
var pRssStatus = document.getElementById("RssStatus");
if( pRssStatus ) {
pRssStatus.innerHTML = strMessage;
}
}
}
function NotifyRssComplete( eObj )
{
CbcHideWaitDialog();
if (g_PolygonDrawMode == true) return;
if( eObj.length == 0 ) {
SetRssStatusMessage('<b>No results found, try expanding your search</b>');
} else {
var iListing = 0;
var iOffice = 0;
var xThisPin = null;
var aLocs = new Array();
for(var i=0; i < eObj.length; i++ ) {
aLocs.push(eObj[i].latlong);
if( eObj[i].dataMarker.icon == '/images/pushpins/office.gif' ) {
iOffice++;
} else {
iListing++;
}
}
if( iListing == 0 ) SetRssStatusMessage('<b>No results found, try expanding your search</b>');
else {
SetRssStatusMessage('<b>' + iListing + '<b>listings found, click the Search button to view them all</b>');
}
}
}
function SynchronizeZoomSlider(){
if( g_pAreaMap ) {
if( g_pZoomSlider ) {
g_pZoomSlider.SetValue(RfgGetZoomLevel(g_strAreaMapObjId));
}
}
}
function ZoomSliderCallback( pSlider )
{
var iNewZoom = pSlider.GetValue();
if( g_pAreaMap && g_pAreaMap.GetZoomLevel() != iNewZoom ) {
g_pAreaMap.SetZoomLevel(iNewZoom);
}
}
function SetupMapDashboard(strMapObjectId)
{
var pMap = g_pRfgMapContainer[strMapObjectId];
if( pMap ) {
var objControl = document.getElementById('map_controls');
var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf( "firefox" ) >= 0 ) {
objControl.style.top = '124px';
objControl.style.left = '248px';
}else{
objControl.style.top = '122px';
objControl.style.left = '246px';
}
try {
g_pZoomSlider = new CyberSlider('mapzoomslider', true, 3, 16, 3,
'/images/mapcontrols/zoombg.jpg', 13, 124, '',
'/images/mapcontrols/zoomfg.gif', 13, 13, ZoomSliderCallback );
} catch (e) {
}
SynchronizeZoomSlider();
pMap.AddControl(objControl, null);
objControl.style.position = 'absolute';
if ( ua.indexOf( "firefox" ) >= 0 ) {
objControl.style.top = '124px';
objControl.style.left = '248px';
}else{
objControl.style.top = '122px';
objControl.style.left = '246px';
}
}
}
function mapDragHandleOnMouseDown( objEvent )
{
if (!objEvent) objEvent = window.event;
g_bInClickEvent = true;
g_iLastPosX = objEvent.pageX?objEvent.pageX:(objEvent.clientX + (document.body.scrollLeft?document.body.scrollLeft:0));
g_iLastPosY = objEvent.pageY?objEvent.pageY:(objEvent.clientY + (document.body.scrollTop?document.body.scrollTop:0));
if( g_iMiniDetailsId != ''){
var pMiniDetails = document.getElementById( 'MapMiniDetailsDiv' );
if ( pMiniDetails ) {
pMiniDetails.style.display = 'none';
}
}
return false;
}
function mapDragHandleOnMouseUp( objEvent )
{
if (!objEvent) objEvent = window.event;
g_bInDragEvent = false;
g_bInClickEvent = false;
g_iLastPosX = objEvent.pageX?objEvent.pageX:(objEvent.clientX + (document.body.scrollLeft?document.body.scrollLeft:0));
g_iLastPosY = objEvent.pageY?objEvent.pageY:(objEvent.clientY + (document.body.scrollTop?document.body.scrollTop:0));
if( g_iMiniDetailsId != ''){
var pMiniDetails = document.getElementById( 'MapMiniDetailsDiv' );
if ( pMiniDetails ) {
var intX = 0;
var intY = 0;
var pElement = document.getElementById( g_iMiniDetailsId );
if( pElement ) {
var coord = RfgPixelFromLatLong(g_strAreaMapObjId, (pElement.vePushpin).GetLatitude(), (pElement.vePushpin).GetLongitude() );
intX = coord.x;
intY = coord.y;
}
RfgSetObjectPosition(pMiniDetails, intX+7, intY - 83);
pMiniDetails.style.display = 'block';
}
}
}
function mapDragHandleOnMouseMove( objEvent )
{
if (!objEvent) objEvent = window.event;
if( g_bInClickEvent ) {
var iCurrPosX = objEvent.pageX?objEvent.pageX:(objEvent.clientX + (document.body.scrollLeft?document.body.scrollLeft:0));
var iCurrPosY = objEvent.pageY?objEvent.pageY:(objEvent.clientY + (document.body.scrollTop?document.body.scrollTop:0));
var iMoveX = g_iLastPosX - iCurrPosX;
var iMoveY = g_iLastPosY - iCurrPosY;
g_iLastPosX = iCurrPosX;
g_iLastPosY = iCurrPosY;
RfgStartPanMap('RFGMAPDIV_1', iMoveX, iMoveY);
RfgStopPanMap('RFGMAPDIV_1');
g_bInDragEvent = true;
}
return false;
}
var g_iTempSeq = 999999999;
function mapPolygonHandleOnMouseMove( objEvent ){
if (!objEvent) objEvent = window.event;
var endVELoc = RfgLatLongFromPixel(g_strAreaMapObjId, objEvent.clientX, objEvent.clientY);
var startVELoc = g_aPolygonDrawPoints[(g_aPolygonDrawPoints.length - 1)];
var aDynamicLine = new Array();
aDynamicLine.push(startVELoc);
aDynamicLine.push(endVELoc);
if( g_polyDrawDynamicLine != null && g_polyDrawDynamicLine.strId != null ) {
try{
g_pAreaMap.DeletePolyline(g_polyDrawDynamicLine.strId);
}catch (e){
}
}
g_polyDrawDynamicLine = new VEPolyline("tmp" + g_iTempSeq, aDynamicLine, g_polyDrawEdgeColor, g_polyDrawEdgeWidth );
g_polyDrawDynamicLine.strId = "tmp" + g_iTempSeq;
g_pAreaMap.AddPolyline(g_polyDrawDynamicLine);
}
function handlePushpinMouseover( iListingId, strTitle ){
if(g_iMiniDetailsId == iListingId ) return;
if ( g_bRfgSearchTipVisible ) {
if( g_objRfgLastTooltip ) {
if( g_objRfgLastTooltip.iListingId == iListingId ) {
return;
}
}
RfgHideSearchToolTip();
}
g_bRfgSearchTipVisible = true;
g_bRfgSearchTipCancelCloseRequest = true;
g_bRfgSearchTipTimeoutActive = true;
g_bRfgSearchTipNeedsRepositioned = false;
if( g_objRfgLastTooltip ) {
g_objRfgLastTooltip.iListingId = iListingId;
}
var intX = 0;
var intY = 0;
var pElement = document.getElementById( ""+ iListingId );
if( pElement ) {
var coord = RfgPixelFromLatLong(g_strAreaMapObjId, (pElement.vePushpin).GetLatitude(), (pElement.vePushpin).GetLongitude() );
intX = coord.x;
intY = coord.y;
}
var pSearchToolTip = document.getElementById( 'RfgMapHoverDiv' );
if ( pSearchToolTip == null ) {
pSearchToolTip = document.createElement("div");
pSearchToolTip.id = 'RfgMapHoverDiv';
pSearchToolTip.style.display = 'none';
document.body.appendChild(pSearchToolTip);
}
pSearchToolTip.innerHTML = '<div class="triangle"></div><div class="shadow"><div class="content">' + strTitle + '</div></div>';
RfgSetObjectPosition(pSearchToolTip, intX+7, intY-20);
pSearchToolTip.style.display = 'block';
}
function polyDrawStartHighlight(){
document.polydrawstart.src = '/images/polydrawstart_on.gif';
}
function polyDrawStartNormal(){
if(document.getElementById("RFGMAPDIV_1").onmousemove == null) {
document.onmousemove = mapPolygonHandleOnMouseMove;
}
document.polydrawstart.src = '/images/polydrawstart.gif';
}
function mapPolygonHandleOnMouseUp( objEvent ){
if (!objEvent) objEvent = window.event;
g_iPolyPointSeq++;
var velatlon = RfgLatLongFromPixel(g_strAreaMapObjId, objEvent.clientX, objEvent.clientY);
if( g_aPolygonDrawPoints.length == 0) {
g_aPolygonDrawPoints.push(velatlon);
document.getElementById("maphelptext").innerHTML = '2. Move to the next point and click.<div style="height:5px;"></div>3. Repeat step 2 as needed.';
document.onmousemove = mapPolygonHandleOnMouseMove;
} else {
g_iPolySeq++;
g_aPolygonDrawPoints.push(velatlon);
g_pAreaMap.DeleteAllPolylines();
g_polyDrawDynamicLine = null;
g_pAreaMap.DeleteAllPolygons();
if( g_aPolygonDrawPoints.length > 2 ) {
var screenloc = RfgPixelFromLatLong(g_strAreaMapObjId, g_aPolygonDrawPoints[0]);
document.getElementById('polydrawimg').style.top = (screenloc.y - (document.polydrawstart.height / 2)) +'px';
document.getElementById('polydrawimg').style.left = (screenloc.x - (document.polydrawstart.width / 2)) +'px';
document.getElementById('polydrawimg').title = 'Click here to complete your polygon and search for properties within its borders.';
document.getElementById("maphelptext").innerHTML = '4. Continue to add points as necessary.<div style="height:5px;"></div>5. To finish drawing and perform the property search, click on the starting point or the <i>Done</i> button.';
document.getElementById("polydrawbuttons").innerHTML = '<a href="Javascript:finishPolygonDraw(event);"><img id="poly_done" src="/images/btnpolydone.gif" border=0 onclick=""></a> <a href="Javascript:restartPolygonDraw();"><img id="poly_restart" src="/images/btnpolyrestart.gif" border=0></a>';
g_pAreaMap.AddPolygon( new VEPolygon("" + g_iPolySeq, g_aPolygonDrawPoints, g_polyDrawFillColor, g_polyDrawEdgeColor, g_polyDrawEdgeWidth));
document.getElementById("poly_done").onmousedown=stopBubble;
document.getElementById("poly_done").onmouseup=finishPolygonDraw;
document.getElementById("poly_done").onclick=finishPolygonDraw;
document.getElementById("poly_done").onmousemove=stopBubble;
document.getElementById("poly_restart").onmousedown=stopBubble;
document.getElementById("poly_restart").onmouseup=restartPolygonDraw;
document.getElementById("poly_restart").onclick=restartPolygonDraw;
document.getElementById("poly_restart").onmousemove=stopBubble;
} else {
g_pAreaMap.AddPolyline(new VEPolyline("" + g_iPolySeq, g_aPolygonDrawPoints, g_polyDrawEdgeColor, g_polyDrawEdgeWidth ));
}
}
}
function CorrectPolygonStart( eObj ){
if( g_PolygonDrawMode ) {
if( g_aPolygonDrawPoints.length > 2 ) {
var screenloc = RfgPixelFromLatLong(g_strAreaMapObjId, g_aPolygonDrawPoints[0]);
document.getElementById('polydrawimg').style.top = (screenloc.y - (document.polydrawstart.height / 2)) +'px';
document.getElementById('polydrawimg').style.left = (screenloc.x - (document.polydrawstart.width / 2)) +'px';
}
}
}
function ClearPropertySearch(){
var pElement = document.getElementById('prop_what_text');
if( pElement ) {
pElement.value = '';
}
var pElement = document.getElementById('prop_where_text');
if( pElement ) {
pElement.value = '';
}
}
function ClearOfficeSearch(){
var pElement = document.getElementById('officename');
if( pElement ) {
pElement.value = '';
}
var pElement = document.getElementById('officestate');
if( pElement ) {
pElement.selectedIndex = 0;
}
var pElement = document.getElementById('officecity');
if( pElement ) {
pElement.value = '';
}
var pElement = document.getElementById('officezip');
if( pElement ) {
pElement.value = '';
}
}
function ClearAgentSearch(){
var pName = document.getElementById('agent_name_first');
if( pName ) {
pName.value = '';
}
pName = document.getElementById('agent_name_last');
if( pName ) {
pName.value = '';
}
}
function DoPolygonSearch(){
if( g_aPolygonDrawPoints.length > 2 ) {
var strParms = '';
for(var i = 0; i < (g_aPolygonDrawPoints.length - 1); i++) {
if( i > 0 ) strParms += '&';
strParms += '&Lat=' + escape(g_aPolygonDrawPoints[i].Latitude);
strParms += '&Lon=' + escape(g_aPolygonDrawPoints[i].Longitude);
}
document.getElementById("polygonsearch_yn").value = 'Y';
document.getElementById("searchpolygon").value = strParms;
switch(aTabs[g_iActiveTabId].name){
case 'property':
ClearPropertySearch();
DoPropertySearch(null, true);
break;
case 'office':
ClearOfficeSearch();
DoOfficeSearch(null);
break;
case 'agent':
ClearAgentSearch();
DoAgentSearch(null);
break;
}
showMapSearchNav();
}
}
function finishPolygonDraw(evt){
if( g_aPolygonDrawPoints.length > 2 ) {
g_PolygonDrawMode = false;
document.onmousedown = null;
document.onmouseup = null;
document.onmousemove = null;
document.getElementById('polydrawimg').style.left = -100 +'px';
RfgClearMap(g_strAreaMapObjId);
var velatlon = new VELatLong(g_aPolygonDrawPoints[0].Latitude, g_aPolygonDrawPoints[0].Longitude);
g_aPolygonDrawPoints.push(velatlon);
g_iPolySeq++;
g_pAreaMap.AddPolygon( new VEPolygon("" + g_iPolySeq, g_aPolygonDrawPoints, g_polyFinishedFillColor, g_polyFinishedEdgeColor, g_polyFinishedEdgeWidth));
document.getElementById("maphelptext").innerHTML = 'To draw a new search area, click the <i>New</i> button.';
document.getElementById("polydrawbuttons").innerHTML = '<a href="Javascript:startPolygonDrawMode();"><img src="/images/btnpolynew.gif" border=0></a>';
DoPolygonSearch();
RfgDetachMapEvent( 'RFGMAPDIV_1', Events.ONCHANGEVIEW, CorrectPolygonStart );
document.getElementById("map_core_mid").onmousemove=null;
document.getElementById("map_core_left").onmousemove=null;
document.getElementById("map_core_right").onmousemove=null;
document.getElementById("map_core_nav").onmousemove=null;
document.getElementById("map_description").onmousemove=null;
document.getElementById("search_window").onmousemove=null;
document.getElementById("main_window").onmousemove=null;
document.getElementById("top_menu").onmousemove=null;
document.getElementById("footer").onmousemove=null;
document.getElementById("cbc_logo").onmousemove=null;
document.getElementById("map_core_mid").onmouseup=null;
document.getElementById("map_core_left").onmouseup=null;
document.getElementById("map_core_right").onmouseup=null;
document.getElementById("map_core_nav").onmouseup=null;
document.getElementById("map_description").onmouseup=null;
document.getElementById("search_window").onmouseup=null;
document.getElementById("main_window").onmouseup=null;
document.getElementById("top_menu").onmouseup=null;
document.getElementById("footer").onmouseup=null;
document.getElementById("cbc_logo").onmouseup=null;
document.getElementById("map_core_mid").onclick=null;
document.getElementById("map_core_left").onclick=null;
document.getElementById("map_core_right").onclick=null;
document.getElementById("map_core_nav").onclick=null;
document.getElementById("map_description").onclick=null;
document.getElementById("search_window").onclick=null;
} else {
alert('You must select at least 3 points before closing the polygon');
}
stopBubble(evt);
return false;
}
function stopBubble(evt){
if (window.event)
window.event.cancelBubble = true;
else{
if( evt ) {
evt.cancelBubble = true;
}
}
return false;
}
function restartPolygonDraw(evt){
if (g_SearchByMapDisplay == true) {
endPolygonDrawMode();
startPolygonDrawMode()
}
return stopBubble(evt);
}
function startPolygonDrawMode(){
while (g_aPolygonDrawPoints.length > 0) {
g_aPolygonDrawPoints.pop();
}
document.onmousedown = null;
document.onmouseup = mapPolygonHandleOnMouseUp;
document.onmousemove = null;
RfgAttachMapEvent( 'RFGMAPDIV_1', Events.ONCHANGEVIEW, CorrectPolygonStart );
document.getElementById("maphelptext").innerHTML = '<b>Outline the area you would like to search.</b><div style="height:5px;"></div>1. Move to a starting point on the map and click.';
document.getElementById("polydrawbuttons").innerHTML = '<a href="Javascript:restartPolygonDraw();"><img id="poly_restart" src="/images/btnpolyrestart.gif" border=0></a>';
document.getElementById("poly_restart").onmousedown=stopBubble;
document.getElementById("poly_restart").onmouseup=restartPolygonDraw;
document.getElementById("poly_restart").onclick=restartPolygonDraw;
document.getElementById("poly_restart").onmousemove=stopBubble;
document.getElementById("description_close").onmousemove=stopBubble;
document.getElementById("description_close").onmouseup=mapHelpClose;
document.getElementById("description_close").onclick=mapHelpClose;
document.getElementById("map_core_mid").onmousemove=stopBubble;
document.getElementById("map_core_left").onmousemove=stopBubble;
document.getElementById("map_core_right").onmousemove=stopBubble;
document.getElementById("map_core_nav").onmousemove=stopBubble;
document.getElementById("map_description").onmousemove=stopBubble;
document.getElementById("search_window").onmousemove=stopBubble;
document.getElementById("main_window").onmousemove=stopBubble;
document.getElementById("top_menu").onmousemove=stopBubble;
document.getElementById("footer").onmousemove=stopBubble;
document.getElementById("cbc_logo").onmousemove=stopBubble;
document.getElementById("map_core_mid").onmouseup=stopBubble;
document.getElementById("map_core_left").onmouseup=stopBubble;
document.getElementById("map_core_right").onmouseup=stopBubble;
document.getElementById("map_core_nav").onmouseup=stopBubble;
document.getElementById("map_description").onmouseup=stopBubble;
document.getElementById("search_window").onmouseup=stopBubble;
document.getElementById("main_window").onmouseup=stopBubble;
document.getElementById("top_menu").onmouseup=stopBubble;
document.getElementById("footer").onmouseup=stopBubble;
document.getElementById("cbc_logo").onmouseup=stopBubble;
document.getElementById("map_core_mid").onclick=stopBubble;
document.getElementById("map_core_left").onclick=stopBubble;
document.getElementById("map_core_right").onclick=stopBubble;
document.getElementById("map_core_nav").onclick=stopBubble;
document.getElementById("map_description").onclick=stopBubble;
document.getElementById("search_window").onclick=stopBubble;
RfgClearMap(g_strAreaMapObjId);
g_PolygonDrawMode = true;
}
function endPolygonDrawMode(){
document.onmousedown = null;
document.onmouseup = null;
document.onmousemove = null;
RfgClearMap(g_strAreaMapObjId);
while (g_aPolygonDrawPoints.length > 0) {
g_aPolygonDrawPoints.pop();
}
document.getElementById('polydrawimg').style.left = -100 +'px';
g_PolygonDrawMode = false;
}
function hideMapSearchNav(){
var pLocation = document.getElementById('location_search');
if( !pLocation ){
var pLocation = document.getElementById('agent_search');
}
if( pLocation ){
pLocation.style.visibility = 'visible';
}
document.getElementById("search_by_location_button").style.visibility = "hidden";
document.getElementById('property_map_overlay').style.visibility = 'hidden';
}
function endSearchByMap(){
if (g_SearchByMapDisplay == true) {
if (g_MapHelpOpen == true) {
mapHelpClose();
}
endPolygonDrawMode();
g_SearchByMapDisplay = false;
SetCookie("WTSC", "PSQ", "", "/", false);
document.getElementById("polygonsearch_yn").value = '';
document.getElementById("searchpolygon").value = '';
}
hideMapSearchNav();
}
function showMapSearchNav(){
if (g_bLeftNavLoaded == true) {
var pLocation = document.getElementById('location_search');
if( !pLocation ){
var pLocation = document.getElementById('agent_search');
}
if( pLocation ){
pLocation.style.visibility = 'hidden';
}
reheightMain(0, MAIN_WINDOW_INCREMENT, MAIN_WINDOW_TIMING, "postMainShrink();");
document.getElementById('search_by_location_button').style.visibility = 'visible';
document.getElementById('property_map_overlay').style.visibility = 'visible';
} else {
setTimeout(showMapSearchNav, 150);
}
}
function startSearchByMap(){
if (g_SearchByMapDisplay != true) {
mapHelpOpen();
document.getElementById("maphelptext").innerHTML = 'To draw a search area on the map, click on the <i>Start</i> button below.';
document.getElementById("polydrawbuttons").innerHTML = '<a href="Javascript:startPolygonDrawMode();"><img src="/images/btnpolystart.gif" border=0></a>';
showMapSearchNav();
g_SearchByMapDisplay = true;
SetCookie("WTSC", "PSM", "", "/", false);
}else{
document.getElementById("maphelptext").innerHTML = 'To draw a search area on the map, click on the <i>Start</i> button below.';
document.getElementById("polydrawbuttons").innerHTML = '<a href="Javascript:startPolygonDrawMode();"><img src="/images/btnpolystart.gif" border=0></a>';
}
}
function toggleSearchByMap(){
if (g_SearchByMapDisplay == true) {
endSearchByMap();
} else {
startSearchByMap();
}
}
function toggleHelpOpen(){
if (g_MapHelpOpen == true) {
mapHelpClose();
}else{
mapHelpOpen();
}
}
function mapHelpOpen() {
if (g_MapHelpOpen == true) {
return;
}
g_SearchByMapDisplay = true;
var button = document.getElementById("map_draw");
if( button.className.search("active")==-1 ) {
button.className += " active";
}
var helptext = document.getElementById('maphelptext');
var helpbuttons = document.getElementById('polydrawbuttons');
helptext.display='none';
helpbuttons.display="none";
var helpbox = document.getElementById('map_description');
helpbox.height='0px';
helpbox.style.visibility='visible';
for (var i = 0 ; i <= 120 ; i++) {
setTimeout('document.getElementById("map_description").style.height = "'+(i)+'px";', i * g_iMAPTIMEINC);
}
setTimeout("document.getElementById('maphelptext').display='inline';", (111* g_iMAPTIMEINC));
setTimeout("document.getElementById('polydrawbuttons').display='inline';", (112* g_iMAPTIMEINC));
g_MapHelpOpen = true;
var iDelay = 100 * g_iMAPTIMEINC;
}
function mapHelpClose(evt) {
if (g_MapHelpOpen == false) {
return;
}
var button = document.getElementById("map_draw");
if( button.className.search("active")!=-1 ) {
button.className = button.className.replace(/active/g, "");
}
document.getElementById('maphelptext').display='none';
document.getElementById('polydrawbuttons').display="none";
var helpbox = document.getElementById('map_description');
helpbox.height='0px';
for (var i = 120 ; i >= 0 ; i--) {
setTimeout('document.getElementById("map_description").style.height = "'+(i)+'px";', (120-i) * g_iMAPTIMEINC);
}
setTimeout("document.getElementById('map_description').style.visibility='hidden';", (121* g_iMAPTIMEINC));
var draw_button = document.getElementById("map_draw");
draw_button.className = draw_button.className.replace(/active/g, "");
g_MapHelpOpen = false;
return stopBubble(evt);
}
function activateNavButton(obj, group){
if (obj.id=="birdseye_view"){
if( g_pAreaMap.IsBirdseyeAvailable() ) {
var activeFields = getElementsByClassName("active", document.getElementById("map_controls"));
for( var i=0; i<activeFields.length; i++ ) {
if( activeFields[i].className.search(group)!=-1) {
activeFields[i].className = activeFields[i].className.replace(/active/g, "");
}
}
obj.className = obj.className + " active";
}
}else{
var activeFields = getElementsByClassName("active", document.getElementById("map_controls"));
for( var i=0; i<activeFields.length; i++ ) {
if( activeFields[i].className.search(group)!=-1) {
activeFields[i].className = activeFields[i].className.replace(/active/g, "");
}
}
obj.className = obj.className + " active";
}
}
function setMapStyle(style){
RfgSetMapStyle('RFGMAPDIV_1', style);
if( style=='ObliqueVE' && g_pAreaMap.IsBirdseyeAvailable() ) {
document.getElementById('rotate_right').style.display="inline";
document.getElementById('rotate_left').style.display="inline";
var core_left = document.getElementById('map_core_left');
core_left.className = core_left.className+" big";
document.getElementById('3D').style.backgroundImage = "url(/images/mapcontrols/small_but_off.gif)";
}else{
document.getElementById('rotate_right').style.display="none";
document.getElementById('rotate_left').style.display="none";
var core_left = document.getElementById('map_core_left');
core_left.className = core_left.className.replace("big", "");
g_OrientationCurrent = 0;
document.getElementById('map_core_nav_img').src = "/images/mapcontrols/core_nav_n.gif";
document.getElementById('3D').style.backgroundImage = "url(/images/mapcontrols/small_but.gif)";
}
}
function rotateOrientation(dir){
if( dir=='left' ) {
g_OrientationCurrent--;
if( g_OrientationCurrent<0 ) {
g_OrientationCurrent = g_Orientation.length-1;
}
}else{
g_OrientationCurrent++;
if( g_OrientationCurrent>=g_Orientation.length ) {
g_OrientationCurrent = 0;
}
}
var dir_image = document.getElementById('map_core_nav_img');
switch( g_Orientation[g_OrientationCurrent] ) {
case 'North':
dir_image.src = "/images/mapcontrols/core_nav_n.gif";
g_pAreaMap.SetBirdseyeOrientation(VEOrientation.North);
break;
case 'South':
dir_image.src = "/images/mapcontrols/core_nav_s.gif";
g_pAreaMap.SetBirdseyeOrientation(VEOrientation.South);
break;
case 'East':
dir_image.src = "/images/mapcontrols/core_nav_e.gif";
g_pAreaMap.SetBirdseyeOrientation(VEOrientation.East);
break;
case 'West':
dir_image.src = "/images/mapcontrols/core_nav_w.gif";
g_pAreaMap.SetBirdseyeOrientation(VEOrientation.West);
break;
}
}
function open3dMap(){
var zoom = g_pAreaMap.GetZoomLevel();
var style = g_pAreaMap.GetMapStyle();
if( style=='o' ) {
return;
}
var winW = 800;
var winH = 600;
if( typeof( window.innerWidth ) == 'number' ) {
winW = window.innerWidth;
winH = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
winW = document.documentElement.clientWidth;
winH = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
winW = document.body.clientWidth;
winH = document.body.clientHeight;
}
var velatlong = g_pAreaMap.GetCenter();
var latlong = String(velatlong).split(",", 2);
var lat = latlong[0];
var lon = latlong[1];
lon = lon.replace( /^\s+/g, "" ); lon = lon.replace( /\s+$/g, "" );
var officetab = document.getElementById('tab_link_office');
var maptype='property';
if( officetab.className.search('active')>=0) {
maptype='office';
}
var newWindow = window.open('/enhanced/map3d.php?zoom='+zoom+'&lat='+lat+'&lon='+lon+'&style='+style+'&maptype='+maptype,'','scrollbars=no,menubar=no,height='+winH+',width='+winW+',resizable=yes,toolbar=no,location=no,status=no');
}
function checkZoom(){
var velatlong = g_pAreaMap.GetCenter();
var latlong = String(velatlong).split(",", 2);
var lat = (latlong[0]);
var lon = latlong[1];
if(lon){
lon = lon.replace( /^\s+/g, "" ); lon = (lon.replace( /\s+$/g, "" )); }
var zoom = g_pAreaMap.GetZoomLevel();
var style = g_pAreaMap.GetMapStyle();
if(zoom>13){
if(style!='r'){
if (lat && lon && !(lon<0 && lon>-125 && lon<-66.8 && lat>0 && lat<49 && lat>24.5)){
g_pAreaMap.SetZoomLevel(13);
}
}
}
return false;
}
var g_iAgentSearchAttempts = 0;
function Initialize_AgentSearch()
{
if (g_AjaxQueue.isLocked("LeftNavLoaded") == false &&
g_AjaxQueue.isLocked("MainDataLoaded") == false) {
try {
var pSearch = document.getElementById("init_what");
if( pSearch && pSearch.value != '' && pSearch.value != 'Professional Last Name') {
document.getElementById('agent_name_last').value = pSearch.value;
pSearch.value = '';
}
setBreadcrumb(0, "Our Professionals", "CloseProfileDialog('profile_pane')", true);
displayBreadcrumb();
document.getElementById("agent_name_first").onkeyup = agentTextSubmit;
document.getElementById("agent_name_last").onkeyup = agentTextSubmit;
} catch ( e ) { }
g_AjaxQueue.disengageLock("TabTransition");
g_AjaxQueue.registerLock("DoingAgentSearch");
setTimeout(applySavedAgentSearch, 500);
SetCookie("WTSC", "PSS", "", "/", false);
} else {
setTimeout(Initialize_AgentSearch, 250);
return;
}
}
function Destroy_AgentSearch() {
g_AjaxQueue.unregisterLock("DoingAgentSearch");
}
function ShowAgent( strCbcPersonKey ) {
OpenLink('/ajaxhtmlbin/agent?cbcpersonkey='+strCbcPersonKey,
'profile-agent',
null,
'Professional Profile');
}
function handleAgentSearchResults(responseXML) {
try {
if( g_strActiveMainDialog != 'searchagent' ) {
return;
}
CloseProfileDialog( "profile_pane" );
SetPendingHistoryProfile();
var oWindow = document.getElementById("agent_results");
if( oWindow ) {
oWindow.innerHTML = '';
oWindow.scrollTop = 0;
oWindow.scrollLeft = 0;
var results = responseXML.getElementsByTagName('agent');
var elePar = null;
var eleCld = null;
var eleA = null;
var eleCon = null;
var eleImg = null;
if( results.length == 0 ) {
oWindow.innerHTML = '<div class="noresults">No results found</div>';
}
var iNumResults = getNodeValue(responseXML, 'numresults');
var iCurrLimit = getNodeValue(responseXML, 'limit');
var iCurrOffset = getNodeValue(responseXML, 'offset');
var strPageLinks = GetPaginatedPageLinks('DoAgentSearch', iNumResults, iCurrLimit, iCurrOffset);
var strCurrentlyShowing = GetCurrentlyShowing(iNumResults, iCurrLimit, iCurrOffset);
SetInnerHtml('agent_bottom_page_links', strPageLinks);
SetInnerHtml('agent_top_page_links', strPageLinks);
SetInnerHtml('agent_bottom_curr_showing', strCurrentlyShowing);
SetInnerHtml('agent_top_curr_showing', strCurrentlyShowing);
for (var i=0; i<results.length; i++) {
var cbcPersonKey = getNodeValue(results[i], 'personkey');
var cbcOfficeKey = getNodeValue(results[i], 'officekey');
var strImg = '/images/nophoto/person.gif';
var strTemp = getNodeValue(results[i], 'miniprofilephoto');
if( strTemp ) {
strImg = strTemp;
}
var strPKPrefix = cbcPersonKey.substr(0, 3);
var strPKNumber = cbcPersonKey.substr(3);
var strEmailLink = "/emailto/agent.php?id=" + strPKNumber + "&src=" + strPKPrefix;
elePar = document.createElement('div');
elePar.className = 'agent';
eleCon = document.createElement('div');
eleCon.className = 'person_icon_container';
eleA = document.createElement("a");
eleA.setAttribute('href', "Javascript:ShowAgent('"+ cbcPersonKey +"');");
eleImg = document.createElement("img");
eleImg.setAttribute('src', strImg);
eleImg.className = 'person_icon';
eleA.appendChild(eleImg);
eleCon.appendChild(eleA);
elePar.appendChild(eleCon);
eleCld = document.createElement('div');
eleCld.className = 'name_title';
eleCld.innerHTML = '<h4><a href="Javascript:ShowAgent(\''+cbcPersonKey+'\');">' + getNodeValue(results[i],'firstname') + " " + getNodeValue(results[i],'lastname') + '</h4></a>' +
'<b>' + getNodeValue(results[i], 'title') + '</b>' +
getNodeValue(results[i], 'specialties').replace(/,/, "<br />");
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'address';
eleCld.innerHTML = getNodeValue(results[i],'address') +
'<br />' +
getNodeValue(results[i],'city') + ", " + getNodeValue(results[i],'state') + " " + getNodeValue(results[i],'zip');
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'email_phone';
eleCld.innerHTML =
'<a class="bodyHref" '+
'onclick="return OpenLink(\''+strEmailLink+'\', \'contact-agent\', this);" '+
'title="Contact Professional" href="'+strEmailLink+'">Email this professional</a>' +
'<br />' +
PhoneFormat(getNodeValue(results[i],'phone'));
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'actions';
eleCld.innerHTML = '<a href="Javascript:ShowAgent(\''+cbcPersonKey+'\');"><img src="/images/buttons/profile.gif" class="profilebtn" border="0" align="middle" /></a>';
elePar.appendChild(eleCld);
oWindow.appendChild(elePar);
}
g_AjaxQueue.disengageLock("DoingAgentSearch");
dcsMultiTrack('DCS.dcsuri',location.href,'WT.ti','Our Professionals','WT.si_n', 'AgentSearch','WT.si_x','1');
pageTracker._trackPageview("AgentSearch");
} else {
alert("Could not display search results (1).");
}
} catch (e) {
alert("Could not display search results. " + e.message);
}
}
function setAgentBrowseTabs(strActiveTab) {
var pTab;
var idx;
var aChars = new Array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' );
var strActiveTab = strActiveTab.toString();
strActiveTab = strActiveTab.toLowerCase();
for( idx in aChars ) {
pTab = document.getElementById('agentbrowse_' + aChars[idx]);
if( pTab ) {
if( aChars[idx] == strActiveTab ) {
pTab.className = 'active';
} else {
pTab.className = '';
}
}
}
}
function DoAgentSearch(iOffset) {
g_iAgentSearchAttempts = 0;
setAgentBrowseTabs('');
var strUrl = '/xmlbin/searchagent?limit=20';
if( iOffset ) {
strUrl += "&offset=" + escape(iOffset);
}
aElSpecialties = document.getElementsByName('specialty');
var bSpecialtyChecked = false;
for (var i = 0; i < aElSpecialties.length; i++) {
var el = aElSpecialties[i];
if (el.checked) {
strUrl += '&specialty=' + escape(el.value);
bSpecialtyChecked = true;
}
}
if(bSpecialtyChecked) strUrl += '&specialty=General';
var pCbcCompanyKey=document.getElementById('cbccompanykey');
if(pCbcCompanyKey && pCbcCompanyKey.value!='') {
strUrl += "&cbccompanykey=" + escape(trim(pCbcCompanyKey.value));
}
var pFirst=document.getElementById('agent_name_first');
var pLast=document.getElementById('agent_name_last');
if( pFirst && pFirst.value != '' && pFirst.value != 'Professional First Name') {
strUrl += "&firstname=" + escape(trim(pFirst.value));
}
if( pLast && pLast.value != '' && pLast.value != 'Professional Last Name') {
strUrl += "&lastname=" + escape(trim(pLast.value));
if( pLast.value.length == 1 ) {
setAgentBrowseTabs(pLast.value);
}
}
var pPolygonMode = document.getElementById('polygonsearch_yn');
if( pPolygonMode && pPolygonMode.value == 'Y' ) {
var pPolygon = document.getElementById('searchpolygon');
if( pPolygon && pPolygon.value != '' ) {
strUrl += pPolygon.value;
}
}
CbcShowWaitDialog();
var fCallback = function(pCbcAjaxReq) {
CbcHideWaitDialog();
g_AjaxQueue.engageLock("DoingAgentSearch");
if(pCbcAjaxReq.readyState == 4 && pCbcAjaxReq.status == 200) {
handleAgentSearchResults(pCbcAjaxReq.responseXML);
}
}
g_AjaxQueue.schedule("AgentSearch", strUrl, fCallback);
SetCookie("cbcw_savedagent", strUrl);
}
function DoAgentBrowse(strLetter) {
var pLast=document.getElementById('agent_name_last');
if( pLast ) {
pLast.value = strLetter;
}
DoAgentSearch();
return;
}
function agentTextSubmit(e) {
if (!e) e = window.event;
if (checkForEnter(e)) {
DoAgentSearch();
}
}
function applySavedAgentSearch() {
var strUrl = GetCookie("cbcw_savedagent");
if ((strUrl == undefined || strUrl == null) ||
document.getElementById("init_what").value != '' ||
document.getElementById("init_where").value != '') {
document.getElementById("init_what").value = '';
document.getElementById("init_where").value = '';
DoAgentSearch();
return;
}
var aPairSplit;
var aSearchKeys = new Array();
aGetPairs = strUrl.split("?")[1].split("&");
for (var i in aGetPairs) {
aPairSplit = aGetPairs[i].split('=');
aSearchKeys[aPairSplit[0]] = aPairSplit[1];
}
if (aSearchKeys["firstname"] != undefined) {
document.getElementById("agent_name_first").value = UrlDecode(aSearchKeys["firstname"]);
}
if (aSearchKeys["lastname"] != undefined) {
document.getElementById("agent_name_last").value = UrlDecode(aSearchKeys["lastname"]);
}
DoAgentSearch();
}
var g_iMarketIntelSearchAttempts = 0;
function Initialize_MarketIntelSearch()
{
if (g_AjaxQueue.isLocked("LeftNavLoaded") == false &&
g_AjaxQueue.isLocked("MainDataLoaded") == false) {
try {
g_AjaxQueue.registerLock("DoingMarketIntelSearch");
g_AjaxQueue.registerLock("MarketIntelDisambiguate");
g_AjaxQueue.registerLock("InitMarketIntel");
g_AjaxQueue.engageLock("InitMarketIntel");
var pWhat = document.getElementById('init_what');
if( pWhat && pWhat.value != '' && pWhat.value != 'Keyword') {
document.getElementById('report_what_text').value = pWhat.value;
}
var pLegend = document.getElementById('map_legend_foreground');
if( pLegend && pLegend.src ) {
pLegend.src = '/images/CbcWW_MarketIntelLegend_Foreground.gif';
}
setBreadcrumb(0, "Market Intelligence Reports", "CloseProfileDialog('profile_pane')", true);
displayBreadcrumb();
} catch ( e ) { }
g_AjaxQueue.disengageLock("TabTransition");
setTimeout(applySavedMarketIntelSearch, 500);
} else {
setTimeout(Initialize_MarketIntelSearch, 250);
return;
}
}
function Destroy_MarketIntelSearch() {
g_AjaxQueue.unregisterLock("DoingMarketIntelSearch");
g_AjaxQueue.unregisterLock("MarketIntelDisambiguate");
}
function handleMarketIntelSearchResults(responseXML) {
try {
if( g_strActiveMainDialog != 'searchmarket' ) {
return;
}
CloseProfileDialog( "profile_pane" );
SetPendingHistoryProfile();
g_pAreaMap.DeleteAllPushpins();
var oWindow = document.getElementById("reports_results");
if( oWindow ) {
oWindow.innerHTML = '';
oWindow.scrollTop = 0;
oWindow.scrollLeft = 0;
var results = responseXML.getElementsByTagName('marketintelresult');
var elePar = null;
var eleCld = null;
var eleA = null;
var eleImg = null;
if( results.length == 0 ) {
var eleChoice = responseXML.getElementsByTagName("error");
if (eleChoice.length > 0) {
oWindow.innerHTML = '<div class="noresults">Could not complete search.</div>';
} else {
oWindow.innerHTML = '<div class="noresults">No results found</div>';
}
}
var iNumResults = getNodeValue(responseXML, 'numresults');
var iCurrLimit = getNodeValue(responseXML, 'limit');
var iCurrOffset = getNodeValue(responseXML, 'offset');
var strPageLinks = GetPaginatedPageLinks('DoMarketIntelSearch', iNumResults, iCurrLimit, iCurrOffset);
var strCurrShowing = GetCurrentlyShowing(iNumResults, iCurrLimit, iCurrOffset);
SetInnerHtml('reports_bottom_page_links', strPageLinks);
SetInnerHtml('reports_bottom_curr_showing', strCurrShowing);
SetInnerHtml('reports_top_page_links', strPageLinks);
SetInnerHtml('reports_top_curr_showing', strCurrShowing);
var strCurrentServer = document.location.host.toLowerCase();
for (var i=0; i<results.length;i++) {
var thisreport = results[i];
var cbcMarketIntelKey = getNodeValue(thisreport, 'marketdata_id');
var strPropertytype_desc = getNodeValue(thisreport, 'propertytype_desc');
var strTimeframe_desc = getNodeValue(thisreport, 'timeframe_desc');
var strDatayear = getNodeValue(thisreport, 'datayear');
var strMsa = getNodeValue(thisreport, 'msa');
var strCity = getNodeValue(thisreport, 'city');
var strHeadline = getNodeValue(thisreport, 'headline');
var strLoc = (strMsa.length>0 && strCity.length>0) ? strLoc = strCity + " | " + strMsa : strMsa+strCity;
var strType = 'profile-office';
var strUrl = '/marketdata.php?id=' + cbcMarketIntelKey;
var strLink = 'OpenLink(\''+strUrl+'\', \''+strType+'\', this);';
var strOnClick = 'onClick="return '+ strLink +'"';
var strPhotoUrl = '/images/nophoto/article.gif';
var strTitle = strHeadline;
var strDescription = strTimeframe_desc + ' ' + strDatayear + ', ' + strPropertytype_desc;
if( strUrl.indexOf('://' ) == -1 ) {
strUrl = 'http://' + strCurrentServer + strUrl;
}
elePar = document.createElement('div');
elePar.className = 'result';
eleA = document.createElement("a");
eleA.setAttribute('title', strTitle);
eleA.setAttribute("href", "javascript:ShowMarketIntel('"+cbcMarketIntelKey+"')");
eleImg = document.createElement("img");
eleImg.setAttribute('border', 0);
eleImg.setAttribute('src', strPhotoUrl);
eleImg.className = 'office_icon';
eleA.appendChild(eleImg);
elePar.appendChild(eleA);
eleCld = document.createElement('div');
eleCld.className = 'description';
if( strDescription.length == 200 ) strDescription += '...';
eleCld.innerHTML = '<h3><a href="'+strUrl+'" '+strOnClick+' title="'+strTitle+'">' + strTitle + '</a></h3>' +
strDescription + '<br />' +
'<span class="resulturl">' + strLoc + '</span>';
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'actions';
eleCld.innerHTML = '<a href="'+strUrl+'" '+strOnClick+' title="'+strTitle+'"><img src="/images/buttons/view.gif" class="viewbtn" border="0" align="middle" /></a>';
elePar.appendChild(eleCld);
oWindow.appendChild(elePar);
}
g_AjaxQueue.disengageLock("DoingMarketIntelSearch");
} else {
alert("Could not display search results (1).");
}
} catch (e) {
alert("Could not display search results. " + e.message);
}
}
function DoMarketIntelSearch(iOffset) {
g_iMarketIntelSearchAttempts = 0;
var bIncludeSale = true;
var bIncludeLease = true;
var strUrl = '/searchmarketintel.php?limit=20';
if( iOffset ) {
strUrl += "&offset=" + escape(iOffset);
}
var pCbcCompanyKey=document.getElementById('cbccompanykey');
if(pCbcCompanyKey && pCbcCompanyKey.value!='') {
strUrl += "&cbccompanykey=" + escape(trim(pCbcCompanyKey.value));
}
var pMarketIntelWhat=document.getElementById('report_what_text');
if( pMarketIntelWhat && pMarketIntelWhat.value != '' && pMarketIntelWhat.value != 'Keyword') {
strUrl += "&what=" + escape(trim(pMarketIntelWhat.value));
}
if( document.getElementById('frm').checked ) strUrl += "&listingtype[]=frm";
if( document.getElementById('hos').checked ) strUrl += "&listingtype[]=hos";
if( document.getElementById('ind').checked ) strUrl += "&listingtype[]=ind";
if( document.getElementById('lnd').checked ) strUrl += "&listingtype[]=lnd";
if( document.getElementById('mfa').checked ) strUrl += "&listingtype[]=mfa";
if( document.getElementById('off').checked ) strUrl += "&listingtype[]=off";
if( document.getElementById('ret').checked ) strUrl += "&listingtype[]=ret";
if( document.getElementById('shc').checked ) strUrl += "&listingtype[]=shc";
if( document.getElementById('spc').checked ) strUrl += "&listingtype[]=spc";
if( document.getElementById('oth').checked ) strUrl += "&listingtype[]=oth";
CbcShowWaitDialog();
var fCallback = function(pCbcAjaxReq) {
CbcHideWaitDialog();
g_AjaxQueue.engageLock("DoingMarketIntelSearch");
handleMarketIntelSearchResults(pCbcAjaxReq.responseXML);
}
g_AjaxQueue.disengageLock("InitMarketIntel");
g_AjaxQueue.schedule("MarketIntelSearch", strUrl, fCallback);
SetCookie("cbcw_savedreports", strUrl);
}
function officeTextSubmit(e) {
if (!e) e = window.event;
if (checkForEnter(e)) {
DoMarketIntelSearch();
}
}
function applySavedMarketIntelSearch() {
var strUrl = GetCookie("cbcw_savedreports");
if ((strUrl == undefined || strUrl == null) ||
document.getElementById("init_what").value != '' ||
document.getElementById("init_where").value != '') {
g_AjaxQueue.disengageLock("InitMarketIntel");
document.getElementById("init_what").value = '';
document.getElementById("init_where").value = '';
DoMarketIntelSearch();
return;
}
var aPairSplit;
var aSearchKeys = new Array();
aSearchKeys['listingtype'] = new Array();
aGetPairs = strUrl.split("?")[1].split("&");
for (var i in aGetPairs) {
aPairSplit = aGetPairs[i].split('=');
if (aPairSplit[0] == "listingtype") {
aSearchKeys["listingtype"].push(aPairSplit[1]);
} else {
aSearchKeys[aPairSplit[0]] = aPairSplit[1];
}
}
if (aSearchKeys["what"]) {
document.getElementById("report_what_text").value = UrlDecode(aSearchKeys["what"]);
}
for (i in aSearchKeys['listingtype']) {
try {
var strCheck = aSearchKeys['listingtype'][i].substr(1, 3);
document.getElementById(strCheck).checked = true;
} catch (e) {
alert("Saved Search Push ["+i+"]: " + e.message);
}
}
DoMarketIntelSearch();
}
function MarketIntelFormatExternalUrlWithLink(strUrl) {
var strLink = '';
strUrl = strUrl.toString();
if( strUrl.length > 0 ) {
var strFqUrl;
var strDisplay;
var iProtocolAt = strUrl.indexOf('://');
if( iProtocolAt > 0 ) {
strFqUrl = strUrl;
strDisplay = strUrl.substring(iProtocolAt + 3);
} else {
strDisplay = strUrl;
strFqUrl = 'http://' + strUrl;
}
var iDirectoryAt = strDisplay.indexOf('/');
if( iDirectoryAt > 0 ) {
strDisplay = strDisplay.substring(0, iDirectoryAt);
}
strLink = '<a onclick="logMarketIntelSite(this);" href="'+strFqUrl+'" target="_external">' + strDisplay + '</a>';
}
return strLink;
}
function ShowMarketIntel( strMarketIntelKey ) {
OpenLink('/marketdata.php?id=' + strMarketIntelKey,
'profile-office',
null,
'Market Report');
}
function logMarketIntelSite(eleLink) {
return false;
}
var g_iOfficeSearchAttempts = 0;
function Initialize_OfficeSearch()
{
if (g_AjaxQueue.isLocked("LeftNavLoaded") == false &&
g_AjaxQueue.isLocked("MainDataLoaded") == false) {
try {
g_AjaxQueue.registerLock("DoingOfficeSearch");
g_AjaxQueue.registerLock("OfficeDisambiguate");
g_AjaxQueue.registerLock("InitOffice");
g_AjaxQueue.engageLock("InitOffice");
var pWhat = document.getElementById('init_what');
if( pWhat && pWhat.value != '' && pWhat.value != 'Office Name') {
document.getElementById('officename').value = pWhat.value;
}
var pWhere = document.getElementById('init_where');
if( pWhere && pWhere.value != '' && pWhere.value != 'City, State or Zipcode') {
document.getElementById('officewhere').value = pWhere.value;
}
var pLegend = document.getElementById('map_legend_foreground');
if( pLegend && pLegend.src ) {
pLegend.src = '/images/CbcWW_OfficeLegend_Foreground.gif';
}
setBreadcrumb(0, "Our Locations", "CloseProfileDialog('profile_pane')", true);
displayBreadcrumb();
document.getElementById("officename").onkeyup = officeTextSubmit;
document.getElementById("officewhere").onkeyup = officeTextSubmit;
document.getElementById("officecity").onkeyup = officeTextSubmit;
document.getElementById("officezip").onkeyup = officeTextSubmit;
} catch ( e ) { }
g_AjaxQueue.disengageLock("TabTransition");
setTimeout(applySavedOfficeSearch, 500);
SetCookie("WTSC", "PSO", "", "/", false);
} else {
setTimeout(Initialize_OfficeSearch, 250);
return;
}
}
function Destroy_OfficeSearch() {
g_AjaxQueue.unregisterLock("DoingOfficeSearch");
g_AjaxQueue.unregisterLock("OfficeDisambiguate");
}
function ShowOffice( strCbcOfficeKey ) {
OpenLink('/ajaxhtmlbin/office?cbcofficekey='+strCbcOfficeKey,
'profile-office',
null,
'Office Profile');
}
function MapOffice( cbcOfficeKey, latitude, longitude, strOfficeDBA ) {
try {
var oLatLon = new VELatLong(latitude, longitude);
g_pAreaMap.SetCenterAndZoom( oLatLon, 15 );
var pElement = document.getElementById( ""+ cbcOfficeKey );
if( !pElement ) {
var strHover = '<span class="proptype">Coldwell Banker Commercial</span><br />' + strOfficeDBA;
AddPushPin('RFGMAPDIV_1', cbcOfficeKey, parseFloat(latitude), parseFloat(longitude), strHover, '/images/pushpins/officeicon.gif', 'office' );
}
toggleMainWindow();
dcsMultiTrack('DCS.dcsuri',
'WT.ti',
'Find-An-Office',
'WT.si_n',
'OfficeSearch',
'WT.si_x',
'4',
'WT.z_engage_type',
'Indirect',
'WT.z_engage_event',
'Map');
pageTracker._trackPageview("OfficeSearch/Map");
} catch (e) {
alert("Could not map office, " + e.message);
}
}
function handle3dOfficeSearchResults(responseXML) {
try {
g_pAreaMap.DeleteAllPushpins();
var results = responseXML.getElementsByTagName('officeresult');
for (var i=0; i<results.length;i++) {
var thisofficecollection = results[i].getElementsByTagName('office');
var thisoffice = null;
if( thisofficecollection && thisofficecollection[0] ) {
thisoffice = thisofficecollection[0];
} else {
continue;
}
var cbcOfficeKey = getNodeValue(thisoffice, 'officekey');
var latitude = getNodeValue(thisoffice, 'latitude');
var longitude = getNodeValue(thisoffice, 'longitude');
var strCity = getNodeValue(thisoffice,'city');
var strName = getNodeValue(thisoffice,'officename');
AddOfficePushPin(cbcOfficeKey, latitude, longitude, strName, strCity, 'RFGMAPDIV_3D');
}
} catch (e) {
alert("Could not display 3d office search results. " + e.message);
}
}
function handleOfficeSearchResults(responseXML) {
try {
if( g_strActiveMainDialog != 'searchoffice' ) {
return;
}
CloseProfileDialog( "profile_pane" );
SetPendingHistoryProfile();
g_pAreaMap.DeleteAllPushpins();
var oWindow = document.getElementById("office_results");
if( oWindow ) {
oWindow.innerHTML = '';
oWindow.scrollTop = 0;
oWindow.scrollLeft = 0;
var results = responseXML.getElementsByTagName('officeresult');
var elePar = null;
var eleCld = null;
var eleA = null;
var eleImg = null;
if( results.length == 0 ) {
var eleChoice = responseXML.getElementsByTagName("item");
if (eleChoice.length > 0) {
office_generateDisambiguation(responseXML);
} else {
var eleChoice = responseXML.getElementsByTagName("error");
if (eleChoice.length > 0) {
oWindow.innerHTML = '<div class="noresults">Could not complete search.</div>';
} else {
oWindow.innerHTML = '<div class="noresults">No results found</div>';
}
}
}
var aLatLongPoints = new Array();
var strImgLinks = '';
var iNumResults = getNodeValue(responseXML, 'numresults');
var iCurrLimit = getNodeValue(responseXML, 'limit');
var iCurrOffset = getNodeValue(responseXML, 'offset');
var strPageLinks = GetPaginatedPageLinks('DoOfficeSearch', iNumResults, iCurrLimit, iCurrOffset);
var strCurrShowing = GetCurrentlyShowing(iNumResults, iCurrLimit, iCurrOffset);
SetInnerHtml('office_bottom_page_links', strPageLinks);
SetInnerHtml('office_bottom_curr_showing', strCurrShowing);
SetInnerHtml('office_top_page_links', strPageLinks);
SetInnerHtml('office_top_curr_showing', strCurrShowing);
for (var i=0; i<results.length;i++) {
var thisofficecollection = results[i].getElementsByTagName('office');
var thisoffice = null;
if( thisofficecollection && thisofficecollection[0] ) {
thisoffice = thisofficecollection[0];
} else {
continue;
}
var distance = getNodeValue(results[i], 'distance');
var cbcOfficeKey = getNodeValue(thisoffice, 'officekey');
var latitude = getNodeValue(thisoffice, 'latitude');
var longitude = getNodeValue(thisoffice, 'longitude');
var strImg = '/images/nophoto/office.gif';
var strAddress = getNodeValue(thisoffice,'address') + '<br />'
+ getNodeValue(thisoffice,'city') + ", " + getNodeValue(thisoffice,'state') + " " + getNodeValue(thisoffice,'zip');
var strPhone = getNodeValue(thisoffice,'phone');
var strWebUrl = getNodeValue(thisoffice,'additionalwebsiteurl');
elePar = document.createElement('div');
elePar.className = 'office';
var pBlueprint = thisoffice.getElementsByTagName('blueprintprofile');
if( pBlueprint && pBlueprint[0] && pBlueprint[0].firstChild ) {
var strPhone = getNodeValue(pBlueprint[0],'phone');
var strWebUrl = getNodeValue(pBlueprint[0],'url');
var pMedia = pBlueprint[0].getElementsByTagName('officemedia');
var strTemp = getPrimaryMediaUrl(pMedia);
if( strTemp != '' ) {
strImg = strTemp;
}
}
eleA = document.createElement("a");
eleA.setAttribute('href', "Javascript:ShowOffice('"+ cbcOfficeKey +"');");
eleImg = document.createElement("img");
eleImg.setAttribute('border', 0);
eleImg.setAttribute('src', strImg);
eleImg.className = 'office_icon';
eleA.appendChild(eleImg);
elePar.appendChild(eleA);
eleCld = document.createElement('div');
eleCld.className = 'office_name';
var strOfficeDBA = getNodeValue(thisoffice,'officedba');
var strTitle = 'Coldwell Banker Commercial<br />' + strOfficeDBA;
eleCld.innerHTML = '<h4><a href="Javascript:ShowOffice(\''+cbcOfficeKey+'\');">' + strTitle + '</a></h4>';
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'csz';
eleCld.innerHTML = strAddress;
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'distance';
var fDistance = parseFloat( distance );
if( fDistance != NaN && fDistance > 0 ) {
var m = Math.pow(10, 2);
var strTmp = parseInt(fDistance * m, 10) / m;
strTmp += ' miles';
eleCld.innerHTML = strTmp;
}
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'actions';
strImgLinks = '<a href="Javascript:ShowOffice(\''+cbcOfficeKey+'\');"><img src="/images/buttons/view.gif" class="viewbtn" border="0" align="middle" /></a><br />';
if( latitude != 0 && longitude != 0 ) {
var strHover = '<span class="proptype">Coldwell Banker Commercial</span><br />' + strOfficeDBA;
AddPushPin('RFGMAPDIV_1', cbcOfficeKey, parseFloat(latitude), parseFloat(longitude), strHover, '/images/pushpins/officeicon.gif', 'office' );
strImgLinks += '<a href="Javascript:MapOffice(\''+cbcOfficeKey+'\', '+latitude+', '+longitude+', \''+ strOfficeDBA +'\');"><img src="/images/buttons/map.gif" class="mapbtn" border="0" align="middle" /></a>';
aLatLongPoints.push( new VELatLong(parseFloat(latitude), parseFloat(longitude)) );
} else {
strImgLinks += '<img src="/images/buttons/map_disabled.gif" class="mapbtn" border="0" align="middle" />';
}
eleCld.innerHTML = strImgLinks;
elePar.appendChild(eleCld);
oWindow.appendChild(elePar);
}
if( aLatLongPoints.length > 0 ) {
RfgResizeMapToPoints('RFGMAPDIV_1', aLatLongPoints);
}
dcsMultiTrack('DCS.dcsuri',location.href,'WT.ti','Find-An-Office','WT.si_n','OfficeSearch','WT.si_x','1');
pageTracker._trackPageview("OfficeSearch");
g_AjaxQueue.disengageLock("DoingOfficeSearch");
} else {
alert("Could not display search results (1).");
}
} catch (e) {
alert("Could not display search results. " + e.message);
}
}
function DoOfficeSearch(iOffset) {
g_iOfficeSearchAttempts = 0;
var strUrl = '/xmlbin/searchoffice?limit=20';
if( iOffset ) {
strUrl += "&offset=" + escape(iOffset);
}
var pPolygonMode = document.getElementById('polygonsearch_yn');
if( pPolygonMode && pPolygonMode.value == 'Y' ) {
var pPolygon = document.getElementById('searchpolygon');
if( pPolygon && pPolygon.value != '' ) {
strUrl += pPolygon.value;
}
}
var pCbcCompanyKey=document.getElementById('cbccompanykey');
if(pCbcCompanyKey && pCbcCompanyKey.value!='') {
strUrl += "&cbccompanykey=" + escape(trim(pCbcCompanyKey.value));
}
var pOfficeName=document.getElementById('officename');
if( pOfficeName && pOfficeName.value != '' && pOfficeName.value != 'Office Name') {
strUrl += "&officename=" + escape(trim(pOfficeName.value));
}
var pOfficeWhere=document.getElementById('officewhere');
if( pOfficeWhere && pOfficeWhere.value != '' && pOfficeWhere.value != 'City, State or Zipcode') {
strUrl += "&where=" + escape(trim(pOfficeWhere.value));
}
if( g_sCountry ) {
strUrl += "&country=" + g_sCountry;
}
var pOfficeState=document.getElementById('officestate');
if( pOfficeState && pOfficeState.selectedIndex > 0 ) {
strUrl += "&state=" + escape( pOfficeState[pOfficeState.selectedIndex].value );
}
var pOfficeCity=document.getElementById('officecity');
if( pOfficeCity && pOfficeCity.value != '' && pOfficeCity.value != 'City' ) {
strUrl += "&city=" + escape(trim(pOfficeCity.value));
}
var pOfficeZip=document.getElementById('officezip');
if( pOfficeZip && pOfficeZip.value != '' && pOfficeZip.value != 'Zip Code' ) {
strUrl += "&zip=" + escape(trim(pOfficeZip.value));
}
var pSort = document.getElementById("office_sort");
if (pSort && pSort.selectedIndex) {
strUrl += "&sort=" + pSort[pSort.selectedIndex].value + "-asc";
}
CbcShowWaitDialog();
var fCallback = function(pCbcAjaxReq) {
CbcHideWaitDialog();
g_AjaxQueue.engageLock("DoingOfficeSearch");
handleOfficeSearchResults(pCbcAjaxReq.responseXML);
}
g_AjaxQueue.disengageLock("InitOffice");
g_AjaxQueue.schedule("OfficeSearch", strUrl, fCallback);
var dtExpiration = (new Date((new Date()).getTime() + 30*150000));
SetCookie("cbcw_savedoffice", strUrl, dtExpiration, "/enhanced", null, false);
}
function officeTextSubmit(e) {
if (!e) e = window.event;
if (checkForEnter(e)) {
DoOfficeSearch();
}
}
function applySavedOfficeSearch() {
var strUrl = GetCookie("cbcw_savedoffice");
if ((strUrl == undefined || strUrl == null) ||
document.getElementById("init_what").value != '' ||
document.getElementById("init_where").value != '') {
g_AjaxQueue.disengageLock("InitOffice");
document.getElementById("init_what").value = '';
document.getElementById("init_where").value = '';
DoOfficeSearch();
return;
}
var aPairSplit;
var aSearchKeys = new Array();
aGetPairs = strUrl.split("?")[1].split("&");
for (var i in aGetPairs) {
aPairSplit = aGetPairs[i].split('=');
aSearchKeys[aPairSplit[0]] = aPairSplit[1];
}
if (aSearchKeys["officename"]) {
document.getElementById("officename").value = UrlDecode(aSearchKeys["officename"]);
}
if (aSearchKeys["officecity"]) {
document.getElementById("officecity").value = UrlDecode(aSearchKeys["city"]);
}
if (aSearchKeys["zip"]) {
document.getElementById("officezip").value = UrlDecode(aSearchKeys["zip"]);
}
var oState = document.getElementById("officestate");
if (aSearchKeys["state"]) {
for (var x in oState.options) {
if (oState.options[x].value == aSearchKeys["state"]) {
oState.options[x].selected = true;
}
}
}
DoOfficeSearch();
}
function ToggleOfficeSearchType(strType) {
var pCitySt = document.getElementById('citystatezip');
var pWhere = document.getElementById('wheresearch');
if( strType == 'citystatezip' ) {
pCitySt.style.display = 'block';
pWhere.style.display = 'none';
document.getElementById('officewhere').value = '';
} else {
pCitySt.style.display = 'none';
pWhere.style.display = 'block';
document.getElementById("officecity").value = '';
document.getElementById("officestate").selectedIndex = 0;
document.getElementById("officezip").value = '';
}
}
function OfficeFormatExternalUrlWithLink(strUrl) {
var strLink = '';
strUrl = strUrl.toString();
if( strUrl.length > 0 ) {
var strFqUrl;
var strDisplay;
var iProtocolAt = strUrl.indexOf('://');
if( iProtocolAt > 0 ) {
strFqUrl = strUrl;
strDisplay = strUrl.substring(iProtocolAt + 3);
} else {
strDisplay = strUrl;
strFqUrl = 'http://' + strUrl;
}
var iDirectoryAt = strDisplay.indexOf('/');
if( iDirectoryAt > 0 ) {
strDisplay = strDisplay.substring(0, iDirectoryAt);
}
strLink = '<a onclick="logOfficeSite(this);" href="'+strFqUrl+'" target="_external">' + strDisplay + '</a>';
}
return strLink;
}
function logOfficeSite(eleLink) {
dcsMultiTrack('DCS.dcsuri',location.href,'WT.ti','Find-An-Office','WT.si_n','OfficeSearch',
'WT.si_x','4','WT.z_engage_type','Indirect','WT.z_engage_event','Office Weblink');
pageTracker._trackPageview("OfficeSearch/OfficeWeblink");
return false;
}
function office_openDPopup(strHtml) {
var eleBg = document.getElementById("disambiguate_bg");
var eleDis = document.getElementById("disambiguate_canvas");
SetInnerHtml("disambiguate_canvas", strHtml);
eleBg.style.visibility = "visible";
eleDis.style.visibility = "visible";
}
function office_closeDPopup() {
var eleBg = document.getElementById("disambiguate_bg");
var eleDis = document.getElementById("disambiguate_canvas");
eleBg.style.visibility = "hidden";
eleDis.innerHTML = '';
eleDis.style.visibility = "hidden";
g_AjaxQueue.disengageLock("OfficeDisambiguate");
}
function office_generateDisambiguation(responseXML) {
var strCanvas = '';
var elements = responseXML.getElementsByTagName("item");
var strPlace = '';
var node;
g_AjaxQueue.engageLock("OfficeDisambiguate");
strCanvas = "<h3>More than one location matched your search, please select one.</h3><ul>";
for (var i = 0 ; i < elements.length ; i++) {
strPlace = elements[i].firstChild.nodeValue;
strCanvas += "<li><a href='javascript:DisambiguateOfficeSearch(\""+ escape(strPlace) +"\");'>"+strPlace+"</a></li>";
}
strCanvas += "</ul><a class='close' href='javascript:office_closeDPopup();'>X</a>";
office_openDPopup(strCanvas);
}
function DisambiguateOfficeSearch(strWhere) {
document.getElementById("officewhere").value = UrlDecode(strWhere);
g_AjaxQueue.disengageLock("OfficeDisambiguate");
DoOfficeSearch();
office_closeDPopup();
}
var g_oPriceSlider = null;
var g_oSqFtSlider = null;
var g_oAcreSlider = null;
var g_iPropSearchAttempts = 0;
var g_bUseMosaic = true;
var g_bInPropertySearch = false;
var g_sCountry = 'US';
var g_iSqFtMin = 1000;
var g_iSqFtMax = 20000;
var g_iAcreMin = 0;
var g_iAcreMax = 20;
var g_iPriceMin = 1000;
var g_iPriceMax = 1000000;
var PRICE_SLIDER_LOW = 0;
var PRICE_SLIDER_HIGH = 60;
var g_AdvancedPane_ButtonIncrement = 20;
var g_AdvancedPane_WindowIncrement = 20;
var g_AdvancedPane_WindowSpacing = 40;
var g_AdvancedPane_Expanded = false;
function Initialize_PropSearch(bNoSave) {
if(isLandOnly()) {
document.getElementById("div_sqft").style.display = "none";
document.getElementById("div_acre").style.display = "block";
}else{
document.getElementById("div_sqft").style.display = "block";
document.getElementById("div_acre").style.display = "none";
}
if (g_AjaxQueue.isLocked("LeftNavLoaded") == false &&
g_AjaxQueue.isLocked("MainDataLoaded") == false) {
try {
g_AjaxQueue.registerLock("DoingPropertySearch");
g_AjaxQueue.registerLock("PropSliders");
g_AjaxQueue.registerLock("PropDisambiguate");
g_AjaxQueue.registerLock("InitProperty");
g_AjaxQueue.engageLock("InitProperty");
var pWhat = document.getElementById('init_what');
if(pWhat && pWhat.value != '' && pWhat.value != 'Keyword') {
document.getElementById('prop_what_text').value = pWhat.value;
}
var pWhere = document.getElementById('init_where');
if(pWhere && pWhere.value != '' && pWhere.value != 'City, State or Zipcode') {
document.getElementById('prop_where_text').value = pWhere.value;
}
var pLegend = document.getElementById('map_legend_foreground');
if( pLegend && pLegend.src ) {
pLegend.src = '/images/CbcWW_Legend_Foreground.gif';
}
setBreadcrumb(0, "Search Properties", "CloseProfileDialog('profile_pane')", true);
displayBreadcrumb();
document.getElementById("price_slider_low").onclick = function() {
document.getElementById("price_manual_low").value = getPriceFromSliderPosition(g_oPriceSlider.GetLowValue(), getPurchType());
fader("set_price_low", 0, 100, 2) ;
setTimeout('document.getElementById("price_manual_low").focus();', 250);
setTimeout('document.getElementById("price_manual_low").select();', 250);
}
document.getElementById("go_price_manual_low").onclick = function() {
var iMin = getSliderPositionFromPrice(document.getElementById("price_manual_low").value, getPurchType());
g_oPriceSlider.SetValues(iMin, g_oPriceSlider.GetHighValue(), true);
fader("set_price_low", 100, 0, 2);
}
document.getElementById("price_slider_high").onclick = function() {
document.getElementById("price_manual_high").value = getPriceFromSliderPosition(g_oPriceSlider.GetHighValue(), getPurchType());
fader("set_price_high", 0, 100, 2);
setTimeout('document.getElementById("price_manual_high").focus();', 250);
setTimeout('document.getElementById("price_manual_high").select();', 250);
}
document.getElementById("go_price_manual_high").onclick = function() {
var iMax = getSliderPositionFromPrice(document.getElementById("price_manual_high").value, getPurchType());
var iCurLow = g_oPriceSlider.GetLowValue();
g_oPriceSlider.SetValues(iCurLow, iMax, true);
fader("set_price_high", 100, 0, 2);
}
document.getElementById("sqft_slider_low").onclick = function() {
document.getElementById("sqft_manual_low").value = g_oSqFtSlider.GetLowValue();
fader("set_sqft_low", 0, 100, 2);
setTimeout('document.getElementById("sqft_manual_low").focus();', 250);
setTimeout('document.getElementById("sqft_manual_low").select();', 250);
}
document.getElementById("go_sqft_manual_low").onclick = function() {
var iMin = parseInt(document.getElementById("sqft_manual_low").value);
g_oSqFtSlider.SetValues(iMin, g_oSqFtSlider.GetHighValue(), true);
fader("set_sqft_low", 100, 0, 2);
}
document.getElementById("sqft_slider_high").onclick = function() {
document.getElementById("sqft_manual_high").value = g_oSqFtSlider.GetHighValue();
fader("set_sqft_high", 0, 100, 2);
setTimeout('document.getElementById("sqft_manual_high").focus();', 250);
setTimeout('document.getElementById("sqft_manual_high").select();', 250);
}
document.getElementById("go_sqft_manual_high").onclick = function() {
var iMax = parseInt(document.getElementById("sqft_manual_high").value);
var iCurLow = g_oSqFtSlider.GetLowValue();
if (iMax > g_iSqFtMax) {
g_iSqFtMax = iMax;
reinitializeSliders();
}
g_oSqFtSlider.SetValues(iCurLow, iMax, true);
fader("set_sqft_high", 100, 0, 2);
}
document.getElementById("acre_slider_low").onclick = function() {
document.getElementById("acre_manual_low").value = g_oAcreSlider.GetLowValue();
fader("set_acre_low", 0, 100, 2);
setTimeout('document.getElementById("acre_manual_low").focus();', 250);
setTimeout('document.getElementById("acre_manual_low").select();', 250);
}
document.getElementById("go_acre_manual_low").onclick = function() {
var iMin = parseInt(document.getElementById("acre_manual_low").value);
g_oAcreSlider.SetValues(iMin, g_oAcreSlider.GetHighValue(), true);
fader("set_acre_low", 100, 0, 2);
}
document.getElementById("acre_slider_high").onclick = function() {
document.getElementById("acre_manual_high").value = g_oAcreSlider.GetHighValue();
fader("set_acre_high", 0, 100, 2);
setTimeout('document.getElementById("acre_manual_high").focus();', 250);
setTimeout('document.getElementById("acre_manual_high").select();', 250);
}
document.getElementById("go_acre_manual_high").onclick = function() {
var iMax = parseInt(document.getElementById("acre_manual_high").value);
var iCurLow = g_oAcreSlider.GetLowValue();
if (iMax > g_iAcreMax) {
g_iAcreMax = iMax;
reinitializeSliders();
}
g_oAcreSlider.SetValues(iCurLow, iMax, true);
fader("set_acre_high", 100, 0, 2);
}
document.getElementById("prop_what_text").onkeyup = propertyTextSubmit;
document.getElementById("prop_where_text").onkeyup = propertyTextSubmit;
document.getElementById("proptype_dropdown").onchange = function() {
var strVal = this.options[this.selectedIndex].value;
OnPropertyPurchaseTypeChange(strVal);
}
} catch ( e ) { }
g_AjaxQueue.engageLock("PropSliders");
initializeSliders();
document.getElementById("property_advanced_filters").onclick = function () {
toggleExpandFilters(this);
}
document.getElementById("as_close_button").onclick = function() {
propertyCollapseFilters();
}
SetCookie("WTSC", "PSQ", "", "/", false);
setTimeout(applySavedPropertySearch, 500);
} else {
setTimeout(Initialize_PropSearch, 250);
return;
}
}
function Destroy_PropSearch() {
if (g_AdvancedPane_Expanded == true) {
propertyCollapseFilters(true);
}
if (g_AjaxQueue.isLocked("PropSliders") == false) {
if( g_oPriceSlider ) {
g_oPriceSlider.Destroy();
g_oPriceSlider = null;
}
if( g_oSqFtSlider ) {
g_oSqFtSlider.Destroy();
g_oSqFtSlider = null;
}
if( g_oAcreSlider ) {
g_oAcreSlider.Destroy();
g_oAcreSlider = null;
}
}
g_AjaxQueue.unregisterLock("DoingPropertySearch");
g_AjaxQueue.unregisterLock("PropSliders");
g_AjaxQueue.unregisterLock("PropDisambiguate");
g_AjaxQueue.unregisterLock("InitProperty");
}
function initializeSliders() {
if( !document.getElementById('price_slider')) {
setTimeout(initializeSliders, 250);
return;
}
try {
g_oPriceSlider = new CyberDualSlider('price_slider', false, PRICE_SLIDER_LOW, PRICE_SLIDER_HIGH, PRICE_SLIDER_LOW, PRICE_SLIDER_HIGH, '/images/slider_bg.gif', 196, 8, 'width: auto;', '/images/slider_widget.gif', '/images/slider_widget.gif', 13, 13, onPropPriceSlideDrop, onPropPriceSlideMove);
} catch (e) {
g_AjaxQueue.engageLock("PropSliders");
return;
}
try {
g_oSqFtSlider = new CyberDualSlider('sqft_slider', false, g_iSqFtMin, g_iSqFtMax, g_iSqFtMin, g_iSqFtMax, '/images/slider_bg.gif', 196, 8, 'width: auto;', '/images/slider_widget.gif', '/images/slider_widget.gif', 13, 13, onPropSqFtSlideDrop, onPropSqFtSlideMove);
} catch (e) {
g_AjaxQueue.engageLock("PropSliders");
return;
}
try {
g_oAcreSlider = new CyberDualSlider('acre_slider', false, g_iAcreMin, g_iAcreMax, g_iAcreMin, g_iAcreMax, '/images/slider_bg.gif', 196, 8, 'width: auto;', '/images/slider_widget.gif', '/images/slider_widget.gif', 13, 13, onPropAcreSlideDrop, onPropAcreSlideMove);
} catch (e) {
g_AjaxQueue.engageLock("PropSliders");
return;
}
g_AjaxQueue.disengageLock("TabTransition");
g_AjaxQueue.disengageLock("PropSliders");
onPropPriceSlideMove(g_oPriceSlider);
onPropSqFtSlideMove(g_oSqFtSlider);
onPropAcreSlideMove(g_oAcreSlider);
}
function testIntInRange(iTest, iLow, iHigh, iRetFail) {
var iReturn;
if (iTest < iLow | iTest > iHigh) {
iReturn = iRetFail;
} else {
iReturn = iTest;
}
return iReturn;
}
function reinitializeSliders(bSkipSet) {
var iPriceLow = g_iPriceMin;
var iPriceHigh = g_iPriceMax;
var iSqFtLow = g_iSqFtMin;
var iSqFtHigh = g_iSqFtMax;
var iAcreLow = g_iAcreMin;
var iAcreHigh = g_iAcreMax;
g_oPriceSlider.Destroy();
g_oSqFtSlider.Destroy();
g_oAcreSlider.Destroy();
g_AjaxQueue.engageLock("PropSliders");
try {
g_oPriceSlider = new CyberDualSlider('price_slider', false, PRICE_SLIDER_LOW, PRICE_SLIDER_HIGH, PRICE_SLIDER_LOW, PRICE_SLIDER_HIGH, '/images/slider_bg.gif', 196, 8, 'width: auto;', '/images/slider_widget.gif', '/images/slider_widget.gif', 13, 13, onPropPriceSlideDrop, onPropPriceSlideMove);
} catch (e) {
g_AjaxQueue.engageLock("PropSliders");
return;
}
try {
g_oSqFtSlider = new CyberDualSlider('sqft_slider', false, g_iSqFtMin, g_iSqFtMax, iSqFtLow, iSqFtHigh, '/images/slider_bg.gif', 196, 8, 'width: auto;', '/images/slider_widget.gif', '/images/slider_widget.gif', 13, 13, onPropSqFtSlideDrop, onPropSqFtSlideMove);
} catch (e) {
g_AjaxQueue.engageLock("PropSliders");
return;
}
try {
g_oAcreSlider = new CyberDualSlider('acre_slider', false, g_iAcreMin, g_iAcreMax, iAcreLow, iAcreHigh, '/images/slider_bg.gif', 196, 8, 'width: auto;', '/images/slider_widget.gif', '/images/slider_widget.gif', 13, 13, onPropAcreSlideDrop, onPropAcreSlideMove);
} catch (e) {
g_AjaxQueue.engageLock("PropSliders");
return;
}
g_AjaxQueue.disengageLock("PropSliders");
onPropSqFtSlideMove(g_oSqFtSlider);
onPropAcreSlideMove(g_oAcreSlider);
onPropPriceSlideMove(g_oPriceSlider);
DoPropertySearch();
}
function onPropSqFtSlideMove(pSlider) {
if (g_AjaxQueue.isLocked("PropSliders") == false) {
var iLow = pSlider.GetLowValue();
var iHigh = pSlider.GetHighValue();
if( iLow == g_iSqFtMin ) { iLow = 'No minimum'; }
else iLow = addCommas(iLow);
if( iHigh == g_iSqFtMax ) { iHigh = 'No limit'; }
else iHigh = addCommas(iHigh);
document.getElementById("sqft_slider_low").innerHTML = iLow;
document.getElementById("sqft_slider_high").innerHTML = iHigh;
}
}
function onPropSqFtSlideDrop(pSlider) {
onPropSqFtSlideMove(pSlider);
DoPropertySearch();
}
function onPropAcreSlideMove(pSlider) {
if (g_AjaxQueue.isLocked("PropSliders") == false) {
var iLow = pSlider.GetLowValue();
var iHigh = pSlider.GetHighValue();
if( iLow == g_iAcreMin ) { iLow = 'No minimum'; }
else iLow = addCommas(iLow);
if( iHigh == g_iAcreMax ) { iHigh = 'No limit'; }
else iHigh = addCommas(iHigh);
document.getElementById("acre_slider_low").innerHTML = iLow;
document.getElementById("acre_slider_high").innerHTML = iHigh;
}
}
function onPropAcreSlideDrop(pSlider) {
onPropAcreSlideMove(pSlider);
DoPropertySearch();
}
function onPropPriceSlideMove(pSlider) {
if (g_AjaxQueue.isLocked("PropSliders") == false) {
var iLow = pSlider.GetLowValue();
var iHigh = pSlider.GetHighValue();
pPurchaseType = document.getElementById("proptype_dropdown");
if( pPurchaseType ) {
var strPurchType = pPurchaseType[pPurchaseType.selectedIndex].value
} else {
var strPruchType = "sa";
}
if( iLow == PRICE_SLIDER_LOW ) {
iLow = 'No minimum';
} else {
iLow = addCommas(getPriceFromSliderPosition(iLow, strPurchType));
}
if( iHigh == PRICE_SLIDER_HIGH ) {
iHigh = 'No limit';
} else {
iHigh = addCommas(getPriceFromSliderPosition(iHigh, strPurchType));
}
document.getElementById("price_slider_low").innerHTML = '$' + iLow;
document.getElementById("price_slider_high").innerHTML = '$' + iHigh;
}
}
function onPropPriceSlideDrop(pSlider) {
onPropPriceSlideMove(pSlider);
DoPropertySearch();
}
function handle3dPropertySearchResults(responseXML){
try{
g_pAreaMap.DeleteAllPushpins();
var aSelectedListings = new Array();
var strCookie = GetCookie("PropCompare");
if( strCookie ){
var aCompare = strCookie.split("|");
for( var i = 0; i < aCompare.length; i++) {
var aProperty = aCompare[i].split('*');
aSelectedListings.push(aProperty[0]);
}
}
var results = responseXML.getElementsByTagName('result');
var eleContainer = null;
var elePar = null;
var eleCld = null;
var eleA = null;
var eleImg = null;
if( results.length == 0 ) {
var eleChoice = responseXML.getElementsByTagName("item");
if (eleChoice.length > 0) {
generateDisambiguation(responseXML);
} else {
oWindow.innerHTML = '<div class="noresults">No results found</div>';
}
}
var aLatLongPoints = new Array();
var strImgLinks = '';
var iNumResults = getNodeValue(responseXML, 'numresults');
var iCurrLimit = getNodeValue(responseXML, 'limit');
var iCurrOffset = getNodeValue(responseXML, 'offset');
for (var i=0; i<results.length;i++) {
var listing = null;
var listingcollection = results[i].getElementsByTagName('listing');
if( listingcollection && listingcollection[0] ) {
listing = listingcollection[0];
} else {
continue;
}
var iCbcListingId = getNodeValue(listing, 'listingid');
var strImageUri = getNodeValue(listing, 'imagepreviewuri');
var latitude = getNodeValue(listing, 'latitude');
var longitude = getNodeValue(listing, 'longitude');
var strType = getNodeValue(listing,'listingtype');
var strPrice = '';
var iPrice = parseInt(getNodeValue(listing,'baseprice'));
var cDisplayPrice = getNodeValue(listing,'displayprice');
if( cDisplayPrice == 'Y' ) {
strPrice = '$' + addCommas(iPrice);
} else {
strPrice = '$call';
}
var strName = getNodeValue(listing, 'name');
var strAddress = getNodeValue(listing, 'address1');
var strCity = getNodeValue(listing, 'city');
var strState = getNodeValue(listing, 'stateprovince');
var strZip = getNodeValue(listing, 'postalcode');
if( latitude != 0 && longitude != 0 ) {
aLatLongPoints.push( new VELatLong(parseFloat(latitude), parseFloat(longitude)) );
handlePopulate3dMiniProfile( listing );
}
}
} catch (e) {
alert("Could not display 3d search results. " + e.message);
}
}
function handlePropertySearchResults(responseXML) {
try {
if( g_strActiveMainDialog != 'searchproperty' ) {
return;
}
CloseProfileDialog( "profile_pane" );
SetPendingHistoryProfile();
g_pAreaMap.DeleteAllPushpins();
hideMiniProfile();
var aSelectedListings = new Array();
var strCookie = GetCookie("PropCompare");
if( strCookie ){
var aCompare = strCookie.split("|");
for( var i = 0; i < aCompare.length; i++) {
var aProperty = aCompare[i].split('*');
aSelectedListings.push(aProperty[0]);
}
}
var oWindow = document.getElementById("property_results");
if( oWindow ) {
oWindow.innerHTML = '';
oWindow.scrollTop = 0;
oWindow.scrollLeft = 0;
var results = responseXML.getElementsByTagName('result');
var eleContainer = null;
var elePar = null;
var eleCld = null;
var eleA = null;
var eleImg = null;
if( results.length == 0 ) {
var eleChoice = responseXML.getElementsByTagName("item");
if (eleChoice.length > 0) {
generateDisambiguation(responseXML);
} else {
oWindow.innerHTML = '<div class="noresults">No results found</div>';
}
}
var aLatLongPoints = new Array();
var strImgLinks = '';
var iNumResults = getNodeValue(responseXML, 'numresults');
var iCurrLimit = getNodeValue(responseXML, 'limit');
var iCurrOffset = getNodeValue(responseXML, 'offset');
var strPageLinks = GetPaginatedPageLinks('DoPropertySearch', iNumResults, iCurrLimit, iCurrOffset);
var strCurrShowing = GetCurrentlyShowing(iNumResults, iCurrLimit, iCurrOffset);
SetInnerHtml('property_bottom_page_links', strPageLinks);
SetInnerHtml('property_bottom_curr_showing', strCurrShowing);
SetInnerHtml('property_top_page_links', strPageLinks);
SetInnerHtml('property_top_curr_showing', strCurrShowing);
SetInnerHtml('property_listings_total', number_addCommas(iNumResults));
for (var i=0; i<results.length;i++) {
var listing = null;
var listingcollection = results[i].getElementsByTagName('listing');
if( listingcollection && listingcollection[0] ) {
listing = listingcollection[0];
} else {
continue;
}
var iCbcListingId = getNodeValue(listing, 'listingid');
var strImageUri = getNodeValue(listing, 'imagepreviewuri');
var latitude = getNodeValue(listing, 'latitude');
var longitude = getNodeValue(listing, 'longitude');
var strChecked;
var strFormValue;
elePar = document.createElement('div');
if( g_bUseMosaic ) {
elePar.className = 'property_asmosaic';
} else {
elePar.className = 'property_aslist';
}
eleA = document.createElement("a");
eleA.setAttribute('href', 'Javascript:ShowProperty('+ iCbcListingId +', '+ latitude +', '+ longitude +');');
eleImg = document.createElement("img");
eleImg.setAttribute('border', 0);
if( strImageUri && strImageUri != '' ) {
eleImg.setAttribute('src', strImageUri);
} else {
eleImg.setAttribute('src', '/images/nophoto/listing.gif');
}
eleImg.className = 'listing_icon';
eleA.appendChild(eleImg);
elePar.appendChild(eleA);
var strType = getNodeValue(listing,'listingtype');
eleCld = document.createElement('h4');
eleCld.appendChild(document.createTextNode(strType));
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.appendChild(document.createTextNode(getNodeValue(listing,'address1')));
eleCld.className = 'addressblock';
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.appendChild(document.createTextNode(getNodeValue(listing,'city') + ", " + getNodeValue(listing,'stateprovince') + " " + getNodeValue(listing,'postalcode') ));
eleCld.className = 'citystatezip';
elePar.appendChild(eleCld);
var strPrice = '';
eleCld = document.createElement('div');
var strExtendedPrice = getNodeValue(results[i],'searchdisplayprice')
var cDisplayPrice = getNodeValue(listing,'displayprice');
if(cDisplayPrice == 'N' || !strExtendedPrice || strExtendedPrice == '') {
strExtendedPrice = '$call';
}
var iPrice = parseInt(getNodeValue(listing,'baseprice'));
if( cDisplayPrice == 'Y' ) {
strPrice = '$' + addCommas(iPrice);
} else {
strPrice = '$call';
}
eleCld.appendChild(document.createTextNode(strExtendedPrice));
eleCld.className = 'price';
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
if( g_bUseMosaic ) {
eleCld.className = 'actions_asmosaic';
} else {
eleCld.className = 'actions_aslist';
}
strFormValue = iCbcListingId + "*" + latitude + "*" + longitude +"*"+ strType +"*"+ strPrice;
strChecked = (CheckCompare(strFormValue)) ? "checked" : "";
strImgLinks = '<label><input type="checkbox" id="compare'+ iCbcListingId +'" name="propselect" value="'+strFormValue+
'" onclick="propertyToggleCompare(this);" '+strChecked+' /> Select</label>&nbsp;';
strImgLinks += '<span class=actionbuttons>';
strImgLinks += '<a href="Javascript:ShowProperty('+iCbcListingId+', '+latitude+', '+longitude+');"><img src="/images/buttons/details.gif" class="detailsbtn" border="0" align="middle" /></a> ';
if( latitude != 0 && longitude != 0 ) {
AddPropertyPushPin(iCbcListingId, latitude, longitude, strType, strPrice, aSelectedListings);
strImgLinks += '<a href="Javascript:MapProperty('+iCbcListingId+', '+latitude+', '+longitude+', \''+ strType +'\', \''+ strPrice +'\');"><img src="/images/buttons/mapit.gif" class="mapitbtn" border="0" align="middle" /></a>';
aLatLongPoints.push( new VELatLong(parseFloat(latitude), parseFloat(longitude)) );
} else {
strImgLinks += '<img src="/images/buttons/mapit_disabled.gif" class="mapitbtn" border="0" align="middle" />';
}
strImgLinks += '</span>';
eleCld.innerHTML = strImgLinks;
elePar.appendChild(eleCld);
oWindow.appendChild(elePar);
}
if( aLatLongPoints.length > 0 ) {
RfgResizeMapToPoints('RFGMAPDIV_1', aLatLongPoints);
}
g_AjaxQueue.disengageLock("DoingPropertySearch");
if (g_strSearchFilterString != undefined &&
g_strSearchFilterString != '') {
var aCity = new Array();
dcsMultiTrack('DCS.dcsuri',
location.href,
'WT.ti',
'Property Search',
'WT.si_n',
'PropertySearch',
'WT.si_x',
'1',
'WT.z_prop_city',
g_aSearchFiltered["citymsas"].join(';'),
'WT.z_prop_state',
g_aSearchFiltered["states"].join(';')
);
pageTracker._trackPageview("PropertySearch/"+g_aSearchFiltered["states"].join(';')+";"+g_aSearchFiltered["citymsas"].join(';'));
} else {
dcsMultiTrack('DCS.dcsuri',
location.href,
'WT.ti',
'Property Search',
'WT.si_n',
'PropertySearch',
'WT.si_x',
'1');
pageTracker._trackPageview("PropertySearch");
}
}
} catch (e) {
alert("Could not display search results. " + e.message);
}
setTimeout("SetBirdseyeButton();", 4000);
g_bInPropertySearch = false;
}
function OnPropertyPurchaseTypeChange( strPurchaseType )
{
if( strPurchaseType == 'sa' ) {
g_iPriceMin = 100000;
g_iPriceMax = 2000000;
document.getElementById('frm').disabled = false;
document.getElementById('hos').disabled = false;
document.getElementById('ind').disabled = false;
document.getElementById('lnd').disabled = false;
document.getElementById('mfa').disabled = false;
document.getElementById('off').disabled = false;
document.getElementById('ret').disabled = false;
document.getElementById('shc').disabled = false;
document.getElementById('spc').disabled = false;
} else if( strPurchaseType == 'le' || strPurchaseType == 'le-yr' || strPurchaseType == 'le-mo' ) {
g_iPriceMin = 5;
g_iPriceMax = 1000;
if( strPurchaseType == 'le-mo' ) {
g_iPriceMin = 0;
g_iPriceMax = 7;
} else if( strPurchaseType == 'le-yr' ) {
g_iPriceMin = 0;
g_iPriceMax = 40;
}
document.getElementById('frm').checked = false;
document.getElementById('hos').checked = false;
document.getElementById('mfa').checked = false;
document.getElementById('spc').checked = false;
document.getElementById('frm').disabled = true;
document.getElementById('hos').disabled = true;
document.getElementById('ind').disabled = false;
document.getElementById('lnd').disabled = false;
document.getElementById('mfa').disabled = true;
document.getElementById('off').disabled = false;
document.getElementById('ret').disabled = false;
document.getElementById('shc').disabled = false;
document.getElementById('spc').disabled = true;
} else {
g_iPriceMin = 1000;
g_iPriceMax = 1000000;
document.getElementById('frm').disabled = false;
document.getElementById('hos').disabled = false;
document.getElementById('ind').disabled = false;
document.getElementById('lnd').disabled = false;
document.getElementById('mfa').disabled = false;
document.getElementById('off').disabled = false;
document.getElementById('ret').disabled = false;
document.getElementById('shc').disabled = false;
document.getElementById('spc').disabled = false;
}
reinitializeSliders(true);
}
function SetPropertySeachView( strViewType ) {
switch( strViewType ) {
case 'mosaic':
default:
g_bUseMosaic = true;
document.getElementById('view_tab_aslist').className = '';
document.getElementById('view_tab_asmosaic').className = 'active';
break;
case 'list':
g_bUseMosaic = false;
document.getElementById('view_tab_aslist').className = 'active';
document.getElementById('view_tab_asmosaic').className = '';
break;
}
DoPropertySearch();
}
function SetCountry(oAnchor,sCountry) {
sButtonID = oAnchor.id;
sPreOtherButtonID = sButtonID.replace(/_us|_ca/,'');
sOtherButtonID = (sCountry == 'US') ? sPreOtherButtonID+'_ca':sPreOtherButtonID+'_us';
if(oOtherButton = document.getElementById(sOtherButtonID)) {
oOtherButton.className = sOtherButtonID.replace(/1/,'');
}
if(oViewStatesLink = document.getElementById('prop_search_view_states_link')) {
oViewStatesLink.innerHTML = ( sCountry=='US' ) ? oViewStatesLink.innerHTML.replace(/Province/,'State'):oViewStatesLink.innerHTML.replace(/State/,'Province');
}
oAnchor.className = sButtonID.replace(/1/,'')+'_selected';
oAnchor.blur();
g_sCountry = sCountry;
}
function GetPropertySearchUrlParms( iOffset ){
var strUrl = 'showcalculatedprice=yes&limit=20';
if( iOffset ) {
strUrl += "&offset=" + escape(iOffset);
}
var pWhat=document.getElementById('prop_what_text');
var pWhere=document.getElementById('prop_where_text');
if( pWhat && pWhat.value != '' && pWhat.value != 'Keyword') {
strUrl += "&what=" + escape(trim(pWhat.value));
}
if( pWhere && pWhere.value != '' && pWhere.value != 'City, State or Zipcode') {
strUrl += "&where=" + escape(trim(pWhere.value));
}
if( g_sCountry ) {
strUrl += "&country=" + g_sCountry;
}
var pPolygonMode = document.getElementById('polygonsearch_yn');
if( pPolygonMode && pPolygonMode.value == 'Y' ) {
var pPolygon = document.getElementById('searchpolygon');
if( pPolygon && pPolygon.value != '' ) {
strUrl += pPolygon.value;
}
}
var bInclAll = false;
var pInclAll = document.getElementById('prop_incl_all');
if( pInclAll && pInclAll.checked ) bInclAll = true;
if( !bInclAll ) {
var pPerson = document.getElementById('cbcpersonkey');
if( pPerson && pPerson.value != '' ) {
strUrl += '&cbcpersonkey=' + escape(trim(pPerson.value));
}
var pOffice = document.getElementById('cbcofficekey');
if( pOffice && pOffice.value != '' ) {
strUrl += '&cbcofficekey=' + escape(trim(pOffice.value));
}
var pComp = document.getElementById('cbccompanykey');
if( pComp && pComp.value != '' ) {
strUrl += '&cbccompanykey=' + escape(trim(pComp.value));
}
}
var strPurchType = "";
pPurchaseType = document.getElementById("proptype_dropdown");
if( pPurchaseType ) {
strPurchType = pPurchaseType[pPurchaseType.selectedIndex].value
if( strPurchType == 'sa' ) {
strUrl += "&purchasetype=sa";
bIncludeLease = false;
} else if( strPurchType == 'le-mo' ) {
strUrl += "&purchasetype=le-mo";
bIncludeSale = false;
} else if( strPurchType == 'le-yr' ) {
strUrl += "&purchasetype=le-yr";
bIncludeSale = false;
}
}
if (g_AjaxQueue.isLocked("PropSliders") == false) {
if( g_oPriceSlider.GetLowValue() > PRICE_SLIDER_LOW ) strUrl += "&minprice=" + getPriceFromSliderPosition(g_oPriceSlider.GetLowValue(), strPurchType);
if( g_oPriceSlider.GetHighValue() < PRICE_SLIDER_HIGH ) strUrl += "&maxprice=" + getPriceFromSliderPosition(g_oPriceSlider.GetHighValue(), strPurchType);
if(isLandOnly()) { if( g_oAcreSlider.GetLowValue() > g_iAcreMin ) strUrl += "&minlandacres=" + g_oAcreSlider.GetLowValue();
if( g_oAcreSlider.GetHighValue() < g_iAcreMax ) strUrl += "&maxlandacres=" + g_oAcreSlider.GetHighValue();
}else{
if( g_oSqFtSlider.GetLowValue() > g_iSqFtMin ) strUrl += "&minsqft=" + g_oSqFtSlider.GetLowValue();
if( g_oSqFtSlider.GetHighValue() < g_iSqFtMax ) strUrl += "&maxsqft=" + g_oSqFtSlider.GetHighValue();
}
}
var bIncludeSale = true;
var bIncludeLease = true;
var pPurchaseType = document.getElementById('purchasetype_sa');
if( pPurchaseType && pPurchaseType.checked ) {
strUrl += "&purchasetype=sa"
bIncludeLease = false;
} else {
pPurchaseType = document.getElementById('purchasetype_le');
if( pPurchaseType && pPurchaseType.checked ) {
strUrl += "&purchasetype=le";
bIncludeSale = false;
}
}
if( bIncludeSale ) {
if( document.getElementById('frm').checked ) strUrl += "&listingtype=sfrm";
if( document.getElementById('hos').checked ) strUrl += "&listingtype=shos";
if( document.getElementById('ind').checked ) strUrl += "&listingtype=sind";
if( document.getElementById('lnd').checked ) strUrl += "&listingtype=slnd";
if( document.getElementById('mfa').checked ) strUrl += "&listingtype=smfa";
if( document.getElementById('off').checked ) strUrl += "&listingtype=soff";
if( document.getElementById('ret').checked ) strUrl += "&listingtype=sret";
if( document.getElementById('shc').checked ) strUrl += "&listingtype=sshc";
if( document.getElementById('spc').checked ) strUrl += "&listingtype=sspc";
}
if( bIncludeLease ) {
if( document.getElementById('ind').checked ) strUrl += "&listingtype=lind";
if( document.getElementById('lnd').checked ) strUrl += "&listingtype=llnd";
if( document.getElementById('off').checked ) strUrl += "&listingtype=loff";
if( document.getElementById('ret').checked ) strUrl += "&listingtype=lret";
if( document.getElementById('shc').checked ) strUrl += "&listingtype=lshc";
}
var pSort = document.getElementById('property_sort');
if( pSort && pSort.selectedIndex ) {
strUrl += "&sort=" + pSort[pSort.selectedIndex].value;
}
return strUrl;
}
function DoClearPropertySearch(iOffset, bSaveSearch) {
g_strSearchFilterString = undefined;
g_aSearchFiltered = new Array();
DoPropertySearch(iOffset, bSaveSearch);
}
function DoPropertySearch(iOffset, bSaveSearch) {
if(isLandOnly()) {
document.getElementById("div_sqft").style.display = "none";
document.getElementById("div_acre").style.display = "block";
}else{
document.getElementById("div_sqft").style.display = "block";
document.getElementById("div_acre").style.display = "none";
}
g_bInPropertySearch = true;
g_iPropSearchAttempts = 0;
if (g_bDisableAutoMaximize == false) maximizeMainWindow();
var strUrl = '/xmlbin/searchproperty?' + GetPropertySearchUrlParms(iOffset);
var dtExpiration = (new Date((new Date()).getTime() + 30*150000));
SetCookie("cbcw_savedproperty", strUrl, dtExpiration, "/", null, false);
if (g_strSearchFilterString != undefined) {
strUrl += "&" + g_strSearchFilterString;
}
UpdateFilterMessageArea();
CbcShowWaitDialog();
var fCallback = function(pCbcAjaxReq) {
if(pCbcAjaxReq.readyState == 4) {
CbcHideWaitDialog();
g_AjaxQueue.engageLock("DoingPropertySearch");
handlePropertySearchResults(pCbcAjaxReq.responseXML);
}
}
g_AjaxQueue.schedule("PropertySearch", strUrl, fCallback);
}
function isLandOnly(){
if( !document.getElementById('frm').checked && !document.getElementById('hos').checked && !document.getElementById('ind').checked &&
document.getElementById('lnd').checked && !document.getElementById('mfa').checked && !document.getElementById('off').checked &&
!document.getElementById('ret').checked && !document.getElementById('shc').checked && !document.getElementById('spc').checked ) {
return true;
}
return false;
}
function applySavedPropertySearch() {
g_bInPropertySearch = true;
var strUrl = GetCookie("cbcw_savedproperty");
if ((strUrl == undefined || strUrl == null) ||
document.getElementById("init_what").value != '' ||
document.getElementById("init_where").value != '') {
g_AjaxQueue.disengageLock("InitProperty");
document.getElementById("init_what").value = '';
document.getElementById("init_where").value = '';
DoPropertySearch();
return;
}
var aPairSplit;
var aSearchKeys = new Array();
aSearchKeys['listingtype'] = new Array();
aGetPairs = strUrl.split("?")[1].split("&");
for (var i in aGetPairs) {
aPairSplit = aGetPairs[i].split('=');
if (aPairSplit[0] == "listingtype") {
aSearchKeys["listingtype"].push(aPairSplit[1]);
} else {
aSearchKeys[aPairSplit[0]] = aPairSplit[1];
}
}
var eleDropDown = document.getElementById("proptype_dropdown");
for (var i = 0 ; i < eleDropDown.options.length ; i++) {
if (aSearchKeys["purchasetype"] == eleDropDown.options[i].value) {
eleDropDown.options[i].selected = true;
}
}
if(g_AjaxQueue.isLocked("PropSliders")) {
var iMinPrice = parseInt(aSearchKeys["minprice"]);
var iMaxPrice = parseInt(aSearchKeys["maxprice"]);
iMinPrice = (!isNaN(iMinPrice)) ? iMinPrice : g_iPriceMin;
iMaxPrice = (!isNaN(iMaxPrice)) ? iMaxPrice : g_iPriceMax;
g_oPriceSlider.SetValues(iMinPrice, iMaxPrice, false); onPropPriceSlideMove(g_oPriceSlider);
var iMinSqFt = parseInt(aSearchKeys["minsqft"]);
var iMaxSqFt = parseInt(aSearchKeys["maxsqft"]);
iMinSqFt = (!isNaN(iMinSqFt)) ? iMinSqFt : g_iSqFtMin;
iMaxSqFt = (!isNaN(iMaxSqFt)) ? iMaxSqFt : g_iSqFtMax;
g_oSqFtSlider.SetValues(iMinSqFt, iMaxSqFt, false);
var iMinAcre = parseInt(aSearchKeys["minlandacres"]);
var iMaxAcre = parseInt(aSearchKeys["maxlandacres"]);
iMinAcre = (!isNaN(iMinAcre)) ? iMinAcre : g_iAcreMin;
iMaxAcre = (!isNaN(iMaxAcre)) ? iMaxAcre : g_iAcreMax;
g_oAcreSlider.SetValues(iMinAcre, iMaxAcre, false);
}
var pWhat=document.getElementById('prop_what_text');
var pWhere=document.getElementById('prop_where_text');
if( pWhat && aSearchKeys["what"] != undefined) {
pWhat.value = UrlDecode(aSearchKeys["what"]);
}
if( pWhere && aSearchKeys["where"] != undefined ) {
pWhere.value = UrlDecode(aSearchKeys["where"]);
}
var pPerson = document.getElementById('cbcpersonkey');
if( pPerson && aSearchKeys["cbcpersonkey"] != undefined ) {
pPerson.value = UrlDecode(aSearchKeys["cbcpersonkey"]);
}
var pOffice = document.getElementById('cbcofficekey');
if( pOffice && aSearchKeys["cbcofficekey"] != undefined ) {
pOffice.value = UrlDecode(aSearchKeys["cbcofficekey"]);
}
var pCompany = document.getElementById('cbccompanykey');
if( pCompany && aSearchKeys["cbccompanykey"] != undefined ) {
pCompany.value = UrlDecode(aSearchKeys["cbccompanykey"]);
}
for (i in aSearchKeys['listingtype']) {
try {
var strCheck = aSearchKeys['listingtype'][i].substr(1, 3);
document.getElementById(strCheck).checked = true;
} catch (e) {
alert("Saved Search Push ["+i+"]: " + e.message);
}
}
g_AjaxQueue.disengageLock("InitProperty");
DoPropertySearch();
}
function propertyTextSubmit(e) {
if (!e) e = window.event;
if (checkForEnter(e) && g_bInPropertySearch == false) {
DoClearPropertySearch();
}
}
function propertyToggleCompare(eCheckbox) {
try {
if (eCheckbox.checked == true) {
if (CountCompare() == 3) {
alert("Compare works for up to three properties.");
eCheckbox.checked = false;
} else {
ToggleCompare(eCheckbox.value);
}
} else {
ToggleCompare(eCheckbox.value);
}
} catch (e) {
alert("Could not toggle property: " + e.message);
}
}
function openDPopup(strHtml) {
var eleBg = document.getElementById("disambiguate_bg");
var eleDis = document.getElementById("disambiguate_canvas");
SetInnerHtml("disambiguate_canvas", strHtml);
eleBg.style.visibility = "visible";
eleDis.style.visibility = "visible";
}
function closeDPopup() {
var eleBg = document.getElementById("disambiguate_bg");
var eleDis = document.getElementById("disambiguate_canvas");
eleBg.style.visibility = "hidden";
eleDis.innerHTML = '';
eleDis.style.visibility = "hidden";
g_AjaxQueue.disengageLock("PropDisambiguate");
}
function generateDisambiguation(responseXML) {
var strCanvas = '';
var elements = responseXML.getElementsByTagName("item");
var strPlace = '';
var node;
g_AjaxQueue.engageLock("PropDisambiguate");
strCanvas = "<h3>More than one location matched your search, please select one.</h3><ul>";
for (var i = 0 ; i < elements.length ; i++) {
strPlace = elements[i].firstChild.nodeValue;
strCanvas += "<li><a href='javascript:DisambiguatePropertySearch(\""+ escape(strPlace) +"\");'>"+strPlace+"</a></li>";
}
strCanvas += "</ul><a class='close' href='javascript:closeDPopup();'>X</a>";
openDPopup(strCanvas);
}
function DisambiguatePropertySearch(strWhere) {
document.getElementById("prop_where_text").value = UrlDecode(strWhere);
g_AjaxQueue.disengageLock("PropDisambiguate");
DoPropertySearch();
closeDPopup();
}
function ViewAgentListings( strCbcPersonKey ){
var strUrl = '/xmlbin/searchproperty?cbcpersonkey=' + escape(trim(strCbcPersonKey));
var dtExpiration = (new Date((new Date()).getTime() + 30*150000));
SetCookie("cbcw_savedproperty", strUrl, dtExpiration, "/", null, false);
ChangeToTabById('tab_link_properties');
}
function ViewOfficeListings( strCbcOfficeKey ){
var strUrl = '/xmlbin/searchproperty?cbcofficekey=' + escape(trim(strCbcOfficeKey));
var dtExpiration = (new Date((new Date()).getTime() + 30*150000));
SetCookie("cbcw_savedproperty", strUrl, dtExpiration, "/", null, false);
ChangeToTabById('tab_link_properties');
}
function getPriceFromSliderPosition(iPos, strPurchaseType) {
var fReturn;
switch (strPurchaseType) {
default:
if (iPos <= 20) {
fReturn = iPos * 25000;
} else if (iPos <= 30) {
fReturn = ((iPos - 20) * 50000) + 500000;
} else if (iPos <= 40) {
fReturn = ((iPos - 30) * 100000) + 1000000;
} else if (iPos <= 46 ) {
fReturn = ((iPos - 40) * 500000) + 2000000;
} else if (iPos <= 60) {
fReturn = ((iPos - 46) * 1000000) + 5000000;
}
break;
case "le-mo":
if (iPos <= 40) {
fReturn = iPos * .05;
} else if (iPos <= 50) {
fReturn = (iPos - 40) * .1 + 2;
} else {
fReturn = (iPos - 50) * .5 + 3;
}
fReturn = fReturn.toFixed(2);
break;
case "le-yr":
if (iPos <= 40) {
fReturn = iPos * .5;
} else if (iPos <= 50) {
fReturn = (iPos - 40) * 1 + 20;
} else if (iPos <= 60) {
fReturn = (iPos - 50) * 2 + 30;
}
fReturn = fReturn.toFixed(2);
break;
}
return fReturn;
}
function getSliderPositionFromPrice(fPrice, strPurchaseType) {
var iPos = 0;
switch (strPurchaseType) {
default:
if(fPrice > 5000000) {
iPos = ((fPrice - 5000000) / 1000000) + 46;
} else if (fPrice > 2000000) {
iPos = ((fPrice - 2000000) / 500000) + 40;
} else if (fPrice > 1000000) {
iPos = ((fPrice - 1000000) / 100000) + 30;
} else if (fPrice > 500000) {
iPos = ((fPrice - 500000) / 50000) + 20;
} else {
iPos = fPrice / 25000;
}
break;
case "le-mo":
if (fPrice > 3) {
iPos = ((fPrice - 3) / .5) + 50;
} else if (fPrice > 2) {
iPos = ((fPrice - 2) / .1) + 40;
} else {
iPos = fPrice / .05;
}
break;
case "le-yr":
if (fPrice > 30) {
iPos = ((fPrice - 30) / 2) + 50;
} else if (fPrice > 20) {
iPos = fPrice + 20;
} else {
iPos = fPrice / .5;
}
break;
}
iPos = Math.round(iPos);
iPos = (iPos > PRICE_SLIDER_HIGH) ? PRICE_SLIDER_HIGH : iPos;
iPos = (iPos < PRICE_SLIDER_LOW) ? PRICE_SLIDER_LOW : iPos;
return iPos;
}
function getPurchType() {
pPurchaseType = document.getElementById("proptype_dropdown");
if( pPurchaseType ) {
var strPurchType = pPurchaseType[pPurchaseType.selectedIndex].value
} else {
var strPruchType = "sa";
}
return strPurchType;
}
var g_MaxCityZipSearchResults = 50;
var g_strSearchFilterString;
var g_aSearchFiltered = new Array();
var g_aCheckedRegion = new Array();
g_aCheckedRegion["Midwest"] = false;
g_aCheckedRegion["Northeast"] = false;
g_aCheckedRegion["South"] = false;
g_aCheckedRegion["West"] = false;
var g_RegionStates = new Array();
g_RegionStates["Midwest"] = new Array("MI",
"MN",
"MO",
"ND",
"NE",
"OH",
"SD",
"WI",
"IA",
"IL",
"IN",
"KS");
g_RegionStates["Northeast"] = new Array("MA",
"ME",
"NH",
"NJ",
"NY",
"PA",
"RI",
"VT",
"CT");
g_RegionStates["South"] = new Array("MD",
"MS",
"NC",
"OK",
"PR",
"SC",
"TN",
"TX",
"VA",
"WV",
"AL",
"AR",
"DC",
"DE",
"FL",
"GA",
"KY",
"LA");
g_RegionStates["West"] = new Array("MT",
"NM",
"NV",
"OR",
"UT",
"WA",
"WY",
"AK",
"AZ",
"CA",
"CO",
"HI",
"ID");
function getPocFilters() {
var strFilterItem = '';
var pPerson = document.getElementById('cbcpersonkey');
if( pPerson && pPerson.value != '' ) {
strFilterItem += '<a href="javascript:removePocFilter(\'cbcpersonkey\');">1 Professional Filter Active [REMOVE]</a> ';
}
var pOffice = document.getElementById('cbcofficekey');
if( pOffice && pOffice.value != '' ) {
strFilterItem += '<a href="javascript:removePocFilter(\'cbcofficekey\');">1 Office Filter Active [REMOVE]</a> ';
}
var pCompany = document.getElementById('cbccompanykey');
if( pCompany && pCompany.value != '' ) {
strFilterItem += '<a href="javascript:removePocFilter(\'cbccompanykey\');">1 Company Filter Active [REMOVE]</a> ';
}
return strFilterItem;
}
function removePocFilter( strPersonOfficeCompany ) {
var pKey = document.getElementById( strPersonOfficeCompany );
if( pKey ) {
pKey.value = '';
DoPropertySearch();
}
}
function changeCountry(bUseFilters, callback){
g_aSearchFiltered["states"] = new Array();
g_aSearchFiltered["zips"] = new Array();
g_aSearchFiltered["citymsas"] = new Array();
g_aSearchFiltered["regions"] = new Array();
strFiltersURL = GetCookie("cbcw_savedproperty");
strFiltersURL = strFiltersURL.replace("country=US", "");
strFiltersURL = strFiltersURL.replace("country=CA", "");
var dtExpiration = (new Date((new Date()).getTime() + 30*150000));
SetCookie("cbcw_savedproperty", strFiltersURL, dtExpiration, "/", null, false);
document.getElementById('filter_state').innerHTML="<br/><br/><br/><center>Loading...</center>";
document.getElementById('filter_msa').innerHTML="";
document.getElementById('filter_zip').innerHTML="";
performSearchFiltersWithCallback(bUseFilters, callback);
}
function performSearchFiltersWithCallback(bUseFilters, callback) {
var strFiltersURL = '';
strFiltersURL = GetCookie("cbcw_savedproperty");
var filter_country = document.getElementById("filter_country").value;
var filter_region = document.getElementById('filter_region');
var state_province = document.getElementById('state_province');
if (strFiltersURL != undefined) {
strFiltersURL = strFiltersURL.replace(/searchproperty/, "searchpropertyfilters")+"&country="+filter_country;
if(filter_country=="CA") {
filter_region.style.visibility="hidden";
if(state_province) {
state_province.innerHTML="Choose Province";
}
}else{
filter_region.style.visibility="visible";
if(state_province) {
state_province.innerHTML="Choose State";
}
}
}else {
strFiltersURL = '/xmlbin/searchpropertyfilters?'+"country="+filter_country;
if(filter_country=="CA") {
filter_region.style.visibility="hidden";
if(state_province) {
state_province.innerHTML="Choose Province";
}
}else{
filter_region.style.visibility="visible";
if(state_province) {
state_province.innerHTML="Choose State";
}
}
}
if (bUseFilters == true) {
generateSearchString();
strFiltersURL += "&" + g_strSearchFilterString;
}
var fCallback = function(xml) {
return callback(xml.responseXML);
}
g_AjaxQueue.schedule("PropSearchFilters", strFiltersURL, fCallback);
}
function PropertyUpdateSearchFilterPane()
{
var strUrl = '/xmlbin/searchpropertyfilters?' + GetPropertySearchUrlParms();
var fCallback = function(xmlSPF) {
SetInnerHtml("advanced_pane_canvas", xmlSPF.responseText);
performSearchFiltersWithCallback(false, populatePropertySearchFilters);
}
g_AjaxQueue.schedule("PropSearchFilterPane", "/enhanced/getform.php?type=leftnav&id=propertysearchfilters", fCallback);
}
function populatePropertySearchFilters(xmlResponse) {
populatePSFStates(xmlResponse);
if (g_aSearchFiltered["states"] != undefined && g_aSearchFiltered["states"].length > 0) {
var fSubHandler = function(xmlResponse) {
populatePSFCities(xmlResponse);
populatePSFZips(xmlResponse);
}
setTimeout("performSearchFiltersWithCallback(true, "+fSubHandler+");", 40);
} else {
populatePSFCities(xmlResponse);
populatePSFZips(xmlResponse);
}
document.getElementById("apply_filter_button").onclick = applySearchFilters;
document.getElementById("region_south").onclick = toggleStatesByRegion;
document.getElementById("region_west").onclick = toggleStatesByRegion;
document.getElementById("region_midwest").onclick = toggleStatesByRegion;
document.getElementById("region_northeast").onclick = toggleStatesByRegion;
if (g_aCheckedRegion["South"] == true) {
document.getElementById("region_south").checked = true;
}
if (g_aCheckedRegion["North"] == true) {
document.getElementById("region_north").checked = true;
}
if (g_aCheckedRegion["Midwest"] == true) {
document.getElementById("region_midwest").checked = true;
}
if (g_aCheckedRegion["Northeast"] == true) {
document.getElementById("region_northeast").checked = true;
}
}
function populatePSFStates(xmlResponse) {
var xmlStates = xmlResponse.getElementsByTagName("state");
populateSearchFilterList(xmlStates, "filter_state", "states", "onStateClick(this)");
}
function populatePSFZips(xmlResponse) {
var xmlZips = xmlResponse.getElementsByTagName("zip");
if( xmlZips.length < g_MaxCityZipSearchResults) {
populateSearchFilterList(xmlZips, "filter_zip", "zips", "setSearchFilterSelected();");
} else {
SetInnerHtml("filter_zip", "Please narrow your search to see a list of Zipcodes");
}
}
function populatePSFCities(xmlResponse) {
var aMsas = new Array();
var aCM = new Array();
var xmlCities = xmlResponse.getElementsByTagName("city");
var xmlMsa = xmlResponse.getElementsByTagName("msa");
if( (xmlCities.length + xmlMsa.length) < g_MaxCityZipSearchResults ) {
for (var i = 0 ; i < xmlCities.length ; i++) {
aCM.push(xmlCities[i]);
}
for (var i = 0 ; i < xmlMsa.length ; i++) {
aCM.push(xmlMsa[i]);
}
populateSearchFilterList(aCM, "filter_msa", "citymsas", "onCityClick();");
} else {
SetInnerHtml("filter_msa", "Please narrow your search to see a list of Cities/MSAs");
}
}
function onStateClick(eleState) {
if (eleState) {
var strRegion = getRegionByStateName(eleState.value);
if (eleState.checked == false && strRegion) {
var strRegionId = "region_" + strRegion.toLowerCase();
g_aCheckedRegion[strRegion] = false;
document.getElementById(strRegionId).checked = false;
}
}
setSearchFilterSelected();
g_aSearchFiltered["zips"] = new Array();
g_aSearchFiltered["citymsas"] = new Array();
var fHandler = function(xmlResponse) {
populatePSFCities(xmlResponse);
populatePSFZips(xmlResponse);
}
setTimeout("performSearchFiltersWithCallback(true, "+fHandler+");", 30);
}
function onCityClick() {
setSearchFilterSelected();
var fHandler = function(xmlResponse) {
populatePSFZips(xmlResponse);
}
setTimeout("performSearchFiltersWithCallback(true, "+fHandler+");", 30);
}
function populateSearchFilterList(elements, domId, strA, strOnclick) {
var strName = '';
var strCount = '';
var strCanvas = '';
var strChecked = '';
for (var i = 0 ; i < elements.length ; i++) {
strName = getNodeValue(elements[i], "name");
strCount = getNodeValue(elements[i], "count");
strChecked = (find_in_array(g_aSearchFiltered[strA], strName)) ? "checked" : "";
strCanvas += '<li><label><input type="checkbox" value="'+strName+'" '+strChecked+' onclick="'+strOnclick+'" />'+strName+' ('+strCount+')</label><li>\n';
}
SetInnerHtml(domId, strCanvas);
}
function setSearchFilterSelected() {
var eleStates = document.getElementById("filter_state").getElementsByTagName("input");
var eleZips = document.getElementById("filter_zip").getElementsByTagName("input");
var eleRegions = document.getElementById("filter_region").getElementsByTagName("input");
var eleMsa = document.getElementById("filter_msa").getElementsByTagName("input");
var aStates = getCheckedValues(eleStates);
var aZips = getCheckedValues(eleZips);
var aCityMsas = getCheckedValues(eleMsa);
var aRegions = getCheckedValues(eleRegions);
g_aSearchFiltered = new Array();
g_aSearchFiltered["states"] = aStates;
g_aSearchFiltered["zips"] = aZips;
g_aSearchFiltered["citymsas"] = aCityMsas;
g_aSearchFiltered["regions"] = aRegions;
}
function generateSearchString() {
var aRegionStates = new Array();
var strWhat = '';
var aStates = g_aSearchFiltered["states"];
var aZips = g_aSearchFiltered["zips"];
var aCityMsas = g_aSearchFiltered["citymsas"];
if (aZips.length > 0) {
strWhat += "zipcode="+ aZips.join(",");
}
for (var i in aStates) {
strWhat += "&state="+escape(aStates[i]);
}
var strCity;
var aCity;
for (var i in aCityMsas) {
aCity = aCityMsas[i].split(', ');
aCity.pop();
strCity = aCity.join(', ');
strWhat += "&city="+escape(strCity);
}
g_strSearchFilterString = strWhat;
}
function getNumberOfFilters() {
var aKeys = array_keys(g_aSearchFiltered);
var iCount = 0;
for (var i in aKeys) {
iCount += g_aSearchFiltered[aKeys[i]].length;
}
return iCount;
}
function applySearchFilters() {
var iCount = getNumberOfFilters();
if (iCount > 0) {
generateSearchString();
DoPropertySearch(null, false);
}
propertyCollapseFilters();
return false;
}
function removeSearchFilters() {
g_aSearchFiltered = new Array();
g_strSearchFilterString = '';
DoPropertySearch(null, false);
}
function getCheckedValues(elements) {
var aReturn = new Array();
if (elements.length > 0) {
for (var i=0; i<elements.length; i++) {
if (elements[i].checked == true) {
aReturn.push(elements[i].value);
}
}
}
return aReturn;
}
function toggleStatesByRegion() {
var strRegion = this.value;
var bCheck = this.checked;
var aStates = g_RegionStates[strRegion];
var eleBoxes = document.getElementById("filter_state").getElementsByTagName("input");
var element = null;
if (aStates.length == undefined) {
return;
}
for (var i in eleBoxes) {
element = eleBoxes[i];
if (find_in_array(aStates, element.value)) {
element.checked = bCheck;
}
}
g_aCheckedRegion[strRegion] = bCheck;
onStateClick();
}
function getStatesByRegionName(strRegion) {
return g_RegionStates[strRegion];
}
function getRegionsByStatesArray(aStates) {
var aStatesRegions = new Array();
var aRegions = new Array();
for (var str in g_RegionStates) {
for (var i in g_RegionStates[str]) {
aStatesRegions[ g_RegionStates[str][i] ] = str;
}
}
strCanvas = '';
for (var str2 in aStatesRegions) {
strCanvas += str2 + " " + aStatesRegions[str2] + "\n";
}
for (var i in aStates) {
if( aStatesRegions[aStates[i]] != undefined ) {
aRegions[ aStatesRegions[ aStates[i] ] ]++;
}
}
return array_keys(aRegions);
}
function getRegionByStateName(strState) {
for (var str in g_RegionStates) {
if (find_in_array(g_RegionStates[str], strState)) {
return str;
}
}
}
function getRegionsByStatesElements(elements) {
var aStates = new Array();
for (var i = 0 ; i < elements.length ; i++) {
aStates.push(getNodeValue(elements[i], "name"));
}
return getRegionsByStatesArray(aStates);
}
function array_keys(aArr) {
var aReturn = new Array();
for (var i in aArr) {
aReturn.push(i);
}
return aReturn;
}
function find_in_array(aArr, strSearch) {
for (var i in aArr) {
if (aArr[i] == strSearch) {
return true;
}
}
return false;
}
function toggleExpandFilters() {
if (g_AdvancedPane_Expanded == true) {
propertyCollapseFilters();
} else {
propertyExpandFilters();
}
}
function propertyExpandFilters() {
if (g_AdvancedPane_Expanded == true) {
return;
}
SetCookie("WTSC", "PSA", "", "/", "false");
var widget = document.getElementById("property_advanced_filters");
maximizeMainWindow();
widget.style.marginLeft = "5px";
widget.style.marginRight = "0px";
var iAfterButton = g_AdvancedPane_ButtonIncrement * 7;
document.getElementById("advanced_pane").style.width = "0px";
if(!document.getElementById('property_filters')) {
PropertyUpdateSearchFilterPane();
}
for (var i = 1 ; i < 8 ; i++) {
setTimeout("document.getElementById('property_advanced_filters').style.paddingRight = '"+i+"px';", i * g_AdvancedPane_ButtonIncrement);
}
setTimeout("document.getElementById('advanced_pane').style.visibility = 'visible';", iAfterButton);
setTimeout("document.getElementById('advanced_pane_canvas').style.visibility = 'visible';", iAfterButton);
setTimeout("document.getElementById('advanced_pane_canvas').style.display = 'block';", iAfterButton);
var iCount = 1;
for (var x = 0 ; x < 671 ; x += g_AdvancedPane_WindowSpacing) {
setTimeout("document.getElementById('advanced_pane').style.width = '"+x+"px';",
(iCount * g_AdvancedPane_WindowIncrement) + iAfterButton);
iCount++;
}
g_AdvancedPane_Expanded = true;
}
function propertyCollapseFilters(bIgnoreButton) {
if (g_AdvancedPane_Expanded == false) {
return;
}
SetCookie("WTSC", "PSQ", "", "/", false);
var iCount = 0;
var iBCount = 0
document.getElementById('advanced_pane_canvas').style.display = 'none';
for (var i = 670 ; i > 0 ; i -= g_AdvancedPane_WindowSpacing) {
iCount++;
setTimeout("document.getElementById('advanced_pane').style.width = '"+i+"px';",
iCount * g_AdvancedPane_WindowIncrement);
}
setTimeout("document.getElementById('advanced_pane').style.visibility = 'hidden';",
iCount * g_AdvancedPane_WindowIncrement);
setTimeout("document.getElementById('advanced_pane_canvas').style.visibility = 'hidden';",
iCount * g_AdvancedPane_WindowIncrement);
var iAfterWindow = iCount * g_AdvancedPane_WindowIncrement;
if (!bIgnoreButton) {
for (var x = 7 ; x > 0 ; x--) {
iBCount++;
setTimeout("document.getElementById('property_advanced_filters').style.paddingRight = '"+x+"px';",
(iBCount * g_AdvancedPane_ButtonIncrement) + iAfterWindow);
}
setTimeout("document.getElementById('property_advanced_filters').className = 'fold_tab';",
(iBCount * g_AdvancedPane_ButtonIncrement) + iAfterWindow);
}
g_AdvancedPane_Expanded = false;
}
function UpdateFilterMessageArea()
{
var strFilterMsg = '';
strFilterMsg += getPocFilters();
var iCount = getNumberOfFilters();
if (iCount > 0) {
strFilterMsg += "<a href='javascript:removeSearchFilters();'>"+iCount+" Location Filters Active [REMOVE]</a>";
}
if( strFilterMsg == '' ) {
SetInnerHtml("property_subheader", "Search Property");
} else {
SetInnerHtml("property_subheader", "Search Property - " + strFilterMsg);
}
}
var g_iSiteSearchAttempts = 0;
function Initialize_SiteSearch()
{
if (g_AjaxQueue.isLocked("LeftNavLoaded") == false &&
g_AjaxQueue.isLocked("MainDataLoaded") == false) {
try {
document.getElementById('searchkeyword').value = document.getElementById("init_what").value;
setBreadcrumb(0, "Search Sites", "CloseProfileDialog('profile_pane');", true);
displayBreadcrumb();
document.getElementById("searchkeyword").onkeyup = function(e) {
if (!e) e = window.event;
if (checkForEnter(e)) {
DoSiteSearch();
}
}
} catch ( e ) { }
g_AjaxQueue.disengageLock("TabTransition");
g_AjaxQueue.registerLock("DoingSiteSearch");
setTimeout(applySavedSiteSearch, 500);
} else {
setTimeout(Initialize_SiteSearch, 250);
return;
}
}
function Destroy_SiteSearch() {
g_AjaxQueue.unregisterLock("DoingSiteSearch");
}
function handleSiteSearchResults(responseXML) {
try {
if( g_strActiveMainDialog != 'searchsites' ) {
return;
}
CloseProfileDialog("profile_pane");
g_pAreaMap.DeleteAllPushpins();
maximizeMainWindow();
var oWindow = document.getElementById("sites_results");
if( oWindow ) {
var aDocTypes = new Array();
aDocTypes["agent"] = 0;
aDocTypes["office"] = 0;
aDocTypes["listing"] = 0;
aDocTypes["other"] = 0;
oWindow.innerHTML = '';
oWindow.scrollTop = 0;
oWindow.scrollLeft = 0;
var results = responseXML.getElementsByTagName('result');
var elePar = null;
var eleCld = null;
var eleA = null;
var eleImg = null;
if( results.length == 0 ) {
oWindow.innerHTML = '<div class="noresults">No results found</div>';
}
var iNumResults = getNodeValue(responseXML, 'numresults');
var iCurrLimit = getNodeValue(responseXML, 'limit');
var iCurrOffset = getNodeValue(responseXML, 'offset');
var strPageLinks = GetPaginatedPageLinks('DoSiteSearch', iNumResults, iCurrLimit, iCurrOffset);
var strCurrShowing = GetCurrentlyShowing(iNumResults, iCurrLimit, iCurrOffset);
SetInnerHtml('site_bottom_page_links', strPageLinks);
SetInnerHtml('site_bottom_curr_showing', strCurrShowing);
var strCurrentServer = document.location.host.toLowerCase();
for (var i=0; i<results.length;i++) {
var strUrl = getNodeValue(results[i], 'url');
var strTitle = getNodeValue(results[i], 'title');
var strKey = getNodeValue(results[i], 'key');
var strType = getNodeValue(results[i], 'type');
var strDescription = getNodeValue(results[i], 'description').substr(0, 200);
var strPhotoUrl = '/images/nophoto/article.gif';
var strPhotoClass = 'office_icon';
var strOnClick = '';
var strLink = '';
switch( strType ) {
case "profile-agent":
strLink = 'OpenLink(\'/ajaxhtmlbin/agent?cbcpersonkey='+strKey+'\', \''+strType+'\', this);';
strOnClick = 'onClick="return '+ strLink +'"';
strPhotoUrl = '/images/nophoto/person.gif';
aDocTypes["agent"]++;
break;
case "profile-office":
strLink = 'OpenLink(\'/ajaxhtmlbin/office?cbcofficekey='+strKey+'\', \''+strType+'\', this);';
strOnClick = 'onClick="return '+ strLink +'"';
strPhotoUrl = '/images/nophoto/office.gif';
aDocTypes["office"]++;
break;
case "profile-listing":
strLink = 'OpenLink(\'/ajaxhtmlbin/listing?cbclistingid='+strKey+'\', \''+strType+'\', this);';
strOnClick = 'onClick="return '+ strLink +'"';
strPhotoUrl = '/images/nophoto/listing.gif';
aDocTypes["listing"]++;
break;
default:
strLink = 'OpenLink(\''+strUrl+'\', \''+strType+'\', this);';
strOnClick = 'onClick="return '+ strLink +'"';
strPhotoUrl = '/images/nophoto/article.gif';
aDocTypes["other"]++;
break;
}
elePar = document.createElement('div');
elePar.className = 'result';
eleA = document.createElement("a");
eleA.setAttribute('href', "#");
eleA.onclick = function() {
return OpenLink(strUrl, strType, this);
}
eleA.setAttribute('title', strTitle);
eleImg = document.createElement("img");
eleImg.setAttribute('border', 0);
eleImg.setAttribute('src', strPhotoUrl);
eleImg.className = strPhotoClass;
eleA.appendChild(eleImg);
elePar.appendChild(eleA);
eleCld = document.createElement('div');
eleCld.className = 'description';
if( strUrl.indexOf('://' ) == -1 ) {
strUrl = 'http://' + strCurrentServer + strUrl;
}
if( strDescription.length == 200 ) strDescription += '...';
eleCld.innerHTML = '<h3><a href="'+strUrl+'" '+strOnClick+' title="'+strTitle+'">' + strTitle + '</a></h3>' +
strDescription + '<br />' +
'<span class="resulturl">' + strUrl + '</span>';
elePar.appendChild(eleCld);
eleCld = document.createElement('div');
eleCld.className = 'actions';
eleCld.innerHTML = '<a href="'+strUrl+'" '+strOnClick+' title="'+strTitle+'"><img src="/images/buttons/view.gif" class="viewbtn" border="0" align="middle" /></a>';
elePar.appendChild(eleCld);
oWindow.appendChild(elePar);
}
SiteSearchSummary(responseXML.getElementsByTagName("counts"));
g_AjaxQueue.disengageLock("DoingSiteSearch");
} else {
alert("Could not display search results (1).");
}
} catch (e) {
alert("Could not display search results. " + e.message);
}
}
function showMainSearchEmptyForm()
{
var oWindow = document.getElementById("sites_results");
if( oWindow ) {
oWindow.innerHTML = '<div class="noresults">Please enter at least one search term in the box on the left.</div>';
}
}
function DoSiteSearch(iOffset) {
g_iSiteSearchAttempts = 0;
var strUrl = '/xmlbin/searchall?limit=20';
if( iOffset ) {
strUrl += "&offset=" + escape(iOffset);
}
var pKeyword=document.getElementById('searchkeyword');
if( pKeyword && pKeyword.value != '' ) {
strUrl += "&s=" + escape(trim(pKeyword.value));
} else {
showMainSearchEmptyForm();
return;
}
CbcShowWaitDialog();
var fCallback = function(pCbcAjaxReq) {
g_AjaxQueue.engageLock("DoingSiteSearch");
CbcHideWaitDialog();
handleSiteSearchResults(pCbcAjaxReq.responseXML);
}
g_AjaxQueue.schedule("SiteSearch", strUrl, fCallback);
SetCookie("cbcw_savedsite", strUrl);
}
function DoRelatedPropertyRedir() {
var strWhat = '';
var pKeyword=document.getElementById('searchkeyword');
if( pKeyword && pKeyword.value != '' ) {
strWhat = pKeyword.value;
}
document.getElementById("init_type").value = 'property';
document.getElementById("init_what").value = strWhat;
document.getElementById("init_where").value = '';
ChangeToTabByName('property');
}
function DoRelatedOfficeRedir() {
var strWhat = '';
var pKeyword=document.getElementById('searchkeyword');
if( pKeyword && pKeyword.value != '' ) {
strWhat = pKeyword.value;
}
document.getElementById("init_type").value = 'office';
document.getElementById("init_what").value = strWhat;
document.getElementById("init_where").value = '';
ChangeToTabByName('office');
}
function applySavedSiteSearch() {
var strUrl = GetCookie("cbcw_savedsite");
if ((strUrl == undefined || strUrl == null) ||
document.getElementById("init_what").value != '') {
document.getElementById("init_what").value = '';
document.getElementById("init_where").value = '';
DoSiteSearch();
return;
}
var aPairSplit;
var aSearchKeys = new Array();
aGetPairs = strUrl.split("?")[1].split("&");
for (var i in aGetPairs) {
aPairSplit = aGetPairs[i].split('=');
aSearchKeys[aPairSplit[0]] = aPairSplit[1];
}
if (aSearchKeys["s"] != undefined) {
document.getElementById("searchkeyword").value = unescape(aSearchKeys["s"]);
}
DoSiteSearch();
}
function SiteSearchSummary(eleCounts) {
var strHtml = "";
var iAgent = 0;
var iOffice = 0;
var iListing = 0;
var iOther = 0;
var eleChildren = eleCounts[0].childNodes;
var strType;
var iCount;
for (var i = 0 ; i < eleChildren.length ; i++) {
if (eleChildren[i].nodeType == 1) {
strType = eleChildren[i].nodeName;
iCount = eleChildren[i].firstChild.data;
switch ( strType ) {
case "profile-agent":
iAgent = iCount;
break;
case "profile-office":
iOffice = iCount;
break;
case "profile-listing":
iListing = iCount;
break;
default:
iOther += parseInt(iCount);
break;
} } }
if (iAgent + iOffice + iListing + iOther > 0) {
strHtml = "<span class='header'>This Search Resulted In:</span><ul>";
if (iAgent != 0) {
strHtml += "<li><span>"+iAgent+"</span> Professional Profiles</li>";
}
if (iOffice != 0) {
strHtml += "<li><span>"+iOffice+"</span> Office Profiles</li>";
}
if (iListing != 0) {
strHtml += "<li><span>"+iListing+"</span> Property Listings</li>";
}
if (iOther != 0) {
strHtml += "<li><span>"+iOther+"</span> Site Documents</li>";
}
strHtml += "</ul>";
SetInnerHtml("sitesearch_summary", strHtml);
}
}
var MAIN_WINDOW_TIMING = 8;
var MAIN_WINDOW_INCREMENT = 20;
var OVERLAY_OPACITY_TOTAL = 20;
var OVERLAY_OPACITY_TIMING = 10;
var SEARCH_OPACITY_TOTAL = 80;
var SEARCH_OPACITY_TIMING = 10;
var LOWER_BORDER_BUFFER = 67;
if(document.getElementById("minimize_button")) {
document.getElementById("minimize_button").onclick = function() {
toggleMainWindow();
}
}
if(document.getElementById("arrows")) {
document.getElementById("arrows").onclick = function() {
toggleMainWindow();
}
}
if(document.getElementById("RFGMAPDIV_1")) {
document.getElementsByTagName("body")[0].onresize = function() {
var aDims = get_browser_dims();
g_pAreaMap = RfgGetMapById('RFGMAPDIV_1');
g_pAreaMap.Resize(aDims[0], aDims[1]);
}
}
function toggleMainWindow() {
try {
if (document.getElementById("main_background").offsetHeight > 10) {
minimizeMainWindow();
document.getElementById("arrows").className = "arrows_down";
} else {
maximizeMainWindow();
document.getElementById("arrows").className = "arrows_up";
}
} catch (e) {
}
}
function minimizeMainWindow() {
var oBg = document.getElementById("main_background");
var iCurrentHeight = oBg.offsetHeight;
if (iCurrentHeight > 10) {
reheightMain(0, MAIN_WINDOW_INCREMENT, MAIN_WINDOW_TIMING, "postMainShrink();");
}
var img = document.getElementById("minimize_button");
if( img ) img.src = '/images/maximize_butn.gif';
}
function maximizeMainWindow() {
var oBg = document.getElementById("main_background");
var iCurrentHeight = oBg.offsetHeight;
if (iCurrentHeight < 10) {
var aDims = get_browser_dims();
var iFullSize = aDims[1] - 55 - 50 - 45 - 29;
document.getElementById("map_controls").style.visibility = "hidden";
document.getElementById("map_legend").style.visibility = "hidden";
if (g_PolygonDrawMode == true) {
startSearchByMap();
}
hideMiniProfile();
document.getElementById("main_window").style.bottom = '50px';
document.getElementById("main_window").style.height = '';
fader("overlay", 0, OVERLAY_OPACITY_TOTAL, OVERLAY_OPACITY_TIMING);
fader("sbg1", 100, SEARCH_OPACITY_TOTAL, SEARCH_OPACITY_TIMING);
fader("sbg2", 100, SEARCH_OPACITY_TOTAL, SEARCH_OPACITY_TIMING);
fader("sbg3", 100, SEARCH_OPACITY_TOTAL, SEARCH_OPACITY_TIMING);
fader("sbg4", 100, SEARCH_OPACITY_TOTAL, SEARCH_OPACITY_TIMING);
fader("sbg5", 100, SEARCH_OPACITY_TOTAL, SEARCH_OPACITY_TIMING);
setTimeout("document.getElementById('overlay').style.visibility = 'visible';",
(OVERLAY_OPACITY_TOTAL * OVERLAY_OPACITY_TIMING));
document.getElementById("main_background").style.visibility = "visible";
document.getElementById("page_body").style.visibility = "visible";
reheightMain(iFullSize, MAIN_WINDOW_INCREMENT, MAIN_WINDOW_TIMING, "postMainGrow();");
}
var img = document.getElementById("minimize_button");
if( img ) img.src = '/images/minimize_butn.gif';
}
function reheightMain(iTo, iIncrement, iTiming, strEval) {
var aDims = get_browser_dims();
g_pAreaMap = RfgGetMapById('RFGMAPDIV_1');
g_pAreaMap.Resize(aDims[0], aDims[1]);
var iFrom = document.getElementById("main_background").offsetHeight;
var iTM = 0;
var iSteps = 0;
var iSize = 0;
var aCommands = [ ];
if (iTo > iFrom) {
iSteps = Math.ceil(iTo / iIncrement);
for (var i = 0 ; i < iSteps ; i++) {
iSize = ((iFrom + iIncrement) > iTo) ? iTo : (iFrom + iIncrement);
aCommands.push("document.getElementById('page_body').style.height = '"+iSize+"px';");
aCommands.push("document.getElementById('main_background').style.height = '"+iSize+"px';");
if (iSize > LOWER_BORDER_BUFFER) {
aCommands.push("document.getElementById('main_foot').style.top = '"+ iSize + "px';");
}
iFrom = iSize;
}
document.getElementById('map_description').style.visibility="hidden";
document.getElementById("arrows").className = "arrows_up";
} else if (iFrom > iTo) {
iSteps = Math.ceil(iFrom / iIncrement);
for (var i = 0 ; i < iSteps ; i++) {
iSize = ((iFrom - iIncrement) < 0) ? 0 : (iFrom - iIncrement);
aCommands.push("document.getElementById('page_body').style.height = '"+iSize+"px';");
aCommands.push("document.getElementById('main_background').style.height = '"+iSize+"px';");
if (iSize > LOWER_BORDER_BUFFER) {
aCommands.push("document.getElementById('main_foot').style.top = '"+ iSize + "px';");
}else{
aCommands.push("document.getElementById('main_foot').style.top = '"+ LOWER_BORDER_BUFFER + "px';");
}
document.getElementById("arrows").className = "arrows_down";
iFrom = iSize;
}
aCommands.push("document.getElementById('main_foot').style.top = '67px';");
if(document.getElementById('map_draw').className.search("active")!=-1) {
aCommands.push("document.getElementById('map_description').style.visibility='visible'");;
}
}
for (var i = 0 ; i < aCommands.length ; i++) {
setTimeout(aCommands[i], iTM * iTiming);
iTM++;
}
setTimeout(strEval, iTM * iTiming);
}
function postMainShrink() {
document.getElementById("main_background").style.visibility = "hidden";
document.getElementById("page_body").style.visibility = "hidden";
fader("overlay", OVERLAY_OPACITY_TOTAL, 0, OVERLAY_OPACITY_TIMING);
setTimeout("document.getElementById('overlay').style.visibility = 'hidden';",
(OVERLAY_OPACITY_TOTAL * OVERLAY_OPACITY_TIMING));
fader("sbg1", SEARCH_OPACITY_TOTAL, 100, SEARCH_OPACITY_TIMING);
fader("sbg2", SEARCH_OPACITY_TOTAL, 100, SEARCH_OPACITY_TIMING);
fader("sbg3", SEARCH_OPACITY_TOTAL, 100, SEARCH_OPACITY_TIMING);
fader("sbg4", SEARCH_OPACITY_TOTAL, 100, SEARCH_OPACITY_TIMING);
fader("sbg5", SEARCH_OPACITY_TOTAL, 100, SEARCH_OPACITY_TIMING);
document.getElementById("main_window").style.bottom = '';
document.getElementById("main_window").style.height = '80px';
document.getElementById("RFGMAPDIV_1").onmousedown = mapDragHandleOnMouseDown;
document.getElementById("RFGMAPDIV_1").onmouseup = mapDragHandleOnMouseUp;
document.getElementById("RFGMAPDIV_1").onmousemove = mapDragHandleOnMouseMove;
document.getElementById("map_controls").style.visibility = "visible";
document.getElementById("map_legend").style.visibility = "visible";
if (g_MapHelpOpen == true) {
document.getElementById("map_description").style.visibility = "visible";
}
}
function postMainGrow() {
document.getElementById("main_background").style.height = '';
document.getElementById("main_background").style.className = "bg";
document.getElementById("main_foot").style.top = '';
document.getElementById("main_foot").style.className = "foot";
document.getElementById("page_body").style.height = '';
document.getElementById("page_body").style.className = "page_body";
document.getElementById("main_window").style.bottom = '50px';
document.getElementById("RFGMAPDIV_1").onmousedown = null;
document.getElementById("RFGMAPDIV_1").onmouseup = null;
document.getElementById("RFGMAPDIV_1").onmousemove = null;
g_bInDragEvent = false;
g_bInClickEvent = false;
}
function fader(obj, start_opacity, end_opacity, timing, streval) {
var t = 0;
if (start_opacity < end_opacity) {
for (i = start_opacity ; i <= end_opacity ; i++) {
setTimeout("fade('"+obj+"', "+i+");", (t * timing));
t++;
}
} else if (end_opacity < start_opacity) {
for (i = start_opacity ; i >= end_opacity ; i--) {
setTimeout("fade('"+obj+"', "+i+");", (t * timing));
t++;
}
}
}
function fade(obj, val) {
if (val == 0) {
document.getElementById(obj).style.visibility = "hidden";
} else {
document.getElementById(obj).style.visibility = "visible";
}
document.getElementById(obj).style.opacity = val / 100;
document.getElementById(obj).style.filter = "alpha(opacity="+val+");";
}
function get_browser_dims() {
var height;
var width;
if (typeof(window.innerWidth) == 'number') {
width = window.innerWidth;
height = window.innerHeight;
} else if (document.documentElement.clientHeight) {
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
} else {
width = document.body.clientWidth;
height = document.body.clientHeight;
}
var dims = new Array();
dims[0] = width;
dims[1] = height;
return dims;
}
function getMainWindowDims() {
var oWindow = document.getElementById("");
}
var g_bDisableAutoMaximize = false;
var aTabs = new Array();
var g_bIE6 = false;
aTabs.push( new NavigationTab( 'property', 'tab_link_properties', 'link_properties', 'searchproperty', 'property', 'Initialize_PropSearch', 'Destroy_PropSearch' ) );
aTabs.push( new NavigationTab( 'office', 'tab_link_office', 'link_office', 'searchoffice', 'office', 'Initialize_OfficeSearch', 'Destroy_OfficeSearch') );
aTabs.push( new NavigationTab( 'agent', 'tab_link_professionals', 'link_professionals', 'searchagent', 'agent', 'Initialize_AgentSearch', 'Destroy_AgentSearch' ) );
aTabs.push( new NavigationTab( 'marketintel', 'tab_link_markets', 'link_markets', 'searchmarket', 'marketintel', 'Initialize_MarketIntelSearch', 'Destroy_MarketIntelSearch' ) );
aTabs.push( new NavigationTab( 'site', 'tab_link_search', 'link_search', 'searchsites', 'site', 'Initialize_SiteSearch', 'Destroy_SiteSearch' ) );
function NavigationTab( name, maintab, section, maindialog, leftnavdialog, pDoOnLoad, pDoOnUnload ) {
this.name = name ;
this.maintab = maintab ;
this.section = section ;
this.maindialog = maindialog ;
this.leftnavdialog = leftnavdialog ;
this.pDoOnLoad = pDoOnLoad ;
this.pDoOnUnload = pDoOnUnload ;
}
g_AjaxQueue.registerLock("TabTransition");
g_AjaxQueue.registerLock("MainDataLoaded");
g_AjaxQueue.registerLock("LeftNavLoaded");
var g_strActiveMainDialog = '';
var g_iActiveTabId = -1;
for(var i=0; i < aTabs.length; i++) {
var pThisSection = document.getElementById(aTabs[i].section);
if( pThisSection ) {
pThisSection.iTabId = i;
pThisSection.onclick = switchTab;
}
}
function switchTab() {
if( this.iTabId != undefined ) {
if( this.iTabId == g_iActiveTabId ) {
return;
};
try {
g_AjaxQueue.purgeAllCalls();
maximizeMainWindow();
if (aTabs[g_iActiveTabId].pDoOnUnload != '') {
try {
var pFunct = window[aTabs[g_iActiveTabId].pDoOnUnload];
if( pFunct ) {
pFunct();
} else {
alert("Could not initialize search. (1)");
}
} catch ( e ) {
alert("Could not initialize search. (2) ["+e.message+"]");
}
}
g_AjaxQueue.engageLock("TabTransition");
g_AjaxQueue.engageLock("MainDataLoaded");
g_AjaxQueue.engageLock("LeftNavLoaded");
g_iActiveTabId = this.iTabId;
if (g_AjaxQueue.isLocked("LoadPage") == false) {
setHistoryToActiveTab();
}
g_strActiveMainDialog = aTabs[this.iTabId].maindialog;
for (var i = 0 ; i < aTabs.length ; i++) {
if (document.getElementById(aTabs[i].maintab).className == "active") {
if (document.getElementById(aTabs[i].maintab).className == "tab_" + this.id) {
return;
} else {
document.getElementById(aTabs[i].maintab).className = "";
}
}
}
document.getElementById("tab_" + this.id).className = "active";
getLeftNav( aTabs[this.iTabId].leftnavdialog );
getMainData( aTabs[this.iTabId].maindialog, aTabs[this.iTabId].pDoOnLoad );
} catch (e) {
alert("Could not change tab: " + e.message);
}
}
return false;
}
function ChangeToTabById( iTabId ) {
if (parseInt(g_iActiveTabId) > 0) {
if (aTabs[g_iActiveTabId].pDoOnUnload != '') {
try {
var pFunct = window[aTabs[g_iActiveTabId].pDoOnUnload];
if( pFunct ) {
pFunct();
} else {
alert("Could not initialize search. (1)");
}
} catch ( e ) {
alert("Could not initialize search. (2)");
}
}
}
if( !aTabs[iTabId] ) {
iTabId = 0;
}
g_iActiveTabId = iTabId;
g_AjaxQueue.engageLock("TabTransition");
g_AjaxQueue.engageLock("MainDataLoaded");
g_AjaxQueue.engageLock("LeftNavLoaded");
g_bTabTransitionComplete = false;
g_bMainDataLoaded = false;
g_bLeftNavLoaded = false;
g_strActiveMainDialog = aTabs[iTabId].maindialog;
getLeftNav( aTabs[iTabId].leftnavdialog );
getMainData( aTabs[iTabId].maindialog, aTabs[iTabId].pDoOnLoad );
for (var i = 0 ; i < aTabs.length ; i++) {
if( i == iTabId ) {
document.getElementById("tab_" + aTabs[i].section).className = "active";
} else {
document.getElementById("tab_" + aTabs[i].section).className = "";
}
}
if (g_AjaxQueue.isLocked("LoadPage") == false) {
setHistoryToActiveTab();
}
}
function ChangeToTabByName( strTabName ) {
var iTabId = 0; if( strTabName && strTabName != '' ) {
for(var i=0; i < aTabs.length; i++) {
if( aTabs[i].name == strTabName ) {
iTabId = i;
}
}
}
ChangeToTabById(iTabId);
}
function initializeDefaultTab() {
if (location.hash != '') {
applyHashUrl(location.hash);
} else {
ChangeToTabByName(document.getElementById("init_type").value);
if (document.getElementById("init_subtype").value == "map") {
initializePolygonSearch();
}
}
setTimeout("watchHashUrl();", 5000);
}
function initializePolygonSearch() {
try {
g_bDisableAutoMaximize = true;
document.getElementById("main_background").style.height = "0px";
document.getElementById("page_body").style.height = "0px";
document.getElementById("arrows").className = "arrows_down";
postMainShrink();
toggleSearchByMap();
var img = document.getElementById("minimize_button");
if( img ) img.src = '/images/maximize_butn.gif';
setTimeout('g_bDisableAutoMaximize = false;', 9000);
} catch (e) {
}
}
function getMainData(strId, strFunction) {
var fCallback = function(pCbcAjaxReq) {
document.getElementById("page_body").innerHTML = pCbcAjaxReq.responseText;
g_bMainDataLoaded = true;
g_AjaxQueue.disengageLock("MainDataLoaded");
var iNumTries = 0;
var iMaxTries = 99;
if (strFunction != '') {
try {
var pFunct = window[strFunction];
if( pFunct ) {
pFunct();
} else {
alert("Could not initialize search. (3)");
}
} catch ( e ) {
if(iNumTries >= iMaxTries) {
alert("Could not initialize search. (4):" + e.message);
} else {
iNumTries++;
setTimeout('getMainData(\''+strId+'\',\''+strFunction+'\')',500);
}
}
}
}
g_AjaxQueue.schedule("MainNavTemplate", "getform.php?type=main&id="+strId, fCallback, false, true);
}
function getLeftNav(strId) {
var fCallback = function(xml) {
document.getElementById("search_leftnav").innerHTML = xml.responseText;
g_bLeftNavLoaded = true;
g_AjaxQueue.disengageLock("LeftNavLoaded");
if( g_sCountry ) {
if(document.getElementById('prop_search_button_us')) {
if( g_sCountry == 'US' ) {
SetCountry(document.getElementById('prop_search_button_us'),'US');
} else {
SetCountry(document.getElementById('prop_search_button_ca'),'CA');
}
if(oViewStatesLink = document.getElementById('prop_search_view_states_link')) {
oViewStatesLink.innerHTML = ( g_sCountry=='US' ) ? oViewStatesLink.innerHTML.replace(/Province/,'State'):oViewStatesLink.innerHTML.replace(/States/,'Province');
}
}
}
}
g_AjaxQueue.schedule("LeftNav", "getform.php?type=leftnav&id="+strId, fCallback, true, true);
}
RfgQueueCommand("initializeDefaultTab();");
var pTempTop = document.getElementById("atop_properties");
if( pTempTop ) {
pTempTop.onclick = function() {
ChangeToTabByName("property");
}
}
var pTempBot1 = document.getElementById("abot_properties");
if( pTempBot1 ) {
pTempBot1.onclick = function() {
ChangeToTabByName("property");
}
}
var pTempBot2 = document.getElementById("abot_office");
if( pTempBot2 ) {
pTempBot2.onclick = function() {
ChangeToTabByName("office");
}
}
g_AjaxQueue.registerLock("LoadPage");
function silentError( e ) { return; }
g_AjaxQueue.RegisterErrorHandler( silentError );
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
return stringToTrim.replace(/\s+$/,"");
}
function SetInnerHtml(strObjId, strValue) {
var pObj = document.getElementById(strObjId);
if( pObj ) {
pObj.innerHTML = strValue;
}
}
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function getNodeValue(obj, tag)
{
if( obj ) {
var pElement = obj.getElementsByTagName(tag);
if( pElement && pElement[0] ) {
if( pElement[0].firstChild ) {
return pElement[0].firstChild.nodeValue;
}
}
}
return "";
}
function CbcShowWaitDialog()
{
try {
var pWaitDlg = document.getElementById("cbc_wait_dialog");
if( pWaitDlg ) {
pWaitDlg.style.visibility = 'visible';
}
} catch (e) {
}
}
function CbcHideWaitDialog()
{
try {
var pWaitDlg = document.getElementById("cbc_wait_dialog");
if( pWaitDlg ) {
pWaitDlg.style.visibility = 'hidden';
}
} catch (e) {
}
}
function CloseProfileDialog( strDivId )
{
var oWindow = document.getElementById("page_body");
if( oWindow ) {
var eDiv = document.getElementById(strDivId);
if( eDiv ) {
oWindow.removeChild(eDiv);
truncateBreadcrumb();
displayBreadcrumb();
setHistoryToActiveTab();
}
var eActionArea = document.getElementById("tab_action_area");
if( eActionArea ) {
eActionArea.innerHTML = '';
}
}
if (g_bDisableAutoMaximize == false) maximizeMainWindow();
if (document.getElementById("property_sort") != undefined &&
g_bIE6 == true) {
document.getElementById("property_sort").style.visibility = "visible";
}
}
function handleShowProfile(responseText, eDiv, strCloseImgSrc)
{
g_AjaxQueue.engageLock("LoadPage");
try {
eDiv.innerHTML = responseText;
eDiv.scrollTop = 0;
eDiv.scrollLeft = 0;
if( strCloseImgSrc ) {
var eActionArea = document.getElementById("tab_action_area");
if( eActionArea ) {
eActionArea.innerHTML = '<a href="Javascript:CloseProfileDialog(\''+eDiv.id+'\');"><img src="' + strCloseImgSrc + '" border=0></a>';
}
}
} catch (e) {
alert("Could not display property. " + e.message);
}
setTimeout("g_AjaxQueue.disengageLock('LoadPage');", 1500);
}
function fitImageToContentArea(pImg, ContentAreaId){
var pDiv = document.getElementById(ContentAreaId);
if( pDiv ) {
var divWidth = parseInt(pDiv.offsetWidth);
if( pImg.width > divWidth ) {
pImg.width = divWidth - 50;
}
}
}
function number_addCommas(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function OpenLink(strUrl, strType, oLink, strTitle, bInterrupt) {
if (document.getElementById("property_sort") != undefined &&
g_bIE6 == true) {
document.getElementById("property_sort").style.visibility = "hidden";
}
if (strTitle == null) {
strTitle = oLink.attributes.title.value;
}
var oLinkType = new LinkStyle(strType);
var oWindow = document.getElementById("page_body");
if (!oWindow) {
alert("Page Body Missing! Fall back to classic site!");
} else {
var eDiv = document.getElementById('profile_pane');
if (eDiv == undefined) {
eDiv = document.createElement('div');
eDiv.className = 'profile_pane';
eDiv.id = 'profile_pane';
}
}
switch (oLinkType.linkStyle) {
case "new":
oLWindow = window.open(strUrl,
"openlink_window",
"");
break;
case "div":
var fCallback = function(pCbcAjaxReq) {
eDiv.innerHTML = 'Loading...';
oWindow.appendChild(eDiv);
CbcHideWaitDialog();
handleShowProfile(pCbcAjaxReq.responseText, eDiv, oLinkType.returnImage);
}
CbcShowWaitDialog();
g_AjaxQueue.schedule("ShowProfileDialog", strUrl, fCallback);
break;
case "iframe":
eDiv.innerHTML = 'Loading...';
oWindow.appendChild(eDiv);
CbcShowWaitDialog();
eDiv.innerHTML = "<iframe class=\"profile_dialog\" frameborder=\"0\" border=\"0\" "+
"width=\"100%\" height=\"100%\" src=\""+strUrl+"\" >Loading...</iframe>";
CbcHideWaitDialog();
break;
case "overwrite":
document.location.href = strUrl;
return;
break;
default:
alert("There was an error determining how to handle this link.\n"+ "Falling back to Classic Mode.");
break;
}
var fBreadCrumbCall = function () {
OpenLink(strUrl, strType, oLink, strTitle, bInterrupt);
}
if (oLinkType.breadcrumbStyle == "append") {
pushBreadcrumb(strTitle,
fBreadCrumbCall);
displayBreadcrumb();
} else if (oLinkType.breadcrumbStyle == "replace") {
setBreadcrumb(oLinkType.breadcrumbPos,
strTitle,
fBreadCrumbCall,
oLinkType.breadcrumbTruncate);
displayBreadcrumb();
}
setHistory(strUrl, strType, strTitle);
if (oLinkType.wtod != null) {
oLinkType.wtod(strUrl, strTitle);
}
return false;
}
function LinkStyle(strType) {
switch (strType) {
case "profile-agent":
this.linkStyle = 'div';
this.breadcrumbStyle = 'replace';
this.breadcrumbPos = 1;
this.breadcrumbTruncate = true;
this.returnImage = '/images/buttons/bcksrchresult.jpg';
this.wtod = function(strUrl, strTitle) {
try {
var aParams = getUrlParams(strUrl);
if (g_iActiveTabId == 0) {
dcsMultiTrack('DCS.dcsuri',
strUrl,
'WT.ti',
'[pageTitle]',
'WT.si_n',
'PropertySearch',
'WT.si_x',
'4',
'WT.z_engage_type',
'Indirect',
'WT.z_engage_event',
'View Agent Info',
'WT.z_agent_id',
aParams["cbcpersonkey"]);
pageTracker._trackPageview("PropertySearch/ViewAgentInfo/"+aParams["cbcpersonkey"]);
} else {
dcsMultiTrack('DCS.dcsuri', strUrl,'WT.ti', strTitle,'WT.si_n', 'AgentSearch','WT.si_x','2');
pageTracker._trackPageview("AgentSearch/AgentProfile");
}
} catch ( e ) {
}
};
break;
case "profile-office":
this.linkStyle = 'div';
this.breadcrumbStyle = 'replace';
this.breadcrumbPos = 1;
this.breadcrumbTruncate = true;;
this.returnImage = '/images/buttons/bcksrchresult.jpg';
this.wtod = function(strUrl, strTitle) {
if (strUrl.match(/roster/)) {
dcsMultiTrack('DCS.dcsuri',
strUrl,
'WT.ti',
strTitle,
'WT.si_n',
'OfficeSearch',
'WT.si_x',
'4',
'WT.z_engage_type',
'Indirect',
'WT.z_engage_event',
'Associate Roster');
pageTracker._trackPageview("OfficeSearch/AssociateRoster");
} else {
var aParams = getUrlParams(strUrl);
var strSin = 'OfficeSearch';
var strSix = '2';
if( aParams['wtodpath'] && aParams['wtodpath'] == 'listing' ) {
strSin = 'PropertySearch';
strSix = '5';
}
dcsMultiTrack('DCS.dcsuri',
strUrl,
'WT.ti',
strTitle,
'WT.si_n',
strSin,
'WT.si_x',
strSix,
'WT.z_engage_type',
'Indirect',
'WT.z_engage_event',
'View Office Info');
pageTracker._trackPageview(strSin+"/ViewOfficeInfo");
}
};
break;
case "profile-listing":
this.linkStyle = 'div';
this.breadcrumbStyle = 'replace';
this.breadcrumbPos = 1;
this.breadcrumbTruncate = true;
this.returnImage = '/images/buttons/bcksrchresult.jpg';
this.wtod = function(strUrl, strTitle) {
var aParams = getUrlParams(strUrl);
if (aParams["showtab"] == "Media") {
dcsMultiTrack('DCS.dcsuri',strUrl,'WT.ti',strTitle,'WT.si_n','PropertySearch','WT.si_x','3','WT.z_engage_type', 'Engage', 'WT.z_engage_event', 'View Prop Multimedia');
pageTracker._trackPageview("PropertySearch/ViewPropMultimedia");
} else {
dcsMultiTrack('DCS.dcsuri',strUrl,'WT.ti',strTitle,'WT.si_n','PropertySearch','WT.si_x','2');
pageTracker._trackPageview("PropertySearch/ProfileListing");
}
};
break;
case "url-local":
this.linkStyle = 'overwrite';
this.breadcrumbStyle = 'append';
this.breadcrumbPos = 0;
this.breadcrumbTruncate = false;
this.wtod = null;
break;
case "url-external":
this.linkStyle = 'new';
this.breadcrumbStyle = 'none';
this.breadcrumbPos = 0;
this.breadcrumbTruncate = false;
this.wtod = null;
break;
case "url-external-marketconnect":
this.linkStyle = 'new';
this.breadcrumbStyle = 'none';
this.breadcrumbPos = 0;
this.breadcrumbTruncate = false;
this.wtod = null;
break;
case "contact-agent":
this.linkStyle = 'iframe';
this.breadcrumbStyle = 'append';
this.breadcrumbPos = 0;
this.breadcrumbTruncate = false;
this.wotd = null;
break;
case "contact-office":
this.linkStyle = 'iframe';
this.breadcrumbStyle = 'append';
this.breadcrumbPos = 0;
this.breadcrumbTruncate = false;
this.wtod = function(strUrl, strTitle) {
dcsMultiTrack('DCS.dcsuri', strUrl,'WT.ti', strTitle,'WT.si_n','OfficeSearch',
'WT.si_x','5','WT.z_engage_type','Direct','WT.z_engage_event','Email Office');
pageTracker._trackPageview("OfficeSearch/EmailOffice");
};
break;
case "contact-listing":
this.linkStyle = 'iframe';
this.breadcrumbStyle = 'append';
this.breadcrumbPos = 0;
this.breadcrumbTruncate = false;
this.wtod = function(strUrl, strTitle) {
dcsMultiTrack('DCS.dcsuri',strUrl,'WT.ti',strTitle,'WT.si_n',
'PropertySearch','WT.si_x','5','WT.z_engage_type',
'Direct','WT.z_engage_event','Appointment');
pageTracker._trackPageview("ProeprtySearch/Appointment");
};
break;
case "url-help":
this.linkStyle = 'new';
this.breadcrumbStyle = '';
this.breadcrumbPos = 0;
this.breadcrumbTruncate = false;
this.wtod = null;
break;
}
}
function checkForEnter(e) {
var iCharCode = (e.which == undefined) ? e.keyCode : e.which;
if (iCharCode == 13) {
return true;
} else {
return false;
}
}
function stripServerName( strUri ){
if( strUri.indexOf('http://') > -1 ) {
var strTemp = strUri.substr(7);
var i = strTemp.indexOf('/');
if( i > -1 ) {
return strTemp.substr(i);
}
}
}
function getPrimaryMediaUrl( pMedia ){
if( pMedia && pMedia[0] && pMedia[0].firstChild ) {
var pSubs = pMedia[0].getElementsByTagName('media');
if( pSubs && pSubs[0] && pSubs[0].firstChild ) {
var type = getNodeValue(pSubs[0], 'type');
var uri = getNodeValue(pSubs[0], 'uri');
var displayonwww = getNodeValue(pSubs[0], 'displayonwww');
if( type == 'Image' && displayonwww == 'true') {
return stripServerName(uri);
}
}
}
return '';
}
function getUrlParams(strUrl) {
var aPairSplit;
var aSearchKeys = new Array();
aSearchKeys['listingtype'] = new Array();
aGetPairs = strUrl.split("?")[1].split("&");
for (var i in aGetPairs) {
aPairSplit = aGetPairs[i].split('=');
aSearchKeys[aPairSplit[0]] = aPairSplit[1];
}
return aSearchKeys;
}
function GetPaginatedPageLinks(strCbFunctionName, iNumResults, iLimit, iOffset)
{
var strPageLinks = '';
if( !iNumResults ) iNumResults = 0;
if( !iLimit ) iLimit = 0;
if( !iOffset ) iOffset = 0;
iNumResults = parseInt(iNumResults);
iLimit = parseInt(iLimit);
iOffset = parseInt(iOffset);
if( iLimit < 5) {
iLimit = 10;
}
var iCurrentPage = parseInt(iOffset / iLimit);
var iNumPages = parseInt(iNumResults / iLimit);
var iRem = iNumResults % iLimit;
if (iRem > 0 ) {
iNumPages++;
}
if( iNumPages < 2 ) {
strPageLinks = " &nbsp; ";
return strPageLinks;
}
var iTmpPage = 0;
var iLastPage = 0;
var iFirstPage = 0;
strPageLinks = "go to page &nbsp; ";
if ( iCurrentPage > 0 ) {
strPageLinks += "<a href=\"Javascript:" + strCbFunctionName + "(" + ( (iCurrentPage - 1) * iLimit ) + ");\">";
strPageLinks += "&lt;</a> ";
}
iTmpPage = iCurrentPage - 2;
iLastPage = iCurrentPage + 3;
if ( iTmpPage < 0 ) iTmpPage = 0;
if ( iCurrentPage < 3 ) iLastPage = 5;
if ( iLastPage >= iNumPages ) iLastPage = iNumPages;
iFirstPage = iTmpPage;
if ( iFirstPage > 0 ) {
strPageLinks += "...";
}
while ( iTmpPage < iLastPage ) {
if ( iTmpPage > iFirstPage ) strPageLinks += " | ";
if ( iTmpPage == iCurrentPage ) {
strPageLinks += "<span class=\"currentpage\">" + ( iTmpPage + 1 ) + "</span>";
} else {
strPageLinks += "<a href=\"Javascript:" + strCbFunctionName + "(" + ( (iTmpPage) * iLimit ) + ");\">";
strPageLinks += parseInt(( iTmpPage + 1 ));
strPageLinks += "</a>";
}
iTmpPage++;
}
if ( iLastPage < iNumPages ) strPageLinks += "...";
if ( (iCurrentPage+1) < iNumPages ) {
strPageLinks += " <a href=\"Javascript:" + strCbFunctionName + "(" + ( (iCurrentPage + 1) * iLimit ) + ");\">";
strPageLinks += "&gt;</a>";
}
return strPageLinks;
}
function GetCurrentlyShowing(iNumResults, iLimit, iOffset)
{
var strCurrShowing = '';
if( !iNumResults ) iNumResults = 0;
if( !iLimit ) iLimit = 0;
if( !iOffset ) iOffset = 0;
iNumResults = parseInt(iNumResults);
iLimit = parseInt(iLimit);
iOffset = parseInt(iOffset);
if( iNumResults > 0 ) {
strCurrShowing = 'Showing listings ';
if( !iOffset || iOffset == 0 ) {
strCurrShowing += '1 - ';
} else {
strCurrShowing += iOffset + ' - ';
}
if( (iOffset + iLimit) > iNumResults ) {
strCurrShowing += iNumResults;
} else {
strCurrShowing += (iOffset + iLimit);
}
strCurrShowing += ' of ' + iNumResults;
} else {
strCurrShowing = 'No listings found';
}
return strCurrShowing;
}
function MarkAllInContainerChecked(strContainerId, bChecked)
{
var pObj = document.getElementById(strContainerId);
if ( pObj ) {
var aInput = pObj.getElementsByTagName('input');
for (var i=0; i< aInput.length; i++) {
if (aInput[i].type == 'checkbox') {
aInput[i].checked = bChecked;
}
}
return true;
}
return false;
}
function MarkChecked(strCheckboxId, bChecked)
{
var pCheckbox = document.getElementById(strCheckboxId);
if( pCheckbox ) {
pCheckbox.checked = bChecked;
}
}
function ShowProperty( iCbcListingId, latitude, longitude ) {
var strUrl = '/ajaxhtmlbin/listing?cbclistingid=' + escape(iCbcListingId);
OpenLink(strUrl, "profile-listing", null, "Property Profile");
if( latitude != 0 && longitude != 0 ) {
var oLatLon = new VELatLong( latitude, longitude );
g_pAreaMap.SetCenterAndZoom( oLatLon, 15 );
}
}
function MapProperty( iCbcListingId, latitude, longitude, strType, strPrice ) {
try {
var oLatLon = new VELatLong( latitude, longitude );
g_pAreaMap.SetCenterAndZoom( oLatLon, 15 );
var pElement = document.getElementById( ""+ iCbcListingId );
if( !pElement ) {
AddPropertyPushPin(iCbcListingId, latitude, longitude, strType, strPrice, null);
}
toggleMainWindow();
setTimeout(SetBirdseyeButton, 3000);
} catch (e) {
alert("Could not map property, " + e.message);
}
}
function showMiniPropertyDetails( iListingId ){
var pMiniDetails = document.getElementById( 'MapMiniDetailsDiv' );
if ( pMiniDetails == null ) {
pMiniDetails = document.createElement("div");
pMiniDetails.id = 'MapMiniDetailsDiv';
pMiniDetails.style.display = 'none';
document.body.appendChild(pMiniDetails);
}
g_iMiniDetailsId = iListingId;
document.getElementById('RfgMapHoverDiv').style.display='none';
g_bRfgSearchTipVisible = false;
g_bRfgSearchTipCurrentId = "";
var strUrl = '/xmlbin/searchproperty?xmlformat=full&cbclistingid='+ iListingId +'&limit=1';
CbcShowWaitDialog();
var fCallback = function(pCbcAjaxReq) {
if(pCbcAjaxReq.readyState == 4) {
CbcHideWaitDialog();
if( pCbcAjaxReq.status == 200 ) {
handleShowMiniProfile(pCbcAjaxReq.responseXML, pMiniDetails );
} else {
alert("Could not load mini profile, please try again.");
pMiniDetails.style.display = 'none';
}
}
}
g_AjaxQueue.schedule("MiniPropertyDetails", strUrl, fCallback);
}
function hideMiniProfile(){
g_iMiniDetailsId = '';
var pMiniDetails = document.getElementById( 'MapMiniDetailsDiv' );
if ( pMiniDetails ) {
pMiniDetails.style.display = 'none';
}
}
function MiniMapShowProperty( iCbcListingId, latitude, longitude){
hideMiniProfile();
maximizeMainWindow();
ShowProperty(iCbcListingId, latitude, longitude );
}
function handlePopulate3dMiniProfile( pListing ){
if( pListing != null ) {
var iCbcListingId = getNodeValue(pListing, 'listingid');
var latitude = getNodeValue(pListing, 'latitude');
var longitude = getNodeValue(pListing, 'longitude');
var type = getNodeValue(pListing, 'listingtype');
var address = getNodeValue(pListing, 'address1');
var addresstwo = getNodeValue(pListing, 'address2');
if( addresstwo != '' && addresstwo != '-' ){
address += '<br />'+ addresstwo;
}
address += '<br />'+ getNodeValue(pListing, 'city')
address += ', '+ getNodeValue(pListing, 'stateprovince')
address += ' '+ getNodeValue(pListing, 'postalcode')
var price = parseInt(getNodeValue(pListing,'baseprice'));
if( price > 0 ) {
price = '$' + addCommas(price);
} else {
price = '$call';
}
var previewimages = '';
var firsturi = getNodeValue(pListing, 'imagepreviewuri');
if( firsturi == null || firsturi.length<1){
firsturi = '/images/nophoto/listing.gif';
}
var strLink = '<a href="Javascript:window.opener.MiniMapShowProperty('+iCbcListingId+', '+latitude+', '+longitude+');window.close();"><img src="/images/buttons/details.gif" class="detailsbtn" border="0" align="middle" /></a> ';
var strDetails = '<div id="propdetails"><span class="miniproptype">'+ type +'</span><br />'+ address +'<br />'+ price +'<br />'+ strLink +'</div>';
var strRequest = '<iframe id="requestinfo" border="0" frameborder="0" src="/emailto/minilistingframe.php?cbclistingid='+ iCbcListingId +'"></iframe>';
var strPreview = '<div id="previewimages">'+ '' +'</div>';
var strContent = '<img id="minimainimage" src="'+ firsturi +'">'+ strDetails + strPreview + strRequest;
strContent = '<div class="MapMiniDetailsDiv"><div class="content">'+strContent+'</div></div>';
var aSelectedListings = new Array();
AddPropertyPushPin(iCbcListingId, latitude, longitude, type, price, aSelectedListings, 'RFGMAPDIV_3D', strContent);
}
}
function handleShowMiniProfile( responseXML, pWindow ){
if( pWindow ) {
var listings = responseXML.getElementsByTagName('listing');
if( listings.length > 0 ) {
var iCbcListingId = getNodeValue(listings[0], 'listingid');
var latitude = getNodeValue(listings[0], 'latitude');
var longitude = getNodeValue(listings[0], 'longitude');
var type = getNodeValue(listings[0], 'listingtype');
var address = getNodeValue(listings[0], 'address1');
var addresstwo = getNodeValue(listings[0], 'address2');
if( addresstwo != '' && addresstwo != '-' ){
address += '<br />'+ addresstwo;
}
address += '<br />'+ getNodeValue(listings[0], 'city')
address += ', '+ getNodeValue(listings[0], 'stateprovince')
address += ' '+ getNodeValue(listings[0], 'postalcode')
var price = parseInt(getNodeValue(listings[0],'baseprice'));
if( price > 0 ) {
price = '$' + addCommas(price);
} else {
price = '$call';
}
var previewimages = '';
var firsturi = '/images/nophoto/listing.gif';
var uri = '/images/nophoto/listing.gif';
var sub = listings[0].getElementsByTagName('listingmedia');
if( sub.length > 0 ) {
var photocount = 0;
var media = sub[0].getElementsByTagName('media');
for( i = 0; i < media.length; i++ ) {
var imgtype = getNodeValue(media[i], 'type');
if( imgtype == 'Image' ) {
uri = getNodeValue(media[i], 'uri');
if( photocount == 0 ) firsturi = uri;
if( photocount < 4 ) {
previewimages += '<img src="'+ uri +'" border=0';
previewimages += ' onClick="document.getElementById(\'minimainimage\').src=\''+ uri +'\';" />';
}
photocount++;
}
}
}
var strLink = '<a href="Javascript:MiniMapShowProperty('+iCbcListingId+', '+latitude+', '+longitude+');"><img src="/images/buttons/details.gif" class="detailsbtn" border="0" align="middle" /></a> ';
var strDetails = '<div id="propdetails"><span class="miniproptype">'+ type +'</span><br />'+ address +'<br />'+ price +'<br />'+ strLink +'</div>';
var strRequest = '<iframe id="requestinfo" border="0" frameborder="0" src="/emailto/minilistingframe.php?cbclistingid='+ iCbcListingId +'"></iframe>';
var strPreview = '<div id="previewimages">'+ previewimages +'</div>';
var strCloseLink = '<a href="#" onClick="hideMiniProfile();" class="closebutton"><img src="/images/close_small_white.jpg" border=0></a>';
var strContent = '<img id="minimainimage" src="'+ firsturi +'">'+ strDetails + strPreview + strRequest + strCloseLink;
pWindow.innerHTML = '<div class="triangle"></div><div class="shadow"><div class="content">'+ strContent +'</div></div>';
}
}
var intX = 0;
var intY = 0;
var pElement = document.getElementById( ""+ iCbcListingId );
if( pElement ) {
var coord = RfgPixelFromLatLong(g_strAreaMapObjId, (pElement.vePushpin).GetLatitude(), (pElement.vePushpin).GetLongitude() );
intX = coord.x;
intY = coord.y;
}
RfgSetObjectPosition(pWindow, intX+7, intY - 83);
pWindow.style.display = 'block';
}
function PropertyMapChecked(){
var strCookie = GetCookie("PropCompare");
if( !strCookie ) {
alert('Please select one or more properties to view them on the map.');
return;
}
var aCompare = strCookie.split("|");
if (aCompare.length < 1) {
alert("Please select properties to map.");
} else {
var aLatLongPoints = new Array();
for( var i = 0; i < aCompare.length; i++) {
var aProperty = aCompare[i].split('*');
var iCbcListingId = aProperty[0];
var latitude = aProperty[1];
var longitude = aProperty[2];
var strType = aProperty[3];
var strPrice = aProperty[4];
if( (latitude != 0) && (longitude != 0) ) {
var pElement = document.getElementById( ""+ iCbcListingId );
if( !pElement ) {
AddPropertyPushPin(iCbcListingId, latitude, longitude, strType, strPrice, null);
}
aLatLongPoints.push( new VELatLong(parseFloat(latitude), parseFloat(longitude)) );
}
}
minimizeMainWindow();
if( aLatLongPoints.length > 0 ) {
RfgResizeMapToPoints('RFGMAPDIV_1', aLatLongPoints);
}
}
}
function PropertyViewChecked(){
var strCookie = GetCookie("PropCompare");
var aCompare = strCookie.split("|");
if (aCompare.length == 0 | aCompare[0] == "") {
alert("Please select properties to compare.");
} else if (aCompare.length == 1) {
aProperty = aCompare[0].split('*');
ShowProperty(aProperty[0], aProperty[1], aProperty[2]);
} else {
var strUrl = '/ajaxhtmlbin/compare?r='+ Math.random();
OpenLink(strUrl, "profile-listing", null, "Property Comparison");
dcsMultiTrack('DCS.dcsuri',
location.href,
'WT.ti',
'Property Search',
'WT.si_n',
'PropertySearch',
'WT.si_x',
'3',
'WT.z_engage_type',
'Engage',
'WT.z_engage_event',
"Compare Properties");
pageTracker._trackPageview("CompareProperties");
}
}
g_aBreadcrumbs = new Array();
function BreadcrumbLink(strTitle, strCode) {
this.name = strTitle;
this.onclick = strCode;
}
function setBreadcrumb(iPosition, strTitle, strCode, bTruncate) {
g_aBreadcrumbs[iPosition] = new BreadcrumbLink(strTitle, strCode);
if (bTruncate) {
g_aBreadcrumbs.length = iPosition + 1;
}
}
function pushBreadcrumb(strTitle, strHref, bNoDisplay) {
g_aBreadcrumbs.push(new BreadcrumbLink(strTitle, strHref));
if (bNoDisplay == false) {
displayBreadcrumb();
}
}
function truncateBreadcrumb() {
if( g_aBreadcrumbs.length > 0 ){
g_aBreadcrumbs.length = g_aBreadcrumbs.length - 1;
}
}
function displayBreadcrumb() {
var aCode = new Array();
if (g_aBreadcrumbs.length > 0) {
for (var i = 0 ; i < g_aBreadcrumbs.length ; i++) {
if (i == (g_aBreadcrumbs.length - 1)) {
aCode.push(g_aBreadcrumbs[i].name);
} else {
aCode.push("<a href=\"javascript:breadcrumbClick("+i+");"+
"\">"+
g_aBreadcrumbs[i].name+
"</a>");
}
}
document.getElementById("a_breadcrumbs").innerHTML = aCode.join(" &gt; ");
}
}
function breadcrumbClick(iLink) {
eval(g_aBreadcrumbs[iLink].onclick);
g_aBreadcrumbs.length = iLink + 1;
displayBreadcrumb();
}
var g_wHelp;
function spawnHelp() {
var strTabName = aTabs[g_iActiveTabId].name;
g_wHelp = window.open("/help/index.php?topic="+strTabName,
"help_window",
"toolbar=yes,status=yes,resizeable=yes,scrollbars=yes");
}
var g_strCurrentHash = '';
var g_oPostSearchLink = new HistoryLink();
function HistoryLink() {
this.ready = false;
this.title = null;
this.location = null;
this.type = null;
}
function applyHashUrl(strHash) {
var hash = strHash.replace("#", "");
var aComponents = hash.split(",");
var aSplit = new Array();
var iTab;
var strLocation;
var strPageType;
var strTitle;
var strLocation;
var strIndex;
var strValue;
if (hash == "") { return; }
for (var s in aComponents) {
aSplit = aComponents[s].split("=");
strIndex = aSplit.shift();
strValue = aSplit.join("=");
switch (strIndex) {
case "t":
iTab = parseInt(strValue);
break;
case "loc":
strLocation = UrlDecode(strValue);
break;
case "ti":
strTitle = UrlDecode(strValue);
break;
case "pt":
strPageType = strValue;
break;
}
}
if (strLocation && strPageType && strTitle) {
g_oPostSearchLink.ready = true;
g_oPostSearchLink.location = strLocation;
g_oPostSearchLink.type = strPageType;
g_oPostSearchLink.title = strTitle;
} else {
CloseProfileDialog("profile_pane");
}
if (iTab != undefined && iTab != g_iActiveTabId) {
ChangeToTabById(iTab);
} else {
SetPendingHistoryProfile();
}
}
function SetPendingHistoryProfile() {
if (g_oPostSearchLink.ready == true) {
OpenLink(g_oPostSearchLink.location,
g_oPostSearchLink.type,
null,
g_oPostSearchLink.title,
false);
g_oPostSearchLink.ready = false;
}
}
function setHistory(strUrl, strPageType, strTitle) {
var strHash = "pt="+strPageType+
",t="+g_iActiveTabId+
",ti="+strTitle+
",loc="+strUrl;
g_strCurrentHash = strHash;
document.getElementById("history_iframe").src = "/enhanced/history.php?pt="+strPageType+
"&t="+g_iActiveTabId+
"&ti="+escape(strTitle)+
"&loc="+escape(strUrl);
}
function watchHashUrl() {
if ((UrlDecode(window.location.hash.replace('#', '')) != UrlDecode(g_strCurrentHash)) &&
g_AjaxQueue.isLocked() == false) {
g_strCurrentHash = window.location.hash.replace('#', '');
applyHashUrl(location.hash);
setTimeout("watchHashUrl()", 3000);
}
setTimeout("watchHashUrl()", 1500);
}
function setHistoryToActiveTab() {
if (g_oPostSearchLink.ready == false) {
document.getElementById("history_iframe").src = "/enhanced/history.php?t="+g_iActiveTabId;
g_strCurrentHash = 't='+g_iActiveTabId;
}
}
var g_iTotalCompareProperties = 3;
var g_iTotalSavedProperties = 18;
function supportCookieSave( strCookieValue, strCookieName, iMax )
{
var bAlreadyInCart = false;
var iCartLocation = 0;
var bFallbackNotify = true;
var strPropString = GetCookie(strCookieName);
var iCurr;
var lCbcListingId;
var lComp;
var aPropertyArray;
var strNewString;
var bFirst = true;
var dtExpiration = (new Date((new Date()).getTime() + 30*150000));
if ( strPropString ) {
aPropertyArray = strPropString.split('|');
} else {
aPropertyArray = new Array;
}
var aTemp = strCookieValue.split('*');
lComp = aTemp[0];
strNewString = "";
for ( iCurr=0; iCurr < aPropertyArray.length; iCurr++ ) {
aTemp = aPropertyArray[iCurr].split('*');
lCbcListingId = aTemp[0];
if ( lCbcListingId == lComp ) {
bAlreadyInCart = true;
iCartLocation = iCurr;
} else {
if ( !bFirst ) {
strNewString += "|" + aPropertyArray[iCurr];
} else {
strNewString += aPropertyArray[iCurr];
bFirst = false;
}
}
}
if ( !bAlreadyInCart ) {
if( aPropertyArray.length > 17 ) {
alert("You may only save up to 18 listings at a time. Please remove one or more listings from your list before trying to add more.");
return;
} else {
if ( !bFirst )
strNewString += "|";
strNewString += strCookieValue;
}
}
SetCookie(strCookieName, strNewString, dtExpiration, "/", null, false);
if ( document.getElementById ) {
var pImg = null; if ( pImg ) {
if ( bAlreadyInCart ) {
pImg.src = 'to-do';
} else {
pImg.src = 'to-do';
}
bFallbackNotify = false;
}
}
if ( bFallbackNotify ) {
if ( bAlreadyInCart ) {
alert("You have removed this property from your saved listings.");
} else {
alert("You have added this property to your saved listings.");
}
}
if( !bAlreadyInCart ){
strPropString = GetCookie(strCookieName);
if( strPropString == null || strPropString == '' )
alert("You must have cookies enabled in your browser to use this feature.");
}
return bAlreadyInCart;
}
function ToggleSaveListing( lCbcListingId ){
supportCookieSave( lCbcListingId, "ListingSave", g_iTotalSavedProperties );
}
function ToggleCompare( strCookieValue ){
var aProperty = strCookieValue.split('*');
var strIcon = '';
var iCbcListingId = aProperty[0];
var latitude = aProperty[1];
var longitude = aProperty[2];
var strType = aProperty[3];
var strPrice = aProperty[4];
if( supportCookieSave( strCookieValue, "PropCompare", g_iTotalCompareProperties ) ){
if( strType.indexOf('Lease') > -1 ) strIcon = '/images/pushpins/proporlease.gif'; else strIcon = '/images/pushpins/propforsale.gif';
} else {
strIcon = '/images/pushpins/selectedprop.gif';
}
g_pAreaMap.DeletePushpin(""+ iCbcListingId);
var strHover = '<span class="proptype">'+ strType +'</span><br />'+ strPrice;
AddPushPin('RFGMAPDIV_1', iCbcListingId, parseFloat(latitude), parseFloat(longitude), strHover, strIcon, 'property');
}
function RemoveCompare( iCbcListingId, latitude, longitude, strType, strPrice ){
var strIcon = '';
var strCookieValue = iCbcListingId +'*'+ latitude +'*'+ longitude +'*'+ strType +'*'+ strPrice;
if( supportCookieSave( strCookieValue, "PropCompare", g_iTotalCompareProperties ) ){
if( strType.indexOf('Lease') > -1 ) strIcon = '/images/pushpins/propforlease.gif'; else strIcon = '/images/pushpins/propforsale.gif';
g_pAreaMap.DeletePushpin(""+ iCbcListingId);
var strHover = '<span class="proptype">'+ strType +'</span><br />'+ strPrice;
AddPushPin('RFGMAPDIV_1', iCbcListingId, parseFloat(latitude), parseFloat(longitude), strHover, strIcon, 'property');
var pCB = document.getElementById('compare'+ iCbcListingId);
if( pCB ) pCB.checked = false;
}
PropertyViewChecked();
}
function CheckCompare(lCbcListingId) {
var strCookie = GetCookie("PropCompare");
if (strCookie == null || strCookie == undefined) return false;
var aProps = strCookie.split("|");
for (var i in aProps) {
if (lCbcListingId == aProps[i]) {
return true;
}
}
return false;
}
function CountCompare() {
var strCookie = GetCookie("PropCompare");
if (strCookie != null) {
var aProps = strCookie.split("|");
return aProps.length;
} else {
return 0;
}
}