/************************* START GLOBAL JS FUNCTIONS **************************/
// document.domain = "usopen.com";
//********************** 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 = 2007;
/***************************** On Load Event */
function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload = function()
{
if (oldonload)
{
oldonload();
}
func();
}
}
}
/****************************************** NS Resize Script */
if (isNav){
origWidth = innerWidth;
origHeight = innerHeight;
}
function resizeDetected(){
if (isNav){
if (innerWidth != origWidth || innerHeight != origHeight){
location.href = location.href;
}
}
}
/***************************** shop navigation */
function openShopExternal(shopId){
if(shopId == "1") {
url = "http://www.usgacatalog.com/default.aspx";
}
if(shopId == "2") {
url = "http://photoarchive.usga.org/";
}
if(shopId == "3") {
url = "https://usgapubs.usga.org/store2/default.asp?cookie%5Ftest=1";
}
openExternal(url,true);
}
function openShop(which){
//location.href="/en_AU/shop/index.html";
openShopExternal(which);
}
/***************************** pulldown redirect */
function _go(fName,sName,div) {
if (document.layers && div){
if (eval("document." + div + ".document." + fName + "." + sName + ".options[document." + div + ".document." + fName + "." + sName + ".selectedIndex].value"))
location.href=eval("document." + div + ".document." + fName + "." + sName + ".options[document." + div + ".document." + fName + "." + sName + ".selectedIndex].value");
} else {
if (eval("document." + fName + "." + sName + ".options[document." + fName + "." + sName + ".selectedIndex].value"))
location.href=eval("document." + fName + "." + sName + ".options[document." + fName + "." + sName + ".selectedIndex].value");
}
}
/***************************** pdf measurement */
function getLink(link) {
if(link) {
sa_onclick('http://www.usopen.com/'+link);
window.open(link);
}
}
/***************************** Surfaid external navigation */
function openExternal(lnk,newWindow,w,h,shared){
if (lnk.indexOf("http://" == -1)){
switch(lnk){
case "ibm": lnk = "http://www.ibm.com/"; break;
case "att": lnk = "http://attblueroom.com/sports/usopen/index.php"; break;
case "exxon": lnk = "http://www.exxonmobile.com/"; break;
default: break;
}
}
//remove http for reporting and measure click
if (window.sa_onclick && !shared){
var rptLnk = lnk;
if (rptLnk.indexOf("http://") == 0){
rptLnk = rptLnk.substring(7);
}
sa_onclick('http://www.usga.org/click/'+rptLnk);
}
if (newWindow){
if (w && h){
newWindow = window.open(lnk,"consoleWindow","width=" + w + ",height=" + h + ",resizable=yes,status=yes,toolbar=yes,menubar=yes,location=yes");
}
else{
newWindow = window.open(lnk,"newWindow","menubar=1,toolbar=1,location=1,directories=1,status=1,scrollbars=1,resizable=1");
}
}
else {
document.location.href = lnk;
}
}
/***************************** Surfaid internal navigation */
function openPDF(loc) {
openInternal(loc,true);
}
function openInternal(loc,newWindow) {
if(loc) {
if (window.sa_onclick){
sa_onclick('http://www.usopen.com/'+loc);
}
if (newWindow){
newWindow = window.open(loc);
} else {
location.href = loc;
}
}
}
// ###################################
// ## 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";
}
}
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";
}
}
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";
}
}
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;
}
/**
preload menu images
*/
// simplePreload( '01.gif', '02.gif' ); 
function preLoadMenuImgs()
{ 
// create array of images to preload
// if tab image names are change, css file, topmenu.css, will also need to be updated
var imgListArr = new Array();
for(var i=0; i<=8; i++) {
// skip image 0 for the home page. 
if(i > 0) {
imgListArr[imgListArr.length] = "/images/nav/ug_hm_nav_0" + i + ".gif";
imgListArr[imgListArr.length] = "/images/nav/ug_hm_nav_sel_0" + i + ".gif";
}
imgListArr[imgListArr.length] = "/images/nav/ug_sub_nav_0" + i + ".gif";
imgListArr[imgListArr.length] = "/images/nav/ug_sub_nav_sel_0" + i + ".gif";
}
document.imageArray = new Array(imgListArr.length);
for(var i=0; i<imgListArr.length; i++)
{
document.imageArray[i] = new Image;
document.imageArray[i].src = imgListArr[i];
}
}
/************************** END GLOBAL JS FUNCTIONS **************************/
