function changePageList(iPage,SID){
	document.listform.PL.value = iPage;
	document.listform.SID.value = SID;
	document.listform.M.value = "List";
	document.listform.submit();
}

function changePageDetail(iPage){
	document.listform.PD.value = iPage;
	document.listform.M.value = "Detail";
	document.listform.submit();
}

function viewDetail(id,rec){
	document.listform.M.value = "Detail";
	document.listform.MD.value = "Detail";
	document.listform.LID.value = id;
	document.listform.PD.value = rec;
	document.listform.submit();
}

function Home(){
	document.listform.action = "http://actrislistings.marketlinx.com/portal/default.aspx";
	document.listform.MD.value = "";
	document.listform.ML.value = "";
	document.listform.LID.value = ""; //VI 68691 AJ
	document.listform.SID.value = "";
	document.listform.PD.value = "";
	document.listform.submit();
}

function backToList(){
	var pls = document.listform.PLS.value;
	var pd = document.listform.PD.value;
	var pl = Math.ceil(pd/pls);
	document.listform.PL.value = pl;
	document.listform.LID.value = ""; //VI 68590 AJ
	document.listform.M.value = "List";
	document.listform.submit();
}		

function Order(sOrderBy){
	document.listform.OB.value = sOrderBy;
	document.listform.PL.value = 1;
	document.listform.M.value = "List";
	document.listform.submit();
}

function Categorize(lid,iCategory,ret){
	document.listform.LID.value = lid;
	document.listform.RET.value = ret;
	document.listform.action = "http://actrislistings.marketlinx.com/portal/publicpropertynote.aspx?cat=" + iCategory;
	document.listform.submit();
}

function AddNote(lid,ret){
	document.listform.action = "http://actrislistings.marketlinx.com/portal/publicpropertynote.aspx";
	document.listform.LID.value = lid;
	document.listform.RET.value = ret;
	document.listform.submit();
}

function EmailProperty(lid,mailType){
	document.listform.action = "http://actrislistings.marketlinx.com/portal/publicMailForm.aspx?mt=" + mailType;
	document.listform.LID.value = lid;
	document.listform.submit();
}

function SingleDetail(iPropID){
	document.listform.M.value = "Detail";
	document.listform.MD.value = "SingleDetail";
	document.listform.LID.value = iPropID;
	document.listform.submit();
}

function SubmitForm(sSID){
	var myForm;
	myForm = document.listform;
	myForm.SID.value = sSID;
	myForm.M.value = "List";
	myForm.ML.value = "Search";
	myForm.MD.value = "";
	myForm.PL.value = 1;
	myForm.OB.value = "";
	myForm.submit();
}

function backToProperty(){
	document.listform.action = "http://actrislistings.marketlinx.com/portal/publiclist.aspx"
	document.listform.M.value = "Detail";
	//document.listform.MD.value changes based on the user's identity and is already correctly persisted. 
	document.listform.submit();
}

function ViewSelected(sContentSectionID){
	if (document.getElementById('HomePage_SelectedItems'+sContentSectionID).value.length > 0){
		document.listform.KL.value = document.getElementById('HomePage_SelectedItems'+sContentSectionID).value.substring(1,document.getElementById('HomePage_SelectedItems'+sContentSectionID).value.length);
		document.listform.M.value = "List";
		document.listform.ML.value = "ListSelected";
		document.listform.OB.value = "";
		
		setTimeout("document.listform.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(){
	document.listform.action = "http://actrislistings.marketlinx.com/portal/publiclist.aspx";
	document.listform.M.value = "List";
	document.listform.ML.value = "MemberProperties";
	document.listform.OB.value = "";
	document.listform.PL.value = "1"; //Reset Page Number to 1 instead of 0 just in case we came from a higher one. 
	                                  //VI 68585 AJ
	document.listform.submit();
}

function MapList(sMapURL){
	var sMapList = document.listform.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 = (document.listform.PLS.value*(document.listform.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){
	var sProspectID = document.listform.PID.value;
	var sMemID = document.listform.MID.value;
	var wMedia = window.open("http://actrislistings.marketlinx.com/portal/publicmedia.aspx?LID=" + PropertyId + "&PID=" + sProspectID + "&MID=" + sMemID ,"wMedia","width=555,height=800,toolbar=no,location=no,menubar=no,resizable=yes,scrollbars=yes");
	wMedia.focus();
}

function VirtualTour(url){
	var wMedia = window.open(url,"wMedia","");
	wMedia.focus();
}