//global event settings
var eventName = "usop";
var siteURL = "www.usopen.org";
var infoImg = new Image();
var ajaxRefresh = 30000;
var newsRefresh = 3000000;
var json_server = "";
/************************ 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=2; 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=2; path="/en_US/scores/draws/bs/index.html?promo=topnav";}
if(path.indexOf('/draws/cs/') != -1){sectionIndex=2; 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=2; path="/en_US/scores/draws/md/index.html?promo=topnav";}
if(path.indexOf('/draws/ms/') != -1){sectionIndex=2; path="/en_US/scores/draws/ms/index.html?promo=topnav";}
if(path.indexOf('/draws/qs/') != -1){sectionIndex=2; path="/en_US/scores/draws/qs/index.html?promo=topnav";}
if(path.indexOf('/draws/wd/') != -1){sectionIndex=2; path="/en_US/scores/draws/wd/index.html?promo=topnav";}
if(path.indexOf('/draws/ws/') != -1){sectionIndex=2; path="/en_US/scores/draws/ws/index.html?promo=topnav";}
if(path.indexOf('/draws/xd/') != -1){sectionIndex=2; 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=2; 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=4; path="/en_US/news/index.html?promo=topnav";}
if(path.indexOf('/news/photos/') != -1){sectionIndex=14; 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=4; path="/en_US/news/interviews/index.html?promo=topnav";}
if(path.indexOf('/news/playerday/') != -1){sectionIndex=15; path="/en_US/news/playerday/index.html?promo=topnav";}
if(path.indexOf('/news/match_reports/') != -1){sectionIndex=4; path="/en_US/news/match_reports/index.html?promo=topnav";}
if(path.indexOf('/news/prematch/') != -1){sectionIndex=16; path="/en_US/news/prematch/index.html?promo=topnav";}
//Ask the Booth pages
if(path.indexOf('/interactive/radio/') != -1){sectionIndex=17; path="/en_US/news/media/radio.html?promo=topnav";}
//Pulse page
if(path.indexOf('en_US/pulse/') != -1){sectionIndex=7; path="/en_US/community/index.html";}
//3rd party links
var pageLoc = location.href;
if(pageLoc.indexOf("http://usta.usopen.org/aroundnewyork/") != -1){sectionIndex=18; path = "/en_US/about/index.html?promo=topnav";}
//if(pageLoc.indexOf("http://www.ticketexchangebyticketmaster.com/USTA/us-open-tennis-tickets/") != -1){path = "http://www.ticketexchangebyticketmaster.com/USTA/us-open-tennis-tickets/";}
if(pageLoc.indexOf("http://usta.usopen.org/Tickets/Subscribers/") != -1){sectionIndex=12; path = "/en_US/about/tickets/index.html?promo=topnav";}
//if(pageLoc.indexOf("http://www.usta.org/fanzone") != -1){path = "http://www.usta.com/fanzone/index.html";}
if(pageLoc.indexOf("http://usopenmbracket.fanball.com/") != -1){sectionIndex=7; path="http://usopenmbracket.fanball.com/";}
var parentLI = $('#navigation a[href^="' + path + '"]').parents("li");
//$(parentLI).children("a:first-child").removeClass("nav_item").addClass('nav_item_active');
$(parentLI).children("a").each(function(index){
if($(this).hasClass("nav_item")){
$(this).removeClass("nav_item").addClass("nav_item_active");
return false;
}
});
//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 top navigation
$.fn.hoverClass = function(c) {
return this.each(function(){
$(this).hover(
function() { $(this).addClass(c); },
function() { $(this).removeClass(c); }
);
});
};
//*****************************/
// launch SlamTracker
//*****************************/
var ttWindow = "";
var launchPage;
var ttWindowHeight;
function launchTT(lang,view,crt,syn,debug,test){
if (hasReqestedFlashVersion && NPRuntime){
if (view == "draw"){
ttWindowHeight = 665;
}
else{
ttWindowHeight = 665;
}
launchPage = "http://www.usopen.org/en_US/tracker/ttFrame.html?";
if (test) launchPage = "/en_US/tracker/ttFrame.html?";
var d = new Date()
var t = d.getTime()
launchPage += "ts=" + t;
launchPage += (lang.length>1)?"&lang="+lang:"&lang=en_GB";
launchPage += (syn)?"&syn="+syn:"&syn=none";
launchPage += "&wh=" + ttWindowHeight;
launchPage += "&mode=" + view;
launchPage += "&ref=" + document.location.host + document.location.pathname;
launchPage += (debug.indexOf("debug")>-1)?"&db=true":"&db=false";
launchPage += (crt)?"&crt="+crt:"&crt=none";
//alert(launchPage);
if (ttWindow.closed || ttWindow==""){
ttWindow = window.open(launchPage,"ttWindow","width=850,height=" + ttWindowHeight + ",top=0,left=0,statusbar=0")
if (ttWindow.opener == null) ttWindow.opener=self;
}
ttWindow.focus();
}
else{
document.location.href = "/" + lang + "/flashupgrade.html?fl=" + hasReqestedFlashVersion + "&br=" + NPRuntime + "&sh=true";
}
}
//*****************************/
// launch visual match
//*****************************/
var vmWindow = "";
var vmLaunchPage;
var vmWindowHeight;
function launch(which,crt){
var loc = "";
var sbLang;
if (!which){
which = 'score';
loc = "/en_US/scores/index.html";
} else {
loc = "/en_US/scores/draws/index.html";
}
sbLang = "en_US";
//uncomment next line when slam tracker is ready
if(browser.isIPad){
document.location.href = loc;
} else {
launchTT(sbLang,which,crt,'','','');
}
//launchTT(sbLang,which,crt,'','','');
//document.location.href = loc;
}
/******************************Live Video Console */
var lcWindow = "";
function launchLC(video_ref,syn,debug,alt,test){
var lcLaunchPage = "http://www.usopen.org/en_US/console/console.html?";
if (test) lcLaunchPage = "/en_US/console/console.html?";
if (hasReqestedFlashVersionLC && NPRuntime){
var d = new Date()
var t = d.getTime()
lcLaunchPage += "ts=" + t;
if ((video_ref == 'A') || (video_ref == 'B') || (video_ref == 'C') || (video_ref == 'K') || (video_ref == 'M')) {
lcLaunchPage += '&video=' + video_ref;
}
else{
lcLaunchPage += '&video=';
}
lcLaunchPage += (syn)?"&syn="+syn:"&syn=";
lcLaunchPage += (debug && debug.indexOf("debug")>-1)?"&db=true":"&db=false";
lcLaunchPage += "&ref=" + document.location.host + document.location.pathname;
lcLaunchPage += (alt)?"&alt="+alt:"&alt=";
if (lcWindow.closed || lcWindow==""){
lcWindow = window.open(lcLaunchPage,"lcWindow","width=960,height=680,top=0,left=0,resizable=no,location=no")
if (lcWindow.opener == null) lcWindow.opener=self;
}
lcWindow.focus();
} else {
//user doesn't have flash9:
document.location.href = "http://www.usopen.org/en_US/flashupgrade.html?fl=" + hasReqestedFlashVersionLC + "&br=" + NPRuntime;
}
}
//*****************************/
//launch standalone radio
//*****************************/
var radioWindow = "";
var radiolaunchPage;
function launchRadio(stream,debug){// where stream in("0") debug in(true,false)
var radioLaunchPage = "/en_US/interactive/radio/radio.html?";
if (hasReqestedFlashVersion && NPRuntime){
var d = new Date()
var t = d.getTime()
radioLaunchPage += "ts=" + t;
radioLaunchPage += (debug && debug.indexOf("debug")>-1)?"&db=true":"&db=false";
radioLaunchPage += "&ref=" + document.location.host + document.location.pathname;
radioLaunchPage += "&lang=en_US";// + lang;
radioLaunchPage += "&stream=" + stream + "&syn=";
if (radioWindow.closed || radioWindow==""){
radioWindow = window.open(radioLaunchPage,"radioWindow","width=420,height=195,top=50,left=50");
if (radioWindow.opener == null) radioWindow.opener=self;
}
radioWindow.focus();
} else {
//user doesn't have flash9:
document.location.href = "/" + lang + "/flashupgrade.html?fl=" + hasReqestedFlashVersion + "&br=" + NPRuntime + "&sh=true";
}
}
/***************************** 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;
}
}
/*
* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
* $Rev: 2447 $
*
* bgIframe
*
* Version 2.1.1
*/
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* @param f onMouseOver function || An object with configuration options
* @param g onMouseOut function || Nothing (use configuration options object)
* @author Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
/**
* SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
* legal reasons.
*/
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}this.DETECT_KEY=_b?_b:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(c){this.addParam("bgcolor",c);}var q=_8?_8:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",_7);this.setAttribute("doExpressInstall",false);var _d=(_9)?_9:window.location;this.setAttribute("xiRedirectUrl",_d);this.setAttribute("redirectUrl","");if(_a){this.setAttribute("redirectUrl",_a);}};deconcept.SWFObject.prototype={setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16.push(key+"="+_18[key]);}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}_19='<embed type="application/x-shockwave-flash" src="'+this.getAttribute("swf")+'" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'"';_19+=' id="'+this.getAttribute("id")+'" name="'+this.getAttribute("id")+'" ';var _1a=this.getParams();for(var key in _1a){_19+=[key]+'="'+_1a[key]+'" ';}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+='flashvars="'+_1c+'"';}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}_19='<object id="'+this.getAttribute("id")+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'">';_19+='<param name="movie" value="'+this.getAttribute("swf")+'" />';var _1d=this.getParams();for(var key in _1d){_19+='<param name="'+key+'" value="'+_1d[key]+'" />';}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+='<param name="flashvars" value="'+_1f+'" />';}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}return _23;};deconcept.PlayerVersion=function(_27){this.major=_27[0]!=null?parseInt(_27[0]):0;this.minor=_27[1]!=null?parseInt(_27[1]):0;this.rev=_27[2]!=null?parseInt(_27[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_29){var q=document.location.search||document.location.hash;if(q){var _2b=q.substring(1).split("&");for(var i=0;i<_2b.length;i++){if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){return _2b[i].substring((_2b[i].indexOf("=")+1));}}}return"";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}var _2d=document.getElementsByTagName("OBJECT");for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};if(typeof window.onunload=="function"){var _30=window.onunload;window.onunload=function(){deconcept.SWFObjectUtil.cleanupSWFs();_30();};}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};if(typeof window.onbeforeunload=="function"){var oldBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){deconcept.SWFObjectUtil.prepUnload();oldBeforeUnload();};}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}if(Array.prototype.push==null){Array.prototype.push=function(_31){this[this.length]=_31;return this.length;};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
//<![CDATA[
jQuery(function($) {
// network tabs
$(".ustaMiscLinks .ustaDropTab").each(function(){
var tab = $(this).find("a");
var swf = $(this).find(".swfHolder");
$(this).click(function(){
if(tab.hasClass("activeTab")) {
tab.removeClass("activeTab");
swf.hide();
//return false;
}
else {
closeTab();
swf.slideDown("fast").bgiframe();
tab.addClass("activeTab");
return false;
}
});
});
$(".swfHolder .ustaCloseBtn").click(function() {
closeTab();
return false;
});
});
function closeTab() {
$(".ustaDropTab .swfHolder").hide();
$(".ustaDropTab a").removeClass("activeTab");
}
//]]>

