
// adds a function to the page onload, so we don't overwrite existing onload functions
function addOnLoad(f) {
    var currentOnLoad = window.onload;
    if (typeof window.onload != "function") {
        window.onload = f;
    } else {
        window.onload = function() {
            currentOnLoad();
            f();
        }
    }
}



// ===========================================================
// - ONLOAD
// ===========================================================
function wrapperSetup(){
   //assignRollOvers('navlist','/tnb/');
	// write logo
	var lo = new FlashObject("http://images.gactv.com/flash/logo.swf", "swflogo", "190", "90", 7, "#000000");
	lo.addParam('wmode', 'transparent');
	lo.addParam("allowScriptAccess", "always");
	lo.write("logo");
	
	// write buckets
	if (document.getElementById("buckets")) {
		document.getElementById("buckets").innerHTML = '<div id="rr-news-holder"></div><div id="rr-artists-watch-it-holder" style="margin-top:15px;"></div>';

		var so = new SWFObject("http://images.gactv.com/flash/latest-news-right-rail.swf", "latest-news-right-rail", "276", "198", "9");
		so.addParam("wmode", "transparent");
		so.addParam("allowscriptaccess", "always");
		so.write("rr-news-holder");

		var so = new SWFObject("http://images.gactv.com/flash/artists-watch-it.swf", "artists-watch-it", "276", "271", "9");
		so.addParam("wmode", "transparent");
		so.addParam("allowscriptaccess", "always");
		so.write("rr-artists-watch-it-holder");
	}
}




/*
----------------------------------------------------------------------
Standard Popup class for print and send to a friend.
----------------------------------------------------------------------
*/

var popupLinkConfig = new Array;

// popupLinkConfig["classname"] = new Array ( "targetname", "width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
popupLinkConfig["pop_email"] = new Array ( "email", "width=519,height=475,scrollbar=yes,menubar=yes");
popupLinkConfig["pop_print"] = new Array ( "print", "width=750,height=650,resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes");
popupLinkConfig["pop_getgac"] = new Array ( "getgac", "width=550,height=560,scrollbars=no,resizable=no");
popupLinkConfig["pop_makegac"] = new Array ( "makegac", "width=480,height=350,scrollbars=no,resizable=no");
popupLinkConfig["pop_fullimage"] = new Array ( "gallery", "width=710,height=710,scrollbars=yes,menubar=no,toolbar=no,resizable=yes");
popupLinkConfig["pop_articleimage"] = new Array ( "image", "width=330,height=450,scrollbars=yes,menubar=no,toolbar=no,resizable=yes");

//send to a friend popup
popupLinkConfig["pop_sendFriend"] = new Array ( "sendFriend", "width=519,height=600,scrollbars=no,resizable=no");


// ==========================================================================
window.onload = initPage;  
// Note: Make sure that no other javscripts assign a fuction to window.onload
// There can be only one function tied to window.onload at a time.

function initPage() {
  initPopupLinks();
  // place here any other code you wish to run when the page loads.
}

function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}

/*
----------------------------------------------------------------------
Milonic, or any other dhtml menus, cannot ensure the menu will position
on top of flash or applets in Safari, so we're disabling the dropdowns
for those users.

This function detects if a user is on Safari.
----------------------------------------------------------------------
*/

function checkSafari() {
	
   var ua = navigator.userAgent.toLowerCase(); 
   this.isSafari = (ua.indexOf('safari') != - 1);

}

/*
----------------------------------------------------------------------
Run the checkSafari function
----------------------------------------------------------------------
*/

checkSafari();

/*
----------------------------------------------------------------------
These functions are called from the navigation to inact the rollover
and dropdown menus. We need to check if the user is on Safari and
only run the popup and popdown functions for non-Safari users.
----------------------------------------------------------------------
*/

function onNav(sMenu,sId) {
	
	// if not a safari user
	if(!(this.isSafari)){
	popup(sMenu,sId);
	}
}

function offNav() {
	
	// if not a safari user
	if(!(this.isSafari)){
	popdown();
	}
}

