// JavaScript Document

$(document).ready(function(){
	// Common functions
	clearClick();
	setBrowserClass();
	cssTweaks();
	if($('body').hasClass('home')) {
		homeText();
	}
	$('.popup a').tooltip({effect: 'slide'});

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

	$('.search_open').click(function() {
		searchClick();
		return false;
	});
	
	// Show non-flash content
	if(!hasFlash){
		$('.no_flash').show();
		$('.has_flash').remove();
	}else{
		$('.no_flash').remove();
	}
	
	// PNG support for IE6
	if(isIE(6)){
		$(document).pngFix();
	}
	
	if(isIE(7)) {
		$('hr').wrap('<div class="hr"></div>');	
	}
	
	$('.coloredTable tr:even').addClass('evenRow');
	$('.coloredTable').attr('cellspacing', '0');
	
	$("a[href*='facebook.com']").addClass('facebook');
	
});

function cssTweaks(){
	$('blockquote').each(function(i,elem){ $(elem).find('p:last').css('margin',0); });
	$('ol li').wrapInner('<span></span>');
}

function searchClick() {
	//alert('Clicked');
	if($('#searchForm').is(':visible')) {
		document.searchForm.submit();
	}
	else {
		$('#searchForm').show();
		$('#header_phone').hide();	
		$('#header_nav-right').animate({
				marginLeft: '-=180px'
		}, 300);
		$('#header_nav').animate({
				width: '-=180px'
		}, 300);

	}
	
}

function homeText() {
	//$('#header h1').delay(5000).fadeOut('slow');
}

function closeForm() {
	$('#header_nav').animate({
			width: '+=180px'
	}, 295);
	$('#header_nav-right').animate({
			marginLeft: '+=180px'
	}, 300, function() {
		$('#header_phone').show();
		$('#searchForm').hide();	
	});
}
