/*
 * REGISTERED SLEEPERS
 * www.registeredsleepers.com
 *
 * Copyright 2011. All Rights Reserved.
 * This file may not be redistributed in whole or part.
 *
 * Applicable JavaScript Definitions
 */

$(function(){
	
	/* Forms */
	$.fn.onFocus = function(){
		return this.focus(function(){
			this.value = (this.value === $(this).attr('title')) ? '' : this.value;
			$(this).parent('.input, .textarea').addClass('focus');
		}).blur(function(){
			if (this.value === '' || /^\s+$/.test(this.value)){
				this.value = $(this).attr('title');
				$(this).removeClass('on');
			}
			else if (this.value === $(this).attr('title')){
				$(this).removeClass('on');
			}
			else {
				$(this).addClass('on');
			}
			$(this).parent('.input, .textarea').removeClass('focus');
		});
	};
	
	$('input, textarea').onFocus();
	$('.auto').focus();
	
	/* Testimonials */
	$('footer .slider').cycle({
		fx:'scrollLeft',
		speed:800,
		timeout:10000,
		prev:'.arrows .prev',
		next:'.arrows .next'
	});
	
	/* FAQ */
	$('#answers li#a1').show();
	$('#questions li a').click(function(){
		var elem = $(this).attr('class');
		$('#questions li').removeClass('current');
		$(this).parent().addClass('current');
		$('#answers li').hide();
		$('#answers li#'+elem).show();
		return false;
	});
	
	/* Disclaimer */
	$('.disclaimer .slide').hide();
	$('.disclaimer .heading').click(function(){
		$('.disclaimer .slide').slideToggle();
		$('.disclaimer .heading span').text($('.disclaimer .heading span').text() == '+' ? '-' : '+');
	});
	
});
