<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="__MSG_title__"
             author="Matt M."
             author_email="matt.feedback+datetime@gmail.com"
             author_affiliation="Google Inc."
             author_location="Mountain View, CA"
             screenshot="http://www.google.com/ig/modules/datetime_content/clock.png"
             thumbnail="http://www.google.com/ig/modules/datetime-thm.png"
             category="tools"
             title_url="http://bbs.cnnas.com"
             description="__MSG_description__"
             render_inline="optional" height="136" scaling="false">
  <Locale messages="http://www.google.com/ig/modules/datetime_content/en_ALL.xml"/> 
  <Locale lang="en" messages="http://www.google.com/ig/modules/datetime_content/en_ALL.xml"/> 
  <Locale lang="he" messages="http://www.google.com/ig/modules/datetime_content/he_ALL.xml" language_direction="rtl"/>
  <Locale lang="iw" messages="http://www.google.com/ig/modules/datetime_content/he_ALL.xml" language_direction="rtl"/>
</ModulePrefs>
<UserPref name="color" datatype="enum" default_value="blue" display_name="__MSG_color__" >
  <EnumValue value="blue" display_value="__MSG_blue__" />
  <EnumValue value="green" display_value="__MSG_green__" />
  <EnumValue value="orange" display_value="__MSG_orange__" />
  <EnumValue value="pink" display_value="__MSG_pink__" />
  <EnumValue value="purple" display_value="__MSG_purple__" />
  <EnumValue value="red" display_value="__MSG_red__" />
  <EnumValue value="yellow" display_value="__MSG_yellow__" />
</UserPref>
<Content type="html"><![CDATA[


<table id="gdt_main___MODULE_ID__" width="100%" height="136" border="0" cellpadding="0" cellspacing="0" style="font-family: Arial, Helvetica, sans-serif; color:#fff;">
  <tr>
    <td id="gdt___BIDI_START_EDGE_____MODULE_ID__" style="width: 12px;"></td>
    <td valign="middle" id="gdt_b_clock___MODULE_ID__" style="width: 112px;">
     <div id="gdt_clock___MODULE_ID__" style="float: left; border: 0px; margin: 0px; padding: 0px; width: 112px; height: 112px;">
       <div id="gdt_hands___MODULE_ID__" style="position: relative; width: 90px; height: 90px; overflow: hidden; margin-left: 9px; margin-top: 9px; margin-right: 13px; margin-bottom: 13px;">
         <div id="gdt_hands_m___MODULE_ID__" style="position: absolute; left: 0px; top: 0px; width: 5400px; height: 90px;"></div>
         <div id="gdt_hands_h___MODULE_ID__" style="position: absolute; left: 0px; top: 0px; width: 3240px; height: 90px;"></div>
       </div>
     </div>
    </td>
    <td valign="middle" id="gdt_b_date___MODULE_ID__" style="padding: 10px; overflow: hidden; height: 136px;">
    <div style="float: left; padding-left: 5px; padding-right: 10px;" id="clicktest">
      <div id="gdt_day___MODULE_ID__" style="font-size: 16px; font-weight: bold;">__MSG_sun__</div>
      <div id="gdt_month___MODULE_ID__" style="font-size: 20px; font-weight: bold;">__MSG_jan__</div>
    </div>
    <div id="gdt_date___MODULE_ID__" style="font-size: 42px; font-weight: bold;">1</div>
  </td>
  <td valign="middle" id="gdt_cal___MODULE_ID__" style="overflow: hidden; display: none;"></td>
  </td>
  <td id="gdt___BIDI_END_EDGE_____MODULE_ID__" style="width: 12px;"></td>
  </tr>
</table>


<script type="text/javascript">
function GDT___MODULE_ID__() {
  this.prefs = new _IG_Prefs(__MODULE_ID__);
  this.clockColor = (this.prefs.getString('color')) ? this.prefs.getString('color') : 'blue';
  this.dispDay = -1;


  // Static globals.
  this.monthsArray = new Array("__MSG_jan__", "__MSG_feb__", "__MSG_mar__", "__MSG_apr__", "__MSG_may__", "__MSG_jun__", "__MSG_jul__", "__MSG_aug__", "__MSG_sep__", "__MSG_oct__", "__MSG_nov__", "__MSG_dec__");
  this.daysArray = new Array("__MSG_sun__", "__MSG_mon__", "__MSG_tue__", "__MSG_wed__", "__MSG_thu__", "__MSG_fri__", "__MSG_sat__");
  this.mhOffset = -90;
  this.hhOffset = -90;


  // Browser detection.
  this.agt = navigator.userAgent.toLowerCase();
  this.is_ie = (this.agt.indexOf("msie")!= -1 && document.all && this.agt.indexOf("opera") == -1);
  this.is_ie5 = this.is_ie && (this.agt.indexOf("msie 5") != -1);
  this.is_ie6 = this.is_ie && (this.agt.indexOf("msie 6") != -1);
  this.is_ie7 = this.is_ie && (this.agt.indexOf("msie 7") != -1);


  /**
   * Writes an element's html for browsers with getElementById()
   */
  this.writeElement = function(eltId, str) {
    _gel(eltId).innerHTML = str;
  }


  /**
   * Changes the clipping (position) of an element's background image for browsers with getElementById()
   */
  this.updateX = function(eltId, xCoord) {
   _gel(eltId).style.left = '' + xCoord + 'px';
  }


  /**
   * Decide whether there is enough room to show the calendar.
   */
  this.toggleCalDisp = function() {
    if (_gel('gdt_main___MODULE_ID__').clientWidth > 315) {
      _gel('gdt_cal___MODULE_ID__').style.display = 'block';
    } else {
      _gel('gdt_cal___MODULE_ID__').style.display = 'none';
    }
  }


  /**
   * Save the background image.
   */
  this.setBkgPng = function (elId, imgSrc, repeat) {
    _gel(elId).style.backgroundImage = 'url(\'' + imgSrc + '\')';
    _gel(elId).style.backgroundRepeat = repeat;
  }


  /**
   * Apply a filter instead of saving the background image.
   */
  this.fixIeBkgPng = function (elId, imgSrc, repeat) {
    _gel(elId).style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src=\''+imgSrc+'\')';
    _gel(elId).style.backgroundImage = 'none';
  }


  /**
   * Updates the clock to the current time.
   */
  this.upClock = function() {
    var ctime = new Date();
    var phr = ctime.getHours();
    var pmin = ctime.getMinutes();
    var pday = ctime.getDay();
    var pmonth = ctime.getMonth();
    var pdate = ctime.getDate();


    // scale clock to 0 - 11
    if (phr >= 12) phr -= 12;


    // adjust background positions for hands... with adjustments to fix slight deviations in position.
    var minVal = (phr * 60 + pmin) / 720;
    var hrAdjust = Math.round(Math.sin(minVal * 2 * Math.PI) * 10);
    var minAdjust = Math.round(Math.sin(pmin / 60 * 2 * Math.PI) * 20);


    this.updateX('gdt_hands_h___MODULE_ID__', Math.round(minVal * 36) * this.hhOffset + hrAdjust );
    this.updateX('gdt_hands_m___MODULE_ID__', pmin * this.mhOffset + minAdjust);


    // update date if necessary
    if (pdate != this.dispDay) {
      this.writeElement('gdt_day___MODULE_ID__', this.daysArray[pday]);
      this.writeElement('gdt_month___MODULE_ID__', this.monthsArray[pmonth]);
      this.writeElement('gdt_date___MODULE_ID__', pdate);
      this.drawCal(pday, pmonth, pdate, ctime.getYear());
      this.dispDay = pdate;
    }
  }


  /**
   * draw calendar
   */
  this.drawCal = function (day, month, date, year) {
    // Each of these should consist of exactly 1 character
    var days_of_week = ['__MSG_sun_a__', '__MSG_mon_a__', '__MSG_tue_a__', '__MSG_wed_a__', '__MSG_thu_a__', '__MSG_fri_a__', '__MSG_sat_a__'];
    var num_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var result = '<table style="margin-top: 3px;" cellspacing="1" cellpadding="2" border="0"><tr>';
    var num_days = num_days_in_month[month];
    if (month == 1 && year % 4 == 0) {
      if (year % 100 != 0 || year % 400 == 0) {
        num_days = 29;
      }
    }


    for (var i = 0; i < 7; i++) {
      result += '<td style="font-size: 9px; color:#ffffff; border-bottom: 1px dotted #eeeeee;">' +
        days_of_week[i] + '</td>';
    }
    result += '</tr>';


    var curr_day = 1;
    var starting_day = ((day - date % 7 + 1) + 7 )% 7;
    for (var i = 0; i < 6; i++) {
      result += '<tr>';
      for (var j = 0; j < 7; j++) {
        var style = 'font-size: 9px; color: #eeeeee;';
        var content = curr_day;
        if ((i == 0 && j < starting_day) || curr_day > num_days) {
          content = '&nbsp;';
        } else {
          if (curr_day == date) {
            style += ' border: 1px solid #eeeeee; color: #ffffff; font-weight: bold;';
          }
          curr_day++;
        }
        result += '<td style="' + style + '">' + content + '</td>';
      }
      result += '</tr>';
    }
    result += '</table>';
    _gel('gdt_cal___MODULE_ID__').innerHTML = result;
  }


  /**
   * Sets up the clock to update every minute.
   */
  this.startInterval = function() {
    window.setInterval('GDT___MODULE_ID___handle.upClock()',60000);
    this.upClock();
  }


  this.setImages = function() {
    if (this.is_ie5 || this.is_ie6) {
      this.fixIeBkgPng('gdt_clock___MODULE_ID__', '/ig/modules/datetime_content/clock.png', 'no-repeat');
      this.fixIeBkgPng('gdt_left___MODULE_ID__', '/ig/modules/datetime_content/l-' + this.clockColor + '.png', 'no-repeat');
      this.fixIeBkgPng('gdt_right___MODULE_ID__', '/ig/modules/datetime_content/r-' + this.clockColor + '.png', 'no-repeat');
      this.setBkgPng('gdt_b_clock___MODULE_ID__', '/ig/modules/datetime_content/b-' + this.clockColor + '.png', 'repeat-x');
      this.setBkgPng('gdt_b_date___MODULE_ID__', '/ig/modules/datetime_content/b-' + this.clockColor + '.png', 'repeat-x');
      this.setBkgPng('gdt_cal___MODULE_ID__', '/ig/modules/datetime_content/b-' + this.clockColor + '.png', 'repeat-x');
      this.fixIeBkgPng('gdt_hands_m___MODULE_ID__', '/ig/modules/datetime_content/hm.png', 'no-repeat');
      this.fixIeBkgPng('gdt_hands_h___MODULE_ID__', '/ig/modules/datetime_content/hh.png', 'no-repeat');
    } else {
      this.setBkgPng('gdt_clock___MODULE_ID__', '/ig/modules/datetime_content/clock.png', 'no-repeat');
      this.setBkgPng('gdt_left___MODULE_ID__', '/ig/modules/datetime_content/l-' + this.clockColor + '.png', 'no-repeat');
      this.setBkgPng('gdt_right___MODULE_ID__', '/ig/modules/datetime_content/r-' + this.clockColor + '.png', 'no-repeat');
      this.setBkgPng('gdt_b_clock___MODULE_ID__', '/ig/modules/datetime_content/b-' + this.clockColor + '.png', 'repeat-x');
      this.setBkgPng('gdt_b_date___MODULE_ID__', '/ig/modules/datetime_content/b-' + this.clockColor + '.png', 'repeat-x');
      this.setBkgPng('gdt_cal___MODULE_ID__', '/ig/modules/datetime_content/b-' + this.clockColor + '.png', 'repeat-x');
      this.setBkgPng('gdt_hands_m___MODULE_ID__', '/ig/modules/datetime_content/hm.png', 'no-repeat');
      this.setBkgPng('gdt_hands_h___MODULE_ID__', '/ig/modules/datetime_content/hh.png', 'no-repeat');
    }
  }


  /**
   * Sets up the clock, and tries its best to sync with the system clock to update at the right time.
   */
  this.main = function() {
    // address differences in relatively positioned elements in different browsers
    if (!this.is_ie5 && !this.is_ie6 && !this.is_ie7) {
      _gel('gdt_hands___MODULE_ID__').style.position = 'relative';
    }
    this.setImages();
    if (window.addEventListener) {
      window.addEventListener('resize', GDT___MODULE_ID___handle.toggleCalDisp, false);
      window.addEventListener('load', GDT___MODULE_ID___handle.toggleCalDisp, false);
    } else if (window.attachEvent) {
      window.attachEvent('onresize', GDT___MODULE_ID___handle.toggleCalDisp);
      window.attachEvent('onload', GDT___MODULE_ID___handle.toggleCalDisp);
    }
    this.upClock();
    window.setTimeout('GDT___MODULE_ID___handle.startInterval()', (60 - new Date().getSeconds()) * 1000 + 5);
  }
}


var GDT___MODULE_ID___handle = new GDT___MODULE_ID__();
function GetObj(objName){
			if(document.getElementById){
				return eval('document.getElementById("' + objName + '")');
			}else if(document.layers){
				return eval("document.layers['" + objName +"']");
			}else{
				return eval('document.all.' + objName);
			}
		}


 var clicktest = GetObj('gdt_main___MODULE_ID__');


function loading() {	   
window.open("http://bbs.cnnas.com"); 
      }


if (window.attachEvent) clicktest.attachEvent('onclick',loading);
    if (window.addEventListener) clicktest.addEventListener('click',loading,false);




_IG_RegisterOnloadHandler(function() {
  GDT___MODULE_ID___handle.main();
});


</script>


]]></Content>
</Module>





