
$(document).ready(function() 
	{
		$('#menu ul li').each(function(){
			$(this).hover(
				function(){
					$(this).addClass('show');
				},
				function(){
					$(this).removeClass('show');
					$("#menu_current").addClass("active");
				});
		});
		
		// outside,inside
		Rounded("div.sidebar-button","#FFF","#10155E");
		
		$('.gallery a').lightBox(
	
			{
				imageLoading: base_url+'assets/js/jquery/lightbox/lightbox-ico-loading.gif',
				imageBtnClose: base_url+'assets/js/jquery/lightbox/lightbox-btn-close.gif',
				imageBtnPrev: base_url+'assets/js/jquery/lightbox/lightbox-btn-prev.gif',
				imageBtnNext: base_url+'assets/js/jquery/lightbox/lightbox-btn-next.gif'
			}	
		
		);
		
	});


function standard_corners()
{
	  settings = 
	  {
		  tl: { radius: 10 },
		  tr: { radius: 10 },
		  bl: { radius: 10 },
		  br: { radius: 10 },
		  antiAlias: false,
		  autoPad: false,
		  validTags: ["div"]
	  }
	

	/*corners1 = new curvyCorners(settings, 'sidebar-search');
	corners1.applyCornersToAll();*/
	
	corners2 = new curvyCorners(settings, 'sidebar-button');
	corners2.applyCornersToAll();	
	
	/*corners3 = new curvyCorners(settings, 'sidebar-profile');
	corners3.applyCornersToAll();
	
	corners4 = new curvyCorners(settings, 'property-listing');
	corners4.applyCornersToAll();*/
	
}

function block_buttons()
{
	  settings = 
	  {
		  tl: { radius: 3 },
		  tr: { radius: 3 },
		  bl: { radius: 3 },
		  br: { radius: 3 },
		  antiAlias: false,
		  autoPad: true,
		  validTags: ["span","a"]
	  }

	corners2 = new curvyCorners(settings, 'block_button');
	corners2.applyCornersToAll();	
}

_w = null;

function open_window(path,width,height,win){
	
	w = window.screen.availWidth;
	h = window.screen.availHeight;	
	
	posL = (w-width)*.5;
	posT = (h-height)*.5;
	
	if(_w && _w.open){
		_w.close();
	}	
	
	_w = window.open(path,win,'width='+width+',height='+height+',top='+posT+',left='+posL+',menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,allowresize=1,dependent=1,resizable=1');
	
}

function show_image(id,src){
	document.getElementById(id).innerHTML = '<img border="0" src="'+src+'" />';
}

function sidebar(which){
	
	if(which=='search'){
		
		document.getElementById('tab1').className='selected'
		document.getElementById('tab2').className='';
		document.getElementById('sidebar_search').className='';
		document.getElementById('sidebar_contact').className='off';
		
	} else {
	
		document.getElementById('tab1').className=''
		document.getElementById('tab2').className='selected';
		document.getElementById('sidebar_search').className='off';
		document.getElementById('sidebar_contact').className='';	
	
	}
	
}

function reveal_menu(which){
	//alert('over');
	document.getElementById(which).className='dropdown';
}
function hide_menu(which){
	//alert('out');
	document.getElementById(which).className='off';
}

	/*search*/

	var sfsIndex       = new Object;
	sfsIndex.populated = false;
	/*
	Typing a name into the suburb entry field will scroll the suburb select
	field to a matching suburb name (if any).
	*/
	function sfsComplete () 
	{
		if (!document.getElementById) return;
		var text   = document.getElementById('tb');
		var select = document.getElementById('u');
		if (!sfsIndex.populated) sfsBuildIndex();
		var suburb = text.value.match(/,*([^,]+)$/);
		if (suburb) {
		var name = suburb[1].toUpperCase().replace(/^\s*/, '').replace(/\s*$/, '');
		for (var i = sfsIndex[name.charAt(0)]; i < select.options.length; i++) {
		if (select.options[i].text.toUpperCase().indexOf(name) == 0) {
		select.selectedIndex = i;
		break;
		}
		else {
		select.selectedIndex = -1;
		}
		}
		}
	}
	/*
	On click event for the suburb select box. When clicked it populates
	the suburb entry field then deselects the clicked suburb. Focus is
	returned to the suburb entry field.
	*/
	function sfsInsert () 
	{
		if (!document.getElementById) return false;
		var text    = document.getElementById('tb');
		var select  = document.getElementById('u');
		// An IE bug means we need another event before select.selectedIndex
		// will update from -1. Since we need to swap the focus anyway we'll
		// do it before we look at what was clicked in the select box.
		text.focus();
		var suburb = select.options[select.selectedIndex];
		
		// short circuit on 'show all suburbs'
		if (select.selectedIndex == 0) {
		text.value = '';
		return true;
		}
	
		// see if the selected suburb is in the list already
		var textSuburbs = text.value.split(/\s*,\s*/);
		if (!textSuburbs) return false;
		var pattern = new RegExp('\s*' + suburb.text + '\s*$');
		for (var i = 0; i < textSuburbs.length; i++) {
		// if it's in the list don't do anything
		if (pattern.exec(textSuburbs[i])) return false;
		}
		// its not in the list so lets add it replacing any incomplete words
		var newvalue = text.value.replace(
		/(^|,)([^,]*)$/,
		"$1 " + suburb.text + ', '
		);
		text.value = newvalue;
		return false;
	}
	/*
	Builds an index based on the first occurrence of suburb starting with a
	letter. This speeds up the 'for' search of the select because we can
	then skip straight to suburbs starting with that letter.
	*/
	function sfsBuildIndex () 
	{
		if (!document.getElementById) return;
		var select = document.getElementById('u');
		for (var i = select.options.length; i--;) {
		sfsIndex[select.options[i].text.toUpperCase().charAt(0)] = i;
		}
		sfsIndex.populated = true;
	}
	
	