jQuery(document).ready(function( $ ) {
	$('.tab').on('click',function() {
		var clicked = $(this);
		var target = clicked.data('target');
		$('.tab').removeClass('active');
		clicked.addClass('active');
		$('.tab-content').removeClass('active');
		$(target).addClass('active');
	});
	if( $('#iris-openwebsite-admin') ) {
		
		if(location.hash === '') {
			$('[data-target="#tab-general-pages"]').addClass('active');
			$('#tab-general-pages').addClass('active');
		} else {

			var target = location.hash.replace('#','#tab-');
			$('.tab-content').removeClass('active');
			$(target).addClass('active');
			$('.tab').removeClass('active');
			$('[data-target="'+target+'"]').addClass('active');
		}
	}
	
	
	$(".custom-notice").detach().appendTo('#custom-notices');
	
	

	$('.help-toggle').on('load click',function() {
		$(this).next('.help-content').toggleClass('active');
		});
	
	
	$('#mtd-ctrl').on('change',function() {
		if( $(this).val() === '1' ) {
			$('#mtd-inputs').slideDown(200);
		} else {
			$('#mtd-inputs').slideUp(200);
		}
	}).trigger('change');
	
	
	(function() {
	var value = $('#media-progress').data('value');
	var max = $('#media-progress').data('max');	
	
	var percent = 100 / max * value;
		

		$('.media-progress-bar.success').width(percent+'%').addClass('active');

		if(percent > 80) {
			$('.media-progress-bar').removeClass('active');
			$('.media-progress-bar.warning').width(percent - 80+'%').addClass('active');
		}		
		if(percent > 90) {
			$('.media-progress-bar').removeClass('active');
			$('.media-progress-bar.alert').width(percent - 90+'%').addClass('active');		
		}
	
		
	
	
	})();
	
	$('#website-package-select').on('change',function() {
    var id = $(this).val();
	if ((id == 'Template Standard') || (id == 'Template Advanced') || (id == 'Bespoke Standard') || (id == 'Bespoke Advanced') || (id == 'Signature') || (id == 'Professional')){
		$("#opt-newsletter").slideDown(200);
	}
		else{
			$("#opt-newsletter").slideUp(200);
		}
    
	}).trigger('change');
	
	
	$('#website-package-select').on('change',function() {
    var value = $(this).val();
	if ((value == 'Professional') || (value == 'Signature')){
		$("#opt_newsletter").val("1").change();
		$("#opt_card").val("1").change();
	}
		else if ((value == 'Select') || (value == 'Essentials')){
			$("#opt_newsletter").val("0").change();
			$("#opt_card").val("0").change();
		}
    
	});
});

