// JavaScript Document
jQuery(document).ready(function($) {	
	
	bbtCount = 0;
	$(".faq-link").each(function(i){
		/*
		if(bbtCount)
			$(this).next().append('<div class="back-to-top"><a href="#top">BACK TO TOP</a></div>');
		bbtCount++;
		*/
			
		$(this).next().append('<div class="faq-close">CLOSE</div>');
		
		$(this).click(function(){
			if($.browser.msie && $.browser.version < 8) {
				$(".faq-content").hide();
				$(this).next().show(0,function(){
					$o = $(this).prev();
					setTimeout('scrollFrom($o);',250);
				});
			}
			else {
				$(".faq-content").slideUp();
				$(this).next().slideDown("fast",function(){
					$o = $(this).prev();
					setTimeout('scrollFrom($o);',250);
				});
			}
		});
	});
	
	$(".faq-close").live('click',function(){
		$(this).parent().slideUp();
	});
	
	autoSroll = false;
	
	$("a").each(function(i){
		if($(this).attr('href')) {
			if($(this).attr('href') != "#" && $(this).attr('href').indexOf("#") !=-1) {
				$(this).click(function(){
					href = $(this).attr('href');
					alink = href.substr(href.indexOf("#")+1,href.length);
					scrollFrom($("a[name="+alink+"]").prev());
					return false;
				});
			}
		}
	});
	
	$(".scroll-link").click(function(){
		title = $(this).attr('title');		
		$to = $("a[name="+title+"]");
		scrollFrom($to);
	});
});

	
function scrollFrom($to) {
	autoSroll = true;
	
	if(jQuery.browser.msie && jQuery.browser.version == '7.0')
		$to = $to.prev();
	else if(jQuery.browser.safari)
		$to = $to;
		
	jQuery.scrollTo( $to, 1000, {axis: 'y', easing: 'easeOutCubic',  
		onAfter:function(whereTo) {
			autoSroll = false;
			$top = jQuery(document).scrollTop();
	}} );
}
