/**
 * @package     Joomla.Site
 * @subpackage  Templates.protostar
 * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 * @since       3.2
 */

(function($)
{
	$(document).ready(function()
	{
		$('*[rel=tooltip]').tooltip()

		// Turn radios into btn-group
		$('.radio.btn-group label').addClass('btn');
		$(".btn-group label:not(.active)").click(function()
		{
			var label = $(this);
			var input = $('#' + label.attr('for'));

			if (!input.prop('checked')) {
				label.closest('.btn-group').find("label").removeClass('active btn-success btn-danger btn-primary');
				if (input.val() == '') {
					label.addClass('active btn-primary');
				} else if (input.val() == 0) {
					label.addClass('active btn-danger');
				} else {
					label.addClass('active btn-success');
				}
				input.prop('checked', true);
			}
		});
		$(".btn-group input[checked=checked]").each(function()
		{
			if ($(this).val() == '') {
				$("label[for=" + $(this).attr('id') + "]").addClass('active btn-primary');
			} else if ($(this).val() == 0) {
				$("label[for=" + $(this).attr('id') + "]").addClass('active btn-danger');
			} else {
				$("label[for=" + $(this).attr('id') + "]").addClass('active btn-success');
			}
		});
	})
	/**********
	 CF-POPUP
	***********/
	$(document).ready(function(){
		// $('#cf-popup-wrap').html("<div id='cf-popup' class='cf-popup'><a id='cf-popup-close' class='cf-popup-close' href='#'>&times;</a>  <p>Welcome to Lost-and-Found.dk (Hittegods.dk), Denmark's leading website and service portal re lost and found.</p><p><strong>Sign up now, not after having lost your keys or phone!</strong></p><p>This site is currently in BETA testing undergoing periodic improvements. Expect in the near future: access to live police actions, a national members-only community forum to assist recovering lost items, additional links to major attractions, and much more.</p><form id='cf-form' class='cf-form' action=''><div class='cf-form-section'><div><label class='cf-form-label' for='cf-name'>Your Name:</label></div><div><input id='cf-name' type='text' name='cf-name-eng' placeholder='John Doe' required /></div><div><label class='cf-form-label' for='cf-email'>Your Email:</label></div><div><input id='cf-email' type='email' placeholder='jon@doe.com' name='cf-email-eng' required /></div></div><div class='cf-form-section cf-form-section__radios'><div class='space-below'><input type='radio' id='radio_1' name='radio_1' value='without' required /><label for='radio_1'>YES, send me periodic important updates re lost and found (max 1-3 times per year) WITHOUT member offers and discounts.</label></div><div><input type='radio' id='radio_2' name='radio_1' value='including' required /> <label for='radio_2'>YES, send me periodic updates re lost and found INCLUDING member offers and discounts (travel, electronics, smart services, etc.</label></div></div><button class='btn'>Subscribe</button></form><p class='privacy-policy'>Privacy Policy</br>Names and emails provided will NOT be sold or shared by us with any third party not directly partnered or part of Hittegods.dk.</p><p class='privacy-policy'><em>To report lost and found items, please contact your local police dept. which can be found using our site.</br>Hittegods.dk does not store or accept any physical items. Its purpose is to assist, inform, guide and refere. Suggestions and feedback are very welcome.</em></p></div>");
	});

	$(document).ready(function(){
	  $('#cf-popup').show(function(){
	  	$('#cf-popup-close').on('click', function(){
	  	  $('#cf-popup').hide();
	  	});
	  });
	});

})(jQuery);