$(document).ready(function(){


	//submit form using <a href>
	$('.button__hidden').css('position','absolute');
	$('.jquery__submit').css('display','inline-block');	
	$('.jquery__submit').click(function(event){
		event.preventDefault();
		$(this).next('.button__hidden').click();
	});
	
	
	//faq - toggle headings
	faqs_collapse(true);
	$('.ct_faq h2').click(function(){
		if( $(this).hasClass('expanded') ){
			faqs_collapse();
		} else {
			faqs_collapse();
			faqs_expand(this);
		}
	});
	function faqs_collapse(is_first_open){
		var time = ( is_first_open )? 0 : 175;
		$('h2', '.ct_faq').each(function(index){
			if( !is_first_open || (is_first_open && index != 0) ){
				if( $(this).hasClass('expanded') ){
					$(this).removeClass('expanded');
					$(this).next('ul').slideUp(time);
				}
			}
		});	
	}
	function faqs_expand(element){
		if( !$(element).hasClass('expanded') ){
			$(element).addClass('expanded');
			$(element).next('ul').slideDown(175);
		}
	}
	
	
	//colorbox
	if( $('a[rel="colorbox"]').length ){
		$('a[rel="colorbox"]').colorbox({
			iframe:true,
			rel:'nofollow',
			transition:'none',
			scrolling:false,
			speed:250,
			width:'95%',
			height:'95%',
			maxWidth:'800px',
			maxHeight:'660px'
		});
	}
});
