
var coordClient = new function()
{	
	this.structure = function()
	{
		document.getElementById('target').innerHTML = "<div style='margin:10%'>"
			+ ydrClientScripts.urlFetchString(rootDir+'/contacts/index.htm')
				.replace(/%userMessage%/,'') 
				.replace(/%rootDir%/,rootDir)
			+ "</div>";
		return false;
	}
	
	this.browse = function(anchor)
	{
		var result; 
		//stop();
		// remember that browseServer will prune the visible lists even further (eg to comply with visbility)
		switch (anchor.getAttribute("id").replace(/legacybrowse/,""))
		{
			case "Committee" :
				result = "<h3 style='text-align:center'>Members of the NHW Group Committee</h3><div style='margin-left:2em'>"
					+browseClient.list("@CORPORATESTATUS='Group' and starts-with(@CONTACTID,'Committee, ')")
					+"</div>"; 
				break; 
			
			case "Area" :
				result = "<h3 style='text-align:center'>NHW Areas within the Reigate and Redhill Group</h3><div style='margin-left:2em'>"
					+browseClient.list("@CORPORATESTATUS='Group' and starts-with(@CONTACTID,'Area, ')")
					+"</div>"; 
				break;
					 
			case "Watch" : 
				result = "<h3 style='text-align:center'>NHW Watches within the Reigate and Redhill Group</h3><div style='margin-left:2em'>"
					+ browseClient.list(
						 "@CORPORATESTATUS='Role' and starts-with(@CONTACTID,'Watch, ')")
					+"</div>"; 
				break;
			
			case "County" :
				result = "<h3 style='text-align:center'>Selected Members of the Surrey Association Committee</h3><div style='margin-left:2em'>"
					+browseClient.list("@CORPORATESTATUS='Group' and starts-with(@CONTACTID,'County, ')")
					+"</div>"; 
				break;
				
			case "People" :
				result = "<h3 style='text-align:center'>Selected Members of the Surrey Association Committee</h3><div style='margin-left:2em'>"
					+browseClient.list("contains('|Person|Barred|',@CORPORATESTATUS) ", "true()")
					+"</div>"; 
				break;
		
			default :
				result = "<div style='margin-left:2em'><p class='developer'> Unrecognised browse action <span class='emph'>" + anchor.getAttribute("id") +"</span></p></div>";
			
		};
		
		ydrClientPane.paneExpand(
			document.getElementById('ydrPopupMain')
			, document.getElementById("target")
			, "base"
			, "<div>" + result +"</div>"
			);
		return false
	}
	
	////////////////////////
	this.someoneElse = function (mode)
	{
		switch (mode)
		{
			case "load" :
				this.load("someoneElse");			
				// TODO preload list
			
			case "start" :
				document.getElementById('someoneElse').style.visibility = 'inherit';
				
				// TODO load list
				break;
			
			case "cancel" :
				document.getElementById('someoneElse').style.visibility = 'hidden';
				
			case "control" :
				document.getElementById('someoneElse').style.visibility = 'hidden';
				window.location.href=rootDir+'/contacts/details.asp?id=' + document.getElementById('someoneElseSelect').value; 
				break
				
			case "edit" :
				document.getElementById('someoneElse').style.visibility = 'hidden';
				// TODO need to proxy
				window.location.href=rootDir+'/contacts/details.asp?id=' + document.getElementById('someoneElseSelect').value
				break;
		};
		return false;
	}
}

