/*
Merchant Tech
Version 1.0
David Janning
*/

(function($){
	
	$(document).ready(function() {

		Cufon.replace('#SideNews h2,.newsHead,.navigation h3, #ArchiveWide h1,.infoStat strong,.infoText h2', { fontFamily: 'geoslab' });
		Cufon.replace('h1, .newsTitle,.newsDate,#NewsItems h2,#NewsItems h3, #ResourceItems h2', { fontFamily: 'Myriad Pro' });


/*		$('.twoCol').columnize({columns:2});
		$('.threeCol').columnize({columns:3});

		$('.twoColover').columnize({
			columns : 2,
			overflow : {
				id : ".overFlow",
				height : 245,
				doneFunc : function(){
					//$('.overFlow').columnize({ columns : 3 });
				}
			}
		});
*/	
	if($('#cntPortal').length) {
		$('#cntPortal').addClass('hideMe');
		$('#cntPortal .closeButt').show();
		
		var windas = function(){

			var anchor = window.location.hash;
			var $clicked, index;
			var $myDivs = $('.cntPort');
			var showWinda = function () {
				$('#cntNav li.active').removeClass('active');			
				$('#cntPortal').removeClass('hideMe');
				
				$myDivs.hide();
				$myDivs.eq(index).show();
				$('#mNarrowR').hide();
				$clicked.addClass('active');
			}

			var closeButt = function () {
				$('#cntNav li.active').removeClass('active');
				$('#cntPortal').addClass('hideMe');
				$('#home').show();
				$('#mNarrowR').show();
			}
			
			if(anchor.length) {
				$clicked = $("#cntNav li a[href="+anchor+"]").parent();
				index = $('#cntPortal div').index($(anchor));
				anchor = null;
				showWinda();	
			}
			$myDivs.removeAttr("ID");

			$('#cntNav li').click(function(e) {	
				$clicked = $(this);
				index = $('#cntNav li').index($clicked);
				showWinda();
				window.location.hash = $(this).find('a').attr("href");;	
				e.preventDefault();
			});

			$('.closeButt').click(function(e) {
				e.preventDefault();
				closeButt();
			});
				
			
		}();
	} //end if cntPortal

		//Features Scrolling Banner  	
		  	if($('#Features').length) {
				// Resize Features div to mNarrow
				$("#Slides li").height($('#mNarrow').height());

			  	if($('#Features li').size() > 1) {
				
					$("#Slides li:first").attr('ID', 'FrameFirst');
					$("#Slides li:last").attr('ID', 'FrameLast');
					$('#greatphoto')
					$('#Navigation .prev').hide();
					
					
					$('#Navigation a').click(function() {
						$('#Features').trigger( 'stop' ); //stop the show						
					});
					
				  	 $('#Main').serialScroll({
				        target:'#Features',
						prev:'a.prev',
						next:'a.next',
				        items:'#Slides li',
				        axis:'x',
				        navigation:'',
				        duration:250,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
				        force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
				        interval:6000,
				        constant:true,
				        stop:true,
				        lock:false,
				        onBefore:function( e, elem, $pane, $items, pos ){
				            e.preventDefault();
				            if( this.blur )
				                this.blur();

								$('#Navigation .prev,#Navigation .next').show();
								if( pos == 0 )
								$('#Navigation .prev').hide();
								else if( pos == $items.length-1 )
								$('#Navigation .next').hide();
												
				        },
				        onAfter:function( elem ){

				        }
				    });

		    	}
				

		    } 	



	});



	})(jQuery);
	
//Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3919453-1']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

