// VALIDATION
//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer


var agt=navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);

if (ie && win) {	pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
if (ns || !win) {
nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
}

function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

//SAMPLE USAGE- detect "Flash"
if (pluginlist.indexOf("Flash")!=-1) {
	//document.write("You have flash installed");
} else {
	var noFlash = window.confirm("This site requires Macromedia Flash.  Would you like to download it now?")
	if (noFlash) {
		if (navigator.appVersion.indexOf("MSIE")!=-1) {
			window.open("http://www.macromedia.com/software/flashplayer/");
		} else {
			window.open("http://www.macromedia.com/software/flashplayer/");
		}
	} else {
		
	}
}	

//alert(pluginlist);



function validate(theForm) {
	
	if (theForm.FullName.value == "")
		{
		alert("Please provide your name");
		theForm.FullName.focus();
		return (false);
		}


	if (theForm.EmailAddress.value == "") {
		alert("Please enter your email address.");
		theForm.EmailAddress.focus();
		return (false);
	}
	var checkEmailAddress = "@.";
	var checkStr = theForm.EmailAddress.value;
	var EmailAddressValid = false;
	var EmailAddressAt = false;
	var EmailAddressPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
			for (j = 0;  j < checkEmailAddress.length;  j++) {
				if (ch == checkEmailAddress.charAt(j) && ch == "@")
					EmailAddressAt = true;
				if (ch == checkEmailAddress.charAt(j) && ch == ".")
					EmailAddressPeriod = true;
				if (EmailAddressAt && EmailAddressPeriod)
				break;
				if (j == checkEmailAddress.length)
				break;
			}
		if (EmailAddressAt && EmailAddressPeriod) {
			EmailAddressValid = true
			break;
		}
	}
	
	if (!EmailAddressValid) {
		alert("The email you entered is invalid. It must contain an \"@\" and a \".\"");
		theForm.EmailAddress.focus();
		return (false);
	}
}




/*==============================================================================
  Browser Normalizations
 =============================================================================*/
// for browsers that don't like array.push()
if (typeof Array.prototype.push == "undefined") { Array.prototype.push = function() { var currentLength = this.length; for (var i = 0; i < arguments.length; i++) { this[currentLength + i] = arguments[i]; } return this.length; }; }

/*==============================================================================
  Flash Object v1.0
 =============================================================================*/
Flash = function(swf, width, height, version)
{
    this.swf = swf || "";
    this.width = width || "100%";
    this.height = height || "100%";
    this.requiredVersion = version || 6;
    this.id = "";
    this.params = new Object();
    this.variables = new Object();
	this.cabVersion = "6,0,29,0";
	this.menu = "false";
	this.altTxt = "";
};
Flash.hasVersion = function(requiredVersion)
{
    var hasVersion = false;
	if (navigator.plugins && navigator.plugins.length) {
		var description = navigator.plugins["Shockwave Flash"].description;
		var version = description.charAt(description.indexOf('.')-1);
		hasVersion = (version >= requiredVersion);
	} else if (window.ActiveXObject && window.execScript && navigator.userAgent.indexOf('Mac') == -1) { // for Win IE
        Flash.hasActiveX = false;
        window.execScript("On error resume next: Flash.hasActiveX = IsObject(CreateObject('ShockwaveFlash.ShockwaveFlash." + requiredVersion + "'))", "VBScript");
        hasVersion = Flash.hasActiveX;
        delete Flash.hasActiveX;
    }
    return hasVersion;
};
Flash.prototype.getSWF = function() { return this.swf; };
Flash.prototype.setSWF = function(swf) { this.swf = swf; };
Flash.prototype.getWidth = function() { return this.width; };
Flash.prototype.setWidth = function(w) { this.width = w; };
Flash.prototype.getHeight = function() { return this.height; };
Flash.prototype.setHeight = function(h) { this.height = h; };
Flash.prototype.getRequiredVersion = function() { return this.requiredVersion; };
Flash.prototype.setRequiredVersion = function(v) { this.requiredVersion = v; };
Flash.prototype.getCabVersion = function() { return this.cabVersion; };
Flash.prototype.setCabVersion = function(cabVersion) { this.cabVersion = cabVersion; };
Flash.prototype.getMenu = function() { return this.menu; };
Flash.prototype.setMenu = function(menu) { this.menu = menu; };
Flash.prototype.getId = function() { return this.id; };
Flash.prototype.setId = function(id) { this.id = id; };
Flash.prototype.getParam = function(name) { return this.params[name]; };
Flash.prototype.getParams = function() { return this.params; };
Flash.prototype.setParam = function(name, value) { this.params[name] = value; };
Flash.prototype.getVariable = function(name) { return this.variables[name]; };
Flash.prototype.getVariables = function() { return this.variables; };
Flash.prototype.setVariable = function(name, value) { this.variables[name] = value; };
Flash.prototype.getVariablePairs = function()
{
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
		variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    } else {
        return null;
    }
};
Flash.prototype.getParamTags = function()
{
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
};
Flash.prototype.getStatic = function() { return this.altTxt; };
Flash.prototype.setStatic = function(altTxt) { this.altTxt = altTxt; };
Flash.prototype.getHTML = function()
{
	var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
		flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.getCabVersion + '" width="' + this.getWidth() + '" height="' + this.getHeight() + '" id="' + this.getId() + '">';
		flashHTML += '<param name="wmode" value="transparent" />';
		flashHTML += '<param name="movie" value="' + this.getSWF() + '" />';
		flashHTML += '<param name="menu" value="' + this.getMenu() + '" />';
		
		if (this.getParamTags() != null) {
			flashHTML += this.getParamTags();
		}
		if (this.getVariablePairs() != null) {
			flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
		}
		flashHTML += '</object>';
	} else {
		flashHTML += '<embed type="application/x-shockwave-flash" wmode="transparent" src="' + this.getSWF() + '" width="' + this.getWidth() + '" height="' + this.getHeight() + '" menu="' + this.getMenu() + '" id="' + this.getId() + '"';
		for (var param in this.getParams()) {
			flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
		}
		if (this.getVariablePairs() != null) {
			flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
		}
		flashHTML += '></embed>';
	}
    return flashHTML;
};
Flash.prototype.render = function(elementId)
{
	var output;
	(Flash.hasVersion(this.getRequiredVersion())) ? output = this.getHTML() : output = this.getStatic();
	
	(elementId) ? document.getElementById(elementId).innerHTML = output : document.write(output);
};


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}