﻿//////////////////////////////////////////////////////////
/// SET DEFAULT VARIABLES FOR GENERIC STATION SETTINGS
//////////////////////////////////////////////////////////
var DEFAULT_SITE_NAME     = "none";
var DEFAULT_CATEGORY_NAME = "M25-54";
var DEFAULT_CHANNEL_NAME  = "radio";
var DEFAULT_ZONE          = "player";
var DEFAULT_HOMEPAGEPATH  = "/home/index.cfm";
var DEFAULT_HOMEPAGEZONE  = "homepage";
var DEFAULT_DISPLAY_OTP   = "true";

/////////////////////////////////////////////////////////////////////////////
/// SET GLOBAL DEFAULT PATH MAPPINGS (Works for 1st Directory in Pathname)
/////////////////////////////////////////////////////////////////////////////


function ConvertPathToZoneName (hp_path, hp_zone, default_zone) {
    var ads_zone_name = "player";
    return ads_zone_name;    
}


function GetFlashVersion() {
    var version = -1;

    if (navigator.plugins && navigator.mimeTypes.length)
    {
        if (navigator.plugins["Shockwave Flash"] && navigator.plugins["Shockwave Flash"].description)
        {
            version = parseInt(navigator.plugins["Shockwave Flash"].description.split('Shockwave Flash ')[1]);
        }           
    }
    else {
        var i = 4;
        while (1) {
            try {
                oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + i + "');");
                if (oFlash) {
                    version = i;
                }
            }
            catch (e) {
                break;
            }
            i = i + 1;
        }
    }
    return version;
}

//////////////////////////////////////////////////////////
/// Ad Object
//////////////////////////////////////////////////////////
if(Ad == "undefined") var Ad = new Object();
function Ad(site, category, display_otp, zone, homepage_path, homepage_zone) {
    var axel = Math.random() + ""; var ord = axel * 1000000000000000000;
    this.attributes = new Array(); 
    
    //Site Attribute
    if (site)           {this.setAttribute('site',     site);}
    else                {this.setAttribute('site',     DEFAULT_SITE_NAME);}
    
    //Category Attribute
    if (category)       {this.setAttribute('category', category);}
    else                {this.setAttribute('category', DEFAULT_CATEGORY_NAME);}
    
    if (display_otp)    {
			 if (display_otp.toLowerCase() == "false") {
				this.setAttribute('displayotp',  "false");
			 }
			 else {
				
				this.setAttribute('displayotp',  "true");
			 }
			}
    else                {this.setAttribute('displayotp',  DEFAULT_DISPLAY_OTP);}

    //Home Page Path Attribute
    if (homepage_path)  {this.setAttribute('homepagepath',  homepage_path);}
    else                {this.setAttribute('homepagepath',  DEFAULT_HOMEPAGEPATH);}

    //Home Page Path Attribute
    if (homepage_zone)  {this.setAttribute('homepagezone',  homepage_zone);}
    else                {this.setAttribute('homepagezone',  DEFAULT_HOMEPAGEZONE);}

    //Zone Attribute
    if (zone)           {this.setAttribute('zone',  zone);}
    else                {
                            this.setAttribute('zone',  DEFAULT_ZONE);
                            this.setAttribute('zone',  ConvertPathToZoneName (this.getAttribute("homepagepath"), this.getAttribute("homepagezone"), DEFAULT_ZONE));
                        }
  
    //DART Attributes used in write method
    this.setAttribute('tile', 1);
    this.setAttribute('ord', ord);
    this.setAttribute('partner', '');
}
Ad.prototype = {
  setAttribute: function(name, value){
    this.attributes[name] = value;
  },
  getAttribute: function(name){
    return this.attributes[name];
  },
  render: function(size, elementid) {

    var str_tiles = "ptile=1;dcopt=ist;";

    if (this.getAttribute("displayotp") == "false") {
        str_tiles = "ptile=1;"; 
    }  
    if (this.getAttribute("tile") != 1) {
	var str_tiles = "ptile=1;"; // + this.getAttribute("tile") + ";";
    }
	var e = document.getElementsByTagName('head').item(0);
	if (elementid) {
		e = document.getElementById(elementid);
        }
        var js_url = 'http://ad.doubleclick.net/adj/' + this.getAttribute("site") + '.site112.tmus/player' + ';part=' + ';page=' + ';flsh=8' + 'sz=' + size + ';ord=' + '?';
	var js = document.createElement('script');
            js.setAttribute('language', 'javascript');
            js.setAttribute('type', 'text/javascript');
            js.setAttribute('src', js_url);
        e.appendChild(js);
        return false;
  },
  write: function(size, tiles, direction, zone){
   if (ads) {
    var str_tiles = "ptile=1;dcopt=ist;";

    if (this.getAttribute("displayotp") == "false") {
        str_tiles = "ptile=1;"; 
    }  
    if (this.getAttribute("tile") != 1) {
	var str_tiles = "ptile=1;"; // + this.getAttribute("tile") + ";";
    }   
    if (tiles) {
        if (direction) {str_tiles = "tn="+tiles+";to="+direction+";tp=1;tbw=0;tsw=0x0;";}
        else           {str_tiles = "tn="+tiles+";to=v;tp=1;tbw=0;tsw=0x0;";}
    }
	var tempZone=this.getAttribute("zone");
	if (zone) {
		this.setAttribute('zone',zone);
	}

    //document.write('<SCR'+'IPT LANGUAGE="JavaScript1.1" SRC="http://ad.doubleclick.net/adj/' + this.getAttribute("site") + '.site112.tmus/' + this.getAttribute("zone") + ';part=' + this.getAttribute("partner") + ';page=' + window.location.pathname + ';flsh=' + GetFlashVersion() + ';' + str_tiles + 'sz=' + size + ';ord=' + this.getAttribute("ord") + '?"><\/SCRIPT>');
	document.write('<SCR'+'IPT LANGUAGE="JavaScript1.1" SRC="http://ad.doubleclick.net/adj/' + this.getAttribute("site") + '.site112.tmus/player' + ';part=' + this.getAttribute("partner") + ';page=' + window.location.pathname + ';flsh=' + GetFlashVersion() + ';' + str_tiles + 'sz=' + size + ';ord=' + this.getAttribute("ord") + '?"><\/SCRIPT>');
    if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0)  || navigator.userAgent.indexOf("WebTV")>= 0) {
        document.write('<A HREF="http://ad.doubleclick.net/jump/' + this.getAttribute("site") + '.site112.tmus/player' +';part=' + this.getAttribute("partner") + ';page=' + window.location.pathname+ ';flsh=-1;' + str_tiles + 'sz=' + size + ';ord=' + this.getAttribute("ord") + '?" TARGET="_blank">');
        document.write('<IMG SRC="http://ad.doubleclick.net/ad/' + this.getAttribute("site") + '.site112.tmus/player' + ';part=' + this.getAttribute("partner") + ';page=' + window.location.pathname + ';flsh=-1;' + str_tiles + 'sz=' + size + ';ord=' + this.getAttribute("ord") + '?" BORDER="0" ALT=""></A>');
    }
    this.setAttribute('tile', this.getAttribute("tile") + 1); 
	this.setAttribute('zone',tempZone);
   }
  }
}



//////////////////////////////////////////////////////////
/// DEPRECIATED FUNCTIONS
//////////////////////////////////////////////////////////
function WriteAdZone(id, unique)  {}
function splice_adjs(z,n)         {}
function splice_adjs_unique(z,n)  {}
function splice_adjs_source(z,n,s){}
function splice_adpop(z,n)        {}


/// COLIN ELION - 2006



