﻿// JavaScript Document

//#############################################
//#############################################

//				CONTROL PANEL

//#############################################
//#############################################



var fadeOutSpeed = 1000;

var fadeInSpeed = 1000;

var slideOn = true;

var slideSpeed = 5000;

var thumbFadeSpeed = 500;

var toolBoxSlideSpeed = 500;

var mainMenuIn = 333;

var mainMenuOut = 226;

var animateMoreTime = 700;

var slideTimerVar;
var slideTimerVarInitial;



//#############################################
//#############################################

var browserName = navigator.appName;
var ua = window.navigator.userAgent;

var ieVer = getInternetExplorerVersion();

//window.onbeforeonload = changeCompatibility();
	
function getInternetExplorerVersion(){
	
   var rv = -1;
   
   if (browserName == 'Microsoft Internet Explorer'){
	   
	  var ua = navigator.userAgent;
	  
	  var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	  
	  if (re.exec(ua) != null){
		  
		 rv = parseFloat( RegExp.$1 );
	  }
   }
   return rv;
}

/*function changeCompatibility(){

	if (browserName == 'Microsoft Internet Explorer' && ieVer == 7){
		
		var _n=navigator,_w=window,_d=document;
		var na=_n.userAgent;
		
		if(/trident\/\d/i.test(na)){
			
			var docHead = document.getElementsByTagName('head')[0];
			var scriptEx = document.createElement('meta');
			scriptEx.httpEquiv = 'X-UA-Compatible';
			scriptEx.content = 'IE=EmulateIE8';
			
			var pageTitle = document.getElementsByTagName('title');
			$(scriptEx).insertAfter(pageTitle);
			
			
		}
	}	
}*/

//#############################################
//#############################################

var eloquaArray = new Array();

var eloquaArray_firstName = '';
var eloquaArray_lastName = '';
var eloquaArray_emailAddress = '';
var eloquaArray_phoneNumber = '';
var eloquaArray_companyName = '';

function SetElqContent(){
    
	if (this.GetElqContentPersonalizationValue){
	
		eloquaArray[0] = GetElqContentPersonalizationValue('V_ElqFirstName');
		eloquaArray[1] = GetElqContentPersonalizationValue('V_ElqLastName');
		eloquaArray[2] = GetElqContentPersonalizationValue('V_ElqEmailAddress');
		eloquaArray[3] = GetElqContentPersonalizationValue('V_ElqPhoneNumber');
		eloquaArray[4] = GetElqContentPersonalizationValue('V_ElqCompanyName');
		/*eloquaArray[5] = GetElqContentPersonalizationValue('M_Address1');
		eloquaArray[6] = GetElqContentPersonalizationValue('M_Address2');
		eloquaArray[7] = GetElqContentPersonalizationValue('M_City');
		eloquaArray[8] = GetElqContentPersonalizationValue('M_State_Prov');
		eloquaArray[9] = GetElqContentPersonalizationValue('M_Zip_Postal');
		
		alert(eloquaArray);*/
		
		eloquaArray_firstName = String(eloquaArray[0]);
		eloquaArray_lastName = String(eloquaArray[1]);
		eloquaArray_emailAddress = String(eloquaArray[2]);
		eloquaArray_phoneNumber = String(eloquaArray[3]);
		eloquaArray_companyName = String(eloquaArray[4]);
	}
}

var numSeconds;
var formSubmitCounter;

function launchLeadGen(leadCode){
		
	var eloquaFormDiv = document.createElement('div');
	eloquaFormDiv.style.display = 'none';
	eloquaFormDiv.id = 'eloquaContainerDiv';
	
	if (document.getElementById('eloquaContainerDiv') == null){
	
		document.body.appendChild(eloquaFormDiv);
	
		document.getElementById('eloquaContainerDiv').innerHTML = '<form id="eloquaForm_Blackbaudv7" class="eloquaForm" method="post" action="http://now.eloqua.com/e/f2.aspx" target="submitIframe" name="Blackbaudv7"><input type="hidden" value="Blackbaudv7" name="elqFormName"><input type="hidden" value="2231" name="elqSiteID"><input type="hidden" value="" name="elqCustomerGUID"><table cellspacing="2" cellpadding="2" border="0" class="elqFormTable"><input type="hidden" value="'+leadCode+'" name="LSC"><tbody><tr class="elqFormHeaderRow"><td colspan="2"><h1>Request More Information</h1><p>Complete the form below and a Blackbaud representative will be in touch with you:</p></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> First Name: </span></td><td><input type="text" value="'+eloquaArray_firstName+'" name="C_FirstName" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> Last Name: </span></td><td><input type="text" value="'+eloquaArray_lastName+'" name="C_LastName" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> Email Address: </span></td><td><input type="text" value="'+eloquaArray_emailAddress+'" name="C_EmailAddress" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> Business Phone: </span></td><td><input type="text" value="'+eloquaArray_phoneNumber+'" name="C_BusPhone" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> Organization: </span></td><td><input type="text" value="'+eloquaArray_companyName+'" name="C_Company" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> Address 1: </span></td><td><input type="text" value="" name="C_Address1" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> Address 2: </span></td><td><input type="text" value="" name="C_Address2" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> City: </span></td><td><input type="text" value="" name="C_City" class="elqFormField"></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> State or Province: </span></td><td><select name="C_State_Prov" class="elqFormField"><option value=""> Please Select…</option><option value="AK"> Alaska</option><option value="AL"> Alabama</option><option value="AR"> Arkansas</option><option value="AS"> American Samoa</option><option value="AZ"> Arizona</option><option value="CA"> California</option><option value="CO"> Colorado</option><option value="CT"> Connecticut</option><option value="DC"> D.C.</option><option value="DE"> Delaware</option><option value="FL"> Florida</option><option value="FM"> Micronesia</option><option value="GA"> Georgia</option><option value="GU"> Guam</option><option value="HI"> Hawaii</option><option value="IA"> Iowa</option><option value="ID"> Idaho</option><option value="IL"> Illinois</option><option value="IN"> Indiana</option><option value="KS"> Kansas</option><option value="KY"> Kentucky</option><option value="LA"> Louisiana</option><option value="MA"> Massachusetts</option><option value="MD"> Maryland</option><option value="ME"> Maine</option><option value="MH"> Marshall Islands</option><option value="MI"> Michigan</option><option value="MN"> Minnesota</option><option value="MO"> Missouri</option><option value="MP"> Marianas</option><option value="MS"> Mississippi</option><option value="MT"> Montana</option><option value="NC"> North Carolina</option><option value="ND"> North Dakota</option><option value="NE"> Nebraska</option><option value="NH"> New Hampshire</option><option value="NJ"> New Jersey</option><option value="NM"> New Mexico</option><option value="NV"> Nevada</option><option value="NY"> New York</option><option value="OH"> Ohio</option><option value="OK"> Oklahoma</option><option value="OR"> Oregon</option><option value="PA"> Pennsylvania</option><option value="PR"> Puerto Rico</option><option value="PW"> Palau</option><option value="RI"> Rhode Island</option><option value="SC"> South Carolina</option><option value="SD"> South Dakota</option><option value="TN"> Tennessee</option><option value="TX"> Texas</option><option value="UT"> Utah</option><option value="VA"> Virginia</option><option value="VI"> Virgin Islands</option><option value="VT"> Vermont</option><option value="WA"> Washington</option><option value="WI"> Wisconsin</option><option value="WV"> West Virginia</option><option value="WY"> Wyoming</option><option value="AA"> Military Americas</option><option value="AE"> Military Europe/ME/Canada</option><option value="AP"> Military Pacific</option><option value="AB"> Alberta</option><option value="MB"> Manitoba</option><option value="BC"> British Columbia</option><option value="NB"> New Brunswick</option><option value="NL"> Newfoundland and Labrador</option><option value="NS"> Nova Scotia</option><option value="NT"> Northwest Territories</option><option value="NU"> Nunavut</option><option value="ON"> Ontario</option><option value="PE"> Prince Edward Island</option><option value="QC"> Quebec</option><option value="SK"> Saskatchewan</option><option value="YT"> Yukon Territory</option></select></td></tr><tr class="elqFormRow"><td valign="top"><span class="elqFormFieldLabel"> Zip or Postal Code: </span></td><td><input type="text" value="" name="C_Zip_Postal" class="elqFormField"></td></tr><tr><td align="center" colspan="2" class="elqFormButtonRow"><input type="submit" value="Submit" class="elqFormSubmit"><div id="submitWait"><div id="submitSpin"></div></div></td></tr></tbody></table><iframe id="eloquaFrame" height="0" name="submitIframe" frameborder="0" scrolling="no" src=""></iframe><div id="formSubmitConfirm"></div></form>';
		
		$("#eloquaContainerDiv").fancybox({
			'autoScale'		: true,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'type'			: 'inline',
			'padding'		: '18',
			'speedIn'		: 400,
			'href'			: '#eloquaForm_Blackbaudv7',
			'onClosed'		: function(){
				
				document.body.removeChild(eloquaFormDiv);
			}
		}).trigger('click');
	
		$(".eloquaForm").bind("submit", function() {

			$("#submitSpin").fadeIn(300);

			document.getElementById('eloquaForm_Blackbaudv7').submit();
			
			document.getElementById("eloquaFrame").onload = new function(){

				displayConfirmation();
			}
	
			return false;
		});
	}
}

function displayConfirmation(){	
	
	numSeconds = 2;	
	
	$("#submitSpin").fadeOut(200);	
	
	document.getElementById('formSubmitConfirm').innerHTML = '<h3>Form Submitted Successfully</h3><p>This window will automatically close in <span id="timerCountSec">' + numSeconds + '</span> seconds...</p>';
	
	$("#formSubmitConfirm").fadeIn(500);
	
	formSubmitCounter = setInterval('formCloseTimer()',1000);
}

function formCloseTimer(){
	
	numSeconds--;
	
	if (numSeconds <= 0){
		
		clearInterval(formSubmitCounter);
		$.fancybox.close();
	}
	else {
		
		document.getElementById('timerCountSec').innerHTML = numSeconds;
	}
}

//#############################################
//#############################################

function addEvent(obj, evt, fn){
	
    if (obj.addEventListener){
       
	    obj.addEventListener(evt, fn, false);
    }
    else if (obj.attachEvent){
        
		obj.attachEvent("on" + evt, fn);
    }
}

addEvent(window,"load",function(e){
	
    addEvent(document, "mouseout", function(e){
		
        e = e ? e : window.event;
        
		var from = e.relatedTarget || e.toElement;
        
		if (!from || from.nodeName == "HTML") {
            
            $("div#wrapToolboxOuter").animate({ left: '-137' }, 500);
        }
    });
});

//#############################################
//#############################################

$(document).ready(function(){
	
	if (browserName != "Microsoft Internet Explorer" || ieVer == 9){ 
	
		$("#wrapMainNav").hide(0);
		$("div.wrapSubMenu").hide(0);
		$("#wrapSlideshowNav").hide(0);
		
		$("div.wrapSubMenu").mouseover(function(){
			  
			showMainNav();
		});
		
		$("div.wrapSubMenu").mouseout(function(){
			  
			hideMainNav();
		});
	}

	$("div#wrapToolboxOuter").mouseover(function(){
		  
		$("div#wrapToolboxOuter").stop();
		$(this).animate({ left: '0' }, toolBoxSlideSpeed);
	});
	$("div#wrapOuter").mouseover(function (){
		  
		$("div#wrapToolboxOuter").stop();
		$("div#wrapToolboxOuter").animate({ left: '-137' }, toolBoxSlideSpeed);
	});

});

//#############################################
//#############################################

$("#slideshowImg1 img").ready(function(){  

	$("#slideshowImg1 .slideshowImg").fadeOut(0);
	$("#slideshowImg2 .slideshowImg").fadeOut(0);
	$("#slideshowImg3 .slideshowImg").fadeOut(0);
	$("#slideshowImg4 .slideshowImg").fadeOut(0);
	
	$("#wrapMainNav").delay(250).fadeIn(fadeInSpeed);
	
	$("#slideshowImg1 .slideshowImg").delay(500).fadeIn(fadeInSpeed);
	
	$("#wrapSlideshowNav").delay(1000).fadeIn(fadeInSpeed);
});

//#############################################
//#############################################

jQuery(document).ready(function(){
	
	$(".boxIframe").click(function(){
		$.fancybox({
			'autoScale'		: false,
			'height'		: '72%',
			'width'			: '70%',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'type'			: 'iframe',
			'speedIn'		: 600,
			'href'			: this.href
		});

		return false;
	});
	
	$(".boxIframeAuto").click(function(){
		$.fancybox({
			'autoScale'		: true,
			'height'		: 550,
			'width'			: 450,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'padding'		: '18',
			'type'			: 'iframe',
			'speedIn'		: 600,
			'href'			: this.href
		});

		return false;
	});
	
	$(".boxIframeChat").click(function(){
		$.fancybox({
			'autoScale'		: true,
			'width'			: 615,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'padding'		: '18',
			'type'			: 'iframe',
			'speedIn'		: 600,
			'href'			: this.href
		});

		return false;
	});
	
	$(".boxImage").click(function(){
		$.fancybox({
			'autoScale'		: true,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'fade',
			'type'			: 'image',
			'href'			: this.href,
			'orig'			: $(this)
		});

		return false;
	});
	
	$(".boxInline").click(function(){
		$.fancybox({
			'autoScale'		: true,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'fade',
			'padding'		: '18',
			'type'			: 'inline',
			'href'			: this.href,
			'orig'			: $(this)
		});

		return false;
	});
	
	$(".boxVideo").click(function(){
		$.fancybox({
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'fade',
			'orig'			: $(this),
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

		return false;
	});
	
	$(".boxFlash").click(function(){
		$.fancybox({
			'autoScale'		: true,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'fade',
			'orig'			: $(this),
			'href'			: this.href,
			'type'			: 'swf',
			'swf'			: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

		return false;
	});
});

//#############################################
//#############################################

var currNav = "";
var prevNav = "";

function showMainNav(){
	
	if (browserName != "Microsoft Internet Explorer" || ieVer == 9){ 
	
		$(currNav).stop();
		$(currNav).show(0);
		$(currNav).animate({ opacity: 1 }, mainMenuIn);
		
		if(currNav != "#wrapMenuItem1"){
			
			$("div#wrapMenuItem1").hide(0);
		}
		if(currNav != "#wrapMenuItem2"){
			
			$("div#wrapMenuItem2").hide(0);
		}
		if(currNav != "#wrapMenuItem3"){
			
			$("div#wrapMenuItem3").hide(0);
		}
		if(currNav != "#wrapMenuItem4"){
			
			$("div#wrapMenuItem4").hide(0);
		}
		if(currNav != "#wrapMenuItem5"){
			
			$("div#wrapMenuItem5").hide(0);
		}
		if(currNav != "#wrapMenuItem6"){
			
			$("div#wrapMenuItem6").hide(0);
		}
	}
}

function hideMainNav(){

	prevNav = currNav;
	
	if (browserName != "Microsoft Internet Explorer" || ieVer == 9){
	
		$(prevNav).stop();
		$(prevNav).animate({ opacity: 0 }, mainMenuOut, function(){
			
			$(prevNav).hide(0);
		});
	}
}

//#############################################
//#############################################
						
var currNum = 1;
var prevNum = 1;

function imageGO(currNum){	

	if (currNum != prevNum){
	
		if(prevNum == 1){
		
			$("#slideshowImg1 .slideshowImg").fadeOut(fadeOutSpeed);
		}
		else if(prevNum == 2){
		
			$("#slideshowImg2 .slideshowImg").fadeOut(fadeOutSpeed);
		}
		else if(prevNum == 3){
		
			$("#slideshowImg3 .slideshowImg").fadeOut(fadeOutSpeed);
		}
		else if(prevNum == 4){
		
			$("#slideshowImg4 .slideshowImg").fadeOut(fadeOutSpeed);
		}
		
		if(currNum == 1){
		
			$("#slideshowImg1 .slideshowImg").fadeIn(fadeInSpeed);
		}
		else if(currNum == 2){
		
			$("#slideshowImg2 .slideshowImg").fadeIn(fadeInSpeed);
		}
		else if(currNum == 3){
		
			$("#slideshowImg3 .slideshowImg").fadeIn(fadeInSpeed);
		}
		else if(currNum == 4){
		
			$("#slideshowImg4 .slideshowImg").fadeIn(fadeInSpeed);
		}
	
		var tempString = "slideNavCol"+prevNum+" .slideNavLinkOver";
		
		if(slideOn == true){

			var tempStringCurrPath = "#slideNavCol" + currNum + " .slideNavLinkOver";
			$(tempStringCurrPath).animate({ opacity: 0 }, thumbFadeSpeed);
				
			var tempStringPrevPath = "#slideNavCol" + prevNum + " .slideNavLinkOver";
			$(tempStringPrevPath).animate({ opacity: 1 }, thumbFadeSpeed);
			
			slideTimerVar = setTimeout("slideTimer()", slideSpeed);
		}
	}
}

//#############################################
//#############################################
	
$(document).ready(function(){
	
	$("#slideNavCol1 .slideNavLinkOver").animate({ opacity: 0 }, 0);
	
	$(".slideNavLinkOver").mouseover(function(){
			
		if(this.parentNode.id != "slideNavCol"+currNum){
			
			$(this).stop();
			$(this).animate({ opacity: .76 }, thumbFadeSpeed);
			
		}
	});
	
	$(".slideNavLinkOver").mouseout(function(){
		  
		if(this.parentNode.id != "slideNavCol"+currNum){
			
			$(this).stop();
			$(this).animate({ opacity: 1 }, thumbFadeSpeed);
			
		}
	});
	
	$(".slideNavLinkOver").mousedown(function(){

		slideOn = false;
		clearTimeout(slideTimerVar);
		clearTimeout(slideTimerVarInitial);

		var tempStringFull = this.parentNode.id;
		var tempStringNum = tempStringFull.slice(11,12);
		
		prevNum = currNum; 
		
		if(this.parentNode.id != "slideNavCol"+currNum){

			$(this).stop();
			$(this).animate({ opacity: 0 }, thumbFadeSpeed);
			
			var tempStringPath = "#slideNavCol"+prevNum+" .slideNavLinkOver";
			$(tempStringPath).animate({ opacity: 1 }, thumbFadeSpeed);
			
		}
		
		currNum = tempStringNum;
		imageGO(currNum);
	});
});

//#############################################
//#############################################

$("#slideshowImg2 img").ready(function(){ 

	if (slideOn == true){
	
		slideTimerVarInitial = setTimeout("slideTimer()", slideSpeed);
	}
});

//#############################################
//#############################################

function slideTimer(){
	
	prevNum = currNum;
	if (currNum < 4){ currNum++; }
	else { currNum = 1; }
	imageGO(currNum);
}

//#############################################
//#############################################

$(document).ready(function(){
	
	if (document.getElementById('bbChartWrap') != null){
		
		var chartDivs = new Array;
		var numDivs = document.getElementById('wrapInternalContent').getElementsByTagName('table');
		
		for (var k = 0; k < numDivs.length; k++){
		
			if (numDivs[k].id == 'bbChartWrap'){
				
				chartDivs.push(numDivs[k]);	
			}
		}

		for (var m = 0; m < chartDivs.length; m++){
		
			$('#bbChartWrap tr:even').css('background-color', '#efefef');
		
			if (chartDivs[m].className == 'chartHeadLeft'){

				var chartRows = chartDivs[m].getElementsByTagName('tr');
				var chartCols = chartDivs[m].getElementsByTagName('td');
				
				var colRatio = (chartRows.length / chartCols.length);
				var rowRatio = (chartCols.length / chartRows.length);
				
				for (var i = 0; i < chartCols.length; i++){
					
					chartCols.item(i).style.width = (colRatio * 100) + '%';	
				}
				
				for (var j = 0; j < chartCols.length; j += rowRatio){
					
					chartCols.item(j).className = 'bbChartHead';	
				}
			}
		}
	}
});

//#############################################
//#############################################

$(document).ready(function(){
	$("a.anchorLink").anchorAnimate();
});

jQuery.fn.anchorAnimate = function(settings){

 	settings = jQuery.extend({
		
		speed : 666
	}, settings);	
	
	return this.each(function(){
		
		var caller = this
		
		$(caller).click(function (event){	
			
			event.preventDefault()
			
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function(){
				
				window.location.hash = elementClick;
			});
			
		  	return false;
		})
	})
}

//#############################################
//#############################################

$(document).ready(function(){

	var topPad = 28;
	var animateMoreTime = 700;
	
	$('.tileContentMore').click(function(){
		
		var targetID = this.parentNode.parentNode.id;
		var targetDiv = this.parentNode.getElementsByClassName('tileContentText');
		var targetHeight = this.parentNode.getElementsByClassName('tileContentHeight');
		
		if (this.innerHTML != '<p>less</p>'){
			
			$(targetDiv).animate({
				height: $(targetHeight).height() + topPad
			}, animateMoreTime);
			
			this.innerHTML = '<p>less</p>';
			this.style.background = 'url("view.image?id=622") no-repeat scroll 30px 15px #FFFFFF';
		}
		
		else {
		
			$(targetDiv).animate({
				height: '165px'
			}, animateMoreTime);
			
			this.innerHTML = '<p>more</p>';	
			this.style.background = 'url("view.image?id=553") no-repeat scroll 34px 15px #FFFFFF';
		}
		
	});
});

//#############################################
//#############################################

$(document).ready(function(){
	
	if (document.getElementById('pageCrumbs') != null){
		
		var crumbArray = new Array();
			
		var crumbWrap = document.getElementById('pageCrumbs');
			
		var crumbLinks = crumbWrap.getElementsByTagName('a');
			
		for (var crumbCount = 0; crumbCount < crumbLinks.length; crumbCount++){
				
			if (crumbLinks[crumbCount].className != 'selected' && crumbLinks[crumbCount].href == ''){
				
				crumbLinks[crumbCount].className = 'noUnderline';
				//crumbArray.push(crumbLinks[crumbCount]);	
			}
		}
	}
});

//#############################################
//#############################################

$(document).ready(function(){
	
	if (document.getElementById('wrapProductMain') != null){
	
		var productBoxTime = 600;
		var navWrapID = 'productNav';
		var productWrapID = 'wrapProduct';
		var productMenuClass = 'productNavItem';
		
		var productMenuItems = document.getElementById('productMenu').getElementsByTagName('li');
		
		for (var h = 0; h < productMenuItems.length; h++){
		
			productMenuItems[h].className = productMenuClass;	
		}
		
		var childAll = document.getElementById('wrapProductMain').getElementsByTagName('div');
		
		var navAll = document.getElementById('productMenu').getElementsByTagName('li');
	
		var childNum = new Array;
		
		var childNav = new Array;
		
		for (var g = 0; g < childAll.length; g++){
		
			if (childAll[g].className == 'wrapProductInfo'){
			
				childNum.push(childAll[g]);	
			}
		}
		
		for (var f = 0; f < navAll.length; f++){
			
			if (navAll[f].className == productMenuClass){
				
				childNav.push(navAll[f]);	
			}	
		}
		
		var productInfoHeight = childNum[0].offsetHeight;
		
		var currNavItem = childNav[0];
		
		currNavItem.className = productMenuClass + ' active';
		
		var prevNavItem;
		
		for (var i = 0; i < childNum.length; i++){
		
			var productWrapObj = childNum[i];
			productWrapObj.style.zIndex = childNum.length - i;
			productWrapObj.id = productWrapID + i;
			
			if (i != 0){
			
				productWrapObj.style.position = 'absolute';
				$(productWrapObj).fadeOut(0);
			}
		}
	
		for (var j = 0; j < childNav.length; j++){
			
			childNav[j].id = navWrapID + j;
			
			if (browserName == "Microsoft Internet Explorer"){
			
				//childNav[j].attachEvent('onclick', iHateIE);
				
				var IEBlows = childNav[j]; 
				
				IEBlows.onclick = function(){ productNavClick(this); };
				
			}
			else {
			
				childNav[j].addEventListener('click', productNavClick, false);
			}
		}
		
		
		
		//var otherTabLinks = document.getElementById('subTabLink');
		//otherTabLinks.addEventListener('click', hitTabFun, false);
	
	
	}
	
	function iHateIE(e){
	
		alert('NOT WORKING IN IE ' + e.id);	
	}
	
	/* function hitTabFun(){
			
		var gotoTabNum = String(navWrapID + this.rel);
		
		var gotoTab = document.getElementById(gotoTabNum);
		
		$(gotoTab).click();
	} */
	
	function productNavClick(e){
	
		if (this != currNavItem || browserName == "Microsoft Internet Explorer" && e != currNavItem){
		
			prevNavItem = currNavItem;
			
			if (browserName == "Microsoft Internet Explorer"){
				
				currNavItem = e;
			}
			else {
			
				currNavItem = this;
			}

			var productGlanceDiv = document.getElementById('productGlance');
			
			if (currNavItem.id == navWrapID + '0' && productGlanceDiv != null){
			
				$(productGlanceDiv).fadeIn(productBoxTime);
			}
			else { 
				
				$(productGlanceDiv).fadeOut(productBoxTime); 
			}
			
			prevNavItem.className = currNavItem.className;
			currNavItem.className = productMenuClass + ' active';
			
			var currInfoLength = currNavItem.id;
			var currInfoID = String(currNavItem.id).slice(navWrapID.length, currInfoLength.length);
			var currInfoItem = productWrapID + currInfoID;
			
			var prevInfoLength = prevNavItem.id;
			var prevInfoID = String(prevNavItem.id).slice(navWrapID.length, prevInfoLength.length);
			var prevInfoItem = productWrapID + prevInfoID; 

			$(document.getElementById(prevInfoItem)).fadeOut(productBoxTime);
			$(document.getElementById(currInfoItem)).fadeIn(productBoxTime);
			
			productInfoHeight = document.getElementById(currInfoItem).offsetHeight;
			
			$('#wrapProductMain').animate({
				height: productInfoHeight
			}, productBoxTime);
		}
	}
});

//#############################################
//#############################################

$(document).ready(function(){
	
	if (document.getElementById('internalNav') != null && document.getElementById('internalNav').getElementsByTagName('a') != null){
		
		var isSelected = false;
		
		var findSelected = document.getElementById('internalNav').getElementsByTagName('a');
		
		for (var tempFind = 0; tempFind < findSelected.length; tempFind++){
		
			if (findSelected[tempFind].className == 'selected'){
				
				isSelected = true;
			}
		}
		
		if (isSelected == true){
	
			var internalNavTitleMax = 18;
			
			var internalNavDoubleSpace = '0px 79px';
			
			if (ua.indexOf('Safari') != -1 || ua.indexOf('Chrome') != -1 || browserName == "Microsoft Internet Explorer"){
			
				internalNavDoubleSpace = '0px 76px';
			}
			
			var internalNavHeader = document.getElementById('internalNav').getElementsByTagName('a');
			
			for (var m = 0; m < internalNavHeader.length; m++){
			
				if (internalNavHeader.item(m).offsetHeight > 50){
					
					var internalHeaderItem = internalNavHeader.item(m);
				}
			}
			
			if (browserName != "Microsoft Internet Explorer" || ieVer >= 9){
				
				if (internalHeaderItem.textContent.length >= internalNavTitleMax){
	
					internalHeaderItem.style.backgroundPosition = internalNavDoubleSpace;
				}
			}
			else if (ieVer < 9){
				
				if (internalHeaderItem.innerHTML.length >= internalNavTitleMax){
	
					internalHeaderItem.style.backgroundPosition = internalNavDoubleSpace;
				}
			}
		}
	}
});
	
//#############################################
//#############################################

var historyLimit = 7;

var historyFadeTime = 400;

var MaximumNumberOfLinks = 15;

var CookieName = "HistoryLinks";

var DaysToLive = 0;

var HistoryLink = new Array();
var HistoryTitle = new Array();
var CurrentPage = new String();
var HistoryContent = new String();
DaysToLive = parseInt(DaysToLive);
MaximumNumberOfLinks = parseInt(MaximumNumberOfLinks);
if (MaximumNumberOfLinks < 1){ MaximumNumberOfLinks = 10; }

$(document).ready(function(){
	
	if (document.getElementById('wrapChat') != null && ieVer < 9){
		
		$('#contactFooterChat').mouseover(function(){
			
			document.getElementById('wrapChatContent').style.display = 'block';
			document.getElementById('wrapChatContent').style.opacity = '1';
		});
		
		$('#contactFooterChat').mouseout(function(){
			
			document.getElementById('wrapChatContent').style.display = 'none';
			document.getElementById('wrapChatContent').style.opacity = '0';
		});
	}
	
	if (document.getElementById('wrapChat') != null && browserName != "Microsoft Internet Explorer" || ieVer > 8){

		$('#contactFooterChat').mouseover(function(){
		
			$('#wrapChatContent').stop();
			$('#wrapChatContent').show(0);
			$('#wrapChatContent').animate({ opacity: 1 }, historyFadeTime);
		});
		
		$('#contactFooterChat').mouseout(function(){
		
			$('#wrapChatContent').stop();
			$('#wrapChatContent').animate({ opacity: 0 }, historyFadeTime / 1.5, function(){
				
				$('#wrapChatContent').hide(0);
			});
		});
	}
	
	/*if (document.getElementById('wrapHistoryBtn') != null){
		
		HistoryTitle.reverse();
		HistoryLink.reverse();
		
		//var headerType = 'h1';
		
		for (var i = 1; i < HistoryTitle.length; i++){
			
			if (i == 2){ headerType = 'h2'; }
			if (i == 3){ headerType = 'h3'; }
			if (i == 4){ headerType = 'h4'; }
			if (i >= 5){ headerType = 'h5'; }
			
			if (i <= historyLimit){
	
				//document.getElementById('historyContentBody').innerHTML += '<' + headerType + '>' + '<a href="' + HistoryLink[i] + '">' + HistoryTitle[i] + '</a>' + '</' + headerType + '>';
				document.getElementById('historyContentBody').innerHTML += '<p><a href="' + HistoryLink[i] + '">' + HistoryTitle[i] + '</a></p>';
			}
		}
		
		if (browserName != "Microsoft Internet Explorer" || ieVer >= 9){
			
			$('#wrapHistoryContent').hide(0);
			$('#wrapHistoryContent').animate({ opacity: 0 }, 0);
		
			$('#wrapBBHistory').mouseover(function(){
	
				$('#wrapHistoryContent').stop();
				$('#wrapHistoryContent').show(0);
				$('#wrapHistoryContent').animate({ opacity: 1 }, historyFadeTime);
			});
			
			$('#wrapBBHistory').mouseout(function(){
			
				$('#wrapHistoryContent').stop();
				$('#wrapHistoryContent').animate({ opacity: 0 }, historyFadeTime / 1.5, function(){
					
					$('#wrapHistoryContent').hide(0);
				});
			});
		}
		
		if (ieVer == 7 || ieVer == 8){
		
			$('#wrapHistoryBtn').mouseover(function(){
	
				document.getElementById('wrapHistoryContent').style.display = 'block';
			});
			
			$('#wrapHistoryBtn').mouseout(function(){
	
				document.getElementById('wrapHistoryContent').style.display = 'none';
			});	
			
			$('#wrapHistoryContent').mouseover(function(){
	
				document.getElementById('wrapHistoryContent').style.display = 'block';
			});	
			
			$('#wrapHistoryContent').mouseout(function(){
	
				document.getElementById('wrapHistoryContent').style.display = 'none';
			});	
		}
	}*/
});

function GetCookie(){
	
	var cookiecontent = '';
	
	if (document.cookie.length > 0){
		
		var cookiename = CookieName + '=';
		var cookiebegin = document.cookie.indexOf(cookiename);
		
		if (cookiebegin > -1){
			cookiebegin += cookiename.length;
			var cookieend = document.cookie.indexOf(";",cookiebegin);
			if (cookieend < cookiebegin){ cookieend = document.cookie.length; }
			cookiecontent = document.cookie.substr(cookiebegin,cookieend-13);
		}
	}
	
	if (cookiecontent.length < 3){ return; }
	cookiecontent = unescape(cookiecontent);
	
	var historyList = cookiecontent.split('&');
	
	for (var i = 0; i < historyList.length; i++){	
	   
	   var link = historyList[i].split('@',2);
	   HistoryLink.push(link[0]);
	   HistoryTitle.push(link[1]);
	   var temparray = link[0].split('~amp;');
	   
	   link[0] = temparray.join('&');
	   
	   //temparray = link[1].split('~amp;');
	   
	   //link[1] = temparray.join('&');
	   //HistoryContent += '<'+'p>'+'<'+'a href="'+link[0]+'">'+link[1]+'<'+'/'+'a>'+'<'+'/'+'p>';
	   HistoryContent += '<'+'p>'+'<'+'a href="'+link[0]+'"><'+'/'+'a>'+'<'+'/'+'p>';
	}
}

function PutCookie(){
	
	if (HistoryLink.length < 1){ return; }
	var len = HistoryLink.length;
	while ( HistoryLink.length > MaximumNumberOfLinks ){
		HistoryTitle.shift();
		HistoryLink.shift();
	}
	var pairs = new Array();
	for (var i = 0; i < HistoryLink.length; i++){
		pairs.push(HistoryLink[i]+'@'+HistoryTitle[i]);
	}
	var value = pairs.join('&');
	var exp = new String();
	
	if (DaysToLive > 0){
		var now = new Date();
		now.setTime( now.getTime() + (DaysToLive * 24 * 60 * 60 * 1000) );
		exp = '; expires=' + now.toGMTString();
	}
	
	document.cookie = CookieName + "=" + escape(value) + ';';
}

function RecordCurrentPage(){
	
	var link = document.URL;
	var title = document.title.length > 1 ? document.title : 'Untitled';
	
	CurrentPage = '<'+'p>'+title+'<'+'/'+'p>';
	
	var temparray = link.split('&');
	link = temparray.join('~amp;');
	var temparray = title.split('&');
	title = temparray.join('~amp;');
	HistoryLink.push(link);
	HistoryTitle.push(title);
}

GetCookie();
RecordCurrentPage();
PutCookie();

//#############################################
//#############################################

function showFooterSEO(){
	
	if (document.getElementById('footerSEO').style.display == 'block'){
		
		document.getElementById('footerSEO').style.display = 'none';
	}
	else {
		
		document.getElementById('footerSEO').style.display = 'block';
	}
}

//#############################################
//#############################################

function fixPositioning(){
	
	$('div[id *= "_panelPopup"]').appendTo('body');
}

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(fixPositioning);

function fixPositioning(){
	
	$('div[id *= "_panelPopup"]').appendTo('body');
	$('div[id *= "_designPaneCloak"]').css({"top": "0px","left": "0px"});
	$('.DesignPane').css("position", "relative");
}

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(fixPositioning);

//#############################################
//#############################################
