﻿/*
Thanks Renishaw plc. All rights reserved
Created: Jan 2007
Last updated: June 2009
*/
/* provide pretty mouse over effect on the (LHS) menu for IE6 and earlier - most others are CSS driven */
function menuHighlightOn(item) { item.className += ' menuSideHover';}
function menuHighlightOff(item) { item.className=item.className.replace(new RegExp("\\b(\\s)?menuSideHover\\b"), "");}

/* Suckerfish drop down menu script, extended slightly */
sfHover = function(){
    var siteNavElement = document.getElementById("siteNav")
    if( siteNavElement != null )
    {
        var sfEls = siteNavElement.getElementsByTagName("LI");
        for (var i=0; i<sfEls.length; i++) 
		{
            sfEls[i].onmouseover=function() {this.className+=" over";}
            sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp("\\b(\\s)?over\\b"), "");}
        }
    }
}
// Pop-up Tooltip
var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

// Provides a way of attaching (and detaching) multiple functions to page load.
function addLoadListener(functionName) /*legacy*/
{
	$(document).ready(functionName);
}


function attachEventListener(target, eventType, functionRef, capture)
{
  if (typeof target.addEventListener != "undefined"){target.addEventListener(eventType, functionRef, capture);}
  else if (typeof target.attachEvent != "undefined"){target.attachEvent("on" + eventType, functionRef);}
  else{
    eventType = "on" + eventType;

    if (typeof target[eventType] == "function")
    {
      var oldListener = target[eventType];

      target[eventType] = function(){
        oldListener();
        return  functionRef();
      }
    }
    else{target[eventType] = functionRef;}
  }
  return true; 
}

// Courtesy of http://www.quirksmode.org/dom/getElementsByTagNames.html
function getElementsByTagNames(list,obj)
{
	if (!obj) var obj = document;
	
	var tagNames = list.split(',');
	var resultArray = new Array();
	
	for (var i=0;i<tagNames.length;i++) {
		var tags = obj.getElementsByTagName(tagNames[i]);
		for (var j=0;j<tags.length;j++) {
			resultArray.push(tags[j]);
		}
	}
	
	var testNode = resultArray[0];
	if (!testNode) return [];
	if (testNode.sourceIndex) {
		resultArray.sort(function (a,b) {
				return a.sourceIndex - b.sourceIndex;
		});
	}
	else if (testNode.compareDocumentPosition) {
		resultArray.sort(function (a,b) {
				return 3 - (a.compareDocumentPosition(b) & 6);
		});
	}
				
	return resultArray;
}

// Generate a ToC from page headings
function generateTOC()
{
	//Get language or fallback to english
	var lang = document.getElementsByTagName('html')[0].getAttribute('Lang');
	if (lang == 'undefined'){lang = 'en';}
	
	var topText, pageContentText;

	switch(lang)
	{
		case 'cs':
			topText = 'Horní strana';
			pageContentText = 'Obsah strany';				
			break;		
		case 'de':
			topText = 'Nach oben';
			pageContentText = 'Seiteninhalt';				
			break;	
		case 'es':
			topText = 'Arriba';
			pageContentText = 'Contenido de la página';				
			break;	
		case 'fr':
			topText = 'Sous';
			pageContentText = 'Sur cette page';				
			break;	
		case 'it':
			topText = 'All\'inizio';
			pageContentText = 'Contenuto della pagina';				
			break;	
		case 'jp':
			topText = 'トップへ';
			pageContentText = 'ページコンテンツ';
			break;
		case 'ko':
			topText = '맨 위';
			pageContentText = '페이지 내용';
			break;
		case 'nl':
			topText = 'Naar boven';
			pageContentText = 'Op deze pagina';			
			break;		
		case 'pl':
			topText = 'Do góry';
			pageContentText = 'Zawartość strony';
			break;
		case 'pt':
			topText = 'Topo da página';
			pageContentText = 'Conteúdo da página';
			break;
		case 'ru':
			topText = 'К началу';
			pageContentText = 'Содержание страницы';
			break;
		case 'sl':
			topText = 'Navzgor';
			pageContentText = 'Vsebina strani';
			break;
		case 'sv':
			topText = 'Upp';
			pageContentText = 'Sidans innehåll';
			break;
		case 'tr':
			topText = 'En başa';
			pageContentText = 'Sayfa içeriği';
			break;
		case 'tw':
			topText = '頂部';
			pageContentText = '頁面內容';
			break;	
		case 'zh':
			topText = '顶部';
			pageContentText = '网页内容';				
			break;
		default:
			topText = 'Top';
			pageContentText = 'Page content';
			break;
	}
		
	var menu = document.getElementById('TOC');
	
	if (null == menu){return;}/*nothing to do*/
	
	var headings = getElementsByTagNames('h2,h3,h4', document.getElementById('colContent'));
	var anchorContainer, anchor, linkId;
	
	if (headings.length < 3) return;	//only make a TOC if more than one heading
	
	// Don't allow more than 10 headings unless they're all top level ones
	if (headings.length > 10)
		headings = getElementsByTagNames('h2', document.getElementById('colContent'));

	menu.className = 'TOC'; /*add classname; only do this now we know we have items as it will make the element appear - visible borders etc*/

	var tocAnchor = document.createElement('a');
	tocAnchor.setAttribute('name', 'pageTop');
	tocAnchor.id = 'pageTop';
	tocAnchor.className = 'TOCTitle';
	
	var anchorText = document.createTextNode(pageContentText);
	tocAnchor.appendChild(anchorText);
	menu.appendChild(tocAnchor);

	//Create the TOC
	tocList = document.createElement("ul");
	
	for (var entryPosition=0; entryPosition<headings.length; entryPosition++) 
	{
		var thisEntry = headings[entryPosition];
		
		// Determine the link
		linkId = thisEntry.id || uniqueId('tocTarget' + entryPosition);

		// Define the anchor container
		anchorContainer = document.createElement("li");
		anchorContainer.className = 'tocEntry' + thisEntry.nodeName.toLowerCase();

		// Define the anchor
		var anchor = document.createElement("a");
		var killTagsRegex = /<\/?[^>]*?>/gim; // Removes tags |  gim - all matches, case insensitive, multiline
		var tocText = thisEntry.innerHTML.replace(killTagsRegex, '');
		anchor.innerHTML = tocText;
		anchor.href = '#' + linkId;

		// Add the item
		anchorContainer.appendChild(anchor);
		if (anchor.innerHTML.replace(/\&nbsp;/, '').replace(/\&#160;/, '').replace(/\s/, '').length > 0) //not an empty link
		{
			tocList.appendChild(anchorContainer);

			// Modify the link target
			thisEntry.id = linkId;	// Change the element to ensure it has an id

			//Make the wrapper around heading so we can add 'top of page' etc with impunity
			var goTopWrapper = document.createElement('a');
			goTopWrapper.href='#pageTop';
			goTopWrapper.className = 'top';

			var goTopContent = document.createTextNode(topText); //Language concerns?
			goTopWrapper.appendChild(goTopContent);

			var hWrapper = document.createElement('div');
			hWrapper.className = 'tocHeader';
			hWrapper.appendChild(goTopWrapper);


			//then copy heading inside wrapper
			var hClone = thisEntry.cloneNode(true);
			hWrapper.appendChild(hClone);	

			//add wrapper next to target...
			thisEntry.parentNode.replaceChild(hWrapper, thisEntry);
		}
	}

	menu.appendChild(tocList);
}

// Generate a unique identity name
// Field: Identity to form the root
function uniqueId(root)
{
	var unique = root;
	while (document.getElementById(unique)) {unique += "_";	}
	return unique;
}

//Create alternate row styles on correct table types
function highlightAlternateRows ()
{
	var tables = document.getElementsByTagName('table');
	var contentTables = getElementsByClassName(tables, 'contentTable');
	
	for(var i = 0; i < contentTables.length; i++)
	{
		//get child nodes of type TBODY - but only the first so we don't affect tables within the one we want to update
		var TBodyNode = contentTables[i].getElementsByTagName('TBODY')[0];
	
		//get child nodes of TBODY that are TRs
		var TBodyChildren = TBodyNode.childNodes;
		var TRs = new Array();
		
		//get an array of all TRs
		for (var m = 0; m < TBodyChildren.length; m++)
		{
			var isHeader = false;
			
			if (TBodyChildren[m].nodeName == 'TR')
			{	
				var cells = TBodyChildren[m].childNodes;
								
				for (var cell = 1; cell < cells.length; cell++) //start at one so we keep row highlighting for tables with vertical headers
				{
					//var thClassName = /\b\s?th\b/; //regex pattern for classname of th
					if (cells[cell].nodeName == 'TH') {	 isHeader = true;}
				}
				
				if (isHeader == false) {TRs[TRs.length] = TBodyChildren[m];}
			}
		}
			
		for(var j = 0; j < TRs.length; j++)
		{
			if ( j % 2 != 0) /*even row*/ {TRs[j].className = " altRow"; /*leave a space so we don't interfere with existing classes*/}
		}	
	}
}

function getElementsByClassName(elementArray, NameofClass)
{
	var matchedArray = new Array();
	
	for (var i = 0; i < elementArray.length; i++)
	{
 		var pattern = new RegExp("(^| )" + NameofClass + "( |$)");

		if (pattern.test(elementArray[i].className))
		{
			matchedArray[matchedArray.length] = elementArray[i];
		}
      }
      return matchedArray;
 }
 


 
 //Search box
 var Search = {
	langcode:'en',
	sb:{},
	init:function() {
		Search.sb = $('#terms');
		if(location.pathname != null && location.pathname.length > 0) {
			var lc = location.pathname.match(/\/([a-zA-Z\-]{2,5})\//i);
			if(lc[1]) Search.langcode = lc[1];
		}
		Search.sb.keydown(Search.Keypress);
	},
	submit:function() {
		try {
			if(Search.sb.val().length > 0) {
				location.href = 'http://resources.hermesco.net/'  + encodeURI(Search.langcode) + '/search/' + encodeURI(Search.sb.val());
			} 
		} catch ( e ) {
			alert("No search terms entered"); //needs translation?
		}
		return false;		
	},
	Keypress: function(e) {
		if (e.keyCode == '13'){	
			if(e.preventDefault) e.preventDefault();
			if(e.stopPropagation) e.stopPropagation();
			setTimeout(Search.submit, 250);
			e.cancelBubble = true;
			e.returnValue = false;			
		}		
	}
 }
function searchSite(searchBoxId, languageCode)
{
	var searchBox = document.getElementById(searchBoxId);
	if ((searchBox != null) && (searchBox != 'undefined'))
	{
		location.href = 'http://resources.hermesco.net/'  + encodeURI(languageCode) + '/search/' + encodeURI(searchBox.value);
	}
	else
	{
		alert ("No search terms entered.");
	}
	return false;
}
 $('document').ready(Search.init);
 /* End Search */
 
function ctaEnhance()
{
	var killTagsRegex = /<\/?[^>]*?>/gim; // Removes tags |  gim - all matches, case insensitive, multiline		
 
	var targets = new Array(	document.getElementById('helpZoneInfo'),document.getElementById('helpZoneQuote'),document.getElementById('helpZoneSupport'),document.getElementById('nextStepsInfo'),document.getElementById('nextStepsQuote'),document.getElementById('nextStepsLocalOffices') );	
	var menuItems = $('#colLeft td.menuItem');	
	if (menuItems.length > 0){ //.com template always has prod line as first item (.info has site name)
		var ProdLine = menuItems[0].innerHTML.replace(killTagsRegex, '');	
		var querystringAddition = '';
		if (ProdLine != '')	{
			var ProdLineId = ProductLineLookup(ProdLine);
			if (!isNaN(ProdLineId)) /*is a number*/ {	querystringAddition = '&productline=' + ProdLineId; /*add productline ID*/	}	}

		for (var i=0; i< targets.length; i++){ if (targets[i] != undefined) { targets[i].href = targets[i].href + querystringAddition;	}}
	}
}
$(document).ready(ctaEnhance);
 
function ProductLineLookup(ProductLineName)
 {
	switch (ProductLineName)
	{
		case 'Laser calibration and ballbar':
			return '1';
		case 'CMM probes, software and retrofits':
			return '2';
		case 'Corporate':
			return '10';
		case 'incise™ dental cad/cam':
			return '4';	
		case 'Digitising':
			return '1';
		case 'Laser encoders':
			return '6';
		case 'Machine tool probes and software':
			return '7';
		case 'Neurological':
			return '12';
		case 'Position encoders':
			return '5';
		case 'Raman spectroscopy':
			return '8';
		case 'Styli for touch probes':
			return '9';
		default:
			var tmp = ProductLineName.substring(0,6);
			if (ProductLineName.substring(0,6) == 'incise')	{return '4';}
			break;
	}
 }

function hideTableRows(tableId, tableRowId, collapse) {
    switch (collapse) {
        case true:
            {
                $("#table_" + tableId + "_row_" + tableRowId).hide();
                $("#table_" + tableId + "_row_" + (tableRowId - 1)).show();
                break;
            }
        case false:
            {
                $("#table_" + tableId + "_row_" + (tableRowId - 1)).hide();
                $("#table_" + tableId + "_row_" + tableRowId).show();
                break;
            }
    }
}

function hideTableColumns(tablename, tableHeight, tableColumnId, collapse) {
    switch (collapse) {
        case true:
            {
                for (var tableRowId = 0; tableRowId < tableHeight; tableRowId = tableRowId + 2) {
                    $("#table_" + tablename + "_row_" + tableRowId + "_column_" + tableColumnId).hide();
                    $("#table_" + tablename + "_row_" + tableRowId + "_column_" + (parseInt(tableColumnId) + 1)).show();
                }
                break;
            }
        case false:
            {
                for (var tableRowId = 0; tableRowId < tableHeight; tableRowId = tableRowId + 2) {
                    $("#table_" + tablename + "_row_" + tableRowId + "_column_" + (parseInt(tableColumnId) + 1)).hide();
                    $("#table_" + tablename + "_row_" + tableRowId + "_column_" + tableColumnId).show();
                }
                break;
            }
    }
}


function addComparisionTable() {
    var tableList = getElementsByClassName(getElementsByTagNames('TABLE'), 'interactiveTable');
	var isFireFox = false;
	
    for (var i = 0; i < tableList.length; i++) {
        var tableRows = tableList[i].getElementsByTagName("TR");
        var rowCount = (tableRows.length * 2);
        var colsToHide = "";
        for (var j = 0; j <= tableRows.length; j=j+2) {
            if (j == 0) {
                // add empty header row
                var newCell = tableRows[j].insertCell(0);
                newCell.innerHTML = '<br />';
            } else {
                // add minus image and javascript on click event
                tableRows[j - 1].id = 'table_' + i + '_row_' + j;

                var newCell = tableRows[j - 1].insertCell(0);
                newCell.innerHTML = '<a onclick=hideTableRows("' + i + '","' + j + '",true);><img src="http://www.hermesco.net/images/icons/minus.gif" /></a>';

                var newRow = tableList[i].insertRow(j - 1);
                newRow.insertCell(0);
                newRow.insertCell(1);
                
                var firstCell = newRow.cells[0];
                firstCell.innerHTML = '<a onclick=hideTableRows("' + i + '","' + j + '",false);><img src="http://www.hermesco.net/images/icons/plus.gif" /></a>'
                
                var lastCell = newRow.cells[1];
                lastCell.colSpan = tableRows[j].cells.length - 1;
                var test = tableRows[j].cells[1];
                if (tableRows[j].cells[1].childNodes[0].data == "\n") {
                    lastCell.innerHTML = tableRows[j].cells[1].childNodes[1].innerHTML;
                }
                else {
                    lastCell.innerHTML = tableRows[j].cells[1].childNodes[0].innerHTML;
                }

                newRow.id = 'table_' + i + '_row_' + (j - 1);
                $("#" + newRow.id).hide();
            }
            
            // add columns
            var tableColumns = tableRows[j].childNodes;
			var firefox = 0;
			var firefox2 = 2;
			var firefox3 = 0;
			var loop = tableColumns.length;
			if (isFireFox) {
				loop = tableColumns.length;
			}
			
            for (var k = 1; k < loop; k = k + 2) {
				if (tableRows[j].childNodes[0].data != "\n") {
					loop++;
					if (j == 0) {
						var toolTip = "";
						toolTip = tableRows[j].childNodes[k].innerHTML;
						
						tableRows[j].childNodes[k].id = 'table_' + i + '_row_' + j + '_column_' + k;
						tableRows[j].childNodes[k].innerHTML = '<a onclick=hideTableColumns("' + i + '","' + rowCount + '","' + k + '",true);><img src="http://www.hermesco.net/images/icons/minus.gif" /></a>' + tableRows[j].childNodes[k].innerHTML;

						var newCell = tableRows[j].insertCell(k + 1);
						newCell.id = 'table_' + i + '_row_' + j + '_column_' + (k + 1);
						newCell.innerHTML = '<a onclick=hideTableColumns("' + i + '","' + rowCount + '","' + k + '",false); title="' + toolTip + '"><img src="http://www.hermesco.net/images/icons/plus.gif" /></a>'
						colsToHide += newCell.id + ",";
					}
					else {
						tableRows[j].childNodes[k].id = 'table_' + i + '_row_' + j + '_column_' + k;
						
						var newCell = tableRows[j].insertCell(k + 1);
						newCell.id = 'table_' + i + '_row_' + j + '_column_' + (k + 1);
						newCell.innerHTML = '<br />';
						colsToHide += newCell.id + ",";
					}
				}
				else
				{
					isFireFox = true;
					firefox += firefox2;
					if (j == 0) {
						var toolTip = "";
						
						toolTip = tableRows[j].childNodes[firefox].innerHTML;
					
						tableRows[j].childNodes[firefox].id = 'table_' + i + '_row_' + j + '_column_' + k;
						tableRows[j].childNodes[firefox].innerHTML = '<a onclick=hideTableColumns("' + i + '","' + rowCount + '","' + k + '",true);><img src="http://www.hermesco.net/images/icons/minus.gif" /></a>' + tableRows[j].childNodes[firefox].innerHTML;

						if (k!=1) {
							firefox -= firefox3;
						}
						
						var newCell = tableRows[j].insertCell(firefox);
						newCell.id = 'table_' + i + '_row_' + j + '_column_' + (firefox);
						newCell.innerHTML = '<a onclick=hideTableColumns("' + i + '","' + rowCount + '","' + k + '",false); title="' + toolTip + '"><img src="http://www.hermesco.net/images/icons/plus.gif" /></a>'
						colsToHide += newCell.id + ",";
					}
					else {
						tableRows[j].childNodes[firefox].id = 'table_' + i + '_row_' + j + '_column_' + k;
						
						if (k!=1) {
							firefox -= firefox3;
						}
						
						var newCell = tableRows[j].insertCell(k+1);
						newCell.id = 'table_' + i + '_row_' + j + '_column_' + (k+1);
						newCell.innerHTML = '<br />';
						colsToHide += newCell.id + ",";
					}
					firefox2++;
					firefox3++;
				}
            }
        }

        // hide all new empty columns
        var colsToHideArray = colsToHide.split(",");
        for (var colId = 0; colId < colsToHideArray.length-1; colId++) {
            $("#" + colsToHideArray[colId]).hide();
        }
    }
}
$(document).ready(addComparisionTable);


/*Load hidden shadowbox inline divs*/
/*Note: this is a temp setup until fully integrated with the CMS*/
function ManualInlineLinks()
{
	//if ($("#ENC-fastrack-perfgraph").length == 1) ElementHTML25759
	if ($("#ElementHTML25759").length == 1) 
	{
		//add click events to trigger
		$("#ElementHTML25759").bind(
			"click", 
			function() {
				Shadowbox.open({
					content: $("#ElementHTML25990").html(),
					player: "html",
					title: "FASTRACK",
					width: 1000,
					height: 600
				});
		}
		);			
	}
}
$(document).ready(ManualInlineLinks);	

/*
SUPERNOTE v1.0beta (c) 2005-2006 Angus Turnbull, http://www.twinhelix.com
Altering this notice or redistributing this file is prohibited.
*/
if(typeof addEvent!='function'){var addEvent=function(o,t,f,l){var d='addEventListener',n='on'+t,rO=o,rT=t,rF=f,rL=l;if(o[d]&&!l)return o[d](t,f,false);if(!o._evts)o._evts={};if(!o._evts[t]){o._evts[t]=o[n]?{b:o[n]}:{};o[n]=new Function('e','var r=true,o=this,a=o._evts["'+t+'"],i;for(i in a){o._f=a[i];r=o._f(e||window.event)!=false&&r;o._f=null}return r');if(t!='unload')addEvent(window,'unload',function(){removeEvent(rO,rT,rF,rL)})}if(!f._i)f._i=addEvent._i++;o._evts[t][f._i]=f};addEvent._i=1;var removeEvent=function(o,t,f,l){var d='removeEventListener';if(o[d]&&!l)return o[d](t,f,false);if(o._evts&&o._evts[t]&&f._i)delete o._evts[t][f._i]}}function cancelEvent(e,c){e.returnValue=false;if(e.preventDefault)e.preventDefault();if(c){e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation()}};function SuperNote(myName,config){var defaults={myName:myName,allowNesting:false,cssProp:'visibility',cssVis:'inherit',cssHid:'hidden',IESelectBoxFix:true,showDelay:0,hideDelay:500,animInSpeed:0.1,animOutSpeed:0.1,animations:[],mouseX:0,mouseY:0,notes:{},rootElm:null,onshow:null,onhide:null};for(var p in defaults)this[p]=(typeof config[p]=='undefined')?defaults[p]:config[p];var obj=this;addEvent(document,'mouseover',function(evt){obj.mouseHandler(evt,1)});addEvent(document,'click',function(evt){obj.mouseHandler(evt,2)});addEvent(document,'mousemove',function(evt){obj.mouseTrack(evt)});addEvent(document,'mouseout',function(evt){obj.mouseHandler(evt,0)});this.instance=SuperNote.instances.length;SuperNote.instances[this.instance]=this}SuperNote.instances=[];SuperNote.prototype.bTypes={};SuperNote.prototype.pTypes={};SuperNote.prototype.pTypes.mouseoffset=function(obj,noteID,nextVis,nextAnim){with(obj){var note=notes[noteID];if(nextVis&&!note.animating&&!note.visible){note.ref.style.left=checkWinX(mouseX,note)+'px';note.ref.style.top=checkWinY(mouseY,note)+'px'}}};SuperNote.prototype.pTypes.mousetrack=function(obj,noteID,nextVis,nextAnim){with(obj){var note=notes[noteID];if(nextVis&&!note.animating&&!note.visible){var posString='with('+myName+'){var note=notes["'+noteID+'"];note.ref.style.left=checkWinX(mouseX,note)+"px";note.ref.style.top=checkWinY(mouseY,note)+"px"}';eval(posString);obj.IEFrameFix(noteID,1);if(!note.trackTimer)note.trackTimer=setInterval(posString,50)}else if(!nextVis&&!nextAnim){clearInterval(note.trackTimer);note.trackTimer=null}}};SuperNote.prototype.pTypes.triggeroffset=function(obj,noteID,nextVis,nextAnim){with(obj){var note=notes[noteID];if(nextVis&&!note.animating&&!note.visible){var x=0,y=0,elm=note.trigRef;while(elm){x+=elm.offsetLeft;y+=elm.offsetTop;elm=elm.offsetParent}note.ref.style.left=checkWinX(x,note)+'px';note.ref.style.top=checkWinY(y,note)+'px'}}};SuperNote.prototype.bTypes.pinned=function(obj,noteID,nextVis){with(obj){return(!nextVis)?false:true}};SuperNote.prototype.docBody=function(){return document[(document.compatMode&&document.compatMode.indexOf('CSS')>-1)?'documentElement':'body']};SuperNote.prototype.getWinW=function(){return this.docBody().clientWidth||window.innerWidth||0};SuperNote.prototype.getWinH=function(){return this.docBody().clientHeight||window.innerHeight||0};SuperNote.prototype.getScrX=function(){return this.docBody().scrollLeft||window.scrollX||0};SuperNote.prototype.getScrY=function(){return this.docBody().scrollTop||window.scrollY||0};SuperNote.prototype.checkWinX=function(newX,note){with(this){return Math.max(getScrX(),Math.min(newX,getScrX()+getWinW()-note.ref.offsetWidth-8))}};SuperNote.prototype.checkWinY=function(newY,note){with(this){return Math.max(getScrY(),Math.min(newY,getScrY()+getWinH()-note.ref.offsetHeight-8))}};SuperNote.prototype.mouseTrack=function(evt){with(this){mouseX=evt.pageX||evt.clientX+getScrX()||0;mouseY=evt.pageY||evt.clientY+getScrY()||0}};SuperNote.prototype.mouseHandler=function(evt,show){with(this){if(!document.documentElement)return true;var srcElm=evt.target||evt.srcElement,trigRE=new RegExp(myName+'-(hover|click)-([a-z0-9]+)','i'),targRE=new RegExp(myName+'-(note)-([a-z0-9]+)','i'),trigFind=1,foundNotes={};if(srcElm.nodeType!=1)srcElm=srcElm.parentNode;var elm=srcElm;while(elm&&elm!=rootElm){if(targRE.test(elm.id)||(trigFind&&trigRE.test(elm.className))){if(!allowNesting)trigFind=0;var click=RegExp.$1=='click'?1:0,noteID=RegExp.$2,ref=document.getElementById(myName+'-note-'+noteID),trigRef=trigRE.test(elm.className)?elm:null;if(ref){if(!notes[noteID]){notes[noteID]={click:click,ref:ref,trigRef:null,visible:0,animating:0,timer:null};ref._sn_obj=this;ref._sn_id=noteID}var note=notes[noteID];if(!note.click||(trigRef!=srcElm))foundNotes[noteID]=true;if(!note.click||(show==2)){if(trigRef)notes[noteID].trigRef=notes[noteID].ref._sn_trig=elm;display(noteID,show);if(note.click&&(srcElm==trigRef))cancelEvent(evt)}}}if(elm._sn_trig){trigFind=1;elm=elm._sn_trig}else{elm=elm.parentNode}}if(show==2)for(var n in notes){if(notes[n].click&&notes[n].visible&&!foundNotes[n])display(n,0)}}};SuperNote.prototype.display=function(noteID,show){with(this){with(notes[noteID]){clearTimeout(timer);if(!animating||(show?!visible:visible)){var tmt=animating?1:(show?showDelay||1:hideDelay||1);timer=setTimeout('SuperNote.instances['+instance+'].setVis("'+noteID+'",'+show+',false)',tmt)}}}};SuperNote.prototype.checkType=function(noteID,nextVis,nextAnim){with(this){var note=notes[noteID],bType,pType;if((/snp-([a-z]+)/).test(note.ref.className))pType=RegExp.$1;if((/snb-([a-z]+)/).test(note.ref.className))bType=RegExp.$1;if(nextAnim&&bType&&bTypes[bType]&&(bTypes[bType](this,noteID,nextVis)==false))return false;if(pType&&pTypes[pType])pTypes[pType](this,noteID,nextVis,nextAnim);return true}};SuperNote.prototype.setVis=function(noteID,show,now){with(this){var note=notes[noteID];if(note&&checkType(noteID,show,1)||now){note.visible=show;note.animating=1;animate(noteID,show,now)}}};SuperNote.prototype.animate=function(noteID,show,now){with(this){var note=notes[noteID];if(!note.animTimer)note.animTimer=0;if(!note.animC)note.animC=0;with(note){clearTimeout(animTimer);var speed=(animations.length&&!now)?(show?animInSpeed:animOutSpeed):1;if(show&&!animC){if(onshow)this.onshow(noteID);IEFrameFix(noteID,1);ref.style[cssProp]=cssVis}animC=Math.max(0,Math.min(1,animC+speed*(show?1:-1)));if(document.getElementById&&speed<1)for(var a=0;a<animations.length;a++)animations[a](ref,animC);if(!show&&!animC){if(onhide)this.onhide(noteID);IEFrameFix(noteID,0);ref.style[cssProp]=cssHid}if(animC!=parseInt(animC)){animTimer=setTimeout(myName+'.animate("'+noteID+'",'+show+')',50)}else{checkType(noteID,animC?1:0,0);note.animating=0}}}};SuperNote.prototype.IEFrameFix=function(noteID,show){with(this){if(!window.createPopup||!IESelectBoxFix)return;var note=notes[noteID],ifr=note.iframe;if(!ifr){ifr=notes[noteID].iframe=document.createElement('iframe');ifr.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=0)';ifr.style.position='absolute';ifr.style.borderWidth='0';note.ref.parentNode.insertBefore(ifr,note.ref.parentNode.firstChild)}if(show){ifr.style.left=note.ref.offsetLeft+'px';ifr.style.top=note.ref.offsetTop+'px';ifr.style.width=note.ref.offsetWidth+'px';ifr.style.height=note.ref.offsetHeight+'px';ifr.style.visibility='inherit'}else{ifr.style.visibility='hidden'}}};

var supernote = new SuperNote('supernote', {});

// Available config options are:
//allowNesting: true/false    // Whether to allow triggers within triggers.
//cssProp: 'visibility'       // CSS property used to show/hide notes and values.
//cssVis: 'inherit'
//cssHid: 'hidden'
//IESelectBoxFix: true/false  // Enables the IFRAME select-box-covering fix.
//showDelay: 0                // Millisecond delays.
//hideDelay: 500
//animInSpeed: 0.1            // Animation speeds, from 0.0 to 1.0; 1.0 disables.
//animOutSpeed: 0.1

// You can pass several to your "new SuperNote()" command like so:
//{ name: value, name2: value2, name3: value3 }

// All the script from this point on is optional!

// Optional animation setup: passed element and 0.0-1.0 animation progress.
// You can have as many custom animations in a note object as you want.
function animFade(ref, counter)
{
 //counter = Math.min(counter, 0.9); // Uncomment to make notes translucent.
 var f = ref.filters, done = (counter == 1);
 if (f)
 {
  if (!done && ref.style.filter.indexOf("alpha") == -1)
   ref.style.filter += ' alpha(opacity=' + (counter * 100) + ')';
  else if (f.length && f.alpha) with (f.alpha)
  {
   if (done) enabled = false;
   else { opacity = (counter * 100); enabled=true }
  }
 }
 else ref.style.opacity = ref.style.MozOpacity = counter*0.999;
};
supernote.animations[supernote.animations.length] = animFade;

// Optional custom note "close" button handler extension used in this example.
// This picks up click on CLASS="note-close" elements within CLASS="snb-pinned"
// notes, and closes the note when they are clicked.
// It can be deleted if you're not using it.
addEvent(document, 'click', function(evt)
{
 var elm = evt.target || evt.srcElement, closeBtn, note;

 while (elm)
 {
  if ((/note-close/).test(elm.className)) closeBtn = elm;
  if ((/snb-pinned/).test(elm.className)) { note = elm; break }
  elm = elm.parentNode;
 }

 if (closeBtn && note)
 {
  var noteData = note.id.match(/([a-z_\-0-9]+)-note-([a-z_\-0-9]+)/i);
  for (var i = 0; i < SuperNote.instances.length; i++)
   if (SuperNote.instances[i].myName == noteData[1])
   {
    setTimeout('SuperNote.instances[' + i + '].setVis("' + noteData[2] +
     '", false, true)', 100);
	cancelEvent(evt);
   }
 }
});

// Extending the script: you can capture mouse events on note show and hide.
// To get a reference to a note, use 'this.notes[noteID]' within a function.
// It has properties like 'ref' (the note element), 'trigRef' (its trigger),
// 'click' (whether its shows on click or not), 'visible' and 'animating'.
addEvent(supernote, 'show', function(noteID)
{
 // Do cool stuff here!
});
addEvent(supernote, 'hide', function(noteID)
{
 // Do cool stuff here!
});

// If you want draggable notes, feel free to download the "DragResize" script
// from my website http://www.twinhelix.com -- it's a nice addition :).

/*END Load hidden shadowbox inline divs*/
