/* ################################################################# */
/*                                                                   */
/*  TITLE:        FULLSCREEN.JS                                      */
/*  SITE:         style.com                                          */
/*  VERSION:      0.03                                               */
/*  LAST UPDATED: 2008/05/19                                         */
/*  UPDATED BY:   Brian Maniere                                      */
/*                                                                   */
/*  FUNCTIONS:                                                       */
/*    openFullScreen()                                               */
/*    resizeThis()                                                   */
/*    getQueryParam()                                                */
/*    ControlVersion()                                               */
/*    flashWrite()                                                   */
/*    flashWrite2()                                                  */
/*    addLoadEvent()                                                 */
/*    updateAd()                                                     */
/*    editBody()                                                     */
/*                                                                   */
/* ################################################################# */
/*
var adRefreshURIpath = location.host;
var adRefreshTest = adRefreshURIpath.indexOf("admin");
if (adRefreshTest !== -1) {
  dart = new Object();
  dart["sz"] = "";
  dart["site"] = "";
  dart["zone"] = "";
  dart["target"] = "";
  dart["dcopt"] = "";
  dart["url"] = "";
}
else {
//  alert("running local");
  var dartCalls = new Array();
  var dartCounter = 0;
  var dartSite = '';
  var dartKeywords = '';
  var dart = new Object();
  dart["sz"] = "300x250";
  dart["site"] = "wstyle.testads.dart";
  dart["zone"] = "";
  dart["target"] = "kw=flashtest;";
  dart["dcopt"] = "";
  dart["url"] = "http://ad.doubleclick.net/adj/";
}


var dartCalls = new Array();
var dartCounter = 0;
var dartSite = '';
var dartKeywords = '';
var dart = new Object();
dart["sz"] = "300x250";
dart["site"] = "flashtest.dart";
dart["zone"] = "";
dart["target"] = "kw=flashtest";
dart["url"] = "";
dart["dcopt"] = "";
*/

var FLASH_CONTENT_VERSION = 9;
var FLASH_CLASS_ID = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
var FLASH_CODEBASE = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';
var FLASH_PLUGINTYPE = 'application/x-shockwave-flash';
var FLASH_PLUGINSPAGE = 'http://www.macromedia.com/go/getflashplayer';
var FLASH_ALLOWSCRIPTACCESS = 'sameDomain';
var FLASH_AUTOPLAY = 'true';
var FLASH_LOOP = 'false';
var FLASH_MENU = 'false';
var FLASH_LIVECONNECT = 'false';
var FLASH_QUALITY = 'high';
var FLASH_DEFAULT_BGCOLOR = '#ffffff';
var FLASH_DEFAULT_ALIGN = 'middle';
var FLASH_DEFAULT_ID = 'styleFlash';

var windowWidth =  screen.availWidth;
var windowHeight = screen.availHeight;

var Navigator = {
  _getVersion: function (a, b) {
    var t = navigator.userAgent.split(a)[1];
    return (t) ? t.split(b)[0] : false;
  },
  isOpera: function () {
    return (
      (window.opera) ?
        (document.createElementNS) ?
          (document.createCDATASection) ?
            (document.styleSheets) ? 9 : 8
          : 7
        : 6
      : false
    );
  },
  isSafari2: function () {
    return (document.createCDATASection && document.createElementNS) ? Navigator._getVersion('AppleWebKit/', '(') : false;
  },
  isKDE: function () {
    return (document.createCDATASection && document.createElementNS) ? Navigator._getVersion('Konqueror/', ';') : false;
  },
  isGecko: function () {
    return (document.createCDATASection && document.createElementNS) ? Navigator._getVersion('Gecko/', ' ') : false;
  },
  isNN4: function () {
    return (document.layers && typeof document.layers == 'object') ? true : false;
  },
  isWinIE: function () {
    return (
      /*@cc_on @if (@_win64 || @_win32 || @_win16)
      (document.getElementsByTagName) ?
        (@_jscript_version > 5.6) ? 7 :
        (@_jscript_version == 5.6) ? 6 :
        (@_jscript_version == 5.5) ? 5.5 :
        5
      : 4
      @else@*/false/*@end @*/
    );
  },
  isMac: function () {
    var av = navigator.appVersion.toLowerCase();
    return ( av.indexOf( 'mac' ) != -1 );
  }
};
var isOpera = Navigator.isOpera();
var isSafari2 = Navigator.isSafari2();
var isKDE = Navigator.isKDE();
var isGecko = Navigator.isGecko();
var isNN4 = Navigator.isNN4();
var isWinIE = Navigator.isWinIE();
var isMac = Navigator.isMac();

function openFullScreen(url) {
  var screenWidth = screen.width;
  var screenHeight = screen.height;
  if (screenHeight <= 600) {
    url = url.replace(/\.html/i,"_small.html");
    return false;
  }
  var winSlideshow = "winSlideshow";
  var features = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + windowWidth + ",height=" + ((isSafari2) ? windowHeight-24 : windowHeight);
  window.open(url,winSlideshow,features);
}

function resizeThis() {
  if (isSafari2) {
    window.moveTo(36,0);
  }
  else {
    window.moveTo(0,0);
  }
  if (document.all) {
    top.window.resizeTo(screen.availWidth,screen.availHeight);
  }
  else if (document.layers || document.getElementById) {
    if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
      top.window.outerHeight = screen.availHeight;
      top.window.outerWidth = screen.availWidth;
    }
  }
}

function getQueryParam(param) {
  var q = document.location.search || document.location.hash;
  if(q) {
    var pairs = q.substring(1).split("&");
    for (var i=0; i < pairs.length; i++) {
      if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
        return pairs[i].substring((pairs[i].indexOf("=")+1));
      }
    }
  }
}

function ControlVersion() {
  var version;
  var axo;
  var e;
    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
  try {
      // version will be set for 7.X or greater players
    axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
    version = axo.GetVariable("$version");
  }
  catch (e) {
  }
  if (!version) {
    try {
        // version will be set for 6.X players only
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
        // installed player is some revision of 6.0
        // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
        // so we have to be careful. 
        // default to the first public version
      version = "WIN 6,0,21,0";
        // throws if AllowScripAccess does not exist (introduced in 6.0r47)   
      axo.AllowScriptAccess = "always";
        // safe to call for 6.0r47 or greater
      version = axo.GetVariable("$version");
    }
    catch (e) {
    }
  }
  if (!version) {
    try {
        // version will be set for 4.X or 5.X player
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
      version = axo.GetVariable("$version");
    } catch (e) {
    }
  }
  if (!version) {
    try {
        // version will be set for 3.X player
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
      version = "WIN 3,0,18,0";
    }
    catch (e) {
    }
  }
  if (!version) {
    try {
        // version will be set for 2.X player
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      version = "WIN 2,0,0,11";
    }
    catch (e) {
      version = -1;
    }
  }
  return version;
}

function flashWrite(strMovie, divName, divLayer, intWidth, intHeight, hexBgcolor, strId, strAlign, intFlashVersion, strPlay, strLoop, strMenu, auxVars) {
  var blnPluginPresent = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if ( blnPluginPresent ) {
    var words = navigator.plugins["Shockwave Flash"].description.split(" ");
      for (var i = 0; i < words.length; ++i) {
        if (isNaN(parseInt(words[i])))
          continue;
        var intPluginVersion = words[i]; 
      }
    blnFlashCanPlay = intPluginVersion >= FLASH_CONTENT_VERSION;
  }
  else if (isWinIE) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
    document.write('on error resume next \n');
    document.write('blnFlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & FLASH_CONTENT_VERSION)))\n');
    document.write('</SCR' + 'IPT\> \n');
  }
  if ( blnFlashCanPlay ) {
    hexBgcolor = (hexBgcolor) ? hexBgcolor : FLASH_DEFAULT_BGCOLOR;
    strId = (strId) ? strId : FLASH_DEFAULT_ID;
    strAlign = (strAlign) ? strAlign : FLASH_DEFAULT_ALIGN;
    intFlashVersion = (intFlashVersion) ? intFlashVersion : FLASH_CONTENT_VERSION;
    strPlay = (strPlay) ? strPlay : FLASH_AUTOPLAY;
    strLoop = (strLoop) ? strLoop : FLASH_LOOP;
    strMenu = (strMenu) ? strMenu : FLASH_MENU;
    divLayer = (divLayer) ? divLayer : divLayer;
    document.write('<OBJECT classid="' + FLASH_CLASS_ID + '"');
    document.write(' codebase="' + FLASH_CODEBASE + '" ');
    document.write(' ID="' + strId + '" WIDTH="' + intWidth + '" HEIGHT="' + intHeight + '" ALIGN="' + strAlign + '">');
    document.write(' <PARAM NAME="movie" VALUE="' + strMovie + '"?dartSZ=' + dart["sz"] + '&dart_site=' + dart["site"] + '&dart_zone=' + dart["zone"] + '&dart_target=' + dart["target"] + '&dart_dcopt=' + dart["dcopt"] + '&dart_url=' + escape(dart["url"]) + '"> ');
    document.write(' <PARAM NAME="quality" VALUE="' + FLASH_QUALITY + '"><PARAM NAME="wmode" VALUE="transparent"><PARAM NAME="MENU" VALUE="' + strMenu + '"><PARAM NAME="LOOP" VALUE="' + strLoop + '"><PARAM NAME="PLAY" VALUE="' + strPlay + '"><PARAM NAME="bgcolor" VALUE="' + hexBgcolor + '"> '); 
    document.write(' <PARAM NAME="FlashVars" VALUE="'+auxVars+'&trend_id='+getQueryParam("t_id")+'&dartSZ=' + dart["sz"] + '&dart_site=' + dart["site"] + '&dart_zone=' + dart["zone"] + '&dart_target=' + dart["target"] + '&dart_dcopt=' + dart["dcopt"] + '&dart_url=' + escape(dart["url"]) + '"> ');
    document.write(' <EMBED src= "' + strMovie + '?dartSZ=' + dart["sz"] + '&dart_site=' + dart["site"] + '&dart_zone=' + dart["zone"] + '&dart_target=' + dart["target"] + '&dart_dcopt=' + dart["dcopt"] + '&dart_url=' + escape(dart["url"]) + '" ');
    document.write(' flashvars="'+auxVars+'&trend_id='+getQueryParam("t_id")+'" quality="' + FLASH_QUALITY + '" play="' + strPlay + '" loop="' + strLoop + '" menu="' + strMenu + '" bgcolor="' + hexBgcolor + '"  wmode="transparent" ');
    document.write(' swLiveConnect="' + FLASH_LIVECONNECT + '" WIDTH="' + intWidth + '" HEIGHT="' + intHeight + '" NAME="' + strId + '" ALIGN="' + strAlign + '"');
    document.write(' TYPE="' + FLASH_PLUGINTYPE + '" PLUGINSPAGE="' + FLASH_PLUGINSPAGE + '">');
    document.write(' </EMBED>');
    document.write(' </OBJECT>');
  }
  else {
    document.getElementById(divName).style.display="block";
  }
}

function flashWrite2(strMovie, divName, divLayer, intWidth, intHeight, hexBgcolor, strId, strAlign, intFlashVersion, strPlay, strLoop, strMenu, auxVars) {
  intFlashVersion = (intFlashVersion) ? intFlashVersion : FLASH_CONTENT_VERSION;
  var blnPluginPresent = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if ( blnPluginPresent != 0 ) { 
    var words = navigator.plugins["Shockwave Flash"].description.split(" ");
    for (var i = 0; i < words.length; ++i) {
      if (isNaN(parseInt(words[i]))) {
        continue;
      }
      var intPluginVersion = words[i]; 
    }
    intPluginVersion = parseInt(intPluginVersion);  
  }
    // Internet Explorer does not properly support navigator object
  if ( blnPluginPresent == 0 && document.all ) {
    intPluginVersion = ControlVersion();            
    if ( intPluginVersion != -1 ) {    
      // Given "WIN 2,0,0,11"
      tempArray        = intPluginVersion.split(" ");  // ["WIN", "2,0,0,11"]
      tempString       = tempArray[1];     // "2,0,0,11"
      versionArray     = tempString.split(",");  // ['2', '0', '0', '11']      
      intPluginVersion = versionArray[0];    
    }
  }
  if (intPluginVersion >= intFlashVersion) {
    blnFlashCanPlay = true;
  }
  if ( blnFlashCanPlay ) {
    hexBgcolor = (hexBgcolor) ? hexBgcolor : FLASH_DEFAULT_BGCOLOR;
    strId = (strId) ? strId : FLASH_DEFAULT_ID;
    strAlign = (strAlign) ? strAlign : FLASH_DEFAULT_ALIGN;
    strPlay = (strPlay) ? strPlay : FLASH_AUTOPLAY;
    strLoop = (strLoop) ? strLoop : FLASH_LOOP;
    strMenu = (strMenu) ? strMenu : FLASH_MENU;
    divLayer = (divLayer) ? divLayer : divLayer;
    intWidth = (intWidth) ? intWidth : windowWidth-300;
    intHeight = (intHeight) ? intHeight : windowHeight - 44;
    if (isGecko && isMac) intHeight = windowHeight - 40;
    if (isWinIE) intHeight = windowHeight - 25;
    if (isSafari2) {
     intHeight = windowHeight - 23;
    }
    document.write('<OBJECT classid="' + FLASH_CLASS_ID + '"');
    document.write(' codebase="' + FLASH_CODEBASE + '" ');
    document.write(' ID="' + strId + '" WIDTH="' + intWidth + '" HEIGHT="100%" ALIGN="' + strAlign + '">');
    document.write(' <PARAM NAME="movie" VALUE="' + strMovie + '"?dartSZ=' + dart["sz"] + '&dart_site=' + dart["site"] + '&dart_zone=' + dart["zone"] + '&dart_target=' + dart["target"] + '&dart_dcopt=' + dart["dcopt"] + '&dart_url=' + escape(dart["url"]) + '"> ');
    document.write(' <PARAM NAME="quality" VALUE="' + FLASH_QUALITY + '"><PARAM NAME="wmode" VALUE="transparent"><PARAM NAME="MENU" VALUE="' + strMenu + '"><PARAM NAME="LOOP" VALUE="' + strLoop + '"><PARAM NAME="PLAY" VALUE="' + strPlay + '"><PARAM NAME="bgcolor" VALUE="' + hexBgcolor + '"> '); 
    document.write(' <PARAM NAME="FlashVars" VALUE="'+auxVars+'&flashWidth='+intWidth+'&flashHeight=' + intHeight + '&trend_id='+getQueryParam("t_id")+'&dartSZ=' + dart["sz"] + '&dart_site=' + dart["site"] + '&dart_zone=' + dart["zone"] + '&dart_target=' + dart["target"] + '&dart_dcopt=' + dart["dcopt"] + '&dart_url=' + escape(dart["url"]) + '"> ');
    document.write(' <EMBED src= "' + strMovie + '?flashWidth=' + intWidth + '&flashHeight='+intHeight+'&dartSZ=' + dart["sz"] + '&dart_site=' + dart["site"] + '&dart_zone=' + dart["zone"] + '&dart_target=' + dart["target"] + '&dart_dcopt=' + dart["dcopt"] + '&dart_url=' + escape(dart["url"]) + '" ');
    document.write(' flashvars="'+auxVars+'&flashWidth='+intWidth+'&flashHeight='+intHeight+'&trend_id='+getQueryParam("t_id")+'" quality="' + FLASH_QUALITY + '" play="' + strPlay + '" loop="' + strLoop + '" menu="' + strMenu + '" bgcolor="' + hexBgcolor + '"  wmode="transparent" ');
    document.write(' swLiveConnect="' + FLASH_LIVECONNECT + '" WIDTH="' + intWidth + '" HEIGHT=' + intHeight + ' NAME="' + strId + '" ALIGN="' + strAlign + '"');
    document.write(' TYPE="' + FLASH_PLUGINTYPE + '" PLUGINSPAGE="' + FLASH_PLUGINSPAGE + '">');
    document.write(' </EMBED>');
    document.write(' </OBJECT>');
  }
  else {
    document.getElementById(divName).style.display="block";
  }
}

function addLoadEvent(func) {
  var oldOnload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  }
  else {
    window.onload = function() {
      oldOnload();
      func();
    }
  }
}

function alertTest(args) {
  alert("alertTest: " + args);
}

function gotoParent(plink) {
    opener.location = plink;
    window.close();
}