﻿function iecheck() {
  if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    var iever = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) <= 7 );
  }
  return iever;
}

MyXssMagic = new function() {
  var BASE_URL = 'http://www.aoa.gov/AoAroot/Site_Utilities/Widget/'; //change this path name
  var STYLESHEET = BASE_URL + "Healthy_Tip/widget.css"
  var CONTENT_URL = BASE_URL + 'Healthy_Tip/json_Healthy_Tip.js';
  var ROOT = 'start_widget';
    var logoimage = "<div id='AoA_widget_box'><img src= '" + BASE_URL + "Healthy_Tip/images/Living_Today.gif' alt='oam logo' /><br />";
        logoimage += "<span style='color:#FF9900; font-size:9px; font-weight:700'>Healthy Living Tips</span>";
        logoimage +=  "<span id='AoA_This_week'> This Week" + "'"+ "s Tip </span><br />";
        logoimage +=  "<span id='AoA_Health_Tip'><a href='http://www.aoa.gov' title='Click for more information'>Healthy Tip Here</a> </span><br />";
        logoimage +=  "<span id='AoA_Previous_Tip' class='AoAShowText AoAorangeColor'><a href='#' onClick='backOne();return false'> Last Week" + "'"+ "s Tip  </a><br /></span>"; //backOne is function from json_Healthy_tip.js
        logoimage +=  "<span class='AoAShowText AoAorangeColor'><a href='" + BASE_URL + "index.aspx#Healthy_Tip'>Share This Widget</a></span>";
        //logoimage +=  "<span style='font:normal 8pt verdana'>Presented by <a href='http://www.aoa.gov' title='Go to AoA website' style='font:normal 9pt verdana'>aoa.gov</a></span>";
        logoimage +=  "</div>";

  function requestStylesheet(stylesheet_url) {
    stylesheet = document.createElement("link");
    stylesheet.rel = "stylesheet";
    stylesheet.type = "text/css";
    stylesheet.href = stylesheet_url;
    stylesheet.media = "all";
    document.lastChild.firstChild.appendChild(stylesheet);
  }
  
  function requestContent( local ) {
    var script = document.createElement("script");
    script.src = CONTENT_URL;
    // IE7 doesn't like this: document.body.appendChild(script);
    // Instead use:
    document.getElementsByTagName('head')[0].appendChild(script);
  }


    requestStylesheet(STYLESHEET);
    document.write("<div id='" + ROOT + "' style='display: visible'></div>");
    //requestContent();


    document.getElementById(ROOT).innerHTML = logoimage;
    document.getElementById('AoA_Health_Tip').firstChild.innerHTML = "Living Today for a Better Tomorrow - Healthy Living Tips";
}
