var sessionID;
var welcomeMessage;
var suppressClose;
var previousFormCategory;
var countyTable = null;
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
var balloon;
var balloonText;
var balloonMiddle;
var tooltipText;
var source;
var tgt;
var balloonTimeout;
var currentShadowObj;
var zoomTimeout;
var zoomObj;
var minPrices = new Array();
var maxPrices = new Array();

var remarksArray = new Array();
var photoObjs;

var photoLevelObj = null;
try {
  var testLevel = top.document.getElementById("photoViewerWindowPhoto");
  if ((testLevel == null) || (testLevel == 'undefined'))
  {
   photoLevelObj = document;
  }
  else
  {
   photoLevelObj = top.document;
  }  
}
catch (err)
{  
  photoLevelObj = document;
 }


document.onmousemove = getMouseXY;
 
 function searchByToggle(showID)
 {
  if (showID!='City') {
   document.getElementById('SearchByCityDiv').style.display = 'BLOCK';
   document.getElementById('SearchByAddressDiv').style.display = 'NONE';
  }
  else
  {
   document.getElementById('SearchByCityDiv').style.display = 'NONE';
   document.getElementById('SearchByAddressDiv').style.display = 'BLOCK';
  } 
 }
 
   function switchSiteTab(id,url,numTabs) {
    
    
     window.location = url;
   
   }
 
            function switchTab(id,numTabs) {
                var i,onOff;
                var p = '/ListitLib/images/tab_';
                numTabs = numTabs;
                for (i=0;i<numTabs;i++) {
                  
                    if (id==i) {
                        onOff = 'on';
                        try {
                         document.getElementById('divContent' + i).style.display = '';
                        }
                        catch (exp)
                        {
                        }
                    } else {
                        onOff = 'off';
                        try {
                         document.getElementById('divContent' + i).style.display = 'none';
                        }
                        catch (exp)
                        {
                        }
                    }
                    
                 
                   if (i == 0) {
                        document.getElementById('tab_start_0').src = p +'divider_start_' + onOff + '.gif';
                    } else {
                        if (onOff == 'on')
                            document.getElementById('tab_end_' + (i - 1)).src = p + 'divider_' + onOff + '1.gif';
                        else
                            document.getElementById('tab_end_' + (i - 1)).src = p + 'divider_' + onOff + '.gif';
                    }
                    document.getElementById('tab_content_' + i).src = p + 'contents_blank_' + onOff + '.gif';
                    if (i == numTabs - 1) {
                        document.getElementById('tab_end_' + i).src = p + 'divider_end_' + onOff + '.gif';
                    } else {
                        document.getElementById('tab_end_' + i).src = p + 'divider_' + onOff + '.gif';
                    }
                }
                if (id == numTabs - 1) {
                    document.getElementById('tab_end_' + id).src = p + 'divider_end_on.gif';
                } else {
                    document.getElementById('tab_end_' + id).src = p + 'divider_on2.gif';
                }
            }
             


function submitHotsheet(hotsheetDataID)
{	

	var hotsheetDataArray = document.getElementById("hotsheet_data_" + hotsheetDataID).value.split("|");

	document.getElementById("hotsheetCategory").value = hotsheetDataArray[0];
	document.getElementById("hotsheetMLSList").value = hotsheetDataArray[1];
	document.getElementById("hotsheetForm").submit();

}

                        
function modelesswin(url,mwidth,mheight){
 if (document.all&&window.print) //if ie5
  eval('window.showModelessDialog(url,"","help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
 else
  eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")')
}
            

function toggleHotsheetCategory()
{
	var hotsheetCategory = document.getElementById("selectHotsheetCategory").options[document.getElementById("selectHotsheetCategory").selectedIndex].value;	
	var hotsheetTables = getElementsByClassName("hotsheetTable", "table");
	
	for(var i=0; i < hotsheetTables.length; i++)
	{
		if(hotsheetTables[i].id == "hotsheetTable_" + hotsheetCategory)
		{
			if(IE)
			{
				hotsheetTables[i].style.display = "block";
			}
			else
			{
				hotsheetTables[i].style.display = "table";
			}
			
		}
		else
		{
			hotsheetTables[i].style.display = "none";
		}
	}

}

function realtorSearchAlpha(letter, officeCode)
{
	if(officeCode == null)
	{
		officeCode = "";
	}
	self.location = "realtorResults.aspx?last_name=" + letter + "&lo_code=" + officeCode;
}

function getServices(selectObj)
{
	var category = selectObj.options[selectObj.selectedIndex].value;
	self.location = 'servicesGuideResults.aspx?category=' + category;
}
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) {
		num = "0";
	}
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) {
		cents = "0" + cents;
	}

	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
	}
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function calculatePayment()
{
	var loanRate = document.getElementById("air").value;
	var loanTerm = document.getElementById("term").value;
	var loanAmount = document.getElementById("amount").value;
	var monthlyInterest;
	var loanPayment;
	var errorMsg;

	loanRate = loanRate.replace(/%/g, "");

	if(isNaN(loanRate) || loanRate == "")
	{
		errorMsg = "You must enter a numeric value for the Annual Interest Rate.";
	}
	else if(isNaN(loanTerm) || loanTerm == "")
	{
		errorMsg = "You must enter a numeric value for the Term of Loan.";
	}
	else if(isNaN(loanAmount) || loanAmount == "")
	{
		errorMsg = "You must enter a numeric value for the Total Loan Amount.";
	}
	
	if(errorMsg != null)
	{
		setAlert("Calculate Payment", "<b>Calculation Error</b><br>" + errorMsg, "alertIconWarning");
		return;
	}

	
	monthlyInterest = loanRate / 1200;	
		
	loanPayment = loanAmount * (monthlyInterest / (1 - Math.pow((1 + monthlyInterest), (loanTerm * 12 * -1))));
	loanPayment = formatCurrency(loanPayment);
	setAlert("Calculate Payment", "<b>Calculation Complete</b><br>The monthly payment for this loan is " + loanPayment + ".", "alertIconInfo");
}

function refreshCountySelection() 
{

//alert('swap location panel here');
countyTable=null; //cause a reload of the county options, should also reset the current selections

toggleAllLocation();
}

function refreshSearchForm()
{
	document.forms[0].action = 'propertySearch.aspx';
	if(document.getElementById("moreSearchMode").value == "true")
	{
		document.forms[0].action = "propertySearch.aspx?btnMoreSearch.x=1"
	}
	document.forms[0].target='_self';
	document.forms[0].submit();
}

function closeLocationWindow(refreshForm)
{

	document.getElementById("locationWindow").style.display = "none";
	document.getElementById("windowShadow").style.display = "none";
	if(IE)
	{
		var selectObjs = document.getElementsByTagName("select");		
		for(var i=0;i<selectObjs.length;i++)
		{
			selectObjs[i].style.visibility = "visible";
		}
	}
	if(document.getElementById("locationWindowBG"))
	{
		document.getElementById("locationWindowBG").style.visibility = "hidden";
	}

	var areaInputArray = getElementsByClassName("arr_area", "input", document.getElementById("locationWindowAreaContainer"));
	var hiddenAreaInput = document.getElementById("arr_area");
	if(hiddenAreaInput && areaInputArray.length > 1)
	{
		var areaString = "";
		hiddenAreaInput.value = "";
		for(var i = 0; i < areaInputArray.length; i++)
		{	
			if(areaInputArray[i].checked)
			{
				areaString += "," + areaInputArray[i].value;
			}
		}
		if(areaString.length > 1)
		{
			areaString = areaString.substring(1, areaString.length);
		}
		hiddenAreaInput.value = areaString;
	}
	


	if(refreshForm)
	{
		refreshSearchForm()
	}
}

function setMoreMode()
{	
	document.getElementById("moreSearchMode").value = "true";
}

function setRealtorMode()
{	
	document.getElementById("moreRealtorMode").value = "True";
}


var locationSelection = new Object();


function toggleFeature(label, calling)
{
	var upOrDown = false //false == Up
	var text = String(calling.innerText);
	if(text.indexOf("[+]") >= 0)
	{
		upOrDown = true //true == Down
	}
		
	var tbl = document.getElementById("tbl_" + label);
	tbl.style.display = (upOrDown)? "block" : "none";
	calling.innerText = (upOrDown)? ("[-] " + "Select") : ("[+] " + "Select");
}


function toggleSubAreas(areaInput)
{
	//NULL or UNDEFINED	check
	if(locationSelection[areaInput.value] == null || locationSelection[areaInput.value] === void(0))
	{
		locationSelection[areaInput.value] = false;
	}
	
	if(areaInput.checked == true)
	{
		locationSelection[areaInput.value] = true;
	}
	else
	{
		locationSelection[areaInput.value] = false;
	}
	
	
	
	var areaString = "";
	var hiddenAreaInput = document.getElementById("arr_area");
	hiddenAreaInput.value = "";
	for(var each in locationSelection)
	{
		if(locationSelection[each])
		{
			areaString += "," + each
		}
	}
	if(areaString.length > 1)
	{
		areaString = areaString.substring(1, areaString.length);
	}
	hiddenAreaInput.value = areaString;
	
	
	var areaCode = areaInput.value;
	var subAreaContainer = document.getElementById("subAreaContainer_" + areaCode);
	var subAreaObjs = getElementsByClassName("", "input", subAreaContainer);

	if(!subAreaContainer)
	{
		return;
	}
	
	
	// If the area is checked, show its sub-areas and make them checked by default.
	if(areaInput.checked)
	{
		subAreaContainer.style.display = 'block';
		
		for(var i=0; i<subAreaObjs.length; i++)
		{			
			//subAreaObjs[i].checked = true;			
		}

	}
	else
	{
		subAreaContainer.style.display = 'none';
		for(var i=0; i<subAreaObjs.length; i++)
		{			
			subAreaObjs[i].checked = false;
		}
	}
}

function toggleAllLocation()
{
	var table = document.getElementById("countyContainerDiv")
	var text = "[+] Click Here to Select Location(s)";
	var cats = document.getElementById("loo_category*");
	if (cats == null) return;
	if(!cats.options){ return; }
	for(var i=0; i<cats.options.length; i++)
	{
		var category = cats.options[i].value;
		var td = document.getElementById("td_location_" + category);
		var tr = document.getElementById("tr_location_" + category);
		var div = document.getElementById("div_location_" + category);
	
		td.innerHTML = "";
		//tr.style.display = "none";
		div.innerText = "[+] Click Here to Select Location(s)";
	}	
}



function toggleLocation(calling, category)
{
	var upOrDown = false //false == Up
	var text = String(calling.innerText);
	if(text.indexOf("[+]") >= 0)
	{
		upOrDown = true //true == Down
	}
	
	
	if (countyTable == null)
	{
		//alert('getting table data');
		try{
		countyTable = document.getElementById("countyContainerDiv" + document.getElementById('loo_county'+document.getElementById("loo_category").value).value);
		}
		catch (err)
		{
		 countyTable = document.getElementById("countyContainerDiv"); 
		}
		var td = document.getElementById("td_location_" + category);	
		td.innerHTML = '<div style=\"text-align:left;border-style:ridge;border-width:1px;overflow:auto;height:105px;width:85%\">' + countyTable.innerHTML + '</div>';
						
	} 
	
	//var tr = document.getElementById("tr_location_" + category);
	var tr = document.getElementById("td_location_" + category);
	tr.style.display = (upOrDown)? "block" : "none";	
	tr.style.height = (upOrDown)? "120px" : "1px";		
	tr.style.overflow = "auto";
	
	calling.innerText = (upOrDown)? "[-] Click Here to Select Location(s)" : "[+] Click Here to Select Location(s)";
	
}
function selectMapArea(areaNumber){
	//var areaBox = document.getElementById("arr_area");
	//var i = 0;
	//var l = areaBox.length;	
	var areaObjs = getElementsByClassName("areaInput", "input", document.getElementById("locationWindowAreaContainer"))
	
	for (var i=0;i<areaObjs.length;i++) {
		if (areaNumber == areaObjs[i].value) {
			if(areaObjs[i].checked)
			{
				areaObjs[i].checked = false;
			}
			else
			{
				areaObjs[i].checked = true;
			}
			toggleSubAreas(areaObjs[i]);
			areaObjs[i].scrollIntoView(true);
			break;
		}		
	}
	
}
	
function showLocationWindow()
{
	var locationWindow = document.getElementById("locationWindow");
	var newLocationTop;
	locationWindow.style.height = '100px';
	if(IE)
	{
		var selectObjs = document.getElementsByTagName("select");		
		for(var i=0;i<selectObjs.length;i++)
		{
			selectObjs[i].style.visibility = "hidden";			
		}
	}

	locationWindow.style.display = "";

	if(document.getElementById("arr_area"))
	{
		document.getElementById("arr_area").style.visibility = "visible";
	}
	
	if(document.getElementById("locationMap"))
	{
		document.getElementById("locationWindowAreaContainer").style.height = document.getElementById("locationMap").offsetHeight;
	}

	if(document.getElementById("mainTable") && document.getElementById("mainTable").offsetHeight > document.body.clientHeight){
		<!--newLocationTop = "10px"; mhk removed, google map feature caused 10px to no longer be a sufficient value -->
		newLocationTop = document.getElementById("searchFormOuterTable").offsetTop;
		locationWindow.style.left = (document.body.clientWidth / 2) - (locationWindow.offsetWidth / 2)		
	}
	else if(document.getElementById("mainTable")) {		
		newLocationTop = (document.body.clientHeight / 2) - (locationWindow.offsetHeight / 2)					
		locationWindow.style.left = (document.body.clientWidth / 2) - (locationWindow.offsetWidth / 2);
	}
	else {
		newLocationTop = "1px";
		locationWindow.style.left = "1px";
	}

	locationWindow.style.top = newLocationTop;
	
	if(document.getElementById("locationWindowBG"))
	{
		document.getElementById("locationWindowBG").style.width = locationWindow.offsetWidth;
		document.getElementById("locationWindowBG").style.height = locationWindow.offsetHeight;
		document.getElementById("locationWindowBG").style.top = locationWindow.style.top;
		document.getElementById("locationWindowBG").style.left = locationWindow.style.left;
		document.getElementById("locationWindowBG").style.visibility = "visible";
	}
	
	showShadow(locationWindow)
}
function closePhotoViewerWindow()
{
	document.getElementById("photoViewerWindow").style.display = "none";
	document.getElementById("windowShadow").style.display = "none";
	if(IE)
	{
		var selectObjs = document.getElementsByTagName("select");		
		for(var i=0;i<selectObjs.length;i++)
		{
			selectObjs[i].style.visibility = "visible";
		}
	}
	document.getElementById("photoViewerWindowBG").style.visibility = "hidden";

}
function mortgageToggle(type,category)
{
	var martgageCount =6;
	var spCount =2;
	if(type =="saleprice")
		{
				for(var i=0;i<martgageCount;i++)
				{					
					document.getElementById("mortgageDiv" +i+category).style.display = "none";		
					clearValuesFromDiv(	"mortgageDiv" +i+category);		
				}		
				for(var j=0;j<spCount;j++)
				{					
					document.getElementById("spDiv" +j+category).style.display = "block";
				}		
		}
		else
		{
				for(var i=0;i<martgageCount;i++)
				{					
					document.getElementById("mortgageDiv" +i+category).style.display = "block";
				}							
				for(var j=0;j<spCount;j++)
				{					
					document.getElementById("spDiv" +j+category).style.display = "none";
					clearValuesFromDiv(	"spDiv" +j+category);		
				}			
				document.getElementById("tex_Annual_rate_interest").value = "6";	
				document.getElementById("tex_Term_of_loan").value = "30";						
		}
				
		
		
}
function clearValuesFromDiv(divName)
{
	var object = new Array();   

					object[0] = document.getElementById(divName).getElementsByTagName('input');   
					object[1] = document.getElementById(divName).getElementsByTagName('textarea');   
					object[2] = document.getElementById(divName).getElementsByTagName('select');
					var type=null;
					for (var x=0; x<object.length; x++){   
						for (var y=0; y<object[x].length; y++){   
							type = object[x][y].type   
								switch(type){   
									case "text":   
									case "textarea":   
									case "password":   
										object[x][y].value = "";   
										break;   
									case "radio":   
									case "checkbox":   
										object[x][y].checked = "";   
										break;   
									case "select-one":   
										object[x][y].options[0].selected = true;   
										break;  
									case "select":   
										object[x][y].options[0].selected = true;   
										break;   
									case "select-multiple":   
										for (z=0; z<object[x][y].options.length; z++){   
										object[x][y].options[z].selected = false;   
										}   
										break;   
							}   
						}   
					} 
}

function cyclePhoto(cycleDirection)
{
	var currentPhotoSource = document.getElementById("photoViewerWindowPhoto").src;
	var photoSourceArray = new Array();
	var currentPhotoIndex;
	var newSourceIndex;

	
	//photoSourceArray.push(document.getElementById("detailsPrimaryPhoto").src);
	currentPhotoIndex = 0;
	var photoObjs = photoLevelObj.photoObjs;
	//var photoObjs = getElementsByClassName("detailsPrinterPhoto", "IMG", document.getElementById("detailsPrinterPhotos"))	
	//var photoObjs = getElementsByClassName("detailsThumbnail", "IMG", document.getElementById("detailsPhotoCell"))	
	for(var i=0;i<photoObjs.length;i++)
	{
		if(photoObjs[i].src == currentPhotoSource)
		{
			currentPhotoIndex = i;
		}
		photoSourceArray.push(photoObjs[i].src);
	}
	
	if(cycleDirection == "previous" && currentPhotoIndex == 0)
	{
		return;
	}
	else if(cycleDirection == "next" && currentPhotoIndex == (photoSourceArray.length - 1))
	{
		return;
	}

	if(cycleDirection == "next")
	{
		newSourceIndex = currentPhotoIndex + 1;
	}
	else if(cycleDirection == "previous")
	{
		newSourceIndex = currentPhotoIndex - 1;
	}

	var remarksObjs  = photoLevelObj.remarksArray;	
	var remarksObjs = getElementsByClassName("detailsPrinterPhotoRemarks", "SPAN", document.getElementById("detailsPrinterPhotos"))	
	for(var i=0;i<remarksObjs.length;i++)
	{		 
		if(i == newSourceIndex)
		{ 
			photoLevelObj.getElementById("photoViewerWindowRemarks").innerHTML = remarksObjs[i].innerHTML;
		}
	}

	photoLevelObj.getElementById("photoViewerWindowRemarks").innerHTML = photoLevelObj.remarksArray[newSourceIndex];
	photoLevelObj.getElementById("photoViewerWindowPhoto").src = photoSourceArray[newSourceIndex];
	photoLevelObj.getElementById("photoViewerWindowText").innerHTML = "Showing Photo " + (newSourceIndex + 1) + " of " + photoSourceArray.length;
	repositionPhotoViewer();
	repositionPhotoViewer();
	repositionPhotoViewer();
}

function showPhotoViewer(photoObj)
{	
	zoomOutPhoto(photoObj);

	//Gather the photos to show:
	var photoCount;
	var currentPhoto;
	//var photoObjs = getElementsByClassName("detailsPrinterPhoto", "IMG", document.getElementById("detailsPrinterPhotos"))	
	photoLevelObj.photoObjs = getElementsByClassName("detailsThumbnail", "IMG", document.getElementById("detailsPhotoCell"))	
	photoObjs = getElementsByClassName("detailsThumbnail", "IMG", document.getElementById("detailsPhotoCell"))	
	currentPhoto = 1;
	

	for(var i=0;i<photoObjs.length;i++)
	{
		if(photoObjs[i].src == photoObj.src)
		{
			currentPhoto = i + 2;
			break;
		}
	}	
	currentPhoto = i + 1;
	
	photoLevelObj.getElementById("photoViewerWindowRemarks").innerHTML = remarksArray[i];
	photoCount = photoObjs.length;
	photoLevelObj.getElementById("photoViewerWindowText").innerHTML = "Showing Photo " + currentPhoto + " of " + photoCount;
	
	var photoViewerWindow = photoLevelObj.getElementById("photoViewerWindow");
	var newLocationTop;

	if(IE)
	{
		var selectObjs = document.getElementsByTagName("select");		
		for(var i=0;i<selectObjs.length;i++)
		{
			selectObjs[i].style.visibility = "hidden";			
		}
	}
		
	photoLevelObj.getElementById("photoViewerWindowPhoto").src = photoObj.src;	
	

	photoViewerWindow.style.display = "block";	

	repositionPhotoViewer();

}

function repositionPhotoViewer()
{
	var newLocationTop;
	var photoViewerWindow = photoLevelObj.getElementById("photoViewerWindow");
	newLocationTop = (photoLevelObj.body.clientHeight / 2) - (photoViewerWindow.offsetHeight / 2);

	photoViewerWindow.style.top = 1;
	photoViewerWindow.style.left = (photoLevelObj.body.clientWidth / 2) - (photoViewerWindow.offsetWidth / 2)		
	photoLevelObj.getElementById("photoViewerWindowBG").style.width = photoViewerWindow.offsetWidth;
	photoLevelObj.getElementById("photoViewerWindowBG").style.height = photoViewerWindow.offsetHeight;
	photoLevelObj.getElementById("photoViewerWindowBG").style.top = photoViewerWindow.style.top;
	photoLevelObj.getElementById("photoViewerWindowBG").style.left = photoViewerWindow.style.left;
	photoLevelObj.getElementById("photoViewerWindowBG").style.visibility = "visible";	
	//showShadow(photoViewerWindow)
}


function showShadow(objectToShadow)
{
	var objectWidth;
	var objectHeight;
	var newWidth;
	var newHeight;	
	
	return;
	
	//var windowShadow = document.getElementById("windowShadow");	
		
	//windowShadow.style.display = "";

	//var floatRemarks = document.getElementById("floatingRemarks")
	//if(objectToShadow.id == "propertyFloatingPhoto")
	//{		
		//newHeight = floatRemarks.offsetHeight + objectToShadow.offsetHeight + 16;
	//}
	//else
	//{		
		//newHeight = objectToShadow.offsetHeight + 18;
	//}
	//newWidth = objectToShadow.offsetWidth + 18;
//
	//windowShadow.style.width = newWidth;
	//windowShadow.style.height = newHeight;
	//currentShadowObj = objectToShadow;
	
	
}

function repositionShadow(objectToShadow)
{	
	if(currentShadowObj != objectToShadow)
	{
		return;
	}	
	var windowShadow = document.getElementById("windowShadow");

	if (windowShadow) {
		windowShadow.style.top = objectToShadow.style.top.split("px")[0] - 9;			
		windowShadow.style.left = objectToShadow.style.left.split("px")[0] - 9;		
	}
}

function hideShadow()
{		
	try {
		if(document.getElementById("alertWindow").style.visibility == "visible")
		{
			return;
		}
	} catch (e) {
	}
	
	try {
		if(document.getElementById("photoViewerWindowBG") && document.getElementById("photoViewerWindowBG").style.visibility == "visible")
		{
			return;
		}
	} catch(e) {
	}
	currentShadowObj = null;
	var windowShadow = document.getElementById("windowShadow");
	if (windowShadow)
		windowShadow.style.display = "none";
}
function selectMapAreaOld(areaNumber){
	var areaBox = document.getElementById("arr_area");
	var i = 0;
	var l = areaBox.length;	
	
	for (i=0;i<l;i++) {
		if (areaNumber == areaBox[i].value) {
			areaBox[i].selected = !areaBox[i].selected;
			break;
		}
	}
	
}

function handleFeedbackFocus(feedbackInput)
{
	if(feedbackInput.value == "Enter your feedback, then press the \"send feedback\" button.")
	{
		feedbackInput.value = "";
		feedbackInput.style.color = "#000000";
		feedbackInput.style.textAlign = "left";
	}
}

function handleFeedbackBlur(feedbackInput)
{
	if(feedbackInput.value == "")
	{		
		feedbackInput.value = "Enter your feedback, then press the \"send feedback\" button.";
		feedbackInput.style.color = "#666666";		
		feedbackInput.style.textAlign = "center";	
	}

}

function toggleMatchedView(src)
{
	var value = src.options[src.selectedIndex].value;	
	self.location = "mymatches.aspx?view=" + value;

}
function submitFeedbackNew(submitButton)
{

	if(!userLoggedIn){
		loginUser();
		return;
	}

	var feedbackContainer = submitButton.parentNode.parentNode;
	feedbackContainer = getElementsByClassName("resultsFeedbackContainer", "DIV", feedbackContainer)[0];
	
	var feedbackInput = feedbackContainer.childNodes[0];

	if(feedbackContainer.style.display != "none" && feedbackInput.value != "" &&  feedbackInput.value != "Enter your feedback, then press the submit button.")
	{
		submitButton.src = '/PublicLib2/images/btn_feedback_dis.png';
		feedbackContainer.style.display = "none";
		processOffscreen("saveProperty.aspx?feedbackID=" + feedbackInput.name + "&feedbackValue=" + feedbackInput.value);	
	}
	else
	{	
		feedbackContainer.style.display = "block";
		feedbackInput.value = "Enter your feedback, then press the \"send feedback\" button.";
		feedbackInput.style.color = "#666666";		
		feedbackInput.style.textAlign = "center";		
	}
	

	
}

function submitFeedback(submitButton, mlsNumber)
{
	var feedbackForm = document.getElementById("feedback_" + mlsNumber);
	var feedbackValue = document.getElementById("feedbackInput_" + mlsNumber).value;

	if(feedbackForm.style.visibility == "hidden")
	{
		setAlert("Send Feedback", "<b>Feedback Error</b><br>Feedback has already been sent for this property.", "alertIconWarning");
		return;
	}
	else if(feedbackValue.length <= 5)
	{
		setAlert("Send Feedback", "<b>Feedback Error</b><br>You must enter at least 5 characters of feedback.", "alertIconWarning");
		return;
	}

	submitButton.src = '/PublicLib2/images/btn_feedback_dis.png';
	
	feedbackForm.style.visibility = "hidden";
	processOffscreen("accountProperties.aspx?feedbackID=" + mlsNumber + "&feedbackValue=" + feedbackValue);

}

function updateSavedSearch(selectObj, searchID)
{
	var updateValue;
	updateValue = selectObj.options[selectObj.selectedIndex].value;
	
	processOffscreen("accountSearches.aspx?updateID=" + searchID + "&updateValue=" + updateValue);
}

function goToAccount()
{
	if(!userLoggedIn){
		loginUser();
	}
	else{
		self.location = "account.aspx"
	}
}

function closePicker(){
	document.getElementById("pickerWindow").style.visibility = "hidden";
	hideShadow();
}
function validateRegistration()
{
	var missingFields = "";

	if(document.getElementById("first_name").value == "")
	{
		missingFields += "<li>First Name</li>";
	}
	if(document.getElementById("last_name").value == "")
	{
		missingFields += "<li>Last Name</li>";				
	}
	if(document.getElementById("email").value == "")
	{
		missingFields += "<li>E-Mail Address</li>";		
	}
	if(document.getElementById("realtorCode").value == "")
	{
		missingFields += "<li>Preferred Realtor</li>";
	}

	if(missingFields != "")
	{		
		setAlert("Account Information", "<b>Save Error</b><br>You must enter information for the following form fields to continue:<ul><b>" + missingFields + "</<b></ul>", "alertIconWarning");
		return false;
	}
	else
	{
		return true;
	}
}

function validateContact()
{
	var missingFields = "";

	if(document.getElementById("r_User name_en").value == "")
	{
		missingFields += "<li>Name</li>";
	}
	if(document.getElementById("q_User Email_ef").value == "")
	{
		missingFields += "<li>E-Mail</li>";				
	}	

	if(missingFields != "")
	{
		setAlert("Contact Agent", "<b>Send Error</b><br>You must enter information for the following form fields to continue:<ul><b>" + missingFields + "</<b></ul>", "alertIconWarning");
		return false;
	}
	else
	{
		return true;
	}
}
function validateMarket()
{
	var missingFields = "";

	if(document.getElementById("r_Contact Name_en").value == "")
	{
		missingFields += "<li>Name</li>";
	}

	if(document.getElementById("r_Contact StreetAddress").value == "")
	{
		missingFields += "<li>Address</li>";				
	}	

	if(document.getElementById("r_Contact City").value == "")
	{
		missingFields += "<li>City</li>";				
	}

	if(document.getElementById("q_Contact email_ef").value == "")
	{
		missingFields += "<li>E-mail:</li>";				
	}

	if(missingFields != "")
	{
		setAlert("Market Analysis", "<b>Send Error</b><br>You must enter information for the following form fields to continue:<ul><b>" + missingFields + "</<b></ul>", "alertIconWarning");
		return false;
	}
	else
	{
		return true;
	}
}

function validateFinancing()
{
	
	var missingFields = "";

	if(document.getElementById("r_User Name_en").value == "")
	{
		missingFields += "<li>Name</li>";
	}

	if(document.getElementById("r_User Email_ef").value == "")
	{
		missingFields += "<li>E-mail:</li>";				
	}	

	if(missingFields != "")
	{
		setAlert("Mortgage Information Packet", "<b>Send Error</b><br>You must enter information for the following form fields to continue:<ul><b>" + missingFields + "</<b></ul>", "alertIconWarning");
		return false;
	}
	else
	{
		return true;
	}	
}

function findRealtor()
{	
	document.getElementById("pickerFrame").src = "realtorSearch.aspx?realtorPicker=1";
	document.getElementById("pickerWindow").style.visibility = "visible";
	repositionPicker();
	showShadow(document.getElementById("pickerWindow"));
}

function showRates()
{	
	document.getElementById("pickerFrame").src = "financingRates.aspx";
	document.getElementById("pickerFrame").style.width = "700px";
	document.getElementById("pickerWindow").style.visibility = "visible";
	document.getElementById("pickerTitleText").innerHTML = "Local Mortgage Rates"
	repositionPicker();
	showShadow(document.getElementById("pickerWindow"));
}

function fillRate(rate, years)
{
	parent.document.getElementById("air").value = rate;
	parent.document.getElementById("term").value = years;
	parent.closePicker();
}

function selectRealtor(realtorID, realtorName)
{
	document.getElementById("realtorCode").value = realtorID;
	document.getElementById("preferredRealtorCell").innerHTML = realtorName;
	closePicker();
}

function toggleAccountLink(itemName)
{
	if(document.getElementById(itemName + "BG").style.visibility == "visible")
	{
		document.getElementById(itemName + "BG").style.visibility = "hidden";	
	}
	else
	{
		document.getElementById(itemName + "BG").style.visibility = "visible";	
	}
}

function setLoginSuccess()
{
	userLoggedIn = true;
}
function saveSearch()
{
	if(!userLoggedIn){
		loginUser();
	}
	else{
		setAlert("Save Search", "<b>Saved Search Description</b><br>Enter a description for this search below, and click the ok button to continue. You can retrieve this search at any time by visiting your account.<br><br><input style=\"width: 300px;\" type=\"text\" id=\"searchDescription\" maxlength=\"50\">", "alertIconSaveSearch", "saveSearchSubmit", null, null)
	}
}
function saveProperty(mlsNumber, propertyCategory)
{
	if(!userLoggedIn){
		loginUser();
	}
	else{
		processOffscreen("saveProperty.aspx?mls=" + mlsNumber + "&category=" + propertyCategory);
	}
}

function saveMatchedListing(mlsNumber)
{
	var currentPage = document.getElementById("_ctl1_inputCurrentPage").value;
	
	self.location = "myMatches.aspx?save=" + mlsNumber + "&page=" + currentPage;
	return;

	if(!userLoggedIn){
		loginUser();
	}
	else{
		self.location = "myMatches.aspx?save=" + mlsNumber;
	}
}

function deleteProperty(mlsNumber)
{

	var currentPage = document.getElementById("_ctl1_inputCurrentPage").value;
	self.location = "myMatches.aspx?delete=" + mlsNumber + "&page=" + currentPage;
	return;

	if(!userLoggedIn){
		loginUser();
	}
	else{
		//processOffscreen("deleteProperty.aspx?mls=" + mlsNumber);
	}
}

function loginUser()
{
	var loginForm = "<form class=\"alertForm\" method=\"post\" action=\"login.aspx\" id=\"loginForm\" target=\"hiddenFrame\"><input type=\"hidden\" name=\"loginAction\"><table id=\"loginFormTable\" cellpadding=0 cellspacing=0><tr><td rowspan=2 width=35><img id=\"loginEmailIcon\" src='/PublicLib2/images/login_email.png'></td><td><b>E-Mail Address</b></td></tr><tr><td><input type=text name=loginEmail id=loginEmail maxlength=180 style=\"width: 310px;\"></td></tr><tr><td rowspan=2 width=35><img id=\"loginPinIcon\" src='/PublicLib2/images/login_pin.png'></td><td><b>Password</b></td></tr><tr><td><input type=text id=loginPin name=loginPin maxlength=20 style=\"width: 310px;\"></td></tr></table></form>"
	var loginButtons = "<img style=\"margin-left: 60px\" class=\"generalButton\" src=\"/PublicLib2/images/btn_login.gif\" onclick=\"loginUserSubmit('login')\"><img class=\"generalButton\" src=\"/PublicLib2/images/btn_forgot.gif\" onclick=\"loginUserSubmit('forgot')\"><img class=\"generalButton\" src=\"/PublicLib2/images/btn_new_user.gif\" onclick=\"registerUser()\">";
	setAlert("Login", "<b>Login Instructions</b><br>When you registered, you were assigned and e-mailed a password. Enter your e-mail address followed by your assigned password below.", "alertIconLogin", null, loginForm, loginButtons)
}
function registerUser()
{
var QueryString2=location.search;
var ShowNav=QueryString2.substring(9,14);
if (ShowNav == 'False')
	{
		self.location = "register.aspx?ShowNav=False&";
	}
	else
	{
		self.location = "register.aspx";
	}
}
function loginUserSubmit(loginAction)
{
	if(loginAction == 'login')
	{
		if(document.getElementById("loginEmail").value == "" || document.getElementById("loginPin").value == "") {
			alert("You must enter your e-mail address and password to login.");
			return;		
		}
	}
	else if(loginAction == 'forgot')
	{
		if(document.getElementById("loginEmail").value == "") {
			alert("You must enter an e-mail address to retrieve your password.");
			return;
		}
	}
	closeAlert();	
	//alert(document.getElementById("loginForm").loginAction);	
	document.getElementById("loginForm").loginAction.value = loginAction;
	document.getElementById("loginForm").submit();
}

function saveSearchSubmit()
{
	closeAlert();
	processOffscreen("saveSearch.aspx?description=" + escape(document.getElementById("searchDescription").value));
}

function submitSiteFeedback()
{
	var feedbackForm = document.getElementById("feedbackForm");
	if(feedbackForm.feedback_name.value == "" || feedbackForm.feedback_email.value == "" || feedbackForm.feedback_body.value == "")
	{
		alert("Please enter the required fields.");			
	}
	else
	{
		feedbackForm.submit()
	}
}

function submitRequestSiteInfo()
{
	var requestSiteInfoForm = document.getElementById("requestSiteInfoForm");
	if(requestSiteInfoForm.customer_name.value == "" || requestSiteInfoForm.customer_email.value == "" )
	{
		alert("Please enter the required fields.");			
	}
	else
	{
		requestSiteInfoForm.submit()
	}
}

function requestInfo(realtorName, realtorID, officeID, mlsNumber)
{	
	document.getElementById("requestInfoAgentID").value = realtorID;
	document.getElementById("requestInfoOfficeID").value = officeID;
	document.getElementById("requestInfoMLSNumber").value = mlsNumber;	
	setAlert("Request Information", "<b>Enter Your Contact Information</b><br>Fill out the form below to receive additional information about this property from <b>" + realtorName + "</b>. Fields marked with an asterisk are required.", "alertIconRequestInfo", "requestInfoSubmit", document.getElementById("requestInfoFormContainer").innerHTML)
}

function requestInfoSubmit()
{	
	var alertForm = document.getElementById("alertFormCell").childNodes[0];
	if(alertForm.customer_name.value == "" || alertForm.customer_email.value == "")
	{
		alert("Please enter the required fields.");	
	}
	else
	{
		alertForm.submit();
	}
}

function emailFriend(realtorName, realtorID, officeID, mlsNumber)
{	
	document.getElementById("emailFriendAgentID").value = realtorID;
	document.getElementById("emailFriendOfficeID").value = officeID;
	document.getElementById("emailFriendMLSNumber").value = mlsNumber;	
	setAlert("Email Friend", "<b>Enter Your Contact Information</b><br>Fill out the form below to send information about this property to your Friend.Fields marked with an asterisk are required.", "alertIconRequestInfo", "emailFriendSubmit", document.getElementById("emailFriendFormContainer").innerHTML)
}

function emailFriendSubmit()
{	
	var alertForm = document.getElementById("alertFormCell").childNodes[0];
	if(alertForm.from_email.value == "" || alertForm.from_email.value == "")
	{
		alert("Please enter the required fields.");	
	}
	else
	{
		alertForm.submit();
	}
}

function getElementsByClassName(sClassName, sTag, oContainer){	
	var oContainer;
	var searchObj;
	var results = new Array(); 

	if(!oContainer) {
		oContainer = document;
	}

	if(sTag == "*" || !sTag){	
		if(document.all) {
			searchObj = oContainer.all;
		}
		else {
			searchObj = oContainer.getElementsByTagName("*");
		}
	}
	else 
	{
		searchObj = oContainer.getElementsByTagName(sTag);
	}
	
	for(var i = 0, el; ((searchObj.all && !neo.bw.isIE6up) ? el = searchObj(i) : el = searchObj.item(i)) ; i++){
		
		if(el.className == sClassName) {
			//alert(el.className);
			results[results.length] = el;
		}
	}
	return results;
}

function selectPhotoPage(hyperlinkObj, pageNumber)
{
	// Hide all the pages	
	var photoContainer = document.getElementById("detailsPhotoCell")
	var photoDivs = getElementsByClassName("detailsPhotoDiv", "*", photoContainer);
	for(var i=0;i<photoDivs.length;i++)
	{
		photoDivs[i].style.display = "none";
	}
	var photoDivs = getElementsByClassName("detailsPhotoControlLinkSel", "*", photoContainer);
	for(var i=0;i<photoDivs.length;i++)
	{				
		photoDivs[i].className = "detailsPhotoControlLink";
	}
	document.getElementById("detailsPhotoPage" + pageNumber).style.display = "";		
	hyperlinkObj.className = "detailsPhotoControlLinkSel";

	//Update the paging label
	var mediaCount = document.getElementById("media_count").value
	var mediaPerPage = document.getElementById("media_per_page").value
		
	var firstPhoto = ((pageNumber - 1) * mediaPerPage) + 1	
	var lastPhoto = firstPhoto + (mediaPerPage - 1)	
	if(lastPhoto > mediaCount) {
		lastPhoto = mediaCount
	}
	document.getElementById("detailsPhotoPages").innerText = firstPhoto + " to " + lastPhoto + " of " + mediaCount;
}

function selectTab(selectedTab)
{
	var tabTable = document.getElementById("detailsTabs");		
	var tabObjs = getElementsByClassName("tabCornerL", "*", tabTable);
	for(var i=0;i<tabObjs.length;i++)
	{
		tabObjs[i].src = "/PublicLib2/images/details_tabl.png";
	}
	var tabObjs = getElementsByClassName("tabCornerR", "*", tabTable);
	for(var i=0;i<tabObjs.length;i++)
	{
		tabObjs[i].src = "/PublicLib2/images/details_tabr.png";
	}
	var tabObjs = getElementsByClassName("tabBG", "*", tabTable);
	for(var i=0;i<tabObjs.length;i++)
	{
		tabObjs[i].src = "/PublicLib2/images/tab_bg.png";
	}
	var selectedTabIndex = selectedTab.cellIndex;	
	var tabName = tabTable.rows[0].cells[selectedTabIndex].childNodes[0].childNodes[1].innerHTML.toLowerCase();

	tabTable.rows[0].cells[selectedTabIndex - 1].childNodes[0].src = "/PublicLib2/images/details_tabl_sel.png";
	tabTable.rows[0].cells[selectedTabIndex].childNodes[0].childNodes[0].src = "/PublicLib2/images/tab_bg_sel.png";
	tabTable.rows[0].cells[selectedTabIndex + 1].childNodes[0].src = "/PublicLib2/images/details_tabr_sel.png";
	
	var tabObjs = getElementsByClassName("infoDiv");
	for(var i=0;i<tabObjs.length;i++)
	{
		tabObjs[i].className = "infoDivHidden";
	}

	switch(tabName)
	{
		case "other information":
			document.getElementById("mainCellOther").className  = "infoDiv";
			break;
		case "units":
			document.getElementById("mainCellUnits").className= "infoDiv";
			break;
		case "property details":
			document.getElementById("mainCellDetails").className = "infoDiv";
			break;
		case "rooms":
			document.getElementById("mainCellRooms").className = "infoDiv";
			break;
	}
	
	document.getElementById("mainCellBG").style.height = document.getElementById("mainCellDiv").offsetHeight;	
}


function checkPriceBoundsmin(minSelectObj)
{
		
	var cellObj = minSelectObj.parentNode;
	var minSelectObj = cellObj.childNodes[0];
	var maxSelectObj = cellObj.childNodes[2];
	var minPrice = parseInt(minSelectObj.options[minSelectObj.selectedIndex].value);
	var maxPrice = parseInt(maxSelectObj.options[maxSelectObj.selectedIndex].value);
	if(isNaN(maxPrice))
	{
		maxPrice = 0;
	}
	var newSelected = false;

	//var newMax = minSelectObj.options[minSelectObj.selectedIndex + 1].value;
	var newMax = minSelectObj.options[minSelectObj.selectedIndex].value;
	if (minSelectObj.selectedIndex < minSelectObj.options.length - 1)
	{
		newMax = minSelectObj.options[minSelectObj.selectedIndex + 1].value;
	}

	if(maxPrice > newMax)
	{
		newMax = maxPrice;
	}
	
	//alert(newMax);
	for (var i=1;i<minSelectObj.options.length; i++)
	{

		//Enable options which are less than the new max.
		//alert(i + ", " + minSelectObj.options[i].value + ", " + minPrice);		
		if(parseInt(minSelectObj.options[i].value) < minPrice)
		{
			//alert("Set it grey");			
			//minSelectObj.options[i].style.color='#999999';
		}
		else if(parseInt(minSelectObj.options[i].value) <= newMax)
		{
			minSelectObj.options[i].style.color='#000000';
		}
		else
		{
			break;
		}
	}

	for (var i=maxSelectObj.options.length - 1;i>=0; i--) {
		if(parseInt(maxSelectObj.options[i].value) < minPrice)
		{
			//maxSelectObj.options[i].disabled = true;					
			//alert(i);
			//alert(maxSelectObj.options[i].style.color);
			maxSelectObj.options[i].style.color = '#999999';
			//alert(maxSelectObj.options[i].style.color);
			if(!newSelected && maxPrice < minPrice)
			{
				if( (i + 2) < maxSelectObj.options.length)
				{					
					if(maxSelectObj.selectedIndex != 0)
					{
						maxSelectObj.options[i + 2].selected = true;
					}
					newSelected = true;
				}
			}
			maxSelectObj.remove(i);
		}
		else
		{
			maxSelectObj.options[i].style.color='#000000';
			//maxSelectObj.options[i].disabled = false;
		}
	}

	//***********************************************//
	/// this code removes the select options from maxPriceRange which are less than the value 
	/// selected in minPriceRange	
	// BugId: 18310 
	
		var j=1;
		var maxPriceRangeLenght = maxSelectObj.options.length;
		for (var x=minSelectObj.selectedIndex;x<minSelectObj.options.length; x++)
		{	
			if(isNaN(parseInt(minSelectObj.options[x].value)) && isNaN(parseInt(maxSelectObj.options[maxSelectObj.selectedIndex].value)))
			{
				break;
			}
			else
			{
				if(isNaN(parseInt(minSelectObj.options[x].value)))
					x=x+1;
					
				if(j<=maxPriceRangeLenght-1)
					maxSelectObj.remove(j);				
										
								
				var newMaxSelect = document.createElement('option');
				newMaxSelect.text = minSelectObj.options[x].text;
				newMaxSelect.value = minSelectObj.options[x].value;				
				var oldMaxSelect = maxSelectObj.options[j];  
				try 
				{
					maxSelectObj.add(newMaxSelect, oldMaxSelect); 
					j=j+1;
				}
				catch(ex) 
				{
					maxSelectObj.add(newMaxSelect,j); 
					j=j+1;
				}
			}
			
		}
		//******************************************//


}

function checkPriceBoundsmax(maxSelectObj)
{	
	var cellObj = maxSelectObj.parentNode;
	var minSelectObj = cellObj.childNodes[0];
	var minPrice = parseInt(minSelectObj.options[minSelectObj.selectedIndex].value);
	var maxPrice = parseInt(maxSelectObj.options[maxSelectObj.selectedIndex].value);
	if(isNaN(minPrice))
	{
		minPrice = 0;
	}
	maxSelectObj.options[maxSelectObj.selectedIndex].style.color = '#000000';
	//var newSelected = false;
	for (var i=minSelectObj.options.length - 1;i>=0; i--) {
		if(parseInt(minSelectObj.options[i].value) >= maxPrice)
		{
			minSelectObj.options[i].style.color='#999999';
			//minSelectObj.options[i].disabled = true;
			//minSelectObj.options[i].style.display = "none"
			//minSelectObj.remove(i);
			if( minPrice > maxPrice)
			{
				minSelectObj.options[i - 1].selected = true;	
				minSelectObj.options[i - 1].style.color = '#000000';
			}
		}	
		else if(parseInt(minSelectObj.options[i].value) >= minPrice)
		{
			minSelectObj.options[i].style.color='#000000';
			//minSelectObj.options[i].disabled = false;
		}
	}
}



function updateSearchForm()
{	
	try {
	//document.getElementById('loo_county'+document.getElementById("loo_category").value).value=""; //reset the current selected county.	
	}
	catch (err)
	{
	}
	countyTable=null;
	toggleAllLocation();
	var categorySelect = document.getElementById("loo_category*");	
	if (categorySelect == null) return;
	if(!categorySelect.options)
	{
		return;
	}	
	var selectedCategory;
	var searchFormTable  = document.getElementById("searchFormTable");	
	selectedCategory = categorySelect.options[categorySelect.selectedIndex].value;
	
	
	//Hide all form input
	if(!isNaN(previousFormCategory)){
		var formRows = searchFormTable.rows;
		for(var i=0;i<formRows.length;i++)
		{
			if(formRows[i].className == "inputRow" + previousFormCategory){				
				formRows[i].style.display = "none";
				
			}
		}	
	}
	

	//Disable the previous category's form elements		
	if(!isNaN(previousFormCategory)){
		var formInput = getElementsByClassName("formInput" + previousFormCategory, "*", searchFormTable);	
		for(var i=0;i<formInput.length;i++)
		{		
			formInput[i].disabled = true;
		}
	}
	else
	{
		for(var j=0;j<categorySelect.options.length;j++)
		{
			var formInput = getElementsByClassName("formInput" + categorySelect.options[j].value, "*", searchFormTable);	
			for(var i=0;i<formInput.length;i++)
			{		
				formInput[i].disabled = true;
			}
		}
	}

	//Enable the current category's form elements
	var formInput = getElementsByClassName("formInput" + selectedCategory, "*", searchFormTable);	
	for(var i=0;i<formInput.length;i++)
	{			
		formInput[i].disabled = false;

		// Adjust the range select box maximums!
		if(formInput[i].id.indexOf("rng_") >= 0)
		{
			var onChangeString = formInput[i].onchange.toString();
			if(onChangeString.indexOf("min") >= 0)
			{
				var cellObj = formInput[i].parentNode;
				var maxSelectObj = cellObj.childNodes[2];
				var maxSelectIndex = maxSelectObj.selectedIndex;				
				checkPriceBoundsmin(formInput[i]);
				maxSelectObj.selectedIndex = maxSelectIndex;
			}
		}
	}	
	

	var formInput = getElementsByClassName("formInput*", "*", searchFormTable);	
	for(var i=0;i<formInput.length;i++)
	{
		//alert(formInput[i].name);
		//alert(formInput[i].disabled);
		formInput[i].disabled = false;
	}

	var formRows = getElementsByClassName("inputRow" + selectedCategory, "tr", searchFormTable);	
	for(var i=0;i<formRows.length;i++)
	{
		formRows[i].style.display = "";
	}

	var formRows = getElementsByClassName("inputRow*", "tr", searchFormTable);	
	for(var i=0;i<formRows.length;i++)
	{
		formRows[i].style.display = "";
	}

	previousFormCategory = selectedCategory;	
	
	try {
	document.getElementById("mortgageSp1"+selectedCategory).checked = true;
	}
	catch (err)
	{	
	}

	//Fix for mozilla	
	if (!IE) 
	{				
		if(document.getElementById("menuTable"))
		{
			document.getElementById("searchFormBGImage").style.height = document.getElementById("searchFormOuterTable").offsetHeight;		
			document.getElementById("menuTable").style.height = document.getElementById("menuCell").offsetHeight;
		}
	}
	
	return true;
	
	
}

function loadInterface()
{		
	//if(document.getElementById("windowShadow") || document.getElementById("propertyFloatingPhoto") || document.getElementById("agentFloatingPhoto"))
	//{
		//document.onmousemove = getMouseXY;
	//}	
	try {
	HideLoader();
	}
	catch (err)
	{	
	}
	
	try {
	document.getElementById("mortgageSp11").checked = true;
	}
	catch (err)
	{	
	}
	
	if(document.getElementById("welcomeMessage"))
	{
		welcomeMessage = document.getElementById("welcomeMessage")
	}
	else
	{
		welcomeMessage = document.getElementById("agentWelcomeMessage")
	}

	//if(screen.availWidth == '800' && document.getElementById("accentPhoto"))
	//{
		//document.getElementById("accentPhoto").src = '/PublicLib2/images/clear.gif';
		//document.getElementById("accentCell").style.backgroundImage = "url('/PublicLib2/images/clear.gif')";
		//welcomeMessage.style.fontSize = "24px";
	//}
	if(document.getElementById("loo_category"))
	{			
		updateSearchForm();
	}
	if(document.getElementById("mainTable"))
	{
		document.getElementById("mainTable").style.visibility = "visible";
	}
	
	if(!suppressClose)
	{
		closeAlert();
	}
	resizeInterface();

	if(this.init)
	{		
		init();
	}
}

function HideLoader()
{
 parent.document.getElementById("AjaxLoader").style.display='none';
}

function resizeInterface()
{			

	if(!document.getElementById("mainTable"))
	{
		repositionAlert();
		repositionPicker();	
		
		return;		
	}

	var newTop = (document.body.clientHeight / 2) - (document.getElementById("mainTable").offsetHeight / 2);
	document.getElementById("mainTable").style.height = document.body.clientHeight;
	if(newTop < 50) {
		newTop = 0;
	}

	try {
	//document.getElementById("mainSpacerImage").style.height = newTop + "px";		
	document.getElementById("mainSpacerImage").style.height = "0px";		
	}
	catch (err)
	{
	}
	
	//document.getElementById("mainTable").style.marginTop = newTop + "px";			
	if (!IE) 
	{	
		try	{
			document.getElementById("menuTable").style.height = document.getElementById("menuCell").offsetHeight;
		} catch (e) {
		}
	}
	
		//Hide accentphot if not enough room.
		if (document.body.clientWidth < 758) {
		 try {
		  document.getElementById("accentPhoto").style.visibility="hidden";
		   document.getElementById("accentPhoto").style.width="1px";		  
		  document.getElementById("homeSplashDiv").style.width='542px';
		  document.getElementById("homeSplashTable").style.width='542px';
		 }
		 catch (err)
		 {
		 }
		}
		
		//Hide accentphot if not enough room.
		if (document.body.clientWidth > 759) {
		 try {
		   document.getElementById("accentPhoto").style.visibility="visible";
		   document.getElementById("accentPhoto").style.width="202px";
		   document.getElementById("homeSplashDiv").style.width='650px';
		   document.getElementById("homeSplashTable").style.width='650px';
		 }
		 catch (err)
		 {
		 }
		}

	// Adjust the welcome message
	if(document.body.clientWidth < 918)
	{
		//var newRight = (918 - document.body.clientWidth) + 4;
		//if(newRight > 150) {
			//newRight = 150;
		//}
		//newRight = newRight + 20;
		newRight = 30;
		try {
		welcomeMessage.style.right = newRight + "px";
		}
		catch (err)
		{
		}		
		
	}
	else
	{
		try		{
		welcomeMessage.style.right = "4px";
		}
		catch (err)
		{
		}	
	}			
	repositionAlert();
	repositionPicker();	
	
}

function closeAlert()
{
	if(document.getElementById("alertWindow"))
	{
		document.getElementById("alertWindow").style.visibility = "hidden";
		document.getElementById("alertShadow").style.visibility = "hidden";	
		hideShadow();
	}
	if(IE)
	{
		var selectObjs = document.getElementsByTagName("select");		
		for(var i=0;i<selectObjs.length;i++)
		{
			selectObjs[i].style.visibility = "visible";
		}
	}	
}

function repositionPicker()
{
	var pickerWindow = document.getElementById("pickerWindow");
	var newPickerTop;
	if(!pickerWindow){
		return;		
	}

	if(document.getElementById("mainTable") && document.getElementById("mainTable").offsetHeight > document.body.clientHeight){		
		newPickerTop = (document.body.clientHeight / 2) - (pickerWindow.offsetHeight / 2)			
	}
	else {		
		//newPickerTop = document.getElementById("mainSpacerImage").offsetHeight + 200;
		newPickerTop = (document.body.clientHeight / 2) - (pickerWindow.offsetHeight / 2)			
	}

	pickerWindow.style.top = newPickerTop;
	pickerWindow.style.left = (document.body.clientWidth / 2) - (pickerWindow.offsetWidth / 2)
	
}
function repositionAlert()
{
	var alertWindow = document.getElementById("alertWindow")
	var alertShadow = document.getElementById("alertShadow")
	var newAlertTop;
	if(!alertWindow){
		return;		
	}
	if(document.getElementById("mainTable") && document.getElementById("mainTable").offsetHeight > document.body.clientHeight){
		newAlertTop = (document.body.clientHeight / 2) - (alertWindow.offsetHeight / 2)			
	}
	else if(document.getElementById("mainSpacerImage")) {
		newAlertTop = document.getElementById("mainSpacerImage").offsetHeight + 200;
	}
	else
	{
		newAlertTop = 10;
	}
	//alert(newAlertTop);
	newAlertTop = document.body.scrollTop + newAlertTop;		

	alertWindow.style.top = newAlertTop;
	alertWindow.style.left = (document.body.clientWidth / 2) - (alertWindow.offsetWidth / 2)
	
	alertShadow.style.top = newAlertTop - 9;		
	alertShadow.style.left = parseInt(alertWindow.style.left.split("px")[0]) - 9;
	
	document.getElementById("alertBG").style.height = alertWindow.offsetHeight;	
}

function setAlert(alertTitle, alertMessage, alertIconID, alertAction, alertForm, alertButtons)
{	
	if(IE)
	{		
		var selectObjs = document.getElementsByTagName("select");
		for(var i=0;i<selectObjs.length;i++)
		{
			selectObjs[i].style.visibility = "hidden";
		}
	}
	//Adjust the alert window		
	document.getElementById("alertTitleText").innerHTML = alertTitle;
	document.getElementById("alertMessageCell").innerHTML = alertMessage;
	document.getElementById("alertWindow").style.visibility = "visible";
	document.getElementById("alertShadow").style.visibility = "visible";


	if(alertButtons == null)
	{
		document.getElementById("alertButtonCell").innerHTML = "<img id=\"alertButton\" class=\"generalPNGButton\" src=\"/PublicLib2/images/btn_ok.png\" onclick=\"closeAlert()\">";
	}
	else
	{
		document.getElementById("alertButtonCell").innerHTML = alertButtons;
	}
	if(alertAction != null)
	{
		document.getElementById("alertButton").onclick = eval(alertAction);	
	}
	else if(document.getElementById("alertButton")) {
		document.getElementById("alertButton").onclick = closeAlert;
	}
	if(alertIconID != null)
	{
		document.getElementById("alertIcon").src = document.getElementById(alertIconID).src;
	}
	else {
		document.getElementById("alertIcon").src = "/PublicLib2/images/alert_icon.png";
	}
	if(alertForm != null)
	{		
		document.getElementById("alertFormCell").innerHTML = alertForm;		
	}
	else {
		document.getElementById("alertFormCell").innerHTML = "";
	}

	repositionAlert()
	showShadow(document.getElementById("alertWindow"));
}
function processOffscreen(sURL)
{		
	var now = new Date();
	if(sURL.indexOf("?") > -1)
	{
		sURL = sURL + "&"
	}
	else
	{
		sURL = sURL + "?"
	}
	sURL = sURL + "time=" + now.getTime();	
	document.getElementById("hiddenFrame").src = sURL;	
	
}

function getMouseXY(e)
{
	var alignRight = false;
	var alignBottom = false;
	var floatType;
	var targetObj;
	var photoTempX;
	var shadowTempX;
	var photoTempY;
	var shadowTempY;
	
	if (IE)
	{
		targetObj = event.srcElement;
	}
	else
	{
		targetObj = e.target;
	}

	if(targetObj.className != "resultsPhoto" && targetObj.id != "detailsAgentPhoto" && targetObj.id != "detailsOfficePhoto" && targetObj.id != "realtorSearchAgentPhoto" && targetObj.className != "savedPropertyPhoto" )
	{
		return;
	}
	var floatRemarks = document.getElementById("floatingRemarks")

	if(targetObj.className == "detailsThumbnail")
	{
		alignRight = true;
		floatType = "property";
	}
	else if(targetObj.id == "detailsOfficePhoto")
	{
		alignRight = true;
		floatType = "office";
	}
	else if(targetObj.id == "detailsAgentPhoto" || targetObj.id == "realtorSearchAgentPhoto")
	{
		if(!document.getElementById("agentFloatingPhoto")){
			return;
		}
		floatType = "agent";
	}	

	if (IE) {
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  	


	if(floatType == "agent")
	{		
		var floatPhoto = document.getElementById("agentFloatingPhoto");		
	}
	else if(floatType == "property")
	{	
		var floatPhoto = document.getElementById("propertyFloatingPhoto");
	}
	else
	{	
		var floatPhoto = document.getElementById("resultsFloatingPhoto");
	}
	var UIBottom;	

	if(document.getElementById("dividerCellTwo"))
	{
		UIBottom = findPosY(document.getElementById("dividerCellTwo")) + 80;
	}
	else {
		UIBottom = document.body.clientHeight;
	}
	var photoBottom = (tempY - document.body.scrollTop) + floatPhoto.offsetHeight + 34;
	if(floatRemarks) {
		photoBottom = photoBottom + floatRemarks.offsetHeight;
	}
	if(photoBottom > UIBottom && ((tempY - floatPhoto.offsetHeight) > 0))
	{
		alignBottom = true;
	}

	if(photoBottom > document.body.clientHeight)
	{			
		alignBottom = true;
	}	
	
	if(!alignRight)
	{
		var photoRight = (tempX - document.body.scrollLeft) + floatPhoto.offsetWidth + 4;
		
		if( photoRight > document.body.clientWidth)
		{
			tempX = tempX - (photoRight - document.body.clientWidth);
		}
	}
	
	if(tempY < 0)
	{
		alignBottom = false;
	}
	
	if(alignRight){
		photoTempX = tempX - floatPhoto.offsetWidth - 9;
	}
	else{
		photoTempX = tempX + 9;
	}
	if(alignBottom){
		photoTempY = tempY - floatPhoto.offsetHeight - 15;
		if(floatRemarks) {
			photoTempY = photoTempY - floatRemarks.offsetHeight;
		}
	}
	else{
		photoTempY = tempY + 25;
	}

	if(photoTempY < 0) {
		photoTempY = 8;
	}
	floatPhoto.style.left = photoTempX;	
	floatPhoto.style.top = photoTempY;
	
	if(floatRemarks) {
		floatRemarks.style.top = parseInt(floatPhoto.style.top.split("px")[0]) + 242;
		floatRemarks.style.left = floatPhoto.style.left;
	}
	if(document.getElementById("alertWindow").style.visibility == "hidden")
	{		
		repositionShadow(floatPhoto);
	}
}

function performZoom(zoomType)
{		
	if(zoomType == "agent")
	{
		if(!document.getElementById("agentFloatingPhoto"))
		{
			return;
		}		
		document.getElementById("agentFloatingPhoto").style.visibility = "visible";		
		document.getElementById("agentFloatingPhoto").src = zoomObj.src;
		showShadow(document.getElementById("agentFloatingPhoto"));
	}
	else if(zoomType == "property")
	{
		positionPhoto();
		document.getElementById("propertyFloatingPhoto").style.visibility = "visible";		
		document.getElementById("propertyFloatingPhoto").src = zoomObj.src;
		document.getElementById("floatingRemarks").style.display = "";
		showShadow(document.getElementById("propertyFloatingPhoto"));		
	}
	else {
		document.getElementById("resultsFloatingPhoto").style.visibility = "visible";		
		document.getElementById("resultsFloatingPhoto").src = zoomObj.src;
		showShadow(document.getElementById("resultsFloatingPhoto"));
	}	
}

function positionPhoto()
{
	var floatPhoto = document.getElementById("propertyFloatingPhoto");
	var floatRemarks = document.getElementById("floatingRemarks")
	var tempX = document.body.scrollLeft;
	var tempY = document.body.scrollTop;	
	if(document.getElementById("dividerCellOne"))
	{
		var UITop = findPosY(document.getElementById("dividerCellOne")) + 100;
		var UILeft = findPosX(document.getElementById("contentCell")) + 60;
	}
	else {
	
		var UITop = document.body.scrollTop+145;
		var UILeft = document.body.scrollLeft+25;
	}


	floatPhoto.style.left = UILeft;	
	floatPhoto.style.top = UITop;

	if(floatRemarks) {
		floatRemarks.style.top = parseInt(floatPhoto.style.top.split("px")[0]) + 242;
		floatRemarks.style.left = floatPhoto.style.left;
	}
	if(document.getElementById("alertWindow").style.visibility == "hidden")
	{		
		repositionShadow(floatPhoto);
	}

}

function zoomInPhoto(photoObj, remarksText)
{	
	try {
		if(document.getElementById("alertWindow").style.visibility == "visible")
		{
			return;
		}	
	} catch (e) {
	}
	
	try {
		if(document.getElementById("photoViewerWindowBG") && document.getElementById("photoViewerWindowBG").style.visibility == "visible")
		{
			return;
		}
	} catch (e) {
	}	
	zoomObj = photoObj;
	if(photoObj.id == "detailsAgentPhoto" || photoObj.id == "realtorSearchAgentPhoto")
	{
		performZoom("agent");
	}
	else if(photoObj.className == "detailsThumbnail")
	{		
		zoomTimeout = setTimeout("performZoom('property')", 100);	
	}
	else if(photoObj.id == "detailsOfficePhoto") 
	{		
		performZoom();
	}
	else {
		zoomTimeout = setTimeout("performZoom()", 500);
	}
	if(remarksText != null) 
	{
		document.getElementById("floatingRemarksText").innerHTML = remarksText;
		
		var floatRemarks = document.getElementById("floatingRemarks")
		if(floatRemarks) {
			//alert(floatRemarks.style.height + ',' + remarksText.length)
			floatRemarks.style.height = (((remarksText.length / 50) + 1) * 20);
		}
	}
}

function zoomOutPhoto(photoObj)
{
	clearTimeout(zoomTimeout);
	if(document.getElementById("resultsFloatingPhoto")) {		
		document.getElementById("resultsFloatingPhoto").style.visibility = "hidden";		
	}
	if(document.getElementById("agentFloatingPhoto"))
	{	
		document.getElementById("agentFloatingPhoto").style.visibility = "hidden";
		document.getElementById("agentFloatingPhoto").style.top = '0px';
		document.getElementById("agentFloatingPhoto").style.left = '0px';
	}
	if(document.getElementById("propertyFloatingPhoto")) {		
		document.getElementById("propertyFloatingPhoto").style.visibility = "hidden";
		document.getElementById("propertyFloatingPhoto").style.top = '0px';
		document.getElementById("propertyFloatingPhoto").style.left = '0px';
	}
	hideShadow();
	var floatRemarks = document.getElementById("floatingRemarks")
	if(floatRemarks) {
		floatRemarks.style.display = "none";		
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function showBalloon()
{

		//alert(tgt);		
		//alert(e.type);
		if(!balloon)
		{
			return;
		}
		
		if(tgt.className == "generalButton" || tgt.className == "generalPNGButton") {			

			
			var elementLeft = findPosX(tgt) + tgt.offsetWidth - 9;
			var elementTop = findPosY(tgt) - 7;	
			if(balloon.id == "menuBalloonRt") 
			{
				var elementLeft = findPosX(tgt) - balloon.offsetWidth;
				var elementTop = findPosY(tgt) + (tgt.offsetHeight / 2) - 10;				
			}
			
			if(tooltipText == "")
			{
				switch(tgt.id)
				{
					case "btnRates":
						tooltipText = "Click here to see local interest rates."; 
						break;
					case "btnFinancing":
						tooltipText = "Click here to calculate the monthly payment for this property."; 
						break;
					case "btnCalculate":
						tooltipText = "Click here to calculate the monthly payment for this mortgage."; 
						break;
					case "btnRetrieveSearch":
						tooltipText = "Click here to retrieve the properties which match the criteria of this search."; 
						break;
					case "btnDeleteSearch":
						tooltipText = "Click here to remove this search from your saved list."; 
						break;
					case "btnRegister":
						tooltipText = "Click here to register an account, for personalized real estate services."; 
						break;
					case "btnDeleteProperty":
						tooltipText = "Click here to remove this property from your saved list."; 
						break;	
					case "btnFeedback":
						tooltipText = "Click here to send your preferred REALTOR&reg; feedback on this property."; 
						break;	
					case "btnUpdate":
						tooltipText = "Click here to instantly update your account settings."; 
						break;
					case "btnSearch":
						tooltipText = "Click here to find property matching your search criteria."; 
						break;
					case "btnMoreSearch":
						tooltipText = "Click here for more search options, to perform a more detailed search."; 
						break;
					case "btnPrint":
						tooltipText = "Click here to print this listing."; 
						break;
					case "btnDetails":
						tooltipText = "Click here for more information about this property."; 
						break;
					case "btnMapSearch":
						tooltipText = "Click here to view your located property on a virtual map."; 
						break;
					case "btnRequestInfo":
						tooltipText = "Click here to have a realtor contact you with more information."; 
						break;
						case "btnemailFriend":
						tooltipText = "Click here to Email Friend about property information."; 
						break;
					case "btnRequestSiteInfo":
						tooltipText = "Click here to have a realtor contact you with more information."; 
						break;	
					case "btnSave":
						tooltipText = "Click here to save this property to your account for later viewing."; 
						break;
					case "btnOthers":
						tooltipText = "Click here to automatically find other listed properties near this one."; 
						break;
					case "btnNewSearch":
						tooltipText = "Click here to return to the search form, and enter new criteria."; 
						if (IE) {
							document.getElementById("sortSelect").style.visibility = "hidden";
							document.getElementById("perPageSelect").style.visibility = "hidden";
						}
						break;
					case "btnSaveSearch":
						tooltipText = "Click here to save the critieria of this search for later viewing."; 
						if (IE) {
							document.getElementById("sortSelect").style.visibility = "hidden";
							document.getElementById("perPageSelect").style.visibility = "hidden";
						}
						break;
					case "btnSaveSearchLogin":
						tooltipText = "To save this search, you must register or login. Click here to login now."; 
						if (IE) {
							document.getElementById("sortSelect").style.visibility = "hidden";
							document.getElementById("perPageSelect").style.visibility = "hidden";
						}
						break;
					case "btnRefreshSearch":
						tooltipText = "Click here to update the sorting and # per page of your search."; 
						break;
					case "btnNextPage":
						tooltipText = "Click here to display the next page of matching properties."; 
						break;
					case "btnPreviousPage":
						tooltipText = "Click here to display the previous page of matching properties."; 
						break;
				
					
				}
			}
		}
		else if(source == null)
		{			
			var elementLeft = findPosX(tgt) + document.getElementById("menuCell").offsetWidth - 19;
			var elementTop = findPosY(tgt) - 3;	
		}
		else {
			//alert(findPosX(tgt));
			if(source == "hotw") {
				tgt = document.getElementById("homeWeekPhoto");	
			}
			else if(source == "register") {
				tgt = document.getElementById("registerPhoto");	
			}			

			var elementLeft = findPosX(tgt) - balloon.offsetWidth + 25;
			var elementTop = findPosY(tgt) + (tgt.offsetHeight / 2) - 25;				
		}
		

		//Show the menu highlight
		tgt.parentNode.childNodes[0].style.visibility = 'visible';

		//Show the balloon
		
		balloon.style.top = elementTop;
		balloon.style.left = elementLeft;
		
		balloonText.innerHTML = tooltipText;		
		var textHeight = balloonText.offsetHeight
		var newHeight = textHeight - 53;
		if(newHeight < 1) {
			newHeight = 1;
		}
		balloonMiddle.style.height = newHeight;
		balloon.style.visibility = "visible";
}


function hideBalloon()
{
	if(!balloon)
	{
		return;
	}
	if(source == null && tgt.className != "generalButton" && tgt.className != "generalPNGButton")
	{
		tgt.parentNode.childNodes[0].style.visibility = 'hidden';
	}		
	balloon.style.visibility = "hidden";
	tooltipText = "";
	if (IE) {
		if(tgt.id == "btnNewSearch") {
			document.getElementById("sortSelect").style.visibility = "visible";
			document.getElementById("perPageSelect").style.visibility = "visible";
		}
		else if(tgt.id == "btnSaveSearch" || tgt.id == "btnSaveSearchLogin") {
			document.getElementById("sortSelect").style.visibility = "visible";
			document.getElementById("perPageSelect").style.visibility = "visible";
		}
	}
}

function toggleBalloon(e, argTooltipText, argSource)
{	

	if(!document.getElementById("menuBalloon"))
	{
		return;
	}
	tooltipText = argTooltipText
	source = argSource
	if(e.type == "mouseover") 
	{
		if(e.target) {
			tgt = e.target;
		}
		else {
			tgt = e.toElement
		}
	}
	else
	{
		if(e.target) {
			tgt = e.target;			
		}
		else {
			tgt = e.fromElement
		}
	}
	
	var bodyWidth = document.body.offsetWidth;
	var balloonRight = findPosX(tgt) + document.getElementById("menuBalloon").offsetWidth + 25;	

	if(argSource != null || balloonRight > bodyWidth)
	{
		
		balloon = document.getElementById("menuBalloonRt");
		balloonText = document.getElementById("menuBalloonTextRt")
		balloonMiddle = document.getElementById("menuBalloonImageMiddleRt");
	}
	else
	{
	
		balloon = document.getElementById("menuBalloon");
		balloonText = document.getElementById("menuBalloonText")
		balloonMiddle = document.getElementById("menuBalloonImageMiddle");
	}
	if(e.type == "mouseover") 
	{	
		if(argSource == null && tgt.className != "generalButton")
		{
			//Show the menu highlight
			tgt.parentNode.childNodes[0].style.visibility = 'visible';
		}		
		balloonTimeout = setTimeout("showBalloon()", 500);
	}
	else
	{
		clearTimeout(balloonTimeout);
		hideBalloon();
	}				
}

function openWindow(URL, width, height)
{
	var now = new Date();
	var win = window.open(URL, 'popup' + now.getTime(), 'left=0,top=0,width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=1,scrollbars=1');
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
    document.getElementById(id).style.color='#000000';
}

function searchLostFocus(id)
{ 
    document.getElementById(id).style.color='#787878';
}

function clickButton(e, buttonid){ 
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){ 
          if (evt.keyCode == 13){ 
                bt.click(); 
                return false; 
          } 
      } 
}
//Added by DPanati for 1.5 Print Flyer
function printPreviewHide()
{
var printDiv=document.getElementById("myPrint");
printDiv.style.display="none";
}
 

//****************** scrolling images




imgPlaces=6 // number of images visible
imgWidth=125 // width of the images
imgHeight=100 // height of the images

if (navigator.userAgent.toLowerCase().indexOf("firefox")>0) {
 imgSpacer=0 // space between the images
}
else
{
 imgSpacer=125 // space between the images
}


dir=0 // 0 = left, 1 = right

newWindow=0 // 0 = Open a new window for links 0 = no  1 = yes

 

moz=document.getElementById&&!document.all

step=1
timer=""
speed=50
nextPic=1
initPos=new Array()
nowDivPos=new Array()

function initHIS3(){

for(var i=0;i<imgPlaces+1;i++){ // create image holders
newImg=document.createElement("IMG")
newImg.setAttribute("id","pic_"+i)
newImg.setAttribute("src","")
newImg.style.position="absolute"
newImg.style.width=imgWidth+"px"
newImg.style.height=imgHeight+"px"
newImg.style.border=0
newImg.alt=""
newImg.i=i
newImg.onclick=function(){his3Win(data[this.i][2])}
document.getElementById("display_area").appendChild(newImg)
}

containerEL=document.getElementById("his3container")
displayArea=document.getElementById("display_area")
pic0=document.getElementById("pic_0")

containerBorder=(document.compatMode=="CSS1Compat"?0:parseInt(containerEL.style.borderWidth)*2)
containerWidth=510
containerEL.style.width="510px"
containerEL.style.height=imgHeight+(!moz?containerBorder:"")+"px"

displayArea.style.width="600px"
displayArea.style.clip="rect(0,"+(containerWidth+"px")+","+(imgHeight+"px")+",0)"
displayArea.onmouseover=function(){stopHIS3()}
displayArea.onmouseout=function(){scrollHIS3()}

imgPos= -pic0.width

for(var i=0;i<imgPlaces+1;i++){
currentImage=document.getElementById("pic_"+i)

if(dir==0){imgPos+=pic0.width+imgSpacer} // if left

initPos[i]=imgPos
if(dir==0){currentImage.style.left=initPos[i]+"px"} // if left

if(dir==1){ // if right
document.getElementById("pic_"+[(imgPlaces-i)]).style.left=initPos[i]+"px"
imgPos+=pic0.width+imgSpacer
}

if(nextPic==data.length){nextPic=0}

currentImage.src=data[nextPic][0]
currentImage.alt=data[nextPic][1]
currentImage.i=nextPic
currentImage.onclick=function(){his3Win(data[this.i][2])}
nextPic++
}

scrollHIS3()
}

timer=""
function scrollHIS3(){
clearTimeout(timer)
for(var i=0;i<imgPlaces+1;i++){
currentImage=document.getElementById("pic_"+i)

nowDivPos[i]=parseInt(currentImage.style.left)

if(dir==0){nowDivPos[i]-=step}
if(dir==1){nowDivPos[i]+=step}

if(dir==0&&nowDivPos[i]<= -(pic0.width+imgSpacer) || dir==1&&nowDivPos[i]>containerWidth){

if(dir==0){currentImage.style.left=containerWidth+imgSpacer+"px"}
if(dir==1){currentImage.style.left= -pic0.width-(imgSpacer*2)+"px"}

if(nextPic>data.length-1){nextPic=0}

currentImage.src=data[nextPic][0]
currentImage.alt=data[nextPic][1]
currentImage.i=nextPic
currentImage.onclick=function(){his3Win(data[this.i][2])}

nextPic++

}
else{
currentImage.style.left=nowDivPos[i]+"px"
}

}
timer=setTimeout("scrollHIS3()",speed)

}

function stopHIS3(){
clearTimeout(timer)
}

function his3Win(loc){
if(loc==""){return}
if(newWindow==0){
location=loc
}
else{
//window.open(loc)
newin=window.open(loc,'win1','left=430,top=340,width=300,height=300') // use for specific size and positioned window
newin.focus()
}
}
 

var formKey;
function d2h(d) {
  return d.toString(16);
}
function h2d(h) {
 return parseInt(h,16);
} 

function generateFormKey()
{
  formKey = Math.floor(Math.random()*4999)+2001;  
  formKey = d2h(formKey)+'';  
}

function getFormKey()
{
 return h2d(formKey)+'';
}

function displayFormKey()
{
 document.write('<b>');
 var fKey = h2d(formKey)+'';
 var x;
 for (x=1;x<=4; x++)
 { 
  document.write('<div style=\"display:none\">&nbsp;</div>');
  document.write(fKey.charAt(x-1));
 }
 document.write('</b>');
}


