/* Forms */

$(document).ready(function(){ //Instantiate jquery

    $(".wpcf7-validates-as-required").live("focus", function() {
        if ($(this).val() == "Type question here...") {
            $(this).val("");
        }
    })

	var newsletterForm = $('#newsletter>form>input[type=text]');
	newsletterForm.focus(function(){ //Remove newsletter signup text on focus
		this.value='';
	});
	newsletterForm.blur(function(){ //Replace newsletter signup text on blur
		if(this.value==''){
			this.value = 'Sign up for email updates';
		}
	});
	
	var newsletterForm = $('#ask_gina input[name=question]');
	newsletterForm.focus(function(){ //Remove question text on focus
		this.value='';
	});
	newsletterForm.blur(function(){ //Replace question text on blur
		if(this.value==''){
			this.value = 'Type question here...';
		}
	});

	var newsletterForm = $('#ask_gina input[name=email]');
	newsletterForm.focus(function(){ //Remove email text on focus
		this.value='';
	});
	newsletterForm.blur(function(){ //Replace email text on blur
		if(this.value==''){
			this.value = 'Enter email address';
		}
	});
	
	var _content = $('#container'),
		_left = $('#sidebar-body'),
		_right = $('#right');

	//calculate content height
	if(_content.height() < _left.height() || _content.height() < _right.height())
	{
		if(_left.height() > _right.height()) 
		{
			_content.height(_left.height()) 
			_right.height(_left.height()+20)
		}
		else
		{
			_content.height(_right.height()) 
			_left.height(_right.height()+20)
		}
	}
	else
	{
		_left.height(_content.height()-($('#sidebar-left h2').height()+45));
		_right.height(_content.height()-50);
	}
	
	
	//ie fixes
	if($.browser.msie)
	{
		$('#center .nav li:last-child').css('border','none');
		if($.browser.version <= 7.0)
			$('#container .column').css({ marginLeft: '-200px' });
			
		if($.browser.version == 8.0)
		{
			$('#center, #container').css({
				height: _left.height()+100,
				position: 'absolute',
				zIndex: 100,
				float: 'left',
				width: '431px'
			});	
		}
	}
	
	if($('.wpcf7-mail-sent-ok').text())
	{
		var text = $('.wpcf7-mail-sent-ok').text();	
		$('.wpcf7-display-none').text(text).removeClass('wpcf7-display-none');
	}
	
	var homeMiddle = $('#home_columns #middle'),
		homeLeft = $('#home_columns #left');
		
	homeMiddle.height(homeLeft.height())
});
