/*****************************************************************************
SIFR-CONFIG
*****************************************************************************/

	var helvetica_neue = { src: '/assets/swf/helvetica_neue.swf' };
	var helvetica_neue_heavier = { src: '/assets/swf/helvetica_neue.swf' };
	var bembo = { src: '/assets/swf/bembo_regular.swf' };
	
	// Next, activate sIFR:
	sIFR.activate(helvetica_neue, helvetica_neue_heavier);
	
	//comment out relpace function and use this one
	//sIFR.debug.ratios({ src: 'assets/swf/futura.swf', selector: 'h1' });
	
	sIFR.replace(helvetica_neue, {
	  selector: 'h1'
	  ,wmode: 'transparent'
	  ,css: [
	      '.sIFR-root {color: #27292f; font-size: 32px;}',
	      'em { font-style:normal; color:#FF0000; font-size:18px;}'
	    ]
	  ,ratios: [9, 1.49, 10, 1.39, 13, 1.41, 16, 1.39, 19, 1.38, 20, 1.35, 23, 1.36, 29, 1.35, 30, 1.33, 39, 1.34, 40, 1.32, 44, 1.33, 46, 1.32, 47, 1.33, 74, 1.32, 76, 1.31, 77, 1.32, 1.31]
	});
	
	
	if (!$.browser.msie) {
	
		sIFR.replace(helvetica_neue, {
		  selector: '.property_info span'
		  ,wmode: 'transparent'
		  ,css: [
		      '.sIFR-root a { color: #27292f; font-size: 18px; text-decoration: none; cursor: pointer; }',
		      '.sIFR-root a:hover {color: #27292f; font-size: 18px; cursor: pointer; }'
		    ]
		  ,ratios: [9, 1.49, 10, 1.39, 13, 1.41, 16, 1.39, 19, 1.38, 20, 1.35, 23, 1.36, 29, 1.35, 30, 1.33, 39, 1.34, 40, 1.32, 44, 1.33, 46, 1.32, 47, 1.33, 74, 1.32, 76, 1.31, 77, 1.32, 1.31]
		});
	
	} else {
	
		sIFR.replace(helvetica_neue, {
		  selector: '.property_info span'
		  ,wmode: 'opaque'
		  ,css: [
		  		'.sIFR-root {  background-color:#e27d01; }',
		      '.sIFR-root a { color: #27292f; font-size: 18px; text-decoration: none; cursor: pointer; }',
		      '.sIFR-root a:hover {color: #27292f; font-size: 18px; cursor: pointer; }'
		    ]
		  ,ratios: [9, 1.49, 10, 1.39, 13, 1.41, 16, 1.39, 19, 1.38, 20, 1.35, 23, 1.36, 29, 1.35, 30, 1.33, 39, 1.34, 40, 1.32, 44, 1.33, 46, 1.32, 47, 1.33, 74, 1.32, 76, 1.31, 77, 1.32, 1.31]
		});
		
	}
	
	sIFR.replace(helvetica_neue_heavier, {
	  selector: '.numbers'
	  ,wmode: 'transparent'
	  ,css: [
	      '.sIFR-root {color: #305d87; font-size: 22px;}',
	      'em { font-style:normal; font-size: 22px;}'
	    ]
	  ,ratios: [9, 1.49, 10, 1.39, 13, 1.41, 16, 1.39, 19, 1.38, 20, 1.35, 23, 1.36, 29, 1.35, 30, 1.33, 39, 1.34, 40, 1.32, 44, 1.33, 46, 1.32, 47, 1.33, 74, 1.32, 76, 1.31, 77, 1.32, 1.31]
	});
	
	sIFR.replace(bembo, {
	  selector: '.bembo'
	  ,wmode: 'transparent'
	  ,css: [
	      '.sIFR-root {color: #000000; font-size: 22px;}',
	      'em { font-style:normal; color:#FF0000; font-size:18px;}'
	    ]
	  ,ratios: [9, 1.49, 10, 1.39, 13, 1.41, 16, 1.39, 19, 1.38, 20, 1.35, 23, 1.36, 29, 1.35, 30, 1.33, 39, 1.34, 40, 1.32, 44, 1.33, 46, 1.32, 47, 1.33, 74, 1.32, 76, 1.31, 77, 1.32, 1.31]
	});

/*****************************************************************************
END SIFR-CONFIG
*****************************************************************************/

$(document).ready( function() {
	
	// http://docs.jquery.com/Plugins/Validation - more info / options
	$("#validatedForm").validate({
		// set the required fields
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			phone: "required",
			message: "required"
		},
		
		// if you want to have an element appear next 
		// to the incorrect field specify it here (em, label, div, etc.)
		errorElement: "",
		
		// what you would like to have displayed in the error element
		messages: {
			name: "",
			email: "",
			phone: "",
			message: ""
		},
		
		// what occurs when the element(s) are invalid
		invalidHandler: function(form, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'You missed 1 field. It has been highlighted'
          : 'You missed ' + errors + ' fields. They have been highlighted';
        $(".failed").html(message);
        $(".failed").slideDown();
      } else {
        $(".failed").hide();
      }
    },
    // highlighting fields (other options exist here too)
    highlight: function(element, errorClass) {
    	$(element).css('border','1px solid red');
	  },
	  // removing highlighting
	  unhighlight: function(element, errorClass) {
	  	$(element).removeAttr('style');
	  }
	  
	}); // end validation
	
	$("#property_search, #property_search2").fancybox({
      'width'             : 650,
      'height'            : 580,
      'autoScale'         : false,
      'overlayOpacity'		: .8,
      'overlayColor'			: '#FFF',
      'type'              : 'iframe'
  });
	
	// homepage rotation
	if ($('#prop_rotation').length > 0) {
		$(window).load( function() {
			$('#prop_rotation').rotate();
		});
	}
	
	// changing a state
	$('#PState').change( function() {
		window.location = window.location.pathname + '?state=' + $(this).val();
	});
	
	// changing a city
	$('#PCity').change( function() {
		window.location = window.location.pathname + '?city=' + $(this).val();
	});
	
	// external links
	$("a[rel=external]").each(function() {
		$(this).click(function(){
			window.open(this.href,"mywindow");
	    	return false;
	    });
	});
	
	// default title tags if they aren't set
	$("img").each(function() {
		var alt = $(this).attr('alt');
		var ct = $(this).attr('title');
		if (alt != '' && ct == '') { $(this).parent().attr('title', alt); }
	});
	
}); // end doc ready
