
jQuery(document).ready(function() {
	
	side_height();
	
	jQuery(document).bind("elements", function() {
		side_height();
	
	});
	
	
	jQuery("#all_top .search .submit").click(function(e) {
		e.preventDefault();
		jQuery("#all_top .search").submit();
		
	});


	jQuery("#all_top .search .text_field").focus(function() {
		if (jQuery(this).val()=="SEARCH") {
			jQuery(this).val("");
			jQuery(this).css("border", "1px solid #ffffff");
			//jQuery(this).css("color", "#5a5a5a");
		}
		
	});
	
	jQuery("#all_top .search .text_field").blur(function() {
		if (jQuery.trim($(this).val())=="") {
			jQuery(this).val("SEARCH");
		}
		
		jQuery(this).css("border", "0px solid #ffffff");
	
	});
	
	jQuery("#all_top .search").submit(function() {
		if (jQuery.trim($("#all_top .search .text_field").val())=="SEARCH") {
			jQuery("#all_top .search .text_field").val("");
		}
	});
	


});

//jQuery(window).resize(function() {
//	jQuery(document).trigger("elements");
//});


function side_height() {
	main_height = jQuery("#main_div").outerHeight();
	
	spacer_height = main_height - 50;
	
	jQuery(".grid_side .spacer").height(spacer_height);
	jQuery(".grid_side .bottom").show();


}



/* sponsors */

var sponsors_delay = 5000;
var sponsors_delay_start = 5000;
var sponsors_delay_restart = 6000;

var sponsors_height = 65;

jQuery(document).ready(function() {
	// start rotation
	cmd = "sponsors_rotate()";
	sponsors_timer = setTimeout(cmd, sponsors_delay_start);

	// pause slides on mouseover
	jQuery("#all_sponsors").mouseover(function() {
		clearTimeout(sponsors_timer);

	});

	// restart slides after mouseout
	jQuery("#all_sponsors").mouseout(function() {
		cmd = "sponsors_rotate()";
		sponsors_timer = setTimeout(cmd, sponsors_delay_restart);
	});
});


function sponsors_rotate() {
	board = jQuery("#all_sponsors .scroll .board");
	
	board_position = board.position();
	board_height = board.height();
	
	if ( (board_position.top * -1) + 65 < board_height) {
		board.css("top", board_position.top - 65);
	} else {
		board.css("top", 0);	
	}

	cmd = "sponsors_rotate()";
	sponsors_timer = setTimeout(cmd, sponsors_delay);	
}


