//global event settings
var eventName = "usga";
var siteURL = "www.usopen.com";
var infoImg = new Image();
//********************** Content Shedding Variables
var useFlashNewsApp = true;
//********************** Home Page Blog and News Config
var blogRefresh = 900000;
var newsRefresh = 900000;
//********************** Home Page Summary Scoreboard Config
var staticSB = 0;
var ptOn = 1;
var sbOn = 1;
var homeScoresRefresh = 30000;
var homeNotRefresh = 30000;
var liveRefresh = 300000;
var sumScoreboardYear = 2009;
//********************* Home page Most popular-commented articles config
var commArticlesRefresh = 900000; // timer in milliseconds
var poparticlesFilename = '/en_US/xml/gen/poparticles.xml';
//********************* Home page Leaderboard and My players tab config
var homeScoresTimer = 60000; 	 // timer in milliseconds. blank if no timer
var isTournEnd = false; // set to true when tournament is over;
var leadersFilename = '/en_US/xml/gen/homeScores/homeScoresLive.xml';
var persFilename = '/en_US/xml/gen/homeScores/homeScoresAll.xml';
//********************* Home page Next on Tee tab config
var homeNotTimer = 180000;		// interval in milliseconds, blank if no timer
var isNotTournEnd = false; // set to true when tournament is over
var notFilename = '/en_US/xml/gen/homeScores/homeNot.xml';
/************************ Jquery functions */
$(document).ready(function(){
if (document.all){$("#nav li").hoverClass ("over");}
//var path = location.pathname.substring(0);
var path = new String(location.pathname);
path = path.substring(0);
var url = new String(document.location);
if (path.indexOf('/news/articles/') != -1) {path = "/en_US/news/index.html";}
if (path.indexOf('/news/photos/') != -1) {path = "/en_US/news/photos/index.html";}
if (path.indexOf('/news/dailylog/') != -1) {path = "/en_US/news/dailylog/index.html";}
// if (path.indexOf('/players/') != -1) {
//	 if ((path.indexOf('/interviews.html') == -1) && (path.indexOf('/playerweblog.html') == -1)){
//	 path = "/en_US/players/index.html";
//	 }
//	 }
if (path.indexOf('/news/interviews/') != -1) {path = "/en_US/players/interviews.html";}
if (url.indexOf('http://usga.usopen.com/2009') == 0) {path = url;}
$('#nav a[href$="' + path + '"]').addClass('active').siblings("ul").show();
$('#nav a[href$="' + path + '"]').parents("li").addClass('active');
$('#nav a[href$="' + path + '"]').addClass('active');
$('#nav a[href$="' + path + '"]').parents("ul").prev("ul li").addClass('active');
$('#nav a[href$="' + path + '"]').parents("ul").show();
//jquery code for image rollovers
$("img.rollover").hover(
function(){this.src = this.src.replace("_off","_on");},
function(){this.src = this.src.replace("_on","_off");}
);
//jquery code for selected state
$("img.widgetButton").click(function(){
$("img.widgetButton").each(function(){this.src = this.src.replace("_on","_off");});
this.src = this.src.replace("_off","_on");
});
$('#tabsBios > ul').tabs();
startRotation();
//jquery code for alternating table rows
$('#twitterComments table.striped tr:even').addClass('paleGrayBg');
});
//jquery code for top navigation
$.fn.hoverClass = function(c) {
return this.each(function(){
$(this).hover(
function() { $(this).addClass(c);},
function() { $(this).removeClass(c);}
);
});
};
/****************************** launch leaderboard */
function launch(x,syn,debug){
//launch traditional Leaderboard
var flashWindow = "";
var lbLaunchPage = "/en_US/realtime/init_np_.html?";
if (hasReqestedFlashVersion && NPRuntime){
//document.location.href="/en_US/scores/index.html";
lbLaunchPage += (syn)?"syn="+syn:"syn=none";
lbLaunchPage += "&ref=" + document.location.host + document.location.pathname;
lbLaunchPage += (x)?"&mode="+x:"&mode=none";
lbLaunchPage += (debug)?"&db=true":"&db=false";
if (flashWindow.closed || flashWindow==""){
flashWindow = window.open(lbLaunchPage,"flashWindow","width=739,height=453,top=10,left=10")
if (flashWindow.opener == null) flashWindow.opener=self;
}
flashWindow.focus();
} else {
//user doesn't have flash8:
document.location.href="/en_US/flashupgrade.html";
}
}
function launch2(){
window.location.href="/en_US/realtime/index.html";
}
function launch1(){
launch_on();
}
/***************************** media console launch */
var consoleWindow = "";
var consolelaunchPage;
var windowHeight = 515; //minimized with no ad
function launchMC(targetLink,tab,lang){
if (hasReqestedFlashVersion){
consolelaunchPage = "/en_US/interactive/console/mflash.html?";
consolelaunchPage += "targetLink="+escape(targetLink);
consolelaunchPage += "&tab="+tab;;
consolelaunchPage += "&lang="+lang;
consolelaunchPage += "&localisIE="+isIE;
//alert(isIE);
if (consoleWindow.closed || consoleWindow==""){
consoleWindow = window.open(consolelaunchPage,"consoleWindow","width=430,height=" + windowHeight + ",top=50,left=200")
if (consoleWindow.opener == null) consoleWindow.opener=self;
} else {
//function to set new movie in exisiting console:
consoleWindow.setNewMovie(targetLink,tab,lang);
}
consoleWindow.focus();
} else {
//user doesn't have flash8:
document.location.href="/en_US/flashupgrade.html";
}
}
/******************************Video Console */
var vcWindow = "";
function launchVC(video_ref,syn,debug,alt){
var vcLaunchPage = "/en_US/console/console.html?";
if (hasReqestedFlashVersion && NPRuntime){
var d = new Date()
var t = d.getTime()
vcLaunchPage += "ts=" + t;
vcLaunchPage += '&video=' + video_ref;
vcLaunchPage += (syn)?"&syn="+syn:"&syn=";
vcLaunchPage += (debug && debug.indexOf("debug")>-1)?"&db=true":"&db=false";
vcLaunchPage += "&ref=" + document.location.host + document.location.pathname;
vcLaunchPage += (alt)?"&alt="+alt:"&alt=";
if (vcWindow.closed || vcWindow==""){
vcWindow = window.open(vcLaunchPage,"vcWindow","width=960,height=661,top=0,left=0")
if (vcWindow.opener == null) vcWindow.opener=self;
}
vcWindow.focus();
} else {
//user doesn't have flash9:
document.location.href = "/en_US/flashupgrade.html?fl=" + hasReqestedFlashVersion + "&br=" + NPRuntime + "&sh=true";
}
}
//*****************************
// measurement function for media console
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param tab - which tab is being viewed or clicked on
// @param clip - which clip was loaded
// @param referrer - which page is making the measurement call
// @param launch - boolean, indicates if launch measurement call
// @param external - indicates which external site launched from
//*****************************
function consoleMeasure(lang,tab,clip,referrer,launch,external){
var page = "";
var externalSite = external ? external+"_" : "";
var refPage = "http://" + siteURL + referrer;
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
// Valid chars, only want alpha numeric
var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var clipOut = "";
for (var i=0; i<clip.length; i++) {
if (valid.indexOf(clip.charAt(i)) > -1) {
clipOut += clip.charAt(i);
}
}
if (launch){
page = escape("/" + lang + "/interactive/console/console_launch_" + externalSite + tab + "_" + clipOut + ".html");
}
else {
page = escape("/" + lang + "/interactive/console/console_" + tab + "_" + clipOut + ".html");
}
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
//alert(url);
infoImg.src = url;
}
function consoleMeasureLaunch(lang,tab,clip,referrer,external){
consoleMeasure(lang,tab,clip,referrer,true,external)
}
//*****************************
// measurement function for course app
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param hole - which hole is being viewed
// @param ind - information indicator
//*****************************
function courseMeasure(lang,hole,ind){
var page = "";
var refPage = "http://" + siteURL + "/" + lang + "/course/index.html";
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
page = escape("/" + lang + "/course/hole_" + hole + "_" + ind + ".html");
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
//alert(url);
infoImg.src = url;
}
//*****************************
// measurement function for slideshow app
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param button - "start" or "stop"
//*****************************
function slideshowMeasure(lang,button){
var page = "";
var refPage = "http://" + siteURL + "/" + lang + "/interactive/slideshow/slideshow.html";
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
page = escape("/" + lang + "/interactive/slideshow/slideshow_" + button + ".html");
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
//alert(url);
infoImg.src = url;
}
//*****************************
// measurement function for video app
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param info - either clip name which was clicked or enable/disable autoplay info
//*****************************
function videoMeasure(lang,info){
var page = "";
var refPage = "http://" + siteURL + "/" + lang + "/index.html";
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
// Valid chars, only want alpha numeric
var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var infoOut = "";
for (var i=0; i<info.length; i++) {
if (valid.indexOf(info.charAt(i)) > -1) {
infoOut += info.charAt(i);
}
}
page = escape("/" + lang + "/homevideo_" + infoOut + ".html");
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
//alert(url);
infoImg.src = url;
}
//*****************************
// opens links from apps and measures external links
// @param page - url of page to open
// @param newWindow - boolean, open page in new window, external links always open in new window
//*****************************
function externalOpen(page,newWindow){
var externalMeasure = "http://" + siteURL + "/click/" + page;
var external = false;
var randomnumber=Math.floor(Math.random()*9999999999);
if ( page.indexOf("/") != 0 && (page.indexOf("http")==0 || page.indexOf("www")==0) ){
external = true;
}
if (external){
openNew(page);
}
else {
if (top.opener.closed != null){
if (top.opener.closed || newWindow){
openNew(page);
}
else {
top.opener.location.href = page;
top.opener.focus();
}
}
else{
openNew(page);
}
}
if(external){
var refPage = "http://"+siteURL;
var ck = "";
ck = getCookie("sauid");
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + escape(externalMeasure) + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
//alert(url);
infoImg.src = url;
}
}
function openNew(page){
theWindow = window.open(page, 'fromConsole', 'menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,location=yes,width=800,height=600,top=20,left=20');
}
//*****************************
// measurement function for tabbed content
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param tab - which tab is being viewed or clicked on
//*****************************
function tabContentMeasure(lang,tab){
var page = "";
var refPage = "http://" + siteURL + "/" + lang + "/index.html";
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
page = escape("/" + lang + "/homenews_" + tab + ".html");
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
infoImg.src = url;
}
//*****************************
// measurement function for personalization app
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param action - click type
// @param qs - additional querystring param
//*****************************
function persMeasure(lang,action,qs){
var page = "";
var refPage = "http://" + siteURL + "/" + lang + "/index.html";
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
page = escape("/" + lang + "/personalization_" + action + ".html");
if (qs){
page = page + "?" + qs;
}
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
infoImg.src = url;
}
//*****************************
// measurement function for home promo boxes
// this will need to change after the ajax is done
// but we still need to pull the header image names
//*****************************
function homePromoBoxMeasure(){
var promoArray = new Array();
var promoString = "";
for (var x=0; x<5; x++) {
index = "promobox" + x;
promoArray[x] = document.getElementById(index);
}
for (var y=0; y<promoArray.length; y++) {
var promoText = promoArray[y].src;
var temp = promoText.split("/");
promoText = temp[temp.length -1];
promoString+=promoText;
if (y != (promoArray.length -1)) {
promoString+="|";
}
}
SA_Message = "moth=" + promoString;
}
//*****************************
// measurement function for US Open memory game
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param click - what was clicked or viewed
//*****************************
function gameMeasure(lang,click){
var page = "";
var refPage = "http://" + siteURL + "/" + lang + "/interactive/game/usopen_game.html";
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
page = escape("/" + lang + "/interactive/game/game_" + click + ".html");
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
//alert(url);
infoImg.src = url;
}
//*****************************
// measurement function for permalink, print popup
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param diffTag - unique measurement string
//*****************************
function popupMeasure(poptype){
var page = "";
var refPage = document.location.href;
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookieValue("sauid");
refPage = refPage.substring(refPage.indexOf("/en_US"),refPage.indexOf(".html"));
page = refPage + "_" + poptype + ".html";
var url= "http://stats.surfaid.ihost.com/rc/images/uc.GIF?1.20&events&"+eventName+"&http%3A//" + siteURL + page + "&" + refPage + "&&&" + ck + "&&&&&&" + randomnumber;
// alert(url);
infoImg.src = url;
}
//*****************************
// measurement function for permalink, print popup
// @param lang - lang of app, "en_US", "fr_FR", etc...
// @param diffTag - unique measurement string
//*****************************
function measureClick(id) {
//alert("http://"+siteURL + id);
if (window.sa_onclick){
var url = "http://"+siteURL + id;
if (url.indexOf(siteURL+'/')<0) {
url = 'http://'+siteURL + '/' + id;
}
sa_onclick(url);
}
}