
/* Flash detection script */
// This script will test up to the following version.

flash_versions = 10;
// Initialize variables and arrays
var flash = new Object();
flash.installed=false;
flash.version='0.0';
// Dig through Netscape-compatible plug-ins first.
if (navigator.plugins && navigator.plugins.length)
{
 for (x=0; x < navigator.plugins.length; x++)
 {
  if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1)
  {
   flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
   flash.installed = true;
   break;
  }
 }
}
// Then, dig through ActiveX-style plug-ins afterwords
else if (window.ActiveXObject)
{
 for (x = 2; x <= flash_versions; x++)
 {
  try {
   oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
   if(oFlash)
   {
    flash.installed = true;
    flash.version = x + '.0';
   }
  }
  catch(e) {}
 }
}
// Create sniffing variables in the following style: flash.ver[x]
flash.ver = Array();
for(i = 4; i <= flash_versions; i++)
{
 eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true :  false;");
}

function includeFlash(flashFilePath, width, height, flashId, NotFlash)
{
	var flashDiv = document.getElementById(flashId);
	var noFlashDiv = document.getElementById(NotFlash);
	if(flash.installed)
		{
			if(noFlashDiv)
			{
				noFlashDiv.style.display="none";
			}
			flashDiv.innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' ><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='"+flashFilePath+"' /><param name='quality' value='high' /><embed src='"+flashFilePath+"' quality='high' width='"+width+"' height='"+height+"' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
		}
}
function jsFullWin(target){
	window.open(target,'JCB External Link','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600')	
}

//$ is an alias for the getElementsById function for convenience
function $(id) {
	return document.getElementById(id);
}

var HW = {
	log:function(a) {
		if(window.console) {window.console.log(a);}
	},getElementsByClassName:function(cls,n,t)
	{
		var rtn = [];
		n=n===null?document:n;
		t=t===null?'*':t;
		var els = n.getElementsByTagName ? n.getElementsByTagName(t) : document.all;
		els = (!els||!els.length ) && document.all ? document.all : els;
		if(cls==null){return els;}
		for (var i=0,j=0; i < els.length; i++)
		{
			if(this.hasClass(els[i],cls))
			{
				rtn[j++] = els[i];
			}
		}
		return rtn;
	},
	attachEvent:function(obj,evt,fnc)
	{
		if(window.addEventListener)
		{
			obj.addEventListener(evt, fnc, false);
		}
		else if(window.attachEvent)
		{
			obj.attachEvent('on'+evt, fnc);
		}
		else if (obj.getElementById && evt=='load')
		{
			obj.onload = fnc;
		}
	},
	preventDefault:function(e) {
		e=e||window.event;
		if(e.preventDefault) {e.preventDefault();}
		else {e.returnValue = false;}
	},
	extendObject:function(d, s)
	{
		d=d===null?new Object():d;
		for (p in s)
		{
			d[p] = s[p];
		}
		return d;
	},
	addClass:function(target, theClass)
	{
		if (!this.hasClass(target, theClass))
		{
			if (target.className == "")
			{
				target.className = theClass;
			}
			else
			{
				target.className += " " + theClass;
			}
		}
	},
	hasClass:function(target, theClass)
	{
		var pattern = new RegExp("(^| )" + theClass + "( |$)");
		if (pattern.test(target.className))
		{
			return true;
		}
	
	  return false;
	},
	removeClass:function(target, theClass)
	{
		var pattern = new RegExp("(^| )" + theClass + "( |$)");
		
		target.className = target.className.replace(pattern, "$1");
		target.className = target.className.replace(/ $/, "");
	}
}