/* ************ GLOBAL JAVASCRIPT FUNCTIONS ******************* */
// Add a class target_blank links.
$(document).ready(function(){  
    $("a[href*='http://']:not([href*='"+location.hostname+"'])")
    .attr("target","_blank")
    .addClass("external");  
});   

/* BUTTON ROLLOVER *************** */
	$(document).ready(function() {
		$('.rollover').hover(
			function(){ // Change the input image's source "roll on"
			t = $(this);
			t.attr('src',t.attr('src').replace(/([^.]*)\.(.*)/, "$1_over.$2"));
			},
		function(){ 
			t= $(this);
			t.attr('src',t.attr('src').replace('_over',''));
					}
				);
			});

// DROP DOWN MENU
$(function(){
    $("#global_nav ul li").hover(function(){ 
        $('ul:first',this).css('visibility', 'visible');   
    }, function(){
        $('ul:first',this).css('visibility', 'hidden');  
    });    
});
// FORM VALIDATION

$(document).ready(function() { 
				
var options = { 
	target:    '#alert'
	}; 
	$('#inquire').ajaxForm(options); 
	}); 
										
	$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
		});
	}; 
// MLS SEARCH ALERT	
$(document).ready(function() {
	$('.alert').hide()
	.fadeIn('slow')
	.animate({opacity: 1.0}, 3500)
	.fadeOut('slow', function() {
	 $(this).remove();  	
	});
});

// BANNER
$(document).ready(function() {
	$('#banner_group')
	.cycle({
		fx: 'fade',
	    speed:  '3000', 
	    timeout: 4000	
	});
});

$(document).ready(function() {
	$('#featured')
	.cycle({ 
	    fx:     'scrollHorz', 
	    speedIn:  1000, 
		speedOut: 300, 
	    timeout: 0, 
	    next:   '#pLeft', 
	    prev:   '#pRight' 
	});
});
