$(document).ready(function(){
		
	$(".nova").selectbox({
		onOpen: function (inst) {
			var ee=$(this).parent('div').attr('id');
			$("#"+ee+" a.open_").addClass('selected');
			$("#"+ee+" div.sbHolder .sbSelector").addClass('white_');
			$("#"+ee+" div.sbHolder ul.sbOptions a").addClass('white_');
		},
		onClose: function (inst) {
			$(".open_").removeClass('selected');
			$(".sbSelector").removeClass('white_');
			$(".sbOptions a").addClass('white_');
		}
	});
	$(".open_").click(function(e){
		var $sel = $(this).parent().parent('div').attr('id');
		//alert($sel);
		if($('.sbHolder a').hasClass('sbToggleOpen')){
			$('#'+$sel+' select.nova').selectbox("close");
		}else{
			$('#'+$sel+' select.nova').selectbox("open");
		}
	});
	$(".sbOptions li a").click(function(e){
		var $ea = $(this).parent().parent().attr('class');
		$('.'+$ea+' >li').removeClass('on_state');
		$(this).parent().addClass('on_state');
	});
	$("#map_ area").click(function(){
		$('#loc-text-field2 .sbHolder ul > li').removeClass('on_state');
		//$('#loc-text-field2 #location > option').removeAttr('selected');
		$('#loc-text-field2 #CAT_ProductCatalogue > option').removeAttr('selected');
		$('#search_map').attr('src','_templateFiles/images/map_.jpg');
	    var $areaname = $(this).attr('id');
		//var $optionval = $('#loc-text-field2 #location option.'+$areaname).text();
		//var $relvalue = $('#loc-text-field2 #location option.'+$areaname).val();	
		var $optionval = $('#loc-text-field2 #CAT_ProductCatalogue option.'+$areaname).text();
		var $relvalue = $('#loc-text-field2 #CAT_ProductCatalogue option.'+$areaname).val();
		
		$('#search_map').attr('src','_templateFiles/images/'+$areaname+'.jpg');
		$('#loc-text-field2 .nova').selectbox("open");
		//$('#loc-text-field2 #location option.'+$areaname).attr('selected','selected');
		$('#loc-text-field2 #CAT_ProductCatalogue option.'+$areaname).attr('selected','selected');
		$('#loc-text-field2 .sbHolder a.sbSelector').text($optionval);
		$('#loc-text-field2 .sbHolder ul li a[rel="'+$relvalue+'"]').parent().addClass('on_state');
	});
	// Hide selectbox on mouseoff.
	$(".sbOptions").mouseleave(function(e){
		var $sel = $(this).parent('div').parent('div').attr('id');
		//if($('.sbHolder a').hasClass('sbToggleOpen')){
			$('#'+$sel+' select.nova').selectbox("close");
		//}else{
		//	$('#'+$sel+' select.nova').selectbox("open");
		//}
	});
		
	//search tab
	var tabContainers2 = $('div#property-search-items > div.property-search-container');
	tabContainers2.hide();
	$('#search-first').show();
	$('div#cat_659299_divs ul#nav_659299 li a').click(function () {
			tabContainers2.hide();
			tabContainers2.filter(this.hash).show();
			$('div#cat_659299_divs ul#nav_659299 li a').removeClass('selected');
			$(this).addClass('selected');
			return false;
	}).filter(':first').click();
	//first tab
	var tabContainers = $('div#tab-contents > div.tab-content');
	tabContainers.hide();
	$('#first').show();
	$('div#cat_659302_divs ul#nav_659302 li a').click(function () {
			tabContainers.hide();
			tabContainers.filter(this.hash).show();
			$('div#cat_659302_divs ul#nav_659302 li a').removeClass('selected');
			$(this).addClass('selected');
			return false;
	}).filter(':first').click();
	
	//second tab
	var tabContainers1 = $('div#tab-contents1 > div.tab-content');
	tabContainers1.hide();
	//$('div#tab-contents1 > div.tab-content').hide();
	$('#a_first').show();
	//$('div#cat_659307_divs ul#nav_659307 a').click(function () {
   $('div#cat_659307_divs ul#nav_659307 a').click(function () {
			tabContainers1.hide();
			//$('div#tab-contents1 > div.tab-content').hide();
			//$('div#tab-contents1 > div.tab-content').fliter(this.hash).show();
			tabContainers1.filter(this.hash).show();
			$('div#cat_659307_divs ul#nav_659307 li a').removeClass('selected');
			$(this).addClass('selected');
			return false;
	}).filter(':first').click();
	
	$('body#newhome > div > div > div#inner-wrap').attr('id','inner-wrap_');

	//new search tab
	var tabContainers3 = $('div#property-search-items > div.property-search-nw');
	tabContainers3.hide();
	$('#new-search-first').show();
	$('div#cat_663258_divs ul#nav_663258 a').click(function () {
			tabContainers3.hide();
			tabContainers3.filter(this.hash).show();
			$('div#cat_663258_divs ul#nav_663258 li a').removeClass('selected');
			$(this).addClass('selected');
			return false;
	}).filter(':first').click();
	
	
});
