/**
 * Functions.js v1.0: General javascript functions used throughout Wolfram's websites
 *
 * This file requires swfobject.js in order to be of any use. 
 */
var iedom=document.all||document.getElementById;

function writit(text,id)
{
	if (document.getElementById)
	{
		if (!document.all) {
			//NS6 code - works with Firefox
			dynamiccontentNS6(id,text);
		} else {
			x = document.getElementById(id);
			x.innerHTML = '';
			x.innerHTML = text;
		}
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<P CLASS="body">' + text + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function dynamiccontentNS6(elementid,content){
	if (document.getElementById && !document.all){
		var rng = document.createRange();
		var el = document.getElementById(elementid);
		rng.setStartBefore(el);
		var htmlFrag = rng.createContextualFragment(content);
		while (el.hasChildNodes())
			el.removeChild(el.lastChild);
		el.appendChild(htmlFrag);
	}
}

// the code below adds a Flash script into a DIV, replacing the DIV's content
function loadDivWithFlash(divId, flashPath, flashName, flashWidth, flashHeigth, flashVersionRequired, flashBgColor, flashQuality, flashTransparency) {
   var fo = new SWFObject(flashPath, flashName, flashWidth, flashHeigth, flashVersionRequired, flashBgColor);

   if (flashQuality) {
      fo.addParam("quality", flashQuality);
   }
   
   if (flashTransparency) {
   	fo.addParam("wmode","transparent");
   }
   //check if there's a valid version of Flash and/or Javascript going on
   var version = deconcept.SWFObjectUtil.getPlayerVersion();
   
   if (document.getElementById && (version['major'] > 0)) {
	   fo.write(divId);
   }
}



function displayDate() {
// Get today's current date.
var now = new Date();

// Array list of days.
var days = new 
Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Array list of months.
var months = new Array

('January','February','March','April','May','June','July','August','September','October','November','December');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)     {
        return (number < 1000) ? number + 1900 : number;
                                                                }

// Join it all together
today =  days[now.getDay()] + ", " +
         months[now.getMonth()] + " " +
         date ;

// Print out the data.
document.write(today);
}



function IncludeFlash(){
  // Adds a series of default settings to AC_FL_RunContent (jeremyd June 6,2007)
  var preargs = new Array();
  preargs = [
  	'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
	'quality', 'high',
	'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
	'align', 'middle',
	'play', 'true',
	'loop', 'false',
	'scale', 'noscale',
	'wmode', 'window',
	'devicefont', 'false',
	'bgcolor', '#ffffff',
	'menu', 'false',
	'allowFullScreen', 'false',
	'allowScriptAccess','sameDomain',
	'salign', 'lt'];
  var init=preargs.length;
  //Join default arguments with user specified arguments
  for (var i=0; i < arguments.length; i=i+1){preargs[init + i]=arguments[i];}
  //Convert to string suitable for js function argument list
  preargs="'"+preargs.join("','")+"'";
  eval("AC_FL_RunContent("+preargs+")")
}