var AdvertisementPlayer = {
	datasource: null,
	play: function(pmsg)
	{
	    this.datasource = pmsg;
	},
	getDataSource: function()
	{
	    return this.datasource;	    
	},
	openURL: function(p_url,p_target)
	{
	    if(p_url != "")
	    {
	        window.open(p_url,p_target);
	    }
	},
	onresize: function()
	{
	    try
	    {
	        if(typeof(getFlashVersion) != undefined && getFlashVersion() > 8)
            {
                if (navigator.appName.indexOf("Microsoft") != -1)
                {
                    document.getElementById('adsPlayer').refreshContent();
                }
                else 
                {
                    document['adsPlayer'].refreshContent();
                }
            }
        }
        catch(e){}
	},
	onReady: function()
    {
        if(window.location.href.indexOf("dnnprintmode") >= 0)
	    {
            AdvertisementPlayer.setContainerWidth();
        }
        AdvertisementPlayer.checkFlashVersion();
    },
	setContainerWidth: function()
	{
	    try
        {
            document.getElementsByTagName('table')[0].width = 334;
            document.getElementsByTagName('table')[0].style.paddingLeft = "12px";
            document.getElementsByTagName('table')[0].style.backgroundColor = "#F9F9F6";
            document.body.style.background = "transparent";
            jQuery("param[name*='wmode']").val("transparent");
            jQuery("embed").attr("wmode","transparent");
        }
        catch(e){}
	},
	checkFlashVersion: function()
	{
	    if(document.title.indexOf("Home") != -1)
	    {
            if(getFlashVersion() < 9)
            {
                var confirmToRedirect = confirm("This website requires Flash Player 9 or later. Would you like to update it now?");
                if(confirmToRedirect)
                {
                    window.open("http://www.adobe.com/go/getflashplayer","_blank");
                }
            }
        }
	}
};

jQuery(document).ready(AdvertisementPlayer.onReady);

function getFlashVersion(){ 
  // ie 
  try 
  { 
    try 
    { 
      // avoid fp6 minor version lookup issues 
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
      try { axo.AllowScriptAccess = 'always'; } 
      catch(e) { return 6; } 
    } catch(e) {} 
    return parseInt(new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1].split(',').shift()); 
  // other browsers 
  } 
  catch(e)
  { 
    try
    { 
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
        return parseInt((navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1].split(',').shift()); 
      } 
    } 
    catch(e) {} 
  } 
  return 0; 
}
