/*
========================================
===> [ Copyright © Swarm Media Ltd ] <==
========> All rights reserved. <========
========================================
#::- This code was written by Swarm -::#
========================================
====> RETAIN THIS COPYRIGHT NOTICE! <===
=======> http://www.swarmuk.com <=======
========================================
*/

$(document).ready(function(){

	$('.js_more').click(function() {

		if ($(this).html() == '+ More') {
			$(this).html('- Less');
		} else {
			$(this).html('+ More');	
		}

		return false;
	});

	$('.js_submit').click(function() {
		$(this).parents('form').submit();
		return false;
	});
	
	$('.js_back').click(function() {
		history.back();
		return false;
	});
	
	$('.js_jump').change(function() {

		if ($(this).val() != '') {
			window.location = $(this).val();
		}

		return false;
	});

	$('.js_hide').hide();

	$('.js_toggler').click(function() {
		togglerClass = '.' + $(this).attr('id');
		$(togglerClass).toggle();
		return false;
	});

	$('.js_check_all').click(function() {
		
		if ($(this).attr('value') == 0) {
			$(this).siblings('input').attr('checked', 'checked');
			$(this).closest('li').siblings('li').find('input').attr('checked', 'checked');
			$(this).attr('value', '1');
		} else {
			$(this).siblings('input').removeAttr('checked');
			$(this).closest('li').siblings('li').find('input').removeAttr('checked');
			$(this).attr('value', '0');
		}

	});

	/* Message character limit. */
	function limitChars(textclass, limit, msgid) {
		var msgtext = $('.' + textclass).val();
		var textlength = msgtext.length;

		if (textlength > limit) {
			$('#' + msgid).html('<strong class="red">You have '+ (limit - textlength) +' characters remaining.</strong>');
			$('#' + textclass).val(text.substr(0,limit));
			return false;

		} else {
			$('#' + msgid).html('You have '+ (limit - textlength) +' characters remaining.');
			return true;
		}
	}

	$('.charlimit').keyup(function(){
		limitChars('charlimit', 1500, 'chars_remaining');
	})

	$('#mini_register input').click(function() {
		if ($(this).val() == 'First Name' || $(this).val() == 'Email') {
			$(this).val('');
		}
	});

});
