var isDOM = (document.getElementById ? true : false);
var isIE  = (document.all ? true: false);
var isNS4 = (navigator.appName=='Netscape' && !isDOM ? true : false);
var isIE4 = ((isIE && !isDOM) ? true : false);
var isWin = ((navigator.platform.indexOf('Win') != -1) ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);
function popUp(URL) {day = new Date();id = day.getTime();eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=630,left = 190,top = 85');");}
function getRef(id, par){
 par = (!par ? document : (par.navigator ? par.document : par));
 return (isIE ? par.all[id] :
  (isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
  par.layers[id]));
}

function getSty(id, par){return (isNS4 ? getRef(id, par) : getRef(id, par).style)}

function LayerObj(id, par){
 this.ref = getRef(id, par);
 this.sty = getSty(id, par);
 this.x = function(nX) { if (!isNaN(nX)) this.sty.left = nX; else return parseInt(this.sty.left) }
 this.y = function(nY) { if (!isNaN(nY)) this.sty.top = nY; else return parseInt(this.sty.top) }
 this.vis = function(val) { this.sty.visibility = val }
 this.write = function(txt) {
  if (isNS4) with (this.ref.document) { write(txt); close() }
  else this.ref.innerHTML = txt }
 this.alpha = function(val) { with (this) {
  if (isIE && isWin) {
   if (sty.filter.indexOf('alpha')==-1) sty.filter+='alpha()';
   ref.filters.alpha.opacity=val }
  else if (isDOM) sty.MozOpacity=(val/100); }}
 return this;
}
function getLyr(id, par) { return new LayerObj(id, par) }
function footnoteTrack(evt) { with (this)
{
 if (followMouse && div) {
  sX = (isIE ? document.documentElement.scrollLeft : window.pageXOffset);
  sY = (isIE ? document.documentElement.scrollTop : window.pageYOffset);
  mX = (isIE ? event.clientX + sX : evt.pageX);
  mY = (isIE ? event.clientY + sY : evt.pageY);
  pos()}
}}

function footnotePos() { with (this)
{
 if (lastFootnote) {
  var t=footnotes[lastFootnote], footnoteX=t[0], footnoteY=t[1], footnoteW=t[2], footnoteH=t[3], adjX = 1;
  var winW = (isIE ? document.documentElement.clientWidth : window.innerWidth - 10);
  var winH = (isIE ? document.documentElement.clientHeight : window.innerHeight - 10);
  
  if (mX + footnoteX + footnoteW + 5 > sX + winW) { mX = sX + winW - footnoteX - footnoteW - 5; adjX = 2 }
  if (mY + footnoteY + footnoteH + 5 > sY + winH) mY = sY + winH - footnoteY - (adjX*footnoteH) - 5;
  div.x(mX + footnoteX);
  div.y(mY + footnoteY); }
}}

function footnoteShow(footnoteN) { with (this){
 if(!isIE){alert(footnotes[footnoteN][4])}else{
 sX = (isIE ? document.documentElement.scrollLeft : window.pageXOffset);
 sY = (isIE ? document.documentElement.scrollTop : window.pageYOffset);
 mX = (isIE ? event.clientX + sX : evt.pageX)/2;
 mY = (isIE ? event.clientY + sY : evt.pageY);
 if (!isDyn){return;}
 if (!div) div = getLyr(myName + 'Layer');
 lastFootnote = footnoteN;
 showFootnote = true;
 if (followMouse) pos();
 var str = content;
 for (var i=0; i<10; i++) str = str.replace('%'+i+'%', footnotes[footnoteN][i]);
 div.write(str + ((document.all && !isWin) ? '<small><br></small>' : ''));
 fade();
 }}}

function footnoteHide() { with (this){
 if (!isDyn) return;
 showFootnote = false;
 fade();
}}

function footnoteFade() { with (this)
{
 clearTimeout(fadeTimer);
 if (showFootnote) {
  div.vis('visible');
  if (doFades && alpha < 100)  {
   alpha += fadeSpeed;
   if (alpha > 100) alpha = 100;
   div.alpha(alpha);
   fadeTimer = setTimeout(myName + '.fade()', 50);
   return;
  }
 } else {
  if (doFades && alpha > 0) {
   alpha -= fadeSpeed;
   if (alpha < 0) alpha = 0;
   div.alpha(alpha);
   fadeTimer = setTimeout(myName + '.fade()', 50);
   return;  }
  div.vis('hidden'); }
}}

function FootnoteObj(myName){
 this.myName = myName;
 this.footnotes = new Array();
 this.currFootnote = '';
 this.showFootnote = false;
 this.track = footnoteTrack;
 this.pos = footnotePos;
 this.show = footnoteShow;
 this.hide = footnoteHide;
 this.fade = footnoteFade;
 this.div = null;
 this.followMouse = true;
 this.sX = 0;
 this.sY = 0;
 this.mX = 0;
 this.mY = 0;
 this.doFades = true;
 this.fadeTimer = 0;
 this.fadeSpeed = 10;
 this.alpha = 0;}

if (isNS4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = new Function('evt', 'docFootnotes.track(evt)');
var docFootnotes = new FootnoteObj('docFootnotes');
content = '<table bgcolor="#878CB2" cellpadding="1" cellspacing="0" width="200" border="0">' +'<tr><td><table bgcolor="#F9FAFC" cellpadding="2" cellspacing="0" width="100%" border="0">' +'<tr><td height="%3%" class="body">%4%</td></tr></table></td></tr></table>';		
// 
// videos = function(target) {
// 	var flashvars = {
// 			image: "/images/video_intro.png",// pass image URL if there is one
// 
// 			autoplay: false,					// use to autoplay video
// 			//buffer: 3,						// set buffer length (default is 3)
// 			
// 			navAutoHideIdleTime: 2,				// set mouse idle time for navigation to hide
// 			navAutoHide: true,					// disable navigation auto hide
// 			//hideNav: true,					// turn off navigation
// 
// 			//debug: true,						// debug mode
// 			//scaleMode: "crop",				// use "crop" to change, default mode is "fit"
// 
// 			// THEMES //////////////////////////////////////////////////
// 			
// 			// theming is based on setting hue, saturation, brightness and constrast values
// 			// to 0xff0000 (red) colour
// 			
// 			customTheme: false			// enables custom colours
// 			
// 			// themeHue: 100,       // icons and GUI elements params
// 			// themeBrightness: 100,
// 			// themeConstrast: 25,
// 			// themeSaturation: -100,
// 			// 
// 			// handleHue: 0,        // handles (sliders) params
// 			// handleBrightness: 100,
// 			// handleConstrast: 100,
// 			// handleSaturation: 0,
// 			// 
// 			// preloaderHue: 100,     // preloader progress params
// 			// preloaderBrightness: -80,
// 			// preloaderConstrast: -50,
// 			// preloaderSaturation: 50,
// 			// 
// 			// backgroundFrom: 0xff9697A9,  // background colours (use rgb32, AARRGGBB)
// 			// backgroundTo: 0xff5C5E74
// 		};
// 		
//     $(target).flash(
// 	    {
// 			src: '/flash/flvplayer.swf',
// 			width: 460,
// 			height: 368,
// 			allowFullScreen: true,
// 			flashvars: flashvars
// 	    },
// 	    { 
// 			update: false,
// 			expressInstall: false, 
// 			expressInstallSrc: "/flash/expressInstall.swf", 
// 			version: "9.0.115"
// 	    },
// 	    function(htmlOptions) {
// 			htmlOptions.flashvars.video = $(this).attr("href");
// 			img_class = '';
// 	        if ($($(this).children()[0]).is("img")) {
// 	          htmlOptions.width = $($(this).children()[0]).attr("width");
// 	          htmlOptions.height = $($(this).children()[0]).attr("height");
// 	          img_class = $($(this).children()[0]).attr("align");
// 	          htmlOptions.flashvars.image = $($(this).children()[0]).attr("src")
// 	        };
// 	        z = $.fn.flash.transform(htmlOptions);
// 	        if (img_class) {
// 	          z = z.replace('embed', 'embed class="' + img_class + '"');
// 	        }
// 	        $(this).before(z);
// 	        $(this).remove();
// 			// $(this).empty().append($.fn.flash.transform(htmlOptions));
// 	    }
// 	);
// }
// 
// embed_videos = function() {
// 	$('#articleContainer a[href*="youtube.com"]').flash(
// 		{ width: 425, height: 350, wmode: 'transparent' },
// 		{ version: 8 },
// 		function(htmlOptions) {
// 			htmlOptions.src = "http://www.youtube.com/v/" + this.href.match(/v=(.+)/)[1];
// 			$(this).before($.fn.flash.transform(htmlOptions));
// 			$(this).remove();
// 		}
// 	);
// 
// 	$('#articleContainer a[href*="vimeo.com"]').flash(
// 		{ width: 453, height: 340, quality:'best', allowfullscreen:'true', scale:'showAll' },
// 		{ version: 8 },
// 		function(htmlOptions) {
// 			htmlOptions.src = "http://vimeo.com/moogaloop.swf?clip_id=" + this.href.match(/(\d+)/)[1] + "&amp;server=vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=FFCF4C";
// 			$(this).before($.fn.flash.transform(htmlOptions));
// 			$(this).remove();
// 		}
// 	);
// }

// load = function() {
//   load.getScript("/includes/jquery_1_4_2.js");
//   load.tryReady(0,1); // We will write this function later. It's responsible for waiting until jQuery loads before using it.
//   load.getScript("/includes/jquery_flash.js");
//   load.tryReady(0,0); // We will write this function later. It's responsible for waiting until jQuery loads before using it.
// }
// 
// // dynamically load any javascript file.
// load.getScript = function(filename) {
//   var script = document.createElement('script')
//   script.setAttribute("type","text/javascript")
//   script.setAttribute("src", filename)
//   if (typeof script!="undefined")
//   document.getElementsByTagName("head")[0].appendChild(script)
// }
// 
// load.tryReady = function(time_elapsed,all_loaded) {
//   // Continually polls to see if jQuery is loaded.
//   if (typeof $ == "undefined") { // if jQuery isn't loaded yet...
//     if (time_elapsed <= 5000) { // and we havn't given up trying...
//       setTimeout("load.tryReady(" + (time_elapsed + 200) + ")", 200); // set a timer to check again in 200 ms.
//     } else {
//       // alert("Timed out while loading jQuery.")
//     }
//   } else {
// 	if (all_loaded == 0) {
// 	    // Any code to run after jQuery loads goes here!
// 		if (($videos = $("#articleContainer a[href$='.flv'], #articleContainer a[href$='.mp4']")) && $videos.length > 0) videos($videos);
// 		embed_videos();
// 	}
//   }
// }
// 
// load();

