function coolOpen()
{

/*	$(window).scroll(function () { 
		
		//alert("Before Scroll bar was moved");
							   
		jQuery('.anchor_top img').stop().animate({height:'208px'},2000);
		
		//alert("Scroll bar was moved");
		
    });*/

	if( $('#show_top_menu').length > 0 ) {
		//if ($.browser.msie && $.browser.version.substr(0,1)<7) { // If ie6
			jQuery('html').css({height:'1300px'});
			jQuery('body').css({height:'1300px'});
		//}
		//else {
		//	jQuery('html').css({height:'130%'});
		//}
	
	}
//	jQuery('html').css({height:'100%'});

//	$("#show_top_menu").localScroll({
//		onBefore: function(event,te,ts) {
//			jQuery('html').css({minHeight:'150%'});
//		}, 
//		onAfter: function(){
//			//jQuery('html').css({height:''});
//			//$(".single_block_dummy").removeClass('cool_highlighed');
//			//$(".single_block_dummy").css({backgroundColor: ''});
//		}
//	});


	// Initialize direction, left or right.
	if ( $(".cool_open_left").length ) {		
		var direction_var = "right";
		//alert('right');
	} else {
		var direction_var = "left";
		//alert('left');
	}	
	
	//$(".cool_open a").attr( 'href' : $(this).parent().nextAll('.cool_sublinks:first').children('.cool_sublink:first').children('a:first').attr('href') )
	
	//console.log($('.cool_open a').parent().nextAll('.cool_sublinks:first').children('.cool_sublink:first').children('a:first').attr('href'));
	
	$('.cool_open').each(function(index) {
		//alert(index + ': ' + $(this).text());
		//console.log($(this).nextAll('.cool_sublinks:first').children('.cool_sublink:first').children('a:first').attr('href'));
		
		var anchor_link = $(this).nextAll('.cool_sublinks:first').children('.cool_sublink:first').children('a:first');
		
		var href = anchor_link.attr('href');
		
		$(this).children('a:first').attr( 'href', href );
		
		anchor_link.addClass("highlighted");
		
		
		
	});
		
	
/*	$(".cool_open").bind('click',function(event){ 
				
		imageAninmationUp();
		hidePreviousContent(this);
		displayContent(this);

		jQuery('.single_block_dummy').removeClass('cool_highlighed back_color');

		jQuery(this).addClass('cool_highlighed');

		var cool_open = jQuery(this);
		var cool_sublinks = jQuery(this).nextAll('.cool_sublinks:first');
		var cool_content = jQuery(this).nextAll('.cool_content:first');
		
		jQuery('.append').prepend(cool_content);
		jQuery('.append').prepend(cool_sublinks);
		jQuery('.append').prepend(cool_open);

	});*/
	
	
	function imageAninmationUp(){
		// 1200
		if( $("#show_top_menu a").css('height') != '104px' ) {
			$("#show_top_menu a").css({overflow: 'hidden'});
			$(".anchor_top").animate({height: 0}, 0 , "linear" , function(){
				imageSmaller();
				$(".anchor_top").animate({height: 104}, 0);
			});
		}
	}
	
	
	function imageSmaller() {
		var src =  $("#show_top_menu .main_image").attr('src');
		var array = src.split('.');
		var test = src.split('_');
		
		var reg = /_crop\.jpg/;
		
		//alert(reg.test(src))
		
		if( !reg.test(src) ) {
			var append = array[0] + '_crop' + '.' + array[1];
			$("#show_top_menu  .main_image").attr({src: append});	
		}
	}
	
	
	function hidePreviousContent(self) {

		$(".cool_sublinks").css({float:direction_var,clear:direction_var}); // Needed to keep things aligned
		$(".cool_open").stop().css({padding:"0px", clear: direction_var, float: direction_var}); // Needed to keep things aligned. Decreases heading bar again.

//		$(this).nextAll('.cool_content:first').show();

		$.each( $(".cool_content"), function() {
			if( $(this).is(":visible") ) {
				$(this).hide();
			}
		});
		
		$(".cool_sublinks").hide(); // Hide sub-links
		
		$(".cool_content_outer").css({width: 0});
				
		$(".cool_open a").css({color: '#666666'}); // Revert color back to grey after becoming heading

	}
	
	function displayContent(self) {
		
		$(self).next(".cool_sublinks").show(); // Show sub-links
		$(self).children().css({color: '#ffffff', fontWeight: "bold"});
		$(self).nextAll('.cool_content:first').css({display: 'block'});
		$(self).nextAll('.cool_content:first').children().animate({width: '100%'}, 1250);
		
		
		
		if ( $(".cool_open_left").length ) {
			//$(self).css({backgroundColor: ''});
			$(self).addClass('cool_highlighed');
			$(self).animate({paddingLeft: 350}, 700);
			//alert(112);
			custom_width_right(self);
		} else {
			//$(self).css({backgroundColor: ''});
			$(self).addClass('cool_highlighed');
			$(self).animate({paddingRight: 350}, 700);
			
			custom_width(self);
		
		}

	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Custom Width Function
	function custom_width(self){
		// New Custom Function
		var tabs_holder = $(self).nextAll('.cool_content:first').find('.tabs_holder');
		$width = tabs_holder.width();
		
//		console.log($width);
		if( $width > 400 ) { // use 400 as standard
			$(self).stop().animate({paddingRight: 526}, 2200);
		}
	}
	
	function custom_width_right(self){
		// New Custom Function
		var tabs_holder = $(self).nextAll('.cool_content:first').find('.tabs_holder');
		var tabs_holder_parent = tabs_holder.parent();
		
		$width = tabs_holder.width();
		
//		console.log($width);
		
		if( $width > 400 ) { // use 400 as standard
			$(self).stop().animate({paddingLeft: 526}, 2200);
			
			tabs_holder_parent.width(526);
			
		}
	}

	
	

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Hover colors for 4 pages. IE does not support hover on div

	$('.append .single_block_dummy').hover(
		function() {
			if( !$(this).hasClass('cool_highlighed') ) 
			{
				$(this).removeClass('back_grey');
				$(this).addClass('back_color')
				$(this).children('a').css({color:'#FFFFFF'});
			}
		}, 
		function() {
			if( !$(this).hasClass('cool_highlighed') ) 
			{
				$(this).removeClass('back_color');
				$(this).addClass('back_grey')
				//$(this).css({backgroundColor:'#e3e3e3'});
				$(this).children('a').css({color:''});
			}
	});




	
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//


	
	
	// Reload page for hash links
	$(".cool_content a").click(function(event){
		//event.preventDefault();
		//window.location.reload(true); 
		//window.location = document.location.href;
		
//		if( $(this).attr('href').search(/#/i) > 0 ) {
	
		//if( !$('.no_reload_tabs').length ) {
		if( $('.link_fix').length ) {
			
			//alert($(this).attr('href'));
			
			window.location.replace($(this).attr('href'));
		
			//window.location.hash = $(this).attr('href');
			window.location.reload(true);
		
		
		}
		
			//console.log($(this).attr('href'));

//		}
	
	});
	
	
	

	
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Used to display and animate cool sublinks.	
	
	$(".tabs_holder > div").hide(); // refactor
	//$(".tabs_holder").find("div:first").show(); // refactor
	
	$(".cool_sublinks a").click(function(){

		$(".tabs_holder > div").hide();

		$(this).parent().parent().nextAll('.cool_content:first .tabs_holder > div').hide();

		var href = $(this).attr("href");
		var array = href.split('#');
		var class_name =  "." + array[1];

		$(class_name).show();

		
		$(this).parent().parent().nextAll('.cool_content:first').find('.tabs_holder').parent().css({'width':'322px'});
		//$(".cool_content_outer").css({width: 0});

		var cool_open = $(this).parent().parent().prevAll('.cool_open:first');
		var tabs_holder = $(this).parent().parent().nextAll('.cool_content:first').find('.tabs_holder');
		var tabs_holder_parent = tabs_holder.parent();

		
		if ( !$(".cool_open_left").length ) {
			$width = tabs_holder.width();
			if( $width > 400 ) {
				cool_open.css({paddingRight: 526});
			} else {
				cool_open.css({paddingRight: 350});
			}
		}
		else {

			$width = tabs_holder.width();
			
			//alert($width);
			
			if( $width > 400 ) {
				cool_open.css({paddingLeft: 526});
				tabs_holder_parent.width(526);
			} else {
				cool_open.css({paddingLeft: 350});

			}
			
		}
		
/*		if (jQuery.browser.msie) {
  alert(parseInt(jQuery.browser.version));
}*/
		
		
	});
	
	
	
/*	$(".cool_open").bind('click',function(event){ 
		
		$(".tabs_holder").find("div:first").show(); // refactor
		
		imageAninmationUp();
		hidePreviousContent(this);
		displayContent(this);

		jQuery('.single_block_dummy').removeClass('cool_highlighed back_color');

		jQuery(this).addClass('cool_highlighed');
		
/////////////////////////			
		var highlighted = $(this).nextAll('.cool_sublinks:first .cool_sublink a');
		
		//highlighted.removeClass("highlighted");
		highlighted.addClass("highlighted");
/////////////////////////		
		
		var cool_open = jQuery(this);
		var cool_sublinks = jQuery(this).nextAll('.cool_sublinks:first');
		var cool_content = jQuery(this).nextAll('.cool_content:first');
		
		jQuery('.append').prepend(cool_content);
		jQuery('.append').prepend(cool_sublinks);
		jQuery('.append').prepend(cool_open);

	});*/
	

	$(".cool_open").children("a").addClass("highlight");
		
	// Highlighted sublinks
	$(".cool_sublink a").click(function(){
		//$(".cool_sublink a").removeClass("highlighted");
		
		$(this).parent().parent().children().children('.cool_sublink a').removeClass("highlighted");  // Only sublinks of category change.
		
		$(this).addClass("highlighted");
	});



////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Check if page is bookmarked. If so then display the page.

	if (window.location.hash.toLowerCase().length > 1) {
		var hash = window.location.hash.toLowerCase();
		var array = hash.split('#'); // get rid of hash(#) in string
		var class_name =  "." + array[1];
		
		var cool_open = $(class_name).parents('.cool_content:eq(0)').prevAll('.cool_open:first');
		
		//alert(cool_open.attr('class'));
			
		//alert(class_name);	
			
		var highlighted = $('.cool_sublinks .cool_sublink a'+class_name);
		
		$('.cool_sublink a').removeClass("highlighted");
		highlighted.addClass("highlighted");
		
		//alert(highlighted.attr('href'));
		
		$(class_name).show();
		
		imageAninmationUp();
		hidePreviousContent( cool_open );
		displayContent( cool_open );
	
	
	
//		$(".tabs_holder").find("div:first").show(); // refactor
//		$(".tabs_holder > div").hide();

//		var array = hash.split('#');
//		var class_name =  "." + array[1];

		



		var cool_open = cool_open;
		var cool_sublinks = cool_open.nextAll('.cool_sublinks:first');
		var cool_content = cool_open.nextAll('.cool_content:first');

		jQuery('.append').prepend(cool_content);
		jQuery('.append').prepend(cool_sublinks);
		jQuery('.append').prepend(cool_open);

		//console.log(class_name);
	}






	$(".cool_open").live('click',cool_open_event);

	function cool_open_event(event){ 
		
		$(".tabs_holder").find("div:first").show(); // refactor
		
		imageAninmationUp();
		hidePreviousContent(this);
		displayContent(this);

		jQuery('.single_block_dummy').removeClass('cool_highlighed back_color');

		jQuery(this).addClass('cool_highlighed');






//		cool_open.unbind('click');


		var cool_open = jQuery(this);
		var cool_sublinks = jQuery(this).nextAll('.cool_sublinks:first');
		var cool_content = jQuery(this).nextAll('.cool_content:first');
		
/*		clone_cool_open = cool_open.clone();
		clone_cool_sublinks = cool_sublinks.clone();
		clone_cool_content = cool_content.clone();
		
		//alert(clone_cool_open.attr('class'))
		
		//clone_cool_open.bind('click',this);
		
		jQuery('.append').prepend(clone_cool_content);
		jQuery('.append').prepend(clone_cool_sublinks);
		jQuery('.append').prepend(clone_cool_open);
		
		
		cool_open.remove();
		cool_sublinks.remove();
		cool_content.remove();*/
		
		
		
		
		
		
		
		
		jQuery('.append').prepend(cool_content);
		jQuery('.append').prepend(cool_sublinks);
		jQuery('.append').prepend(cool_open);

		






/////////////////////////			
		
		$('.cool_sublink a').removeClass("highlighted");
		var highlighted = $(this).nextAll('.cool_sublinks:first .cool_sublink a:first');

//		alert(highlighted.attr('href'));

		highlighted.addClass("highlighted");
/////////////////////////	

		


	}



	
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The End.	
	
	
}