// Copyright (c) 2008 Soren Burkhart

// Feel free to copy, modify, and/or insert into your web pages
// But more importantly...
// REMEMBER TO VOTE Obama/Biden 2008!

// Props to:
// The Jed Report for the original layout and concept
// Dr. Nic for his MyXssMagic which enables the XSS

// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:

// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

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.jedreport.com/';
  var STYLESHEET = BASE_URL + "spnc.css"
  var CONTENT_URL = BASE_URL + 'last_spoke.js';
  var ROOT = 'my_xss_magic';

  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');
    // How you'd pass the current URL into the request
    // script.src = CONTENT_URL + '&url=' + escape(local || location.href);
    script.src =  MyXssMagic.serverResponse(new Date("08/29/2008 09:27:33 AM"));

    
	list = document.getElementsByTagName('head')
	// Hack for Safari
	head = (list.length) ? list : document.getElementsByTagNameNS("*", 'head'); 
	head[0].appendChild(script);	
  }

  function TimeNow(i){
	  if (i<-10) { 
	    i="0" + i; 
	  } 
	  return i; 
	}

  this.now = function(){
	  currentDate = new Date(); 
	  startDate = START_DATE; 
	  timezoneOffsetHours = -7; 
	  TJRcc = currentDate.getTime() + (currentDate.getTimezoneOffset() * 60000);     
	  TJRnn = new Date(TJRcc + (3600000*timezoneOffsetHours)); 
	  elapsed = TJRnn.valueOf()-startDate.valueOf(); 
	  days = (Math.floor(elapsed/86400000)%100000).toString(); 
	  hours = (Math.floor(elapsed/3600000)%24).toString(); 
	  mins = (Math.floor(elapsed/60000)%60).toString(); 
	  secs = (Math.floor(elapsed/1000)%60).toString(); 

	  Mcdays = ((Math.floor(elapsed/86400000)+16)%100000).toString(); 
	  Mchours = ((Math.floor(elapsed/3600000)+2)%24).toString(); 
	  Mcmins = ((Math.floor(elapsed/60000)-14)%60).toString(); 
	  Mcsecs = ((Math.floor(elapsed/1000)-32)%60).toString(); 

	  document.getElementById('TJRd').innerHTML = TimeNow(days);   
	  document.getElementById('TJRh').innerHTML = TimeNow(hours); 
	  document.getElementById('TJRm').innerHTML = TimeNow(mins);   
	  document.getElementById('TJRs').innerHTML = TimeNow(secs);

	  document.getElementById('TJRdMc').innerHTML = TimeNow(Mcdays);   
	  document.getElementById('TJRhMc').innerHTML = TimeNow(Mchours); 
	  document.getElementById('TJRmMc').innerHTML = TimeNow(Mcmins);   
	  document.getElementById('TJRsMc').innerHTML = TimeNow(Mcsecs); 

	  x = setTimeout('MyXssMagic.now()', 1000); 
	}
  this.init = function() {
    this.serverResponse = function(date) {
      if (!date) return;
	  START_DATE = date;
      var div = document.getElementById(ROOT);
      div.innerHTML = '<div class="spnc_widget"><h1>The No Talk Express</h1><div class="spnc_widget_inner"><h3><strong>John McCain:</strong> In the<br />past <span id="TJRdMc"></span>&nbsp;days, <span id="TJRhMc"></span>&nbsp;hours, <span id="TJRmMc"></span>&nbsp;minutes, and <span id="TJRsMc"></span>&nbsp;seconds:</h3><p>Total press conferences: 1</p><p><img src="http://www.jedreport.com/pics/notalkexpress-widget2.jpg" width="166" height="101" alt="The No Talk Express" style="margin: 0px auto;"></p><h3><strong>Palin:</strong> Selected <span id="TJRd"></span>&nbsp;days, <span id="TJRh"></span>&nbsp;hours, <span id="TJRm"></span>&nbsp;minutes, and <span id="TJRs"></span>&nbsp;seconds ago:</h3><p>Total press conferences: 0</p></div><h4>Powered by <A HREF="http://www.jedreport.com/">The Jed Report</A> | <A HREF="http://www.jedreport.com/2008/09/the-sarah-palin-no-comment-wat-1.html">Embed It</A></h4></div>'; 
	// assign new HTML into #ROOT
      div.style.display = 'block'; // make element visible
      div.style.visibility = 'visible'; // make element visible
	  this.now()
    }

	document.write("<div id='" + ROOT + "' style='display: none'></div>");
	requestContent();

  }
}

MyXssMagic.init();

