var actionForm;
function changePageList(iPage,SID)
{
	GetForm();
	actionForm.action = "PublicList.aspx";
	actionForm.PL.value = iPage;
	actionForm.SID.value = SID;
	actionForm.M.value = "List";
	actionForm.submit();
}
function changePageDetail(iPage)
{
	GetForm();
	actionForm.action = "PublicList.aspx";
	actionForm.PD.value = iPage;
	actionForm.M.value = "Detail";
	actionForm.submit();
}
function viewDetail(id,rec)
{
	GetForm();
	actionForm.action = "PublicList.aspx";
	actionForm.M.value = "Detail";
	actionForm.MD.value = "Detail";
	actionForm.LID.value = id;
	actionForm.PD.value = rec;
	actionForm.submit();
}
function Home()
{
	GetForm();
	actionForm.action = "default.aspx";
	actionForm.MD.value = "";
	actionForm.ML.value = "";
	actionForm.LID.value = ""; //VI 68691 AJ
	actionForm.SID.value = "";
	actionForm.PD.value = "";
	actionForm.submit();
}
function backToList()
{
	GetForm();
	var pls = actionForm.PLS.value;
	var pd = actionForm.PD.value;
	var pl = Math.ceil(pd/pls);
	actionForm.action = "PublicList.aspx";
	actionForm.PL.value = pl;
	actionForm.LID.value = ""; //VI 68590 AJ
	actionForm.M.value = "List";
	actionForm.submit();
}		
function Order(sOrderBy)
{
	GetForm();
	actionForm.action = "PublicList.aspx";
	actionForm.OB.value = sOrderBy;
	actionForm.PL.value = 1;
	actionForm.M.value = "List";
	actionForm.submit();
}
function Categorize(lid,iCategory,ret)
{
	GetForm();
	actionForm.LID.value = lid;
	actionForm.RET.value = ret;
	actionForm.action = "publicpropertynote.aspx?cat=" + iCategory;
	actionForm.submit();
}
function AddNote(lid,ret)
{
	GetForm();
	actionForm.action = "publicpropertynote.aspx";
	actionForm.LID.value = lid;
	actionForm.RET.value = ret;
	actionForm.submit();
}
function EmailProperty(lid,mailType)
{
	GetForm();
	actionForm.action = "publicMailForm.aspx?mt=" + mailType;
	actionForm.LID.value = lid;
	actionForm.submit();
}
function SingleDetail(iPropID)
{
	GetForm();
	actionForm.action = "PublicList.aspx";
	actionForm.M.value = "Detail";
	actionForm.MD.value = "SingleDetail";
	actionForm.LID.value = iPropID;
	actionForm.submit();
}
function SubmitForm(sSID)
{
	GetForm();
	actionForm.SID.value = sSID;
	actionForm.M.value = "List";
	actionForm.ML.value = "Search";
	actionForm.MD.value = "";
	actionForm.PL.value = 1;
	actionForm.OB.value = "";
	actionForm.action = "publiclist.aspx";
	actionForm.submit();
}
function backToProperty()
{
	GetForm();
	actionForm.action = "publiclist.aspx";
	actionForm.M.value = "Detail";
	//document.listform.MD.value changes based on the user's identity and is already correctly persisted. 
	actionForm.submit();
}
function ViewSelected(sContentSectionID)
{
	GetForm();
	if (document.getElementById('HomePage_SelectedItems'+sContentSectionID).value.length > 0)
	{
		actionForm.action = "publiclist.aspx";
		actionForm.KL.value = document.getElementById('HomePage_SelectedItems'+sContentSectionID).value.substring(1,document.getElementById('HomePage_SelectedItems'+sContentSectionID).value.length);
		actionForm.M.value = "List";
		actionForm.ML.value = "ListSelected";
		actionForm.OB.value = "";
		setTimeout("actionForm.submit();",1);	//in netscape this submit does not work without this delay.  I don't know why.  -AS 1/20/04
	}
	else
	{
		alert("Please select some properties");
	}
}
function SelectAll(sContentSectionID,clickedButton)
{
	var tagList;
	var sUID;
	var bSelect;
	if (clickedButton.value == "Select All")
	{
		bSelect = true;
		clickedButton.value = "Deselect All";
	}
	else
	{
		bSelect = false;
		clickedButton.value = "Select All";
	}
	tagList = document.getElementsByName(sContentSectionID);
	for (var i = 0; i < tagList.length; i++)
	{
		sUID = tagList[i].id.substring(2,tagList[i].id.length);
		if (!((bSelect && tagList[i].checked==true)||(!bSelect && tagList[i].checked!=true)) )
			HandlePropCheckbox(sUID,sContentSectionID)
		if (bSelect)
			tagList[i].checked=true;
		else
			tagList[i].checked=false;
	}
	return(false);
}
function ViewMember()
{
	GetForm();
	actionForm.action = "publiclist.aspx";
	actionForm.M.value = "List";
	actionForm.ML.value = "MemberProperties";
	actionForm.OB.value = "";
	actionForm.PL.value = "1"; //Reset Page Number to 1 instead of 0 just in case we came from a higher one. 
	                                  //VI 68585 AJ
	actionForm.submit();
}
function MapList(sMapURL)
{
	GetForm();
	var sMapList = document.forms[0].maplist.value;
	var aMapList;
	var sSortCode = "";
	var i = 0;
	var iStartNum;
	aMapList = sMapList.split(",");
	sSortCode = "mapsort = case UID ";
	for (i; i < aMapList.length; i++)
	{
		sSortCode = sSortCode + "when '" + aMapList[i] + "' then " + i + " ";
	}
	iStartNum = (actionForm.PLS.value*(actionForm.PL.value-1))+1;
	sSortCode = sSortCode + "else " + (i + 1) + " end";
	window.open(sMapURL+"&startnum="+iStartNum+"&prp=MLS"+"&mlslist="+sMapList+"&SortCode="+sSortCode+"&OrderBy=mapsort","PublicMap","width=800,height=600,location=yes,menubar=yes,status=no,toolbar=no,scrollbars=yes,resizable=yes");
}
function MapSingle(PropertyID,sMapURL)
{
	window.open(sMapURL+"&prp=MLS"+"&mlslist="+PropertyID,"PublicMap","width=800,height=600,location=no,menubar=yes,status=no,toolbar=no,scrollbars=yes,resizable=yes");
}
function HandlePropCheckbox(sPropID,sContentSectionID)
{
	var sWorkingPropID = sPropID + ",";
	var sWorkingIDList = document.getElementById('HomePage_SelectedItems'+sContentSectionID).value+",";
	var locPropID = sWorkingIDList.indexOf(sWorkingPropID);
	if (locPropID > 0)
	{
		sWorkingIDList = sWorkingIDList.substring(0,locPropID)+sWorkingIDList.substring(locPropID+sWorkingPropID.length,sWorkingIDList.length);
		sWorkingIDList = sWorkingIDList.substring(0,sWorkingIDList.length-1);
	}
	else
	{
		sWorkingIDList=sWorkingIDList+sPropID;
	}
	document.getElementById('HomePage_SelectedItems'+sContentSectionID).value = sWorkingIDList;
}
function MediaDisplay(PropertyId)
{
	GetForm();
	var sProspectID = actionForm.PID.value;
	var sMemID = actionForm.MID.value;
	var wMedia = window.open("publicmedia.aspx?LID=" + PropertyId + "&PID=" + sProspectID + "&MID=" + sMemID ,"wMedia","toolbar=no,location=no,menubar=no,resizable=yes,scrollbars=yes");
	wMedia.focus();
}
function VirtualTour(url)
{
	var wMedia = window.open(url,"wMedia","");
	wMedia.focus();
}
function GetForm()
{
	actionForm = document.getElementById("listform");
}
function OpenHouseReportDisplay(url) {
    var wOpenHouse = window.open(url,"OpenHouseReport","width=500,height=500,location=no,menubar=yes,status=no,toolbar=no,scrollbars=yes,resizable=no");
    wOpenHouse.focus();
}

function confirmDelete() {
    if (confirm("Do you want to Delete Inactive Listing from this Prospect?")) {
        return true;
    } else {
        return false;
    }
} 

