(function($) {
	if(typeof(NetEffect) === 'undefined') {
		return;
	}
	var N = NetEffect;
	
	N.SC.config.siteId = 'nes';
	N.SC.config.reportSuiteId = 'NetEffect';
	
	N.Uniform = function() {
		$("select, input[type=text], textarea, input[type=checkbox], input[type=radio], input[type=file], input[type=submit], a.button, button").uniform();
	};
	
	var forms = N.SC.trackForms;
	forms.push({selector: '#contactForm', 
			   formName: 'ContactForm', 
			   successScore: 10,  
			   successEvent: 'event70', 
			   isLeadForm: true,
			   onStart: function() { $.uniform.update(); }, 
			   afterSubmit: function() { N.Uniform(); }
		});
	
	forms.push({selector:'#spInviteForm', 
			formName: 'StagePostInvite', 
			successScore: 10,  
			successEvent: '', 
			isLeadForm: true,
			onStart: function() { $.uniform.update(); },
			afterSubmit: function(success) {	
				N.Uniform();
				if(success === true) {
					$('#spInviteForm').prepend('<h3>We received your question</h3>');
				}					
				
				/*
				var thankYou = '<hr /><h3>Learn more about NetEffect Services here:</p>';
				thankYou += '<p style="text-align:center"><a href="http://www.neteffectservices.com/?nes-lan-1"><img alt="NetEffect" src="/getattachment/html/stagepost-lunch-and-learn/invite/neteffect-logo-2.jpg?width=194&height=75" /></a></p>';
				thankYou += '<hr /><h3>Learn more about StagePost here:</h3>';
				thankYou += '<p style="text-align:center"><a href="http://www.stagepost.com"><img alt="StagePost" src="/getattachment/html/stagepost-lunch-and-learn/invite/stage-post-logo.jpg?width=115&amp;height=90" /></a></p>';
				$('#spInviteForm').append(thankYou);
				*/
			}
		});	
	
	// Page and event tracking extensions
	N.SC.Page = {
		TrackOurWork: function() {
			s.events = s.apl(s.events, 'event46', ',', 2);
		},
		
		TrackAboutUs: function() {
			s.events = s.apl(s.events, 'event47', ',', 2);
		},
		
		TrackService: function() {
			s.events = s.apl(s.events, 'event48', ',', 2);
		},
		
		TrackOurVision: function() {
			s.events = s.apl(s.events, 'event49', ',', 2);
		},
		
		TrackHome: function() {
			s.events = s.apl(s.events, 'event50', ',', 2);
		}
	}
	
	/* Global DOM Ready Script */
	$(function() {
		N.Uniform();
		
		$('.cont-2').containerize({
				bottomHeight: '50%'
		});
		$('.cont-3').zoomHover().hover(function() {
			$(this).find('>.comingSoon').fadeTo(200, .9);
		}, function() {
			$(this).find('>.comingSoon').fadeOut(200);
		}).not('.web').find('.wrapper').append('<div class="comingSoon">Coming Soon!</div>');
		
		/// DO THIS LAST!!!!
		$('.cont-1').containerize({
				bottomHeight: '50%',
				padding: '15px 51px'
		});
	});
	
	
	N.PageScripts = {
		// Home Page Scripts
		InitHome: function() {
			
			var $nav = $('#servicesNav');
			var $summaries = $('#servicesSummary li').hide();
			var aDur = 200;
			
			$nav.wrap('<div class="cont-2"/>').parent().containerize({
				bottomHeight: '50%'
			}).find('a[href^=#]').prepend('<span class="bracket left">[</span><span class="bracket right">]</span><span class="sprite tab"/>')
			.each(function() {
				var $this = $(this);
				var $targ = $( $this.attr('href') ); // Anchor links
				$.data(this, 'origColor', $this.css('color'));
				
				$this.mouseover(function(e) {
					if(!$this.hasClass('active') && e.target.nodeName === 'A') {
						hideActive();
							
						$this.find('.bracket.left').animate({left: '-15px', opacity: 'show'}, aDur)
							.end().find('.bracket.right').delay(50).animate({right: '-15px', opacity: 'show'}, aDur)
							.end().find('.tab').animate({right: '0%', opacity: 'show'}, aDur)
							.end().stop().animate({color:'#FFFFFF'}, aDur).addClass('active');
						
						$targ.stop(true, true).fadeIn(aDur * 1.5);
					}
				}).click(function() {
					location.href = $targ.find('.readMore a').attr('href');
				});
			}).first().find('span').hide().end().trigger('mouseover');
			
			hideActive('a:not(:first)');
			
			function hideActive( selector ) {
				if(!selector) {
					selector = '.active';
				}
				var $active = $nav.find(selector);
				if($active.length) {
					$active.find('.bracket.left').delay(30).animate({left: '-25px', opacity: 'hide'}, aDur)
						.end().find('.bracket.right').delay(30).animate({right: '-25px', opacity: 'hide'}, aDur)
						.end().find('.tab').animate({right: '10%', opacity: 'hide'}, aDur)
						.end().stop().animate({color: $.data($active[0], 'origColor')}, aDur).removeClass('active');
						
					$( $active.attr('href') ).stop(true, true).fadeOut(aDur * 1.5);
				}
			}
		},
		
		InitOurWork: function() {

		},
		
		// Client Page
		InitClientPage: function() {
			var $nav = $('#nav');
			var $info = $('#info').wrapInner('<div id="summary" />').append('<div id="largeImage"><img/><span class="arrow left"/><span class="arrow right"/></div>');
			var $largeImg = $('#largeImage img');
			
			$info.find('.thumbs').each(function() {
					var $this = $(this);
					var id = $this.parents('.project').attr('id');
					$this.remove().appendTo( $nav.find('a[href=#' + id + ']').parent() );
				}).find('a').click(function() {
					var $this = $(this);
					$largeImg.attr({
						src: $this.attr('href') + '?width=400',
						alt: $this.attr('title')
					});
					return false;
				}).first().trigger('click');
		}
	};
}(jQuery));

(function($) {
    $.fn.zoomHover = function(opts) {
		var settings = {
			zoomTo: 120, // Percentage
			wrapperClass: ''
		};
		
		$.extend(settings, opts);
		
		return this.each(function() {
			var $this = $(this);			
			var origW = $this.width();
			// var origH = $this.height() - parseInt($this.css('paddingTop')) - parseInt($this.css('paddingBottom'));
			var targW = origW * 1.2;
			
			$this.wrapInner('<div class="wrapper ' + settings.wrapperClass + '"/>').find('>.wrapper').css({
				width: origW,
				//height: '100%',
				position: 'relative'
			}).hover(function() {
				$(this).stop(true,true).animate({width:targW, top: ((origW - targW)/2) + 'px', left: ((origW - targW)/2) + 'px'}, 200);
			}, function() {
				$(this).stop(true,true).animate({width: origW, top: 0, left: 0}, 200);
			});
		});
	};
}(jQuery));

/*!
 * jQuery Cycle Lite Plugin
 * http://malsup.com/jquery/cycle/lite/
 * Copyright (c) 2008 M. Alsup
 * Version: 1.0 (06/08/2008)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.3 or later
 */
;(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery);

/*
$.fn.infiniteCarousel = function () {
	if(!this.is('ul')) {
		return this;
	}
	
    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }

    return this.each(function () {
		var $slider = $(this);
        var $wrapper = $this.wrap('<div class="scroller"/>').parent().css('overflow', 'hidden'),
            $items = $slider.find('> li'),
            $single = $items.first(),
            singleWidth = $single.outerWidth(), 
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), /// note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            

		$this.css('width', '9999px');
		
        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;
            
            $wrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 

                currentPage = page;
            });                
            
            return false;
        }
        
        $wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');
        
        // 5. Bind to the forward and back buttons
        $('a.back', this).click(function () {
            return gotoPage(currentPage - 1);                
        });
        
        $('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });
        
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
    });  
};

*/
