function staf_SE() {

/*
 * 	 Author : STaF Team
 *
 */


	var omniture_tracking;

	// Email This variables
	var width, height;        // Width and Height of Email Popup
	var im_width, im_height;  // Width and Height of Email Popup
	var lang = "";            // Language parameter

	// IM Variables
	var message = "";        // IM Message
	var linkURL = "";        // Default URL is the current page.
	var pageTitle = "";      // Page Title
	var confirm = false;     // Confirmation pop-up window for non-AOL browsers

	// Launch IM
	var sendIM = function () {
		winl = (screen.width - im_width) / 2;
		wint = (screen.height - im_height) / 2;

		if (winl < 0) winl = 0;
		if (wint < 0) wint = 0;

		window.open("http://sendtoafriend.aol.com/im.adp?url=" + linkURL + "&title=" + pageTitle + "&lang=" + lang, "IM_Window", "height=" + im_height + ",width=" + im_width + ",top=" + wint + ",left=" + winl + ",statusbar=0,toolbar=0,menubar=0,location=0,resizable=0");
	}

	// Launch Email
	var sendEmail = function () {
		winl = (screen.width - width) / 2;
		wint = (screen.height - height) / 2;

		if (winl < 0) winl = 0;
		if (wint < 0) wint = 0;

		window.open("http://sendtoafriend.aol.com/?url=" + linkURL + "&title=" + pageTitle + "&lang=" + lang, "Email_Window", "height=" + height + ",width=" + width + ",top=" + wint + ",left=" + winl + ",statusbar=0,toolbar=0,menubar=0,location=0,resizable=0");
	}

	// Default Values
	var setDefault = function () {
		message = "Your friend wants you to check this out:";
		linkURL = escape(document.location);
		pageTitle = escape(document.title);
		confirm = false;
		width = 292;
		height = 500;
		im_width = 292;
		im_height = 150;
		lang = "en-US";
	}

	// Set default values.
	setDefault();

	return {

		sendIM: function () {

			if (omniture_tracking) {
				setOmniStaf("IM");
			}

			sendIM();
		},

		sendEmail: function () {

			if (omniture_tracking) {
				setOmniStaf("Email");
			}

			sendEmail();
		},

		setMessage: function (custom_message) {
			if (typeof(custom_message) == "string") {
				message = custom_message;
			}
		},

		setWidth: function (custom_width) {
			if (typeof(custom_width) == "number") {
				width = custom_width;
			}
		},

		setHeight: function (custom_height) {
			if (typeof(custom_height) == "number") {
				height = custom_height;
			}
		},

		setIMWidth: function (custom_width) {
			if (typeof(custom_width) == "number") {
				im_width = custom_width;
			}
		},

		setIMHeight: function (custom_height) {
			if (typeof(custom_height) == "number") {
				im_height = custom_height;
			}
		},

		setLang: function (custom_lang) {
			if (typeof(custom_lang) == "string") {
				lang = custom_lang;
			}
		},

		setTitle: function (custom_title) {
			if (typeof(custom_title) =="string") {
				pageTitle = escape(custom_title);
			}
		},

		setURL: function (custom_url) {
			if (typeof(custom_url) =="string") {
				linkURL = escape(custom_url);
			}
		}

	};

}
/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(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));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	if (window.opera || !document.all) return;
	var objects = document.getElementsByTagName("OBJECT");
	for (var i=0; i < objects.length; i++) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
deconcept.SWFObjectUtil.prepUnload = function() {
	__flash_unloadHandler = function(){};
	__flash_savedUnloadHandler = function(){};
	if (typeof window.onunload == 'function') {
		var oldUnload = window.onunload;
		window.onunload = function() {
			deconcept.SWFObjectUtil.cleanupSWFs();
			oldUnload();
		}
	} else {
		window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
	}
}
if (typeof window.onbeforeunload == 'function') {
	var oldBeforeUnload = window.onbeforeunload;
	window.onbeforeunload = function() {
		deconcept.SWFObjectUtil.prepUnload();
		oldBeforeUnload();
	}
} else {
	window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

/*
  -- AOL Standard Feed Subscribe Widget --
  Author: Miodrag Kekic (miodrag.kekic@corp.aol.com)

  Credits:
    Dom object is based on Yahoo UILib YAHOO.util.Dom version 0.11.1
    Copyright (c) 2006, Yahoo! Inc. All rights reserved.
    License: http://developer.yahoo.net/yui/license.txt
*/

new function() {  // closure start

var sfsw =  {

   version: "1.3",
   Locale: 'en_us',  // i18n locale
   CustomText: null,        // custom text - i18n etc.
   CustomMyAOLReader: null, // custom myAOL link
   CustomReaders: null,     // custom reader list
   CustomAlertLink: null,   // custom alert link

   UpdateFeeds: null,

   refEl: null,
   popup: null,
   anchor: null,
   popupFirstTime : false,

   // Template patterns
   atomFeed: null,
   rssFeed:  null,

   /*
     * Customize the widget text
   */
   setText: function( text ) {
      this.CustomText = text;
   },

   /*
    * Customize the widget readers
    */
   setReaders: function( readers ) {
      this.CustomReaders = readers;
      this.atomFeed = this.rssFeed  = null;
   },
   setMyAOLReader: function( myAOL ) {
      this.CustomMyAOLReader = myAOL;
      this.atomFeed = this.rssFeed  = null;
   },

   /*
    * Customize the alert link
    */
   setAlertLink: function( link ) {
      this.CustomAlertLink = link;
      this.atomFeed = this.rssFeed  = null;
   },

   show: function(refEl, atomFeed, rssFeed, anchor) {
      var atom = atomFeed || null;
      var rss  = rssFeed  || null;
      setFeedURLs( atom, rss );
      this.anchor = anchor || null;

      var popup = document.getElementById( POPUP_ID );

      if ( ! popup ) {
         popup = document.createElement('div');
         popup.id  = POPUP_ID;
         popup.className = getClass();
         popup.style.position = 'absolute';
         popup.style.left = '0px';
         popup.style.top  = '0px';
         if ( refEl ) {
             popup.style.display = 'none';
             Dom.setOpacity(popup, 0);
         }
         document.body.appendChild(popup);
         popup.innerHTML = getHtml();
         configFeeds(popup);
         if ( refEl ) {
             popup.style.display = 'block';
             setTimeout(function() { fadeInPopup(0); }, 100);
         }
         else {
             setTimeout(function() { refreshImages(); }, 500);
         }
      } 
      else if ( refEl && popup.style.display != 'none' &&
                refEl == this.refEl ){
         closeTwisty();
         popup.style.display = 'none';
         return popup;
      }
      else  {
         if ( this.UpdateFeeds) {
            popup.innerHTML = getHtml();
            configFeeds(popup);
         }
         closeTwisty();
         if ( refEl ) {
            Dom.setOpacity(popup, 0);
         }
         popup.style.display = 'block';
         if ( refEl ) {
            setTimeout(function() { fadeInPopup(0); }, 100);
         }
      }

      this.popup = popup;
      this.refEl = refEl;
      return popup;
   },
 
   // Aol Journals friendly way to show popup using blog
   showBlog: function(refEl, blogURL, anchor) {
      var feeds = blogToFeedURLs(blogURL);
      return this.show(refEl, feeds[0], feeds[1], anchor );
   },

   // Show/hide subscribe popup
   hide: function () {
      var popup = document.getElementById( POPUP_ID );
      if ( popup != null ) {
         closeTwisty();
         popup.style.display = 'none';
      }
      return false;
   },

   // Turn twisty on/off
   toggleTwisty: function() {
      var feedsNode = document.getElementById( URLS_ID );
      var twistyImg = document.getElementById( TWISTY_ID );

      if ( twistyImg == null || feedsNode == null ) { return false; } // error

      if ( feedsNode.style.display == 'none' ) {
         twistyImg.className='twisty_open';
         feedsNode.style.height = '0px';
         feedsNode.style.display = 'block';
         slideDiv(0, false);
      }
      else {
         twistyImg.className='twisty_closed';
         slideDiv(100, true);
      }
      return false;
   }
}; // end of sfsw

// Text for the widget
var LocaleVars = {
   Text: {
      close    : 'Close', 
      text_0   : 'Subscribe To Updates Using myAOL', 
      text_1   : 'Looking for another service?',
      text_2   : 'Get the feed manually',
      text_3   : 'Copy and paste the appropriate feed into your reader.',
      text_3a  : 'Copy and paste this URL feed into your feed reader.',
      text_4   : 'RSS',
      text_5   : 'or',
      text_6   : 'Atom',
      text_7   : 'Set up an alert for the feed'
   },

   // The main reader - myAOL
   myAOLReader: {
     url:  'http://feeds.my.aol.com/add.jsp?url=__FEED__',
     img:  'http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/feed-icons/myaol_cta1.gif',
     text: 'Subscribe via MyAOL',
     whatis_url: 'http://my.aol.com/v.6/locale/en_US/aol/help/tours_start.htm',
     whatis_text: 'what is myAOL?'
   },

   // Feed Readers' definition
   Readers: {
   reader_1: {
     url:  'http://fusion.google.com/add?feedurl=__FEED__',
     img:  'http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/feed-icons/googlereader.gif',
     text: 'Subscribe via Google Reader',
     id:   'google'
     },
   reader_2: {
     url:  'http://www.newsgator.com/ngs/subscriber/subext.aspx?url=__FEED__',
     img:  'http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/feed-icons/ngsub1.gif',
     text: 'Subscribe via NewsGator',
     id:   'newsgator'
     },
   reader_3: {
     url:  'http://www.bloglines.com/sub/__FEED__',
     img:  'http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/feed-icons/sub_modern5.gif',
     text: 'Subscribe via Bloglines',
     id:   'bloglines'
     },
   reader_4: {
     url:  'http://add.my.yahoo.com/content?url=__FEED__',
     img:  'http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/feed-icons/addtomyyahoo4.gif',
     text: 'Subscribe via Yahoo Reader',
     id:   'yahoo'
     },
   reader_5: {
     url:  'http://www.netvibes.com/subscribe.php?url=__FEED__',
     img:  'http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/feed-icons/add2netvibes.gif',
     text: 'Subscribe via Netvibes',
     id:   'netvibes'
     },
   reader_6: {
     url:  'http://www.pageflakes.com/subscribe.aspx?url=__FEED__',
     img:  'http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/feed-icons/pageflakes_add.gif',
     text: 'Subscribe via Pageflakes',
     id:   'pageflakes'
     }
   },

   AlertLink: 'http://alerts.aol.com/ar/dlink/dlink.rr?dl_type=rss&amp;dl_data=__FEED__'

};

var POPUP_ID  = "aol_feeds_subscribe_popup";
var URLS_ID   = "aol_feeds_subscribe_urls";
var TWISTY_ID = "aol_feeds_subscribe_twisty_img";	

function closeTwisty() {
   var feedsNode = document.getElementById( URLS_ID );
   var twistyImg = document.getElementById( TWISTY_ID );
   if ( twistyImg == null || feedsNode == null ) { return false; } // error
   feedsNode.style.display = 'none';
   twistyImg.className='twisty_closed';
}

function blogToFeedURLs(blogURL) {
   var feeds = [];
   var slash = (blogURL.lastIndexOf('/') == (blogURL.length - 1)) ? '' : '/';
   feeds[0] = blogURL + slash + "atom.xml";
   feeds[1] = blogURL + slash + "rss.xml";
   return feeds;
}

function setFeedURLs(atomFeed, rssFeed) {
   var changed = false;
   if ( sfsw.atomFeed != atomFeed ) {
        sfsw.atomFeed = atomFeed;
        changed = true;
   }
   if ( sfsw.rssFeed != rssFeed ) {
        sfsw.rssFeed = rssFeed;
       changed = true;
   }
   if ( changed ) {
      sfsw.UpdateFeeds = {
           atomFeed: sfsw.atomFeed,
           rssFeed:  sfsw.rssFeed 
      };
   }
}

// Find the widget base
 function getBase() {
   var scripts = document.getElementsByTagName('script');
   for ( var i=0; i < scripts.length; i++) {
      var src = scripts[i].src;
      if ( src && src.length ) {
         if ( src == 'feeds_subscribe_en_us.js' ) { return ''; }
         if ( /\/feeds_subscribe_en_us.js$/.test(src) ) {
            return src.replace(/(^.*\/)feeds_subscribe_en_us.js/, "$1");
         }
      }
   }
   return null;
};

// Replace feed vars in the widget popup template
function replaceFeedVars(el, attr) {
   var atomFeed = sfsw.UpdateFeeds.atomFeed;
   var rssFeed  = sfsw.UpdateFeeds.rssFeed;
   var feed     = atomFeed || rssFeed;
   if ( el[attr] ) {
      replaceFeedVar( el, attr, '__FEED__', feed);
      replaceFeedVar( el, attr, '__ATOM_FEED__', atomFeed);
      replaceFeedVar( el, attr, '__RSS_FEED__', rssFeed);
      if ( el[attr].indexOf('http://some.domain.com/') == 0 ) {
          el[attr] = el[attr].replace('http://some.domain.com/', '');
      }
   }
}

function replaceFeedVar(el, attr, feedVar, feed) {
   if ( el[attr] ) {
      if ( el[attr].indexOf('/' + feedVar) >= 0 ) {
         el[attr] = el[attr].replace(feedVar, encodeURI(feed));
      }
      else if ( el[attr].indexOf('=' + feedVar) >= 0 ) {
         el[attr] = el[attr].replace(feedVar, encodeURIComponent(feed));
      }
      else if ( el[attr].indexOf(feedVar) >= 0 ) {
         el[attr] = el[attr].replace(feedVar, feed);
      }
   }
};

 function configFeeds(popup) {
   if ( sfsw.UpdateFeeds == null ) { return ; }
   var els = popup.getElementsByTagName('a');
   for ( var i=0; i < els.length; i++ ) {
      if ( els[i].href ) {
         replaceFeedVars( els[i], "href" );
      }
   } 
   els = popup.getElementsByTagName('input');
   for ( var i=0; i < els.length; i++ ) {
      if ( els[i].value ) {
         replaceFeedVars( els[i], "value" );
      }
   } 

   // Hide rss or atom feed if undefined
   var el = document.getElementById('aol_feeds_subscribe_rss_feed');
   if ( el ) {
      el.style.display = sfsw.rssFeed == null ? 'none' : '';
   }
   el = document.getElementById('aol_feeds_subscribe_atom_feed');
   if ( el ) {
      el.style.display = sfsw.atomFeed == null ? 'none' : '';
   }

   if ( sfsw.CustomReaders == null &&
      sfsw.CustomAlertLink == null ) {
      sfsw.UpdateFeeds = null;
    }
}

// First popup display might need repositioning. Use fade-in to mask movement.  
function fadeInPopup(opacity) { 
   var  anchor = sfsw.anchor;
   if ( sfsw.popup != null && sfsw.refEl != null ) {
      setPosition(sfsw.refEl, sfsw.popup);
      Dom.setOpacity(sfsw.popup, opacity/100);
      if ( opacity < 100 ) {
         opacity += 10;
         sfsw.anchor = anchor;
         setTimeout(function(){fadeInPopup(opacity);}, 50);
      }
      else if ( ! sfsw.popupFirstTime ) {
         sfsw.popupFirstTime = true;
         setTimeout(function() {refreshImages();}, 200);
      }
   }
}

// Refresh img src and background images on first widget show (IE workaround)
function refreshImages() {
   if ( sfsw.popup ) {
       var images = sfsw.popup.getElementsByTagName('img');
       for ( var i=0; i < images.length; i++ ) {
           images[i].src = images[i].src;
           var className = images[i].className;
           if ( className ) {
               images[i].className = className;
           }
       }
   }
}

// Slide in/out visual effect
function  slideDiv(percent, slideIn) { 
   var feedsNode = document.getElementById( URLS_ID );
   if ( ! slideIn ) {
      percent += 10;
      if ( percent > 90 ) {
         feedsNode.style.height = 'auto';
         if ( sfsw.anchor ) { setPosition(); }
         return;
      }
   }
   else {
      percent -= 10;
      if ( percent < 10 ) {
         feedsNode.style.display = 'none';
         if ( sfsw.anchor ) { setPosition(); }
         return;
      }
   }
   var height = feedsNode.scrollHeight;
   height = Math.round(height*(percent/100));
   feedsNode.style.height = height + 'px';
   if ( sfsw.anchor ) { setPosition(); }
   setTimeout(function(){slideDiv(percent,slideIn);}, 50);
}

function setPosition(refEl, popup) { 

   refEl = refEl || sfsw.refEl;
   if ( refEl == null || refEl == document.body ) { return; }
   popup = popup || sfsw.popup;

   var anchor   = sfsw.anchor;    
   popup.style.position = 'absolute';

   // Ref el geometry
   var elXY = Dom.getXY(refEl);
   if ( ! elXY ) { return; }
   var elLeft = elXY[0];
   var elTop  = elXY[1];
   var elWidth  = refEl.offsetWidth;
   var elHeight = refEl.offsetHeight;

    // Viewport geometry 
   var vpLeft   = document.documentElement.scrollLeft ||
                  document.body.scrollLeft;
   var vpTop    = document.documentElement.scrollTop  ||
                  document.body.scrollTop ;
   var vpWidth  = Dom.getViewportWidth();
   var vpHeight = Dom.getViewportHeight();

   if ( elLeft < vpLeft) { vpWidth += vpLeft - elLeft; vpLeft = elLeft; }
   if ( vpWidth < (elLeft + elWidth) ) { vpWidth = elLeft + elWidth; }

   var vpLeftMax = vpLeft + vpWidth;
   var vpTopMax  = vpTop  + vpHeight;

    // Popup geometry
   var popupLeft = 0;
   var popupTop  = 0;
   var popupLeftMax = 0;
   var popupTopMax = 0;
   var popupWidth = popup.offsetWidth;
   var popupHeight = popup.offsetHeight;

    // Position 1: bottom left [SW]
   popupLeft = elLeft;
   popupTop  = elTop + elHeight;
   if ( 'SW' == anchor) {
      Dom.setXY(popup, [ popupLeft, popupTop ]);
      return;        
   }
   else if ( ! anchor ) {
      popupLeftMax = popupLeft + popupWidth;
      popupTopMax  = popupTop  + popupHeight;
      if (  popupTop  >= vpTop  && popupTopMax  <= vpTopMax   && 
            popupLeft >= vpLeft && popupLeftMax <= vpLeftMax  ) {
         Dom.setXY(popup, [ popupLeft, popupTop ]);
         sfsw.anchor = 'SW';
         return;
      }
   }

   // Position 2: bottom right [SE]
   popupLeft = elLeft + elWidth - popupWidth;
   popupTop  = elTop + elHeight;
   if ( 'SE' == anchor) {
      Dom.setXY(popup, [ popupLeft, popupTop ]);
      return;        
   }
   else if ( ! anchor ) {
      popupLeftMax = popupLeft + popupWidth;
      popupTopMax  = popupTop  + popupHeight;
      if (  popupTop  >= vpTop  && popupTopMax  <= vpTopMax   && 
            popupLeft >= vpLeft && popupLeftMax <= vpLeftMax  ) {
         Dom.setXY(popup, [ popupLeft, popupTop ]);
         sfsw.anchor = 'SE';
         return;
      }
   }

   // Position 3: top left [NW]
   popupLeft = elLeft;
   popupTop  = elTop - popupHeight;
   if ( 'NW' == anchor) {
      Dom.setXY(popup, [ popupLeft, popupTop ]);
      return;        
   }    
   else if ( ! anchor ) {
      popupLeftMax = popupLeft + popupWidth;
      popupTopMax  = popupTop  + popupHeight;
      if (  popupTop  >= vpTop  && popupTopMax  <= vpTopMax   && 
            popupLeft >= vpLeft && popupLeftMax <= vpLeftMax  ) {
         Dom.setXY(popup, [ popupLeft, popupTop ]);
         sfsw.anchor = 'NW';
         return;
      }
   }

   // Position 4: top right [NE]
   popupLeft = elLeft + elWidth - popupWidth;
   popupTop  = elTop - popupHeight;
   if ( 'NE' == anchor) {
      Dom.setXY(popup, [ popupLeft, popupTop ]);
      return;        
   }
   else if ( ! anchor ) {
      popupLeftMax = popupLeft + popupWidth;
      popupTopMax  = popupTop  + popupHeight;
      if (  popupTop  >= vpTop  && popupTopMax  <= vpTopMax   && 
            popupLeft >= vpLeft && popupLeftMax <= vpLeftMax  ) {
         Dom.setXY(popup, [ popupLeft, popupTop ]);
         sfsw.anchor = 'NE';
         return;
      }
   }

   // Can not fit in viewport - apply position 1 or 2
   // Position 1: bottom left /SW
   popupLeft = elLeft;
   popupTop  = elTop + elHeight;
   popupLeftMax = popupLeft + popupWidth;
   if ( popupLeft >= vpLeft && popupLeftMax <= vpLeftMax  ) {
      Dom.setXY(popup, [ popupLeft, popupTop ]);
      sfsw.anchor = 'SW';
      return;
   }

   // Position 2: bottom right /SE
   popupLeft = elLeft + elWidth - popupWidth;
   popupTop  = elTop + elHeight;
   popupLeftMax = popupLeft + popupWidth;
   if ( popupLeft >= vpLeft && popupLeftMax <= vpLeftMax  ) {
      Dom.setXY(popup, [ popupLeft, popupTop ]);
      sfsw.anchor = 'SE';
      return;
   }

   Dom.setXY(popup, [elLeft, elTop + elHeight]);
}
   
/*
  Dom object is created from the Yahoo UILib YAHOO.util.Dom version 0.11.1
*/
var Dom = {
   isOpera: (navigator.userAgent.toLowerCase().indexOf('opera') > -1),
   isSafari: (navigator.userAgent.toLowerCase().indexOf('safari') > -1),
   isFirefox: (navigator.userAgent.toLowerCase().indexOf('firefox') > -1),
   isIE: !!window.ActiveXObject,

   toCamel: function(property) {
      var convert = function(prop) {
         var test = /(-[a-z])/i.exec(prop);
         return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
      };
      while(property.indexOf('-') > -1) {
         property = convert(property);
      }
      return property;
   },
   
   toHyphen: function(property) {
      if (property.indexOf('-') > -1) { // assume hyphen
         return property;
      }
      var converted = '';
      for (var i = 0, len = property.length;i < len; ++i) {
         if (property.charAt(i) == property.charAt(i).toUpperCase()) {
            converted = converted + '-' + property.charAt(i).toLowerCase();
         } else {
            converted = converted + property.charAt(i);
         }
      }
      return converted;
   },

   getStyle: function(el, property) {
      var Dom = this;
      var value = null;
      var dv = document.defaultView;

      var camel =  Dom.toCamel(property);
      var hyphen = Dom.toHyphen(property);

      if (el.style[camel]) { // camelCase for valid styles
         value = el.style[camel];
      }
      else if (Dom.isIE && el.currentStyle && el.currentStyle[camel]) {
         // camelCase for currentStyle;
         // isIE to workaround broken Opera 9 currentStyle
         value = el.currentStyle[camel];
      }
      else if ( dv && dv.getComputedStyle ) {
         // hyphen-case for computedStyle
         var computed = dv.getComputedStyle(el, '');
         if (computed && computed.getPropertyValue(hyphen)) {
            value = computed.getPropertyValue(hyphen);
         }
      }
      return value;
   },

   setOpacity: function(el, val) {
      var Dom = this;
      if (Dom.isIE && typeof el.style.filter == 'string') {
         el.style.filter = 'alpha(opacity=' + val * 100 + ')';
      }
      else {
        el.style.opacity = val;
        el.style['-moz-opacity'] = val;
        el.style['-khtml-opacity'] = val;
      }
   },

   getXY: function(el) {
      var Dom = this;
      
      // has to be part of document to have pageXY
      if (el.offsetParent === null || Dom.getStyle(el, 'display') == 'none') {
         return false;
      }
         
      var parentNode = null;
      var pos = [];
      var box;
         
      if (el.getBoundingClientRect) { // IE
         box = el.getBoundingClientRect();
         var doc = document;
         if ( !Dom.inDocument(el) && parent.document != document) {
            // might be in a frame, need to get its scroll
            doc = parent.document;
   
            if ( !Dom.isAncestor(doc.documentElement, el) ) {
               return false;                 
            }
         }

         var scrollTop = Math.max(doc.documentElement.scrollTop,
                                  doc.body.scrollTop);
         var scrollLeft = Math.max(doc.documentElement.scrollLeft,
                                  doc.body.scrollLeft);
         return [box.left + scrollLeft, box.top + scrollTop];
      }
      else { // safari, opera, & gecko
         pos = [el.offsetLeft, el.offsetTop];
         parentNode = el.offsetParent;
         if (parentNode != el) {
            while (parentNode) {
               pos[0] += parentNode.offsetLeft;
               pos[1] += parentNode.offsetTop;
               parentNode = parentNode.offsetParent;
            }
         }
         if (Dom.isSafari && Dom.getStyle(el, 'position') == 'absolute' ) {
            // safari doubles in some cases
            pos[0] -= document.body.offsetLeft;
            pos[1] -= document.body.offsetTop;
         } 
      }

      if (el.parentNode) { parentNode = el.parentNode; }
      else { parentNode = null; }

      while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' &&
             parentNode.tagName.toUpperCase() != 'HTML') 
      { // account for any scrolled ancestors
         pos[0] -= parentNode.scrollLeft;
         pos[1] -= parentNode.scrollTop;

         if (parentNode.parentNode) { parentNode = parentNode.parentNode; } 
         else { parentNode = null; }
      }
      return pos;
   },

   setXY: function(el, pos, noRetry) {
      var Dom = this;
      var style_pos = Dom.getStyle(el, 'position');
      if (style_pos == 'static') { // default to relative
         el.style.position = 'relative';
         style_pos = 'relative';
      }

      var pageXY = Dom.getXY(el);
      if (pageXY === false) {return false;} //has to be part of doc to have pageXY

      var delta = [ // assuming pixels; if not we will have to retry
         parseInt( Dom.getStyle(el, 'left'), 10 ),
         parseInt( Dom.getStyle(el, 'top'), 10 )
      ];

      if ( isNaN(delta[0]) ) {// in case of 'auto'
         delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
      }
      if ( isNaN(delta[1]) ) { // in case of 'auto'
         delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
      }

      if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
      if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }

      var newXY = Dom.getXY(el);

      // if retry is true, try one more time if we miss 
      if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) {
         Dom.setXY(el, pos, true);
      }
   },

    isAncestor: function(haystack, needle) {
      if (!haystack || !needle) { return false; }
      var Dom = this;

      if (haystack.contains && !Dom.isSafari) {
         // safari "contains" is broken
         return haystack.contains(needle);
      }
      else if ( haystack.compareDocumentPosition ) {
         return (haystack.compareDocumentPosition(needle) & 16) != 0;
      }
      else { // loop up and test each parent
         var parent = needle.parentNode;
      
         while (parent) {
            if (parent == haystack) {
               return true;
            }
            else if (parent.tagName.toUpperCase() == 'HTML') {
               return false;
            }
            parent = parent.parentNode;
         }
         return false;
      }
    },

    inDocument: function(el) {
      var Dom = this;
      return Dom.isAncestor(document.documentElement, el);
   },

   getViewportHeight: function() {
      var Dom = this;
      var height = -1;
      var mode = document.compatMode;

      if ( (mode || Dom.isIE) && !Dom.isOpera ) {
         switch (mode) { // (IE, Gecko)
            case 'CSS1Compat': // Standards mode
               height = document.documentElement.clientHeight;
               break;

            default: // Quirks
               height = document.body.clientHeight;
         }
      } else { // Safari, Opera
         height = self.innerHeight;
      }
      return height;
   },

    getViewportWidth: function() {
      var Dom = this;
      var width = -1;
      var mode = document.compatMode;
         
      if (mode || Dom.isIE) { // (IE, Gecko, Opera)
         switch (mode) {
         case 'CSS1Compat': // Standards mode 
            width = document.documentElement.clientWidth;
            break;
         
         default: // Quirks
            width = document.body.clientWidth;
         }
      } else { // Safari
         width = self.innerWidth;
      }
      return width;
   }

};  // end of Dom object

function getClass() {
   var classSet = '';
   var ua = navigator.userAgent.toLowerCase();
   
   if (ua.indexOf('opera') > -1) {
      classSet = 'opera';
   }
   else if (ua.indexOf('safari') > -1) { 
      classSet = 'safari';
   }
   else if (ua.indexOf('firefox') > -1) { 
      classSet = 'firefox';
   }
   else if ( window.ActiveXObject ) {
      classSet = 'ie';
   } 
   if ( classSet && document.compatMode &&
        document.compatMode.toLowerCase() == 'backcompat' ) {
      classSet += ' quirks_mode';
   }
   return classSet;
}


function getReaderHtml (base) {
   var readers = sfsw.CustomReaders || LocaleVars.Readers;
   var html = '';
   var ids = [];

   for ( var i in readers ) { ids.push(i); }
   ids.sort( function(x,y) {
             return Number(x.replace(/[^0-9]/g, '')) -
                    Number(y.replace(/[^0-9]/g, ''));
   });
    
   for (var i=0; i < ids.length; i++) {
      var reader = readers[ids[i]];
      var img = reader.img.indexOf('http')==0 ? reader.img : base+reader.img;
      html += 
      "<div class='reader_cell' id='aol_feeds_subscribe_" + reader.id + "'>" +
      "<a target='_blank' href='" + reader.url + "' " +
      "onclick='aol_feeds_subscribe.hide();' title='" +reader.text+ "'>" + 
      "<img class='feedIcon' src='" +img+ "'" + 
      " alt='" + reader.text + "'/></a>" +
      "</div>";
   }

   return html;
};


 function getMyAOLHtml(base) {
   var myaol = sfsw.CustomMyAOLReader || LocaleVars.myAOLReader;
   var html = '';

   var img = myaol.img.indexOf('http')==0 ? myaol.img : base+myaol.img;
   html += 
   "<div id='aol_feeds_subscribe_myaol'>" +
   "<a target='_blank' href='" + myaol.url + "' " +
   "onclick='aol_feeds_subscribe.hide();' title='" +myaol.text+ "'>" + 
   "<img src='" +img+ "'" + " alt='" + myaol.text + "'/></a>";

   if ( myaol.whatis_url ) {
      html += 
      "<div><a target='_blank' href='" + myaol.whatis_url + "'>" +
       myaol.whatis_text + "</a></div>";
   }

   html +=
   "</div>";

   return html;
}

function getAlertLinkHtml(t) {
   var a = sfsw.CustomAlertLink;
   if (a == null) { a = LocaleVars.AlertLink };
   var html = '';
   if ( a ) { 
    html +=
   "<div id='aol_feeds_subscribe_alert'>" +
   "<a target='_blank' href='" +a+ "' onclick='aol_feeds_subscribe.hide();'>" + 
   "<span id='aol_feeds_subscribe_text_7'>" + t.text_7 + "</span></a>" +
   "</div>";
   }
   return html;
}

function getManualFeedHtml(t) {
   var singleFeed = sfsw.rssFeed == null || sfsw.atomFeed == null;
   var html = '';

   if ( singleFeed ) {
     html += 
    "<div class='feed_cell single_feed'>" +
    "<input type='text' readonly='readonly' value='__FEED__' " +
    "onclick='this.focus(); this.select();'/>" +
    "</div>" +
 
     "<div id='aol_feeds_subscribe_text_3' class='info_text'>"+
       t.text_3a+
     "</div>";
     return html;
   }

   html += 
   "<div id='aol_feeds_subscribe_rss_feed' class='feed_cell'>" +
   "<a target='_blank' href='http://some.domain.com/__RSS_FEED__' " +
   "onclick='aol_feeds_subscribe.hide();'>" + 
   "<span id='aol_feeds_subscribe_text_4'>" + t.text_4 + "</span></a>" +
   "<input type='text' readonly='readonly' value='__RSS_FEED__' " +
   "onclick='this.focus(); this.select();'/>" +
   "</div>" +
 
   "<div id='aol_feeds_subscribe_text_5' class='info_text'>"+t.text_5+"</div>" +

   "<div id='aol_feeds_subscribe_atom_feed' class='feed_cell'>" +
   "<a target='_blank' href='http://some.domain.com/__ATOM_FEED__' " + 
   "onclick='aol_feeds_subscribe.hide();'>" +
   "<span id='aol_feeds_subscribe_text_6'>" + t.text_6 + "</span></a>" +
   "<input type='text' readonly='readonly' value='__ATOM_FEED__' " + 
   "onclick='this.focus(); this.select();'/>" +
   "</div>" +
 
   "<div id='aol_feeds_subscribe_text_3' class='info_text'>"+t.text_3+"</div>";

   return html;
}

/* popup_html extracted from _feeds_subscribe_.html template */
function getHtml() {
   var t = sfsw.CustomText || LocaleVars.Text;
   var b = getBase() || '';

   var html =
   "<a id='aol_feeds_subscribe_close' href='#'" +
   " onclick='return aol_feeds_subscribe.hide();' title='"  + t.close + "'>" +
   "<img class='close_btn' src='" + b + "http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/clear_pix.gif' alt='" + t.close + "'/></a>" +

   "<div id='aol_feeds_subscribe_head'>" + t.text_0 + "</div>" +

   "<div id='aol_feeds_subscribe_body'>" +

    getMyAOLHtml(b) +

   "<div id='aol_feeds_subscribe_readers'>" +
    "<p id='aol_feeds_subscribe_text_1'>"  + t.text_1 + "</p>" +
    getReaderHtml(b) +
   "</div>" +
 
   getAlertLinkHtml(t) +

   "<div id='aol_feeds_subscribe_get_feeds'>" +
   "<a href='#' onclick='return aol_feeds_subscribe.toggleTwisty();'>" +
   "<img id='aol_feeds_subscribe_twisty_img' class='twisty_closed'" + 
   " src='" + b + "http://o.aolcdn.com/art/webwidgets/sfsw_v1_1/images/clear_pix.gif' alt=''/></a>" +
   "<a href='#' onclick='return aol_feeds_subscribe.toggleTwisty();'>" +
   "<span id='aol_feeds_subscribe_text_2' class='twisty_text'>" + 
   t.text_2 + "</span></a>" +
   "</div>" +
 
   "<div id='aol_feeds_subscribe_urls' style='display: none;'>" +
     getManualFeedHtml(t) + 
   "</div>" + 

   "</div> <!-- aol_feeds_subscribe_body -->";

   return html;
};

/*
   Lazy loading with feeds_subscribe_lazyload.js 
   Send load notification or complete panding calls
*/
if ( typeof aol_feeds_subscribe_lazyload != 'undefined' ) {

   if ( aol_feeds_subscribe_lazyload.loadCallback ) {
      if ( aol_feeds_subscribe_lazyload.timeoutId ) {
         clearTimeout(aol_feeds_subscribe_lazyload.timeoutId);
      }
      aol_feeds_subscribe_lazyload.timeoutId = null;

      var callback = aol_feeds_subscribe_lazyload.loadCallback;
      aol_feeds_subscribe_lazyload.loadCallback = null;
      if ( callback ) {
         callback(true); // Send loaded notification
      }
   }

   // Exec pending calls
   for ( var i=0; i < aol_feeds_subscribe_lazyload.pendingCalls.length; i++ ){
      var call = aol_feeds_subscribe_lazyload.pendingCalls[i];
      if ( call.method == 'setText' ) {
         sfsw.setText(call.text);
      }
      if ( call.method == 'setReaders' ) {
         sfsw.setReaders(call.readers);
      }
      if ( call.method == 'setMyAOLReader' ) {
         sfsw.setMyAOLReader(call.myAOL);
      }
      if ( call.method == 'setAlertLink' ) {
         sfsw.setAlertLink(call.link);
      }
      if ( call.method == 'showBlog' ) {
         sfsw.showBlog(call.refEl, call.blogURL, call.anchor);
      }
      if ( call.method == 'show' ) {
         sfsw.show(call.refEl, call.atomFeed, call.rssFeed, call.anchor);
      }
   }
}

// Create the global widget object
window.aol_feeds_subscribe = sfsw;
	
}();   // closure end




