/************************* START GLOBAL JS FUNCTIONS **************************/
// document.domain = "masters.com";
var siteURL = "masters.com";
var lang = "en_US";
var eventName = "mast";//for measurement calls
var infoImg = new Image();//for measurement calls
//********************** Content Shedding Variables
var useFlashNewsApp = true;
//********************** Home Page Blog and News Config
var blogRefresh = 900000;
var newsRefresh = 900000;
var messageRefresh = 300000;
//********************** 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 = 2008;
/************************ Jquery functions */
$(document).ready(function(){
if(document.all){$("#navLeaderboard").hoverClass("over");}
if(document.all){$("#navPlayers").hoverClass("over");}
if(document.all){$("#navNews").hoverClass("over");}
if(document.all){$("#navCourse").hoverClass("over");}
if(document.all){$("#navVideo").hoverClass("over");}
if(document.all){$("#navCommunity").hoverClass("over");}
if(document.all){$("#navMobile").hoverClass("over");}
if(document.all){$("#navGames").hoverClass("over");}
if(document.all){$("#navTournament").hoverClass("over");}
if(document.all){$("#manyEyesWordList li").hoverClass("over");}
if(document.all){$("#manyEyesDataList li").hoverClass("over");}
if(document.all){$("#manyEyesWordListSmall li").hoverClass("over");}
if(document.all){$("#manyEyesDataListSmall li").hoverClass("over");}
var path = location.pathname.substring(0);
var url = location.href;
//scoring pages
if (path.indexOf('/scores/index2.html') != -1) {path = "/en_US/scores/index.html";}
if (path.indexOf('/scores/past.html') != -1) {path = "/en_US/scores/index.html";}
if (path.indexOf('/scores/us.html') != -1) {path = "/en_US/scores/index.html";}
if (path.indexOf('/scores/international.html') != -1) {path = "/en_US/scores/index.html";}
if (path.indexOf('/scores/amateur.html') != -1) {path = "/en_US/scores/index.html";}
if (path.indexOf('/scores/first.html') != -1) {path = "/en_US/scores/index.html";} 
if (path.indexOf('/scores/stats/') != -1) {path = "/en_US/scores/stats/index.html";} 
if (path.indexOf('/scores/groupings/') != -1) {path = "/en_US/scores/groupings/index.html";} 
if (path.indexOf('/scores/hbyh/') != -1) {path = "/en_US/scores/hbyh/index.html";} 
if (path.indexOf('/players/tournamet_2009.html') == -1 && path.indexOf('/players/') != -1){ 
path = "/en_US/players/index.html";
}
if (path.indexOf('/history/') != -1) {path = "/en_US/history/index.html";}
if (path.indexOf('/news/articles/') != -1) {path = "/en_US/news/articles/index.html";}
if (path.indexOf('/news/interviews/') != -1) {path = "/en_US/news/interviews/index.html";}
if (path.indexOf('/news/photos/') != -1 && path.indexOf('/news/photos/myPhoto.html') == -1) {path = "/en_US/news/photos/index.html";}
if (path.indexOf('/news/galleries/') != -1) {path = "/en_US/news/photos/index.html";}
if (path.indexOf('/news/dailylog/') != -1) {path = "/en_US/news/dailylog/index.html";}
if (path.indexOf('/visualization/') != -1) {path = "/en_US/visualization/index.html";}
if (path.indexOf('/ggw/') != -1) {path = "/ggw/en/index.html";}
if (path.indexOf('/interactive/live/comments/') != -1) {path = "/en_US/interactive/live/index.html";}
//alert(path);
//$('#navSub ul li ul').hide();
if (path.indexOf('/history/') != -1) {path = "/en_US/history/index.html";}
/*PictureU*/
if(url.indexOf("myphoto.masters.com") != -1){
//path = "http://myphoto.masters.com/";
path = "/news/";
}
$('#navSub ul li ul').hide();
$('#navSub a[@href$="' + path + '"]').addClass('active').siblings("ul").show();
$('#navSub a[@href$="' + path + '"]').parents("li").addClass('active');
$('#navSub a[@href$="' + path + '"]').parents("ul").prev("ul li a").addClass('active');
$('#navSub 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");}
);
$("img.widgetButton").click(function(){
$("img.widgetButton").each(function(){this.src = this.src.replace("_on","_off");});
this.src = this.src.replace("_off","_on");
});
$(function() {
$("#accordion").accordion({
header: "h6"/*,
icons: {
header: "ui-icon-plus",
headerSelected: "ui-icon-minus"
} */
});
});
$('#tabsScores > ul').tabs();
$('#tabsCommunity > ul').tabs();
$('#tabsNews > ul').tabs();
$('#tabsGames > ul').tabs();
//$('#meMore').click(function() { $("#manyEyesApp").hide(); $("#manyEyesMore").show(); });
//$('.closebtn').click(function() { $("#manyEyesMore").hide(); $("#manyEyesApp").show();});
StartTimer();
});
//jquery code for top navigation
$.fn.hoverClass = function(c) {
return this.each(function(){
$(this).hover(
function() { $(this).addClass(c);},
function() { $(this).removeClass(c);}
);
});
};
/************** functions for sponsor logo rotation */
var x = 15;
var y = 1;
function StartTimer() {
$('#sponMenu2').hide();
$('#sponMenu3').hide();
random_num = (Math.round((Math.random()*1)+1));
if (random_num == 1) {
$('#sponMenu2').toggle();
setTimeout("switchSponsers()" , 15000);
}
else {
$('#sponMenu3').toggle();
setTimeout("switchSponsers()" , 15000);
}
}
function switchSponsers(){
$('#sponMenu2').toggle();
$('#sponMenu3').toggle();
setTimeout("switchSponsers()", 15000);
}
/******************************masters concentration game launch */
function launchGame(){
var gameWindow = "";
var gameLaunchPage = "/en_US/interactive/game/masters_game.html";
if (hasReqestedFlashVersion && NPRuntime){
if (gameWindow.closed || gameWindow==""){
gameWindow = window.open(gameLaunchPage,"gameWindow","width=863,height=668,top=10,left=10")
if (gameWindow.opener == null) gameWindow.opener=self;
}
gameWindow.focus();
} else {
//user doesn't have flash8:
document.location.href="/en_US/flashupgrade.html";
}
}
/******************************Augusta Live Console */
var alWindow = "";
function launchALC(video_ref,syn,debug,alt){
var alLaunchPage = "/en_US/console/console.html?";
if (hasReqestedFlashVersionALC && NPRuntime){
var d = new Date()
var t = d.getTime()
alLaunchPage += "ts=" + t;
if ((video_ref == '1516') || (video_ref == 'ac') || (video_ref == 'p3') || (video_ref == 'ir') || (video_ref == 'me')) {
alLaunchPage += '&video=' + video_ref;
}
else{
alLaunchPage += '&video=';
}
alLaunchPage += (syn)?"&syn="+syn:"&syn=";
alLaunchPage += (debug && debug.indexOf("debug")>-1)?"&db=true":"&db=false";
alLaunchPage += "&ref=" + document.location.host + document.location.pathname;
alLaunchPage += (alt)?"&alt="+alt:"&alt=";
if (alWindow.closed || alWindow==""){
alWindow = window.open(alLaunchPage,"alWindow","width=960,height=540,top=0,left=0")
if (alWindow.opener == null) alWindow.opener=self;
}
alWindow.focus();
} else {
//user doesn't have flash9:
document.location.href = "/en_US/flashupgrade.html?fl=" + hasReqestedFlashVersionALC + "&br=" + NPRuntime;
}
}
/******************************Leaderboard launch*/
function launchLeaderboard(syn,debug){
//launch Traditional Leaderboard
var lbWindow = "";
var lbLaunchPage = "/en_US/realtime/lb.html?";
if (hasReqestedFlashVersion && NPRuntime){
var d = new Date()
var t = d.getTime()
lbLaunchPage += "ts=" + t;
lbLaunchPage += (syn)?"&syn="+syn:"&syn=none";
lbLaunchPage += (debug && debug.indexOf("debug")>-1)?"&db=true":"&db=false";
lbLaunchPage += "&ref=" + document.location.host + document.location.pathname;
if (lbWindow.closed || lbWindow==""){
lbWindow = window.open(lbLaunchPage,"lbWindow","width=505,height=677,top=10,left=10")
if (lbWindow.opener == null) lbWindow.opener=self;
}
lbWindow.focus();
} else {
//user doesn't have flash8:
document.location.href="/en_US/flashupgrade.html";
}
}
// ###################################
// ## function: printArticle
// ## inputs: divcount - number of page divs
// ## title - page title
// ## previewURL - base href (optional)
// ## desc: open a new window and
// ## display the article div content
// ###################################
function printArticle(divcount, title, previewURL) {
// Set the parameters and open a new window
printWindow = window.open('','print_window','menubar=yes,toolbar=yes,scrollbars=yes,width=720,height=600');
// Write the header and doc info to the new window
printWindow.document.write('<html><head><title>'+ title +'</title><style type="text/css">body,td,select,input{font-family : Arial, Helvetica, sans-serif;} .stext{font-size : 11px;font-family : Arial, Helvetica, sans-serif;}</style>');
if (previewURL)
{
printWindow.document.write('<base href="'+ previewURL +'" />');
}
printWindow.document.write('</head><body topmargin="0" marginheight="0" marginwidth="0">');
printWindow.document.write(document.getElementById("print").innerHTML);
printWindow.document.write('<table cellpadding="5" cellspacing="0" border="0"><tr><td>');
// Based on the divCnt loop through the divs and add their content to the window
for (x=0; x < divcount; x++) {
if (eval('document.getElementById("' + x + '")') != null) {
eval('printWindow.document.write(document.getElementById("' + x + '").innerHTML)');
}
}
// close the table and document
printWindow.document.write('</td></tr>');
printWindow.document.write('<tr><td class="stext"><br/><br/></td></tr>');
printWindow.document.write('</table>');
printWindow.document.write('</body></html>');
printWindow.document.close();
// call a function to record a page view
popupMeasure('print');
// call the print function
// auto print disabled per jda 8/3/05
// printWindow.print();
}
// #######################################################
// ## textCounter - tracks the current no of characters
// ## in a field and prevents the user from entering
// ## more than the max limit
// ## Inputs: field: form field to monitor
// ## cntfield: id of element to write update to
// ## maxlimit: maximum chars allowed for field
// ## Outputs: Writes out to specified html element or if
// ## cntfield is blank, displays js alert
// #######################################################
function textCounter(field,cntfield,maxlimit)
{
if (field.value.length > maxlimit)
{ // if too long...trim it!
field.value = field.value.substring(0, (maxlimit));
if (cntfield != "")
{
document.getElementById(cntfield).innerHTML = "0 characters remain";
} else {
alert("You have reached the maximum number of characters (" + maxlimit + ")");
}
} else {
if (cntfield != "")
{
document.getElementById(cntfield).innerHTML = (maxlimit - field.value.length) + " characters remain";
}
}
}
/***************************** Change Font Size */
var size = 1;
var newsize = 1;
function getLarger()
{
/* if(document.getElementById("articleHorizText")) {
articletext = document.getElementById("articleHorizText");
}
if(document.getElementById("articleVertText")) {
articletext = document.getElementById("articleVertText");
} */
newsize = size + .1;
var articletext = changeableContent();
if (articletext != null)
{
articletext.style.fontSize = newsize+"em";
document.getElementById("sizeImg").src = "/images/misc/ma_ms_0000ga2.gif";
}
popupMeasure('fontlarger');
}
function getLargest()
{
/* if(document.getElementById("articleHorizText")) {
articletext = document.getElementById("articleHorizText");
}
if(document.getElementById("articleVertText")) {
articletext = document.getElementById("articleVertText");
} */
newsize = size + .3;
var articletext = changeableContent();
if (articletext != null)
{
articletext.style.fontSize = newsize+"em";
document.getElementById("sizeImg").src = "/images/misc/ma_ms_0000ga3.gif";
}
popupMeasure('fontlargest');
}
function getNormal()
{
/*if(document.getElementById("articleHorizText")) {
articletext = document.getElementById("articleHorizText");
}
if(document.getElementById("articleVertText")) {
articletext = document.getElementById("articleVertText");
} */
var articletext = changeableContent();
if (articletext != null)
{
articletext.style.fontSize = size+"em";
document.getElementById("sizeImg").src = "/images/misc/ma_ms_0000ga1.gif";
}
popupMeasure('fontnormal');
}
function changeableContent()
{
// get the article element
theArticle = document.getElementById('article');
// get all div elements in the article
allDivs = theArticle.getElementsByTagName('div');
// loop through and
for (i =0; i < allDivs.length; i++)
{
if (allDivs[i].className == "articleHorizText" || allDivs[i].className == "articleVertText")
{
return allDivs[i];
}
}
return null;
}
//*****************************
// measurement function for masters 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/masters_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 eventName = "mast";
var page = "";
var refPage = document.location.href;
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("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 to measure uptime. Used in conjunction with uptime.js
//*****************************
function uptimeMeasure(info){
var page = "";
var refPage = escape(document.location.href);
var randomnumber=Math.floor(Math.random()*9999999999);
var ck = "";
ck = getCookie("sauid");
page = escape(info);
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 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;
}
