// DFP ad serving variables
var ord		= Math.random()*10000000000000000;
var ordnum	= Math.round(Math.random() * 1000000000);


/*******************************************************************
 *	Menu navigation script added by RRO
 *******************************************************************/

function goOn(newURL) 
{

  //--If the selected file name isn't blank, send it to reader.

  if (newURL != "") 
  {

    location.href=newURL

  }

}

/*******************************************************************
 *	Cookie Functions
 *******************************************************************/
// Check for a cookie's existance
function getCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
// Create a new cookie
function setCookie(name, value, expires, path, domain, secure) 
{
	var expDate		= new Date(expires);
	var curCookie	= name + "=" + escape(value) +
		((expires) ? "; expires=" + expDate.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}
// Delete an existing cookie
function deleteCookie(name, path, domain) 
{
	if (getCookie(name)) 
	{
		var curCookie	= name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		document.cookie = curCookie;
	}
}


/*******************************************************************
 *	FireClick Functions
 *******************************************************************/
// Track a click and redirect the page
function flashFire (name, url) 
{
	window.open(url);
	fc_click(name, 'ad', url);
}
// Track a click without redirecting page
function flashFireNoGo (name, url) 
{
	fc_click(name, 'ad', url);
}


/*******************************************************************
 *	CNN Video Player Functions
 *******************************************************************/
// Open popup window
function CNN_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	try 
	{
		window.top.name = "opener";
	} catch (e) {}
	var popupWin = window.open( url, name, widgets );
	if ( popupWin) 
	{
		popupWin.focus();
	}
}
// Play a PGATOUR.com video
function cnnVideo( mode, arg, expiration ) 
{
	cnnVideoArgs = 'url=' + arg;
	openURL = '/video/player/player.html';;
	CNN_openPopup( 'http://www.pgatour.com/'+openURL+'?'+cnnVideoArgs, 'CNNVideoPlayer', 'scrollbars=no,resizable=no,width=770,height=570' );
}
//Gets the current URL and replaces /news/ with /news/print/
//Used on the microsite news articles to pop up a printable version of the article
//TFH - 6/28/2007
function GetPrintURL()
{
	var myURL;
	var newURL;
	var f = "/news/";
	
	myURL = window.location;
	myURL = String(myURL);
	newURL = myURL.replace(f, "/news/print/");
		
	window.open(newURL, "mywindow","location=0,status=1,scrollbars=1,width=650,height=800");	
}
//Used to assist in closing a window in Firefox.
//TFH - 6/28/2007
function closeWindow() 
{

window.open('','_parent','');

window.close();

}
//Used to open to the video page of pga.com from Senior PGA 2008 Microsite
function cnnOpen(url) 
{
    if (url) 
	{
        lowerUrl = url.toLowerCase().replace(" ", "");
		
		if (lowerUrl.indexOf("/video") != -1 || lowerUrl.indexOf("/audio") != -1) 
		{
			if (lowerUrl.indexOf("?") != -1) 
			{ 
				openURL = url;
            }
			else 
			{
				openURL = "/video/?" + url
            }
			
			CNN_openPopup( 'http://www.pga.com' + openURL, 'CNNVideoPlayer', 'scrollbars=yes,status=yes,resizable=yes,width=1000,height=700' );
        }
		
        else if (lowerUrl.indexOf("/video/video") > -1 ||
            lowerUrl.indexOf("/video/audio") > -1 ||
            lowerUrl.indexOf("/video/") > -1 &&
            lowerUrl.indexOf("/video/liveat/") < 0) 
		{
            window.location = "/video/?" + url;
        } 
		else if (lowerUrl.indexOf("/photos/20") > -1) 
		{
            window.location = "/photos/?" + url;
        } 
		else if (lowerUrl.indexOf("/video/liveat/?") == 0) 
		{
            openLiveAt(url.replace("/video/liveat/?", ""));
        } 
		else if (lowerUrl.indexOf("/swingplex") > -1) 
		{
            CNN_openPopup(url, "780x445", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=780,height=445");
        } 
		else 
		{
            window.location = url;
        }
    }
}
function pgaVidOpen( url ) { cnnOpen(url); }