(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","auto");
		});
	}
})(jQuery);


$(document).ready(function(){



$('#inputextra').hide();



$('form#newsletterform').submit(function(event){
		var email = $('#newsletteremail').attr('value');
		var validEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!validEmail.test(email)) {
			$('#response').html('Please enter a valid email address:').css('color','red');
		} else {
			$.ajax({
				dataType:	'text',
				data:		$(this).serialize(),
				type:		$(this).attr('method'),
				url:		$(this).attr('action'),
				success: function(){
					$('#response').html('Thank you for your subscription, your address has been added to our list: '+email).css('color','#888');
				},
				error: function(){
					$('#response').html('An error occured submitting the form data.').css('color','red');
				}
			});
		}
		event.preventDefault();
	});






$(".tabhorizontal").tabs();
$(".sectabs").tabs();



$(".clickable").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});


$('.default-value').each(function() {
    var default_value = this.value;
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
      
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            this.value = default_value;
            
        }
    });
});

var modelsheight = $("#models").height();
$("div.inner.eqh").height($("div.fl").height()-modelsheight);





$('#myLink').click(function(e) {
    e.preventDefault();
    //do other stuff when a click happens
});


	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	
	
	
	
	
	$("ul.topnav li span").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	
	
	$("a..page-parent").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});




	

});
