﻿// Some functions depend on jQuery - be sure jQuery is loaded first

function SetupRollover(imageSelector, imagePath, imageOverPath) {
  $j(imageSelector).hover(
    function() { $j(imageSelector).attr('src', imageOverPath); },
    function() { $j(imageSelector).attr('src', imagePath); }
  );
}

function SetupSideColSlides(navPrevID, navNextID, slidesID) {
  // add CSS selector prefix
  navPrevID = '#' + navPrevID;
  navNextID = '#' + navNextID;
  slidesID = '#' + slidesID;

  // setup nav rollovers
  SetupRollover(navPrevID + ' img', '/images/spifs/spif-nav-prev.png', '/images/spifs/spif-nav-prev-over.png');
  SetupRollover(navNextID + ' img', '/images/spifs/spif-nav-next.png', '/images/spifs/spif-nav-next-over.png');

  var slideTimeout = 0;

  // setup slides
  $j(slidesID).cycle({
    fx: 'scrollHorz',
    timeout: slideTimeout,
    speed: 500,
    next: navNextID,
    prev: navPrevID,
    cleartypeNoBg: true
  });
}


function recordOutboundLink(link, category, action) 
{
    try {
        var pageTracker = _gat._getTracker("UA-2774305-1");    
        pageTracker._trackEvent(category, action);    
        setTimeout('document.location = "http://' + action + '"', 100)  
    }
    catch (err) {
        document.location = 'http://' + action;
    }
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function stripAlphaChars(pstrSource) 
{ 
    var m_strOut = new String(pstrSource); 
    m_strOut = m_strOut.replace(/[^0-9]/g, ''); 

    return m_strOut; 
}
