//global event settings
var eventName = "usop";
var siteURL = "www.usopen.org";
var infoImg = new Image();
var ajaxRefresh = 30000;
/************************ Jquery functions */
$(document).ready(function(){
if (document.all){$("#nav-top li").hoverClass("over");}
var path = location.pathname.substring(0);
//Draws Pages
if(path.indexOf('/draws/as/') != -1){sectionIndex=43; path="/en_US/scores/draws/as/index.html?promo=topnav";}
if(path.indexOf('/draws/bd/') != -1){sectionIndex=2; path="/en_US/scores/draws/index.html?promo=topnav";}
if(path.indexOf('/draws/bs/') != -1){sectionIndex=41; path="/en_US/scores/draws/bs/index.html?promo=topnav";}
if(path.indexOf('/draws/cs/') != -1){sectionIndex=71; path="/en_US/scores/draws/cs/index.html?promo=topnav";}
if(path.indexOf('/draws/gs/') != -1){sectionIndex=2; path="/en_US/scores/draws/index.html?promo=topnav";}
if(path.indexOf('/draws/gd/') != -1){sectionIndex=2; path="/en_US/scores/draws/index.html?promo=topnav";}
if(path.indexOf('/draws/md/') != -1){sectionIndex=54; path="/en_US/scores/draws/md/index.html?promo=topnav";}
if(path.indexOf('/draws/ms/') != -1){sectionIndex=55; path="/en_US/scores/draws/ms/index.html?promo=topnav";}
if(path.indexOf('/draws/qs/') != -1){sectionIndex=60; path="/en_US/scores/draws/qs/index.html?promo=topnav";}
if(path.indexOf('/draws/wd/') != -1){sectionIndex=73; path="/en_US/scores/draws/wd/index.html?promo=topnav";}
if(path.indexOf('/draws/ws/') != -1){sectionIndex=13; path="/en_US/scores/draws/ws/index.html?promo=topnav";}
if(path.indexOf('/draws/xd/') != -1){sectionIndex=57; path="/en_US/scores/draws/xd/index.html?promo=topnav";}
if(path.indexOf('/draws/us/') != -1){sectionIndex=2; path="/en_US/scores/draws/index.html?promo=topnav";}
//Spotlight Pages
if(path.indexOf('/news/spotlight/') != -1){sectionIndex=3; path="/en_US/news/spotlight/ms/index.html?promo=topnav";}
//Schedule Pages 
//Additional Pages in News & Photos Section
if(path.indexOf('/news/articles/') != -1){sectionIndex=6; path="/en_US/news/index.html?promo=topnav";}
if(path.indexOf('/news/photos/') != -1){sectionIndex=7; path="/en_US/news/photos/index.html?promo=topnav";}
if(path.indexOf('/news/galleries/') != -1){sectionIndex=7; path="/en_US/news/photos/index.html?promo=topnav";}
if(path.indexOf('/news/interviews/') != -1){sectionIndex=6; path="/en_US/news/interviews/index.html?promo=topnav";}
if(path.indexOf('/news/playerday/') != -1){sectionIndex=8; path="/en_US/news/playerday/index.html?promo=topnav";}
if(path.indexOf('/news/match_reports/') != -1){sectionIndex=6; path="/en_US/news/match_reports/index.html?promo=topnav";}
if(path.indexOf('/news/prematch/') != -1){sectionIndex=6; path="/en_US/news/prematch/index.html?promo=topnav";}
if(path.indexOf('/news/postmatch/') != -1){sectionIndex=9; path="/en_US/news/postmatch/index.html?promo=topnav";}
//Ask the Booth pages
if(path.indexOf('/interactive/radio/') != -1){sectionIndex=66; path="/en_US/news/media/radio.html?promo=topnav";}
//Pulse page
if(path.indexOf('en_US/pulse/') != -1){sectionIndex=37; path="/en_US/community/index.html";}
//3rd party links
var pageLoc = location.href;
if(pageLoc.indexOf("http://www.usta.com/aroundny") != -1){path = "http://www.usta.com/aroundny";}
if(pageLoc.indexOf("http://www.usta.com/tickets/openticketexchange.sps") != -1){path = "http://www.usta.com/tickets/openticketexchange.sps";}
if(pageLoc.indexOf("http://www.usta.com/subscribers") != -1){path = "http://www.usta.com/subscribers/";}
if(pageLoc.indexOf("http://www.usta.com/fanzone") != -1){path = "http://www.usta.com/fanzone/index.html";}
$('#nav-top a[rel="'+sectionIndex+'"][href^="' + path + '"]').parents("li").addClass('active');
$('#nav-top a[rel="'+sectionIndex+'"][href^="' + path + '"]').parents("ul").prev("ul li a").addClass('active'); 
$('#tabsHeadlines > ul').tabs();
$('#tabsHeadlinesTest > ul').tabs(); //Test tabs for headlines
$('#tabsFanzone > ul').tabs({ selected: 1 });
$('#tabsFanzoneTest > ul').tabs(); //Test tabs for fanzone
//$('#tabsScoreboard > ul').tabs();
//$('#tabsScoreboard > ul').tabs({ selected: 1, disabled: [0, 2] });
//jquery code for selected state
$("#tabsVideos li a").click(function(){
$("#tabsVideos li a").each(function(){this.className = this.className.replace("active","");});
this.className = this.className.replace("","active");
});
//jquery code for usta network
$('#miscLinks > ul').tabs({ selected: null, unselect: true});
});
//jquery code for top navigation
$.fn.hoverClass = function(c) {
return this.each(function(){
$(this).hover(
function() { $(this).addClass(c); },
function() { $(this).removeClass(c); }
);
});
};
/***************************** Launch Pulse */
function launchPulse(){
/* if (window.sa_onclick){
sa_onclick('http://'+siteURL+'/click/http://pulse.usopen.org/pulse/tennis/usta/');
}
window.open("http://pulse.usopen.org/pulse/tennis/usta/","Pulse","height=711,width=996,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,location=no");
*/
document.location.href="/en_US/pulse/index.html";
}
/***************************** Surfaid external navigation - special function for the bracket buster*/
function openBBExternal(lnk,newWindow,w,h,shared){
if (lnk.indexOf("http://" == -1)){
switch(lnk){
case "ibm": lnk = "http://www.ibm.com/"; break;
default: break;
}
}
//remove http for reporting and measure click
if (window.sa_onclick && !shared){
var rptLnk = lnk;
sa_onclick('http://'+siteURL+'/click/'+rptLnk);
}
if (newWindow){
newWindow = window.open(lnk,"consoleWindow","width=620,height=620,resizable=no,status=no,toolbar=no,menubar=no,location=no");
} else {
document.location.href = lnk;
}
}
