//$('.content .field-field-images .field-item').hide();

$(document).ready(function() {
	$('.node .field-field-images .first').fadeIn('slow');
	// styling for jquery & javascript
	$('.field-field-sections').addClass('jQueryActive');	
	$('.field-items .heading').removeAttr('name');
	
 	// hide & deactivate all but the first tab
	$('.field-item a.heading').click(function() {
		$('.heading').removeClass("open");
		$('.jQueryActive .content').fadeOut('slow');
		$(this).next().fadeIn('slow');
		$('#forceheight').height($(this).next().height());
		$(this).toggleClass("open");
	}).next().hide();
	
	if(window.location.hash == ''){
		//show and activate first menu item
		$('.field-item-first a.heading').click(function() {
			$('.heading').removeClass("open");
			$('.jQueryActive .content').fadeOut('slow');
			$(this).next().fadeIn('slow');
			$('#forceheight').height($(this).next().height());
			$(this).toggleClass("open");
		}).toggleClass("open");
		$('#forceheight').height($('.field-item-first .heading').next().height());
	}else{
		//if page has focued on a hashtag, now removed, go back to top of the page
		window.scrollTo(0,0);
		$('.field-item-first a.heading').click(function() {
			$('.heading').removeClass("open");
			$('.jQueryActive .content').fadeOut('slow');
			$(this).next().fadeIn('slow');
			$('#forceheight').height($(this).next().height());
			$(this).toggleClass("open");
			//return false;
	
		}).next().hide();
		$('[class=heading]').each(function(){
			//alert(window.location.hash);
			if(window.location.hash == this.title){
				$(this).toggleClass("open");
				$(this).next().show();
				$('#forceheight').height($(this).next().height());
			} 
		})
		
	}
	
	if($('.content .field-field-images .field-item').length>1){
		//alert($('.content .field-field-images .field-item').length)
		$('.content .field-field-images .field-items').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		pager:  '#thm-pager',
		timeout: 6000,
		pause: 1
	});
		

	}
	
});
