// JavaScript Document
$(document).ready(function() {
	$('.yellow_cta_button')
		.mousedown(function() {$(this).addClass('pushed');})
		.bind('mouseup mouseleave', function() {$(this).removeClass('pushed');});
		
	$('.namefield').blur(function() {
		$(this).val($(this).val().toLowerCase().capitalize());
	});
	/*
	$('.tabs li').each(function() {
		
		var $tab = $(this),
			id	= $tab.attr('id'),
		 	$content = $('#content-' + id.replace(/.*\-/, ''));
		$tab.children('a').click(function() {
			$('.tab-contents .current').removeClass('current');
			$content.addClass('current');
			$('.tabs li').removeClass('current');
			$tab.addClass('current');
		});	
	});	
	*/
	$('.rollover').hover(
		function() {
			var src = $(this).attr('src').replace(/_(.+)\.(\w{3,4})/, '_on.$2');
			$(this).attr('src', src);
		},
		function() {
			var src = $(this).attr('src').replace(/_(.+)\.(\w{3,4})/, '_off.$2');
			$(this).attr('src', src);
		}
	);
});

String.prototype.capitalize = function(){
   return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
  };
  
window.addEventListener("message", carzoneReceiver, false);
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var carzoneReceiver = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
function carzoneReceiver(e) {
	//page height
	var height =parseInt(e.data);
	//alert(height);
	if($('#carzone')) $('#carzone').height(height + 50);
	//alert(height);
}



