﻿var imagePath = "/Style%20Library/Images/";

function pageLoaded()
{

	
try{
	loadCSSBgImgs();
	

	//determine if current page is the property or agent search page
	var pageURL = document.location.href;
	
	if(pageURL.search(/\/Find\//i)!=-1)
	{
		var query = pageURL.split("?");
		var queryArray = query[query.length-1].split("&");
		var searchType = "";
		var tempArray="";
		
		for(var i=0;i<queryArray.length;i++)
		{
			tempArray = queryArray[i].split("=");
			
			if(tempArray.length>1)
				if(tempArray[0]=="search")
					searchType=tempArray[1];
			
		}
		
		if(searchType=="agent")
		{
			document.getElementById('agentSearchBtn').style.backgroundImage = "url('"+imagePath+"blankFindAgentBtnSelected.jpg')";
		}
		else
		{
			document.getElementById('propertySearchBtn').style.backgroundImage = "url('"+imagePath+"blankPropertySearchBtnSelected.jpg')";
		}
		
		
	}
}catch(e){}

try
{
	/*document.getElementById('zz1_GlobalNavn5').style.display="none";
	document.getElementById('zz1_GlobalNavn6').style.display="none";*/
/*	var zz1_GlobalNavn0Items_LastItem = document.getElementById('zz1_GlobalNavn0Items').childNodes[1].childNodes[1].childNodes;
	var zz1_GlobalNavn1Items_LastItem = document.getElementById('zz1_GlobalNavn1Items').childNodes[1].childNodes[1].childNodes;
	var zz1_GlobalNavn2Items_LastItem = document.getElementById('zz1_GlobalNavn2Items').childNodes[1].childNodes[1].childNodes;
	
	zz1_GlobalNavn0Items_LastItem[zz1_GlobalNavn0Items_LastItem.length-2].childNodes[1].childNodes[0].className = "topNavFlyOutsItem_lastCell";
	zz1_GlobalNavn1Items_LastItem[zz1_GlobalNavn1Items_LastItem.length-2].childNodes[1].childNodes[0].className = "topNavFlyOutsItem_lastCell";
	zz1_GlobalNavn2Items_LastItem[zz1_GlobalNavn2Items_LastItem.length-2].childNodes[1].childNodes[0].className = "topNavFlyOutsItem_lastCell";
*/	
}
catch(e){}


try
{
	var currentUrl = document.location.href;
	if (((currentUrl.indexOf('?search=agent') <= -1)&&(currentUrl.indexOf('?search=office') <= -1))
	&&((currentUrl.indexOf('find.aspx') > -1)||(currentUrl.indexOf('Find.aspx') > -1)))			
	{
		var zz1_GlobalNavn2 = document.getElementById('zz1_GlobalNavn2');
		zz1_GlobalNavn2.onmouseover = function() {
		Menu_HoverStatic(this);
		Hide_PriceRange_Buttons();
		}
		zz1_GlobalNavn2.onmouseout = function() {
		Menu_Unhover(this);
		Show_PriceRange_Buttons();
		}
	}
}
catch(e){}
}


function Hide_PriceRange_Buttons()
{
	var minPrice = document.getElementById('minPriceSliderHandle').style.left;
	minPrice = parseInt(minPrice.replace(/px/i,""));
	var maxPrice = document.getElementById('maxPriceSliderHandle').style.left;
	maxPrice = parseInt(maxPrice.replace(/px/i,""));

	if (minPrice < 110)
	{
		document.getElementById('minPriceSliderHandle').style.position = '';
	}
	if (maxPrice < 91)
	{
		document.getElementById('maxPriceSliderHandle').style.position = '';
	}
}

function Show_PriceRange_Buttons()
{
	if (document.getElementById('zz1_GlobalNavn2Items').style.display == 'none')
	{
		SetButtons();			
	}
	else
	{
		setTimeout("Show_PriceRange_Buttons()",100);
	}
}

function SetButtons()
{
	var minPrice = document.getElementById('minPriceSliderHandle').style.left;
	minPrice = parseInt(minPrice.replace(/px/i,""));
	var maxPrice = document.getElementById('maxPriceSliderHandle').style.left;
	maxPrice = parseInt(maxPrice.replace(/px/i,""));

	if (minPrice < 110)
	{
		document.getElementById('minPriceSliderHandle').style.position = 'relative';
	}
	if (maxPrice < 91)
	{
		document.getElementById('maxPriceSliderHandle').style.position = 'relative';
	}
}


function loadCSSBgImgs()
{
	var tables = document.getElementsByTagName('table');
	
	for(var i=0;i<tables.length;i++)
	{
		if(tables[i].className.search(/topNavItem_new/)!=-1)
		{
			//document.getElementsByTagName('table')[i].style.backgroundImage = "url('"+imagePath+"mainNavBtnBack.jpg')";
		}
	}
	
}

function findPageSelected(searchType)
{
	var pageURL = document.location.href;
	
	if(pageURL.search(/\/Find\//i)!=-1)
	{
		if(searchType=="agent")
		{
			document.getElementById('agentSearchBtn').style.backgroundImage = "url('"+imagePath+"blankFindAgentBtnSelected.jpg')";
			document.getElementById('propertySearchBtn').style.backgroundImage = "url('"+imagePath+"blankPropertySearchBtn.jpg')";
			try{setPageView("agent");}catch(e){}
		}
		else
		{
			document.getElementById('propertySearchBtn').style.backgroundImage = "url('"+imagePath+"blankPropertySearchBtnSelected.jpg')";
			document.getElementById('agentSearchBtn').style.backgroundImage = "url('"+imagePath+"blankFindAgentBtn.jpg')";
			try{setPageView("property");}catch(e){}
			
		}
	}
	else
	{
		if(searchType=="agent")
		{
			window.location.href = "/Find/Pages/default.aspx?search=agent";
		}
		else
		{
			window.location.href = "/Find/Pages/default.aspx?search=property";
		}
	}
}
