google.load("search", "1");

function OnLoad() {
	
	// Attach branding
	google.search.Search.getBranding(document.getElementById("branding"));
		
	// Create a search control
	var searchControl = new google.search.SearchControl();
		
	//open in expand mode
	options = new google.search.SearcherOptions();
	options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
	options.setRoot(document.getElementById("returnResults"));
		
	//set up websearch Limit to GNCC Racing
	var siteSearch = new google.search.WebSearch();
	siteSearch.setUserDefinedLabel("MXSports.com");
	siteSearch.setUserDefinedClassSuffix("siteSearch");
	siteSearch.setSiteRestriction("mxsports.com");
	searchControl.addSearcher(siteSearch, options);
	
	
	searchControl.setSearchStartingCallback(this, OnLoad.prototype.OnSearchStarting);

	// Tell the searcher to draw itself and tell it where to attach
	searchControl.draw(document.getElementById("searchcontrol"));
	
	$("div.gsc-clear-button").click(
	  function () {
	  	 $("#branding").css({display:"none"});
		
	  }
	 );


}
OnLoad.prototype.OnSearchStarting = function(sc, searcher, query) {
  $("#branding").css({display:"inline"});
}
google.setOnLoadCallback(OnLoad);

//Animate main menu (also fixes IE 6
function mainmenu(){

$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}
 
$(document).ready(function() {
	$('.articleBody p[style]').each(function() {
		if ($(this + ' + .fullImage') && ($(this).attr('style') == 'text-align: center;') || ($(this).attr('style') == 'TEXT-ALIGN: center')) { 
			$(this).next().addClass('divCenter');
		}
	});						   
						   
	//Activate jQuery Menu Style
	mainmenu();
	//Activate PNG Fix
	if (jQuery.fn.pngFix) $(document).pngFix();
	//Activate FancyBox
	$(".articleImage a, .lightbox a").fancybox({
		'hideOnContentClick': true,
		'overlayOpacity': 0,
		'overlayShow':	true,
		zoomSpeedIn:		250,
		zoomSpeedOut:		250,
		frameWidth: 1000,
		frameHeight: 800

	});
	
	new Image().src ='/images/icons/plus.png';
	
});



$(".articleImage a").hover(
  function () {
	$(this).after('<div class="plus"><img src="/images/icons/plus.png" alt="enlarge" \/><\/div>');
	if (jQuery.fn.pngFix) $(document).pngFix();
  }, 
  function () {
	$('.plus').remove();

  }
);