// mac only css
if (navigator.userAgent.indexOf("Mac")!=-1) {
	document.write('<link rel="stylesheet" type="text/css" media="all" href="includes/css/mac.css" />');
}





$(document).ready(function(){
  
    var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i < anchors.length; i++){
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  anchor.getAttribute("rel") == "external")  anchor.target = "_blank"; 
 }
 
		// primary nav dropdowns
		$("ul.dropdown li").hover(function(){
			$(this).addClass("select");
			$('table',this).css('visibility', 'visible');

		}, function(){

			$(this).removeClass("select");
			$('table',this).css('visibility', 'hidden');

		});
	});

// AJAX callback function that returns list of meetings for specified date
function populate_meetings(day, current_meeting_id)
{
	$.ajax({
		type: "POST",
		url: "/ajax_handler",
		data: "action=populate_meetings&day="+day+"&current_meeting_id="+current_meeting_id,
		success: function(msg){
			$("#sub_menu_meetings").html( msg );
		}
	});
}
// handles result nav submits
function meeting_submit(meeting_id)
{
	var id = meeting_id;
	window.location='/results/meeting/'+id;
}

// handles stat nav submits
function stats_jump_to(anchor_name)
{
  if(anchor_name)
  {
    window.location='#'+anchor_name;
  }
	
}
// handles back to racecard click
function go_to_racecard(race_id)
{
  if(race_id)
  {
    window.location='/racecard/race/'+race_id;
  }

}

// POPUP CODE

var newWindow = null;

function closeWin(){

	if (newWindow != null){

		if(!newWindow.closed)

			newWindow.close();

	}

}

function openVideoWin(url){

	closeWin();

tools = "resizable,toolbar=no,location=no,scrollbars=yes,width=560,height=360,left=0,top=0";

	newWindow = window.open(url, 'newWin', tools);

	newWindow.focus();

}

// end popup code

// print button

$(document).ready(function() {
	$('div#print_button_container').prepend('<a href="#print"><img src="/images/ruk/print_button.gif" alt="Print this racecard" /></a>');
	$('div#print_button_container').click(function() {
		window.print();
		return false;
	});
});
