	$(function() { 
		var idCounter = 1;
		var insideTabCounter = 1;
		var tabName = "";
		
		//////////// Home page tabs, inner tabs creation //////////
		$('.homePageSecondaryTab div:not(.cycleContainer)').each(function() {
			if(tabName == $(this).parent().attr('id')) {
				insideTabCounter++;
			} else {
				insideTabCounter = 1;
			}
			tabName = $(this).parent().attr('id');
			
			$('#'+tabName+" .cycleContainer").append('<a class="insideTabLink" rel="'+idCounter+'">'+insideTabCounter+'</a>');
			++idCounter;
		});
		
		//////////////Defaults ////////////////////////////////
		$('.homePageSecondaryTab').each(function() {	//Hide all but the first story on each tab, leave the cycler alone
			$(this).children('div:not(:first):not(.cycleContainer)').css('display','none');
			$(this).children('div(:first):not(.cycleContainer)').css('display','block');
		});
		
		$('.cycleContainer').each(function() { //Mark the first number as active, in the cycler
			$(this).children('.insideTabLink:eq(0)').addClass('active');
		});
		
		////////////// Initiate the tabs ////////////////////////////
		$('#homepage-tabs').tabs().bind( "tabsselect", function(event, ui) {
			if(ui.index != currentTab) {
				stopCycle = true;
			}
		});

		
		///////////// Cycle Through /////////////////////////////////
		//####################################################################### Change Time Below #####################################//
		var timeToCycle = 5000;
		//###############################################################################################################################//
		
		var currentTab = 0;
		var currentInsideTab = 0;
		var insideTabsCompletelyCycled = false;
		var stopCycle = false;
		
		$('#homepage-tabs, #tabLinkContainer li').click(function() {
			stopCycle = true; //STOP the cycle
		});
		
		function cycleTabs() {
			if(stopCycle == false) {
				if(insideTabsCompletelyCycled == true) {
					//Reset variables
					currentInsideTab = 0;
					insideTabsCompletelyCycled = false;
					
					//Update the currentTab
					currentTab++;
					if(currentTab >= 3) {currentTab = 0;}
				
					//Cycle through the tabs
					$('#homepage-tabs').tabs("select",currentTab);
					cycleTabs();;
				} else {
					cycleInsideTabs();
				}
			}
		}
		
		function cycleInsideTabs() {
			//alert(currentTab+":"+currentInsideTab);
			//Add the active class to the corrent inside number at the bottom
			$('.cycleContainer:eq('+currentTab+') a').removeClass('active');
			$('.cycleContainer:eq('+currentTab+') a:eq('+currentInsideTab+')').addClass('active');
			
			//Hide the current inside tab, show the next one
			$('.homePageSecondaryTab:eq('+currentTab+') div:not(.cycleContainer)').css('display','none');
			$('.homePageSecondaryTab:eq('+currentTab+') div:eq('+currentInsideTab+')').css('display','block');
			
			//Increment counter
			++currentInsideTab;
			
			//Tabs complete, set flag complete
			if(currentInsideTab >= $('.homePageSecondaryTab:eq('+currentTab+') div:not(.cycleContainer)').size()) {insideTabsCompletelyCycled = true;}
			
			//Call next cycle
			setTimeout(function() {cycleTabs();},timeToCycle);
		}
		
		cycleTabs();
		
		
		//////////// On Inside Tab Click ////////////////////////////
		
		$('.insideTabLink').click(function() {
			//Mark the number as active
			$(this).parent().children().removeClass('active');
			$(this).addClass('active')
			
			//Hide the current tab data
			$(this).parent().parent().children('div:not(.cycleContainer)').css('display','none');
		
			//Display
			var spanId = $(this).attr('rel');
			$('#insideTab'+spanId).css('display','block');
		});
		
		////////////////////////////////////////////////////////
		
		
		/////////////// Solutions Dropdown //////////////////////////
		var solutionsOpen = false;

		$('#selector').click(function(){
			//Update the flag
			if(solutionsOpen == false) {solutionsOpen = true; } else {solutionsOpen = false;}
			
			if($.browser.msie && $.browser.version < 7){ // IE6 only
				if($('#content').hasClass('pushback')){ 
					$('#content').removeClass('pushback');
				} else {
					$('#content').addClass('pushback');
				}
			}
			
			//Hide the form filters if they exist on opening of the solutions drop down
			if($(".formFilterForNews").size()) {
				if(solutionsOpen == true) {
					$(".formFilterForNews").css('display','none');
				} 
			}
			
			//Initialize the solutions drop down 
			$(this).children('ul').slideToggle('slow',function() {
				//Display the form filter once the solutions drop is finished
				if($(".formFilterForNews").size()) {
					if(solutionsOpen == false) {
						$(".formFilterForNews").css('display','inline');
					} 
				}
			});
		});
		
		var clickRel;
		$('#channel-names li a').click(function(){
			clickRel = $(this).attr('rel');
			$('#current-selection').html(clickRel);
		});
		
		
		$('#products-main-tabs').tabs({ 
			selected: suiteTab, 
			select: function(event, ui) { 
				$.get('setProductSuiteSession.php?sid='+Math.random()+'&suiteType='+ui.index);
			}
		});
		
		/////////////////// Product Accordions ///////////////////////////
		
		$('.productAccordionLink').click(function() {
			$.ajax({
				url: includePath+'include/setSuiteSession.php?suite='+$(this).attr('rel'),
				async: false
			});
		});
		
		var hashUrlValue = window.location.hash;
		if(hashUrlValue.length > 0) {
			$(hashUrlValue).next('div').slideDown();
			$(hashUrlValue).addClass('active');
		}
		
		$('.accordion-title').click(function(){ 
			if($(this).hasClass('active')){  
				$(this).removeClass('active');
				$(this).next('div').slideUp();
			} else {
				$(this).siblings('a').removeClass('active');
				$(this).siblings('div').slideUp();
				$(this).next('div').slideDown();
				$(this).addClass('active');
			}
			
			return false;
		});
		
		/////////////////////////////////////////////////////////////////////////
		
		$('#flashReplace').cycle({
			fx: 'fade',
			pager: '#cycler',
			timeout: 7000
		});
		
		$('#logos').cycle({ 
			fx: 'fade',
			prev: '#sliderLeft',
			next: '#sliderRight',
			timeout: 7000
		});
		
		$('#scroller').cycle({ 
			fx: 'fade',
			prev: '#scrollerLeft',
			next: '#scrollerRight',
			timeout: 0
		});
		
		$('#customer-slides').cycle({ 
			fx: 'fade',
			prev: '#customerLeft',
			next: '#customerRight',
			timeout: 7000
		});
		
		$('#network-logos').cycle({ 
			fx: 'fade',
			prev: '#networksliderLeft',
			next: '#networksliderRight',
			timeout: 7000
		});
		
		$('.hiders:first').show();
		
		////////////// Awards/Executive Team ////////////////////////////
		$('.rollers').jcarousel({
			wrap: 'circular',
			scroll:1,
			itemFirstInCallback:  mycarousel_itemFirstInCallback,
			initCallback: mycarousel_initCallback,
			// This tells jCarousel NOT to autobuild prev/next buttons
			buttonNextHTML: null,
			buttonPrevHTML: null
		});
		
		function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
			//var teamRel = $('.rollers li:eq('+(idx-1)+') img').attr('rel');
			//$('.hiders').hide();
			//$('#'+teamRel).show();
		};
		
		function mycarousel_initCallback(carousel) {

			$('#scrollerLeft').bind('click', function() {
				carousel.prev();
				return false;
			});

			$('#scrollerRight').bind('click', function() {
				carousel.next();
				return false;
			});
		}
		
		$('.rollers li').livequery('click',function() {
			var teamRel = $(this).children('img').attr('rel');
			//alert(teamRel);
			$('.hiders').hide();
			$('#'+teamRel).show();
			$('.rollers li').addClass('inactive');
			$('.rollers li').removeClass('active');
			$(this).addClass('active');
		});
		
		//////////////////////////////////////////////////////////////////////
		
		/*var teamRel;
		$('.rollers li img').click(function(){
			$('.rollers li img').removeClass('active');
			$(this).addClass('active');
			teamRel = $(this).attr('rel');
			$('.hiders').hide();
			$('#'+teamRel).show();
		});*/
		
		/*$('.form-separator').click(function(){
			if($('.basic-info').hasClass('open')) {
				$(this).next('ul').slideToggle();
			} else { 
				$('.basic-info').slideDown().addClass('open');
				$(this).next('ul').slideToggle();
				$('#submit-form').show();
			}
		});*/
		
		var thisDesc;
		$('.career-accordion:last').addClass('active');
		$('.career-description:last').show();
		$('.career-accordion').click(function(){
			if($(this).hasClass('active')){
				$(this).removeClass('active');
				$('.career-accordion').next().slideUp();
			} else {
				$('.career-accordion').removeClass('active');
				$(this).addClass('active');
				$('.career-description').slideUp(); 
				$(this).next().slideDown();
			}
		});
		
		
		$('.videoModal').livequery(function() {
			$('.videoModal').colorbox({
				iframe: "true",
				innerWidth: 640,
				innerHeight: 426,
				scrolling: false
			});
		});
		
		$('.mediaModalLink').livequery(function() {
			
			$('.mediaModalLink').each(function() {
				var widthHeight = $(this).attr('rel');
				var whArray = new Array();
				whArray = widthHeight.split('-');
				
				$(this).colorbox({
					iframe: "true",
					width: whArray[1],
					height: whArray[0]
				});
			});
		});
		
		var busType = '';
		var productType = '';
		var resourceType = $('#resourceType').val();
		
		///////////Form filtering ///////////
		$('.busFilter').click(function() {
			busType = $(this).val();
			
			if($(this).val() == "company" || $(this).val() == "") {
				productType = '';
				$('.productFilter').val('');
				$('#productFilterContainer').css('display','none');
			} else {
				$('#productFilterContainer').css('display','inline');
			}
			
			var url = "ajaxFiles/" + $('#displayPath').attr('value') + "?busType=" + busType + '&assignedProduct=' + productType + '&resourceType=' + resourceType + '&sid=' + Math.random();
			$('.resourceData').load(url);
			
		});
		
		$('.productFilter').change(function() {
			productType = $(this).val();
			var url = "ajaxFiles/" + $('#displayPath').attr('value') + "?busType=" + busType + '&assignedProduct=' + productType + '&resourceType=' + resourceType + '&sid=' + Math.random();
			$('.resourceData').load(url);
		});
		
		/////////////////// Footer "Share" Link Functionality ///////////////////////////
		
		$('#sh').click(function(){  
			if($('#share-links').hasClass('hellothere')){
				$('#share-links').removeClass('hellothere').fadeOut();
			} else {  
				$('#share-links').addClass('hellothere').fadeIn();
			}	
		});
		
		$('#share-links ul li a').click(function(){  
			$('#share-links').removeClass('hellothere').fadeOut();
		});
		
		///////////////// Locations map view /////////////////
		$('.mapLink').bind('click',function() {
			$('#mapContainer').attr('src',$(this).attr('href'));
			return false;
		});
		
		///////////////Contact IGo e-App demonstation //////////
		$('.igoRequest').livequery(function() {
			$('.igoRequest').colorbox({
				iframe: "true",
				width: 500,
				height: 400
			});
		});
	});
