// ADD THIS PARAMETERS

   function addthisVars() {
      var addthis_pub = "evbrokers";
   	var addthis_brand = "EVBrokers";
   	var addthis_hover_delay = 100;
   	var addthis_options = 'email, favorites, printfriendly, facebook, twitter, linkedin, wordpress, more';
   	var addthis_header_color = '#ffffff';
      var addthis_header_background = '#ec1b2c';
   }
   
   function addthisActions() {
      $('.property a.addthis_button').each(function() {
         var shareURL = $(this).attr('href');
         var shareTitle = $(this).attr('title');
         $(this).click(function() {
            return addthis_sendto();
         });
         $(this).hover(function() {
            return addthis_open(this, '', shareURL, shareTitle);
         }, 
         function() {
            addthis_close();
         }    
         );
      });
   }

// END ADD THIS PARAMETERS

$(document).ready(function() {
    // Populate search box
   $('#searchForm input#search_term').val('Search EVBrokers.com').addClass('clickClear');
	
	// Make text inputs clear when clicked, return when blurred
   $('input.clickClear').blur(function() {
      blurText = $(this).val();
      if (blurText == '') {
         $(this).val(startText);
      };
   });
   // Initialize AddThis Variables
   addthisVars();
    // Make external links validate
   $('a.external').attr('target', '_blank');
   
   // Suckerfish Drop-Down
   sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);
	
	// Property Filtering
	$('p#filter a').click(function() {
	   area = $('select#area').val();
	   type = $('select#type').val();
	   contract = $('select#contract').val();
	   region = $('input#region').val();
	   $('#property-list').html('').css({height:'300px', background:'url(/_img/ajax-loader.gif) no-repeat center center'});
	   $.get('/ajax_properties.php', { 
			'area':area,
			'type':type,
			'contract':contract,
			'region':region			
			}, 
			function(o){				
				$('#property-list').html(o).css({height:'auto', background:'none'});			
            addthisVars();
            addthisActions();
			}
		);
	   return false;
	});
	$('p#property-all a').click(function() {
	   area = "all";
	   type = "all";
	   contract = "all";
	   region = $('input#region').val();
	   $('#property-list').html('').css({height:'300px', background:'url(/_img/ajax-loader.gif) no-repeat center center'});
	   $.get('/ajax_properties.php', { 
			'area':area,
			'type':type,
			'contract':contract,
			'region':region			
			}, 
			function(o){				
				$('#property-list').html(o).css({height:'auto', background:'none'});			
            addthisVars();
            addthisActions();
			}
		);
	   return false;
	});
	/* End Property Sorting */
});
