$(function () {	
/*+++++++++++++++++++++++++++++++++++++*/		
			//GLOBAL VAR OF SITE PATH
			var SITE_ROOT_FOLDER = "../2010/";
/*+++++++++++++++++++++++++++++++++++++*/	
/*+++++++++++++++++++++++++++++++++++++*/		
/*+++++++++++++IMPORTANT++++++++++++++++++++*/		
/*++++++++CHANGE THE SITE ROOT+++++++++++++++*/		
/*+++++++DEPENDING ON DEV or LIVE SITE++++++++++++*/		
			//-----------------------------//
	/*Hide the 'View Page Content' on load*/
	$('.bottomFloatCenter').hide();
	//when tabs are clicked, go to these external pages
	$('li.divBIKESOVERVIEW a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_allbikes.php' ;return false;});
	$('li.divMTFRS a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_category.php?catcode=MTFRS' ;return false;});
	$('li.divMTHT a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_category.php?catcode=MTHT' ;return false;});
	$('li.divROAD a.yesJS').click(function () {	closeMega();location.href = SITE_ROOT_FOLDER+'bike_category.php?catcode=ROAD' ;return false;});
	$('li.divSTREET a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_category.php?catcode=STREET' ;return false;});
	$('li.divPATH a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_category.php?catcode=PATH' ;return false;});
	$('li.divKIDS a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_category.php?catcode=KIDS' ;return false;});
	$('li.divWOMENS a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_cat_women.php' ;return false;});
	$('li.divFINDBYNAME a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'bike_model-list.php' ;return false;});
	$('li.divALLBIKES a.yesJS').click(function () {closeMega();location.href = SITE_ROOT_FOLDER+'All-Marin-Bikes.php' ;return false;});
	//-----------------------------//
			
			
var topNavSection = $('div.topNavWrapper > div');
		//$(topNavSection).hide().fadeIn(2000);
		//var isBikeSpecPage = $('.wrapper').hasClass('yes');
	if ($('#wrapper').hasClass('yes')) {
			//alert("bikeYes");
			$('#content3').removeClass('noVisibility');
			$(topNavSection).hide().fadeIn(4000);//a possible fix for the double load glitch?
		}
	else if ($('#wrapper').hasClass('home')) {
			$('#content3').hide().removeClass('noVisibility').animate({opacity: 1.0}, 2000).fadeIn(2000);
			
	}
		else {
			//alert("no");
			//alert ('ddddd');
			//$('#content3').hide().removeClass('noVisibility').fadeIn(4000);
			$('#content3').hide().removeClass('noVisibility').animate({opacity: 1.0}, 1000).fadeIn(1000);
			$(topNavSection).hide().fadeIn(2000);//a possible fix for the double load glitch?
	}
		//alert(bikeSpecPage);
				//(don't do this, glitch when added with session include
					//$(".topNavWrapper").removeClass('nojs');// if js turned on, this dropdown will show
	topNavSection.removeClass('noVisibility');// fixes glitch when on a spec page
	//topNavLinks.removeClass('noVisibility');
	//$('#topNavLinks').removeClass('noVisibility');
	topNavSection.hide(); // hide the all bikes section on load	
	topNavSection.removeClass('hideThis');
	document.getElementById('topNavWrapper').style.zIndex="1";//when the dropdown is not active put behind everything
	//-----------------------------//
	// Open the mega dropdown.
	function openMega(){
		$('div.topNavWrapper ul.topNav a').addClass('switchingTabs');//switching tabs
		if ((!$(this).hasClass('selected')) && (!$(this).hasClass('off'))){//activate dropdown unless user hovers over the "Find my Bike" tab
			topNavSection.addClass('hideTab');//don't load more than 1 section
			topNavSection.filter(this.hash).removeClass('hideTab');//don't load more than 1 section
			document.getElementById('topNavWrapper').style.zIndex="105";// when dropdown is active, put above everything 
			
			$(this).addClass('selected');//add selected class on hover
		
			$(this).removeClass('switchingTabs');//switching tabs
			topNavSection.filter('.hideTab').hide();//don't load more than 1 section
			topNavSection.filter('.hideTab').removeClass('selected');//don't load more than 1 section
			topNavSection.filter(this.hash).show();//by default this will pop open w/out animation
			$('div.topNavWrapper ul.topNav a').filter('.switchingTabs').removeClass('selected');//switching tabs
			return false;// doesn't let the browser do it's default action	
		}
	}
	function donothing(){}//do nothing here
		var megaConfigOn = {
			 //interval: 75,//number of milliseconds which hoverIntent uses to check on the mouse’s movement
			 interval: 100,//number of milliseconds which hoverIntent uses to check on the mouse’s movement
			 sensitivity: 4,//number of pixels a mouse should have traveled to be considered moving. If less, the mouse is considered hovering
			 over: openMega,
			 timeout: 300,
			 out: donothing//do nothing
		};
	//$('div.topNavWrapper ul.topNav a').hoverIntent(megaConfigOn);// activate the mega dropdown
	$('div.topNavWrapper ul.topNav a').hoverIntent(megaConfigOn);// activate the mega dropdown
	//var Cat;
	//if (Cat !== null){
		//alert ('ddd');
		
		
		/*this following is for the dropdown sections to not appear when you are in the category page of that specific category*/
		
	$('div.topNavWrapper ul.topNav li.div'+Cat+' a').hoverIntent(megaConfigOff);// activate the mega dropdown
	$('div.topNavWrapper ul.topNav li.div'+Cat+' a').hover(function () {
		closeMega();
		});
	//}
	//else if (Cat == "undefined"){alert('dddddddddd');}
	
	// Close the mega dropdown. This section is needed to close the dropdown when user leaves the whole dropdown, not just the topnav
	function donothing2(){}//do nothing here
	function closeMega(){
		$('.sub-sections').hide();
		$('div.topNavWrapper ul.topNav a').removeClass('selected');
		topNavSection.hide();
		document.getElementById('topNavWrapper').style.zIndex="1";
		return false;// doesn't let the browser do it's default action
	}
		 var megaConfigOff = {
			 interval: 100,
			 sensitivity: 4,
			 over: donothing2,//do nothing
			 timeout: 300,
			 out: closeMega
		};
	$('div.topNavWrapper').hoverIntent(megaConfigOff);// close the mega dropdown
	//-----------------------------//
	$(".xclose a").click(function() {//click on close button
		closeMega();//close drop down
	});

	//when user hovers over the "Find my bike" tab
	$('div.topNavWrapper ul.ulToggleThisWrapper a').hover(function () {	
		$('div.topNavWrapper ul.topNav a').removeClass('selected');
		topNavSection.hide();
		closeMega();
		return false;
	});
	
	$('.ulAllBikesWrapper').hover(function () {	
		$('div.topNavWrapper ul.topNav a').removeClass('selected');
		topNavSection.hide();
		closeMega();
		return false;
	});
	
	
	//-----------------------------//
	//toggle the full bg view or page content
	$('a.toggleThisText').click(function() {//toggle the show/hide content to view the full BG image
			//if (!$(this).hasClass('hiddenContent')) {
				
				$('.bottomFloatCenter').removeClass('noVisibility');
				$('.bottomFloatCenter').show();
				$('.catLayout').fadeOut('medium');	
				$('#content3Compared').fadeOut('medium');	
				$('#content').fadeOut('medium');	
				$('#content3').fadeOut('medium');/*This should be consolidated*/
				//$('a.toggleThisTextTopBG').html('+ View Page Contentx');
				$(this).addClass('hiddenContent');
			
				//}
			/*else {
				$('.catLayout').fadeIn('slow');
				$('#content3Compared').fadeIn('slow');
				$('#content').fadeIn('slow');
				$('#content3').fadeIn('medium');/*This should be consolidated
				$('.viewBgRightTopBG').addClass('noVisibility');
				$('.toggleThisText').html('+ View Background Photo');
				$(this).removeClass('hiddenContent');
				*/
			//}
	});
	$('a.toggleThisTextTopBG').click(function() {//toggle the show/hide content to view the full BG image
				$('.bottomFloatCenter').addClass('noVisibility');
				$('.bottomFloatCenter').hide();
				$('.catLayout').fadeIn('slow');
				$('#content3Compared').fadeIn('slow');
				$('#content').fadeIn('slow');
				$('#content3').fadeIn('medium');/*This should be consolidated*/
				//$('a.toggleThisText').html('+ View Background Photo');
		});
	//-----------------------------//
	//when tabs are clicked, go to these external pages
	/*$('li.divBIKESOVERVIEW a').click(function () {return false;});
$('li.divMTFRS a').click(function () {return false;});*/
	/*$('li.divMTHT a').click(function () {return false;});
	$('li.divROAD a').click(function () {return false;});
	$('li.divSTREET a').click(function () {return false;});
	$('li.divPATH a').click(function () {return false;});
	$('li.divKIDS a').click(function () {return false;});
	$('li.divWOMENS a').click(function () {return false;});
	$('li.divFINDBYNAME a').click(function () {return false;});
	//-----------------------------//	*/
	
	//Load the dropdown sections on hover
		/*$('li.divBIKESOVERVIEW a').hover(function () {	
		if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
		$('#divBIKESOVERVIEWSection').html( '<p class="loading">Loading...</p>' );// show loading bar
			ajaxpage(SITE_ROOT_FOLDER+'external/divBIKESOVERVIEW.php', 'divBIKESOVERVIEWSection');//load page, in div id
				$(this).addClass('isLoaded');
		};
	});*//*
$('li.divMTFRS a').hover(function () {	
		if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divMTFRSSection').html( '<p class="loading">Loading...</p>' );
				ajaxpage(SITE_ROOT_FOLDER+'external/divMTFRS.php', 'divMTFRSSection') ;
				$(this).addClass('isLoaded');};

	});

	$('li.divMTHT a').hover(function () {	
		if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divMTHTSection').html( '<p class="loading">Loading...</p>' );
				ajaxpage(SITE_ROOT_FOLDER+'external/divMTHT.php', 'divMTHTSection') ;
				$(this).addClass('isLoaded');};
	});
	$('li.divROAD a').hover(function () {	
		if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divROADSection').html( '<p class="loading">Loading...</p>' );
				ajaxpage(SITE_ROOT_FOLDER+'external/divROAD.php', 'divROADSection') ;
				$(this).addClass('isLoaded');};
	});
	$('li.divSTREET a').hover(function () {	
		if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divSTREETSection').html( '<p class="loading">Loading...</p>' ); 
				ajaxpage(SITE_ROOT_FOLDER+'external/divSTREET.php', 'divSTREETSection') ;
				$(this).addClass('isLoaded');};
	});
	$('li.divPATH a').hover(function () {	
		 if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divPATHSection').html( '<p class="loading">Loading...</p>' );
				ajaxpage(SITE_ROOT_FOLDER+'external/divPATH.php', 'divPATHSection') ;
				$(this).addClass('isLoaded');};
	});*/
	/*$('li.divKIDS a').hover(function () {	
		if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divKIDSSection').html( '<p class="loading">Loading...</p>' );
				ajaxpage(SITE_ROOT_FOLDER+'external/divKIDS.php', 'divKIDSSection'); 
				$(this).addClass('isLoaded');};
	});
	$('li.divWOMENS a').hover(function () {	
		if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divWOMENSSection').html( '<p class="loading">Loading...</p>' );
				ajaxpage(SITE_ROOT_FOLDER+'external/divWOMENS.php', 'divWOMENSSection'); 
				$(this).addClass('isLoaded');};
	});
	$('li.divFINDBYNAME a').hover(function () {	
		 if (!$(this).hasClass('isLoaded')){//prevents the content to be reloaded over and over again
				$('#divFINDBYNAMESection').html( '<p class="loading">Loading...</p>' );
				ajaxpage(SITE_ROOT_FOLDER+'external/divFINDBYNAME.php', 'divFINDBYNAMESection'); 
				$(this).addClass('isLoaded');};
	});*/
	
		$(".centerModelImage").click(function(){// selected state for browse by bikes feature
			
				if (!$(this).hasClass('imgselected')){
								$(this).addClass('imgselected');
					}
					else if ($(this).hasClass('imgselected')){
							$(this).removeClass('imgselected');
					}
		});		
});