
$( document ).ready( function(){

			
	
	
	$('.blink')
		.focus( function(){
			if ( $( this ).val() == $( this ).attr('title') ) {
				 $( this ).attr({ 'value': '' });
				 $( this ).addClass('black');
			}
		})
		.blur( function(){
			if ( $( this ).val() == '' ) {
				$( this ).attr({ 'value': $( this ).attr('title') });
				$( this ).removeClass('black');
			}
		});
		
		

	$('a#closesaved')
		.click( function(){
			$( this ).parent().hide();
		});
		
		
	// choose broker for filter:
	
		$('#brokerid')
		.change( function(){
				 var selected = $("#brokerid option:selected");       
				 if(selected.val() != 0){  
					window.location="?sort=broker&b="+selected.val();  
				 }  
		});

	// make url for propertyname	
	
	$('form#newprop')
		.submit( function(){
			var newURL = $( 'input#propertyname' ).attr('value').toLowerCase();
			newURL = newURL.replace(/[^a-z0-9]/g,"-"); // find only letters and numbers
			newURL = newURL.replace(/-+/g,"-"); // remove duplicate dashes
			
			$('input#propertyurl').val( newURL );			
		});
		
		
	// show prop pop up on map	
		
	$('a.propdot')
		.mouseover( function(){
			var post = $(this).position();
			$(this).next('.proppopup').css({'top':(post.top-16)+'px', 'left':(post.left+16)+'px'});
			$(this).next('.proppopup').show();
		})
		.mouseout( function(){
			$(this).next('.proppopup').hide();
		});
		
	// edit page: edit text/save	
		
	$('a#editn')
		.click( function(){
			$("#pagename").addClass("editthis");
			$("#pagename").attr({"disabled":""});
			$(this).hide();
			$('input#saven').show();
		});

	$('a#editp')
		.click( function(){
			$("#pageproptitle").addClass("editthis");
			$("#pageproptitle").attr({"disabled":""});
			$(this).hide();
			$('input#savep').show();
		});
	
	$('a#editt')
		.click( function(){
			$(".dis-blurb").hide();
			$("span#pagetext_parent").show();
			$(this).hide();
			$('input#savet').show();
		});


// current box switchies

	$('form#geninfo .textbox input, form#geninfo textarea, form#geninfo select, form#geninfo input.check')
		.focus( function(){
			$(".currenton").removeClass("currenton");
			$(this).parent().parent().addClass("currenton");
		});

// on new prop - switch from default city

	$('form#newprop input#othercityname')
		.focus( function(){
			$("input#defcity").attr({"checked":""});
			$("input#othercity").attr({"checked":"checked"});
		});


	// save form on brokercheck
	
	$('input.brokercheck')
		.click( function(){
			$('form#geninfo').submit();
		});

	// toggle hide prop and feature on homepage
	
	$('input#propertyhide')
		.click( function(){
			if ( $('label#phide').hasClass("hideprop") ){
				$('label#phide').removeClass("hideprop");
				$('#featurecheck').show();
			}
			else{
				$('#featurecheck').hide();
				$('label#phide').addClass("hideprop");
				$('input#propertyfeatured').attr({'checked':''});
			}
		});
		
		
	// secure
	
	$('a.tabright').click(function(){
		$('#filesblue').hide();
		$('#filesgray').show();
	});

	$('a.tabblue').click(function(){
		$('#filesgray').hide();
		$('#filesblue').show();
	});


	// secure
	
	$('#securecontent #namepropertydata input').click(function(){
		var propcount = parseInt($('span.spropnum').html());
		if($(this).is(':checked')){
			$(this).next('label').addClass('selectedlabel');
			$('span.spropnum').html(propcount+1);
		}
		else{
			$(this).next('label').removeClass('selectedlabel');
			$('span.spropnum').html(propcount-1);

		}
	
	});
	
	
	$('#securecontent a#selectall').click(function(){
		$('#namepropertydata input.checkright').attr('checked','checked');	
		$('#namepropertydata label').addClass('selectedlabel');	
		$('span.spropnum').html($('span.stotnum').html());
		
															   
	});

	

	$('.secureprop a.viewalltitle, .secureprop a.viewall').click(function(){
		$('.hiddenall').slideUp();
		$('a.viewall').html('view all &gt;');
	
		if($(this).parent().parent().find('.hiddenall').is(':visible')){
			$('.secureprop').removeClass('gogray');	
		}
		else{
			$('.secureprop').addClass('gogray');	
			$(this).parent().parent().removeClass('gogray');
			$(this).parent().parent().find('a.viewall').html('hide &gt;');
			$(this).parent().parent().find('.hiddenall').slideDown();
		}
	});

	
	
		
	
	
		$(function() {
				 // doesn't work in MAC FF?????? FFFFFFF
				
				 var timer = setTimeout(hideMsg, 4000);
			
				function hideMsg() {
					$('.messagebox')
						.stop()
						.fadeOut();
				}
		
		});


});



