// JavaScript Document

// Load Content Via POST

	function loadContent(div, url, id) {
	  
	  new Ajax.Updater(div, url, {method: 'post', postBody:'content='+ id +''});
	}
	
// Load Content Via POST with Action

	function loadContent(div, url, action, id) {
	  
	  new Ajax.Updater(div, url, {method: 'post', postBody:''+action+'='+ id +''});
	}
	
	function postContent(div, url, id) {
	  
	  new Ajax.Updater(div, url, {method: 'post', postBody:'content='+ id +''});
	}
	


// Update Search Results via AJAX //

	function refineContent(searchby, where, pricemin, pricemax) {
		
	function startLoading() {
	 Effect.ScrollTo('container-top');
	 Element.show('dx_refine_updating');
	}
	function finishLoading() {
	 setTimeout("Effect.toggle('dx_refine_updating');", 1000);
	}

	  startLoading();
	  new Ajax.Updater('dx_where', '../components/com_properties/dx.ajax-searchbox.php', {method: 'post', postBody:''+'ajax=1&where='+ where +'&searchby=' + searchby + ''});
	  new Ajax.Updater('dx_props_avail', '../components/com_properties/dx.ajax-areaavail.php', {method: 'post', postBody:''+'ajax=1&where='+ where +'&searchby=' + searchby + ''});
	  new Ajax.Updater('dx_refine_h1', '../components/com_properties/dx.ajax-h1.php', 
					   {method: 'post', postBody:''+'ajax=1&where='+ where +'&searchby=' + searchby + '&pricemin=' + pricemin + '&pricemax=' + pricemax});
	  
	  new Ajax.Updater('dx_refine_right', '../modules/mod_refinesearch/dx.refinesearch.php', 
					   {method: 'post', postBody:''+'ajax=1&where='+ where +'&searchby=' + searchby + '&pricemin=' + pricemin + '&pricemax=' + pricemax});
	  
	  new Ajax.Updater('dx_refine_results', '../components/com_properties/dx.results-'+searchby+'.php', 
					   {method: 'post', postBody:''+'ajax=1&where='+ where +'&searchby=' + searchby + '&pricemin=' + pricemin + '&pricemax=' + pricemax});
	  
	  new Ajax.Updater('dx_search_menu', '../components/com_properties/dx.ajax-searchmenu.php', 
					   {method: 'post', postBody:''+'ajax=1&where='+ where +'&searchby=' + searchby + '&pricemin=' + pricemin + '&pricemax=' + pricemax});
	  
	  finishLoading();
	}
	
	
// Load Content Via GET

	function getContent(div, url, id) {
	  
	  new Ajax.Updater(div, url, {method: 'post', postBody:'content='+ id +''});
	}


function SwitchDiv(Switch,SwitchID)
	{
		if (Switch=='On')
		{
			document.getElementById(''+SwitchID).style.display = '';
			 
			
			
		
		}
		else
		{
			document.getElementById(''+SwitchID).style.display = 'none';
		}
		
	}

// To Open Google Maps on Results Lists ??

function SwitchHeight(Switch,SwitchID)
	{
		if (Switch=='On')
		{
			document.getElementById(''+SwitchID).style.height = '327px';
			 
			
			
		
		}
		else
		{
			document.getElementById(''+SwitchID).style.height = '0px';
		}
		
	}


// Check All TickBoxes ///

function CheckAll(field)
{
count = field.length;
    for (i=0; i < count; i++) 
	{
    if(field[i].checked == true)
    	{field[i].checked = false; }
    else {field[i].checked = true;}
	}
}


function checkAll2(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}


function checkUncheckAll(checkAllState, cbGroup)
{
	// Check that the group has more than one element
	if(cbGroup.length > 0)
	{
		// Loop through the array
		for (i = 0; i < cbGroup.length; i++)
		{
			cbGroup[i].checked = checkAllState.checked;
		}
	}
	else
	{
		// Single element so not an array
		cbGroup.checked = checkAllState.checked;
	}
}


function checkByParent(aId, aChecked) {
    var collection = document.getElementById(aId).getElementsByTagName('INPUT');
    for (var x=0; x<collection.length; x++) {
        if (collection[x].type.toUpperCase()=='CHECKBOX')
            collection[x].checked = aChecked;
    }
}

	
// Toggle Search List 'Selected' class //

function ToggleSelect(SwitchID)
	{
		if (document.getElementById(''+SwitchID).className== '')
		{
			document.getElementById(''+SwitchID).className= 'Selected';
		
		}
		else
		{
			document.getElementById(''+SwitchID).className= '';
		}
		
	}
	
function ToggleDivs(idOn,idOff) {
	
	Effect.Fade (idOff,  { duration: 3.0 });
	Effect.Appear(idOn, { duration: 3.0 });
	
}



function ToggleSlide(thisButton,thisSlide){
	//Select the element you wish to slide
	var mySlide = new Fx.Slide(thisSlide);
 
	//Create a slide in/out
	$(thisButton).addEvent('click', function(e){//add the click function (i.e on an anchor)
		e = new Event(e);//create a new event here
		mySlide.toggle();//do this to the selected element
		e.stop();//stop the event
	});
}

// Close Sear Propert Menus //


function ClosePropRegions(thisDiv)
	{
				
		document.getElementById('dx_prop_1').style.display = 'none';
		document.getElementById('dx_prop_2').style.display = 'none';
		document.getElementById('dx_prop_3').style.display = 'none';
		
		document.getElementById('PropReg1').className = '';
		document.getElementById('PropReg2').className = '';
		document.getElementById('PropReg3').className = '';
		
		Effect.toggle(thisDiv, 'blind');
		
			 	
	}
	
function CloseOfficeRegions(thisDiv)
	{
				
		document.getElementById('dx_office_4').style.display = 'none';
		document.getElementById('dx_office_5').style.display = 'none';
		document.getElementById('dx_office_6').style.display = 'none';
		
		document.getElementById('OfficeReg4').className = '';
		document.getElementById('OfficeReg5').className = '';
		document.getElementById('OfficeReg6').className = '';
		
		Effect.toggle(thisDiv, 'blind');
		
			 	
	}
	
	
function CloseServiceRegions(thisDiv)
	{
				
		document.getElementById('dx_service_7').style.display = 'none';
		document.getElementById('dx_service_8').style.display = 'none';
		document.getElementById('dx_service_9').style.display = 'none';
		
		document.getElementById('ServiceReg7').className = '';
		document.getElementById('ServiceReg8').className = '';
		document.getElementById('ServiceReg9').className = '';
		
		Effect.toggle(thisDiv, 'blind');
		
			 	
	}
	
	
	
function CloseResearchRegions(thisDiv)
	{
				
		document.getElementById('dx_research_10').style.display = 'none';
		document.getElementById('dx_research_11').style.display = 'none';
		document.getElementById('dx_research_12').style.display = 'none';
		
		document.getElementById('ResearchReg10').className = '';
		document.getElementById('ResearchReg11').className = '';
		document.getElementById('ResearchReg12').className = '';
		
		Effect.toggle(thisDiv, 'blind');
		
			 	
	}
	
function CloseNewsRegions(thisDiv)
	{
				
		document.getElementById('dx_news_13').style.display = 'none';
		document.getElementById('dx_news_14').style.display = 'none';
		document.getElementById('dx_news_15').style.display = 'none';
		
		document.getElementById('NewsReg13').className = '';
		document.getElementById('NewsReg14').className = '';
		document.getElementById('NewsReg15').className = '';
		
		Effect.toggle(thisDiv, 'blind');
		
			 	
	}
	
	
// Close all pop ups on full details ///

function CloseElements()
{
	
	document.getElementById('dx_form_enquire').style.display = 'none';
	document.getElementById('dx_form_call').style.display = 'none';
	document.getElementById('dx_form_friend').style.display = 'none';
	
	

}

function CloseDrops(thisDrop) {
	
if(thisDrop=='offices') { document.getElementById('FindOffice').className= 'Selected'; } 
else { document.getElementById('dx_sub_office').style.display = 'none'; document.getElementById('FindOffice').className= ''; }

if(thisDrop=='properties') { document.getElementById('FindProp').className= 'Selected';} 
else { document.getElementById('dx_sub_prop').style.display = 'none'; document.getElementById('FindProp').className= ''; }

if(thisDrop=='services') { document.getElementById('FindService').className= 'Selected';} 
else { document.getElementById('dx_sub_service').style.display = 'none'; document.getElementById('FindService').className= ''; }

if(thisDrop=='news') { document.getElementById('FindNews').className= 'Selected';} 
else { document.getElementById('dx_sub_news').style.display = 'none'; document.getElementById('FindNews').className= ''; }

if(thisDrop=='research') { document.getElementById('FindResearch').className= 'Selected';} 
else { document.getElementById('dx_sub_research').style.display = 'none'; document.getElementById('FindResearch').className= ''; }

/* document.getElementById('dx_sub_research').style.display = 'none'; */

}


// Toggle Services Panels //

function toggleServices(showid) {
			elcount = 30;
			if (document.getElementById) { // DOM3 = IE5, NS6 
				document.getElementById('t'+showid).className = 'Selected';
				document.getElementById("s"+showid).className = 'serviceinfo active';
			}
			var i=1;
			for (i=1;i<=elcount;i++)
			{
				if(i != showid) {
					document.getElementById('t'+i).className = '';
					document.getElementById('s'+i).className = 'serviceinfo inactive';
				}
			}
		}


function fix6ToString(n) {
		return n.toFixed(6).toString();
	}


function popup(pageref,win_name) {
	var remote = window.open(pageref,win_name,"width=830,height=550,left=10,top=10,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");	
	if (remote.opener == null) remote.opener = window; 
	remote.opener.name = "parent_window";
	
}