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];}
}

function prevtext(param){
	text = document.getElementById('casetext');
	text.innerHTML=(param)?"View Previous Case Study":"";
}
function nexttext(param){
	text = document.getElementById('casetext');
	text.innerHTML=(param)?"View Next Case Study":"";
}

  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {
    var even = false;
    var evenColor = arguments[1] ? arguments[1] : "#3F3849";
    var oddColor = arguments[2] ? arguments[2] : "#3F3849";
    var table = document.getElementById(id);
    if (! table) { return; }
    var tbodies = table.getElementsByTagName("tbody");
    for (var h = 0; h < tbodies.length; h++) {
      var trs = tbodies[h].getElementsByTagName("tr");
      for (var i = 0; i < trs.length; i++) {
	    if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
          var tds = trs[i].getElementsByTagName("td");
          for (var j = 0; j < tds.length; j++) {
               var mytd = tds[j];
	        if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
        
		      mytd.style.backgroundColor = even ? evenColor : oddColor;
              
            }
          }
        }
        even =  ! even;
      }
    }
  }



function count(field, countfield, maxlimit) {
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}else {
		target = document.getElementById(countfield);
		target.innerHTML = maxlimit - field.value.length;
	}
}



function validateMember() {	
	document.getElementById('fnerror').innerHTML = '';
	document.getElementById('lnerror').innerHTML = '';
	document.getElementById('emailerror').innerHTML = '';
	document.getElementById('passerror').innerHTML = '';
	error = false;
	if(document.form1.MemberFirstName.value == ''){
		error = true;
		document.getElementById('fnerror').innerHTML = 'Please Enter Your First Name';
	}
	if(document.form1.MemberLastName.value == ''){
		error = true;
		document.getElementById('lnerror').innerHTML = 'Please Enter Your Last Name';
	}
	if(document.form1.MemberEmail.value == ''){
		error = true;
		document.getElementById('emailerror').innerHTML = 'Please Enter an Email Address';
	}
	if(document.form1.MemberPassword.value == ''){
		error = true;
		document.getElementById('passerror').innerHTML = 'Please Enter a Password';
	}
		
	if(error == true){
		return false;
	}else{
		return true;
	}
}






function WriteFlash(url,width,height,altimage){ 
	flash_versions = 20;
	var flash = new Object();
	flash.installed=false;
	flash.version='0.0';
	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;
			}
		}
	}
	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;
				}
			}
			catch(e) {}
		}
	}
	flash.version = parseInt(flash.version);
	if (altimage != 'bypass'){
		if ( !flash.installed || flash.version<8) {
			document.write('<p align=center style=\"color:#eee; font: bold 12px Verdana, Arial, Helvetica, sans-serif \">Flash MX 8.0 Plugin Required');
			if(flash.installed)	document.write('<span style=\"color:#ddd; font: normal 10px Verdana, Arial, Helvetica, sans-serif \"><br>Your Version: '+flash.version+'.0</span>');
			document.write('<br>Please Download Here<br><br>');
			document.write('<a style=\"color:#ccc; font: bold 12px Verdana, Arial, Helvetica, sans-serif \" href=\"http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" target\"_blank\">Flash MX 8.0 Plugin</a>');
		}else{
			document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"'); 
			document.write(' codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"'); 
			document.write(' width=\"' + width + '\"' + ' height=\"' + height + '\">'); 
			document.write(' <param name=movie value=\"' + url + '&ran=' + Math.random() + '\"> <param name=\"quality\" value=\"high\"> <param name=menu value=false> <param name=\"bgcolor\" VALUE=\"#142c60\">'); 
			document.write(' <embed src=\"' + url + '&ran=' + Math.random() + '\" quality=\"high\" bgcolor=\"#142c60\" '); 
			document.write(' width=\"' + width + '\"' + ' height=\"' + height + '\" align=\"middle\" menu=\"false\"'); 
			document.write(' type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">'); 
			document.write(' </embed></object>'); 
		} 
	}else{
		document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"'); 
		document.write(' codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"'); 
		document.write(' width=\"' + width + '\"' + ' height=\"' + height + '\">'); 
		document.write(' <param name=movie value=\"' + url + '?ran=' + Math.random() + '\"> <param name=\"quality\" value=\"high\"> <param name=menu value=false> <param name=\"bgcolor\" VALUE=\"#142c60\">'); 
		document.write(' <embed src=\"' + url + '?ran=' + Math.random() + '\" quality=\"high\" bgcolor=\"#142c60\" '); 
		document.write(' width=\"' + width + '\"' + ' height=\"' + height + '\" align=\"middle\" menu=\"false\"'); 
		document.write(' type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">'); 
		document.write(' </embed></object>'); 
	}
}



function PdfPopUp(articleid){
}

function VideoPopUp(articleid){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('http://www.royharris.com/video_player/?id=" + articleid + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=750,height=530,left = 300,top = 240');");
}
function VideoPopUp2(articleid){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('http://www.royharris.com/video_player/?id=" + articleid + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=750,height=530,left = 300,top = 240');");
}
function VideoSmall(){
	self.resizeTo(440,581);
}
function VideoLarge(){
	self.resizeTo(756,581);
}


function RowHighlighter( tableIdName, highlightedClassName, eventList) {


	// initialize class variables
	this.containerId            = tableIdName;
	this.tableElement           = document.getElementById(tableIdName);
	this.highlightedClassName   = highlightedClassName;
	this.selectedRow;
	this.selectedRowOriginalClass;
	
	if( this.tableElement == null ) {
		return false;
	}
		
	// Note about copying this.
	// For some reason, browsers complain about using "this" from an anonymous function like
	// the one below.  I think it has something to do with a scoping change when
	// inside of an anonymous function. Thus you have to copt the "this" for use.
	var copyOfThis = this;	
	var action 	= 	function( e ) {
						if( e == null ) {
							e = this.tableElement.ownerDocument.parentWindow.event;
						}
						copyOfThis.mouseover(e);
					}
	
	// add a listener for onmouseover W3C compatable
	if (this.tableElement.addEventListener) {
		for( i=0; i< eventList.length; i++ ) {
			this.tableElement.addEventListener(eventList[i], action, false);
		}
	}
	// add a listener for onmouseover Microsoft IE compatable
	else if (this.tableElement.attachEvent) {
	    for( i=0; i< eventList.length; i++ ) {
			eventName = "on" + eventList[i];
			this.tableElement.attachEvent(eventName, action);
		}
	}
	
	return;
	
}

RowHighlighter.prototype.mouseover = function( e ) {
	
	// what node are we over?
	var el;
	if( e.target != null ) {
		el = e.target;
	}
	else {
		el = e.srcElement;
	}
	
	// Move up the tree to the first TAG type node that is not the TABLE parent
	while ( el != null && el.nodeType!=1 && el.parentNode!=this.tableElement ) {
		el = el.parentNode;
	}
	
	if(el == this.tableElement) {
		return false;
	}
	
	//alert("t");
	
	// get the row we are over
	rowEl = this.getCurrentRow(el);
	
	
	if( rowEl == null ) {
		return false;
	}
	
	// we're in the same row, do nothing
	if( rowEl == this.selectedRow ) {
		return false;
	}
	
	// return the currently highlighted row to its original form
	if( this.selectedRow ) {
		this.selectedRow.className = this.selectedRowOriginalClass;
	}
	
	// store the selected row element and its original class
	this.selectedRow              = rowEl;
	// store the selected row class
	this.selectedRowOriginalClass = rowEl.className;
	
	// highlight the current row
	rowEl.className = this.highlightedClassName;
	return;
	
}

RowHighlighter.prototype.getCurrentRow = function(el) {
	// cruise up to the TR tag
	//names = el.nodeName + " " + el.id + "\n";
	while ( el != null && el.parentNode.parentNode.id!=this.containerId && el.parentNode != null) {
		el = el.parentNode;
		//names = names + el.nodeName + " " + el.id + "\n";
	}	
	//alert(el.nodeName);
	
	return el;
}

