jQuery(document).ready(function(){
	
	members_cancellation_customizer();
	//members_cancellation_customizer_default();
	
	jQuery('#pause_resume_select').change(function(){
		
		if(jQuery(this).val() == 'N'){
			jQuery('.pause_resume_outer').hide();
		}else{
			jQuery('.pause_resume_outer').show();	
		}
	});
	
	
	/******Check Page Availability*************/
	
	jQuery('.check_availability_page_btn').click(function(e){
		e.preventDefault();
		dap_member_show_loader();
		
		var page_type = jQuery(this).attr('data-id');
		var page_name = jQuery('#'+page_type).val();
		
		jQuery('.success_'+page_type).hide();
		jQuery('.error_'+page_type).hide();
		
		if(page_name != '') {
			jQuery(this).text("Checking..."); 
			jQuery.post(ajaxurl, {
					action: 'dapcheckPageAvailabilityAjax',
					page_name: page_name,
			}, function(response) {
				dap_member_hide_loader(); 
				
				response = response.split("||");
				if (response[0] == 'yes') {
					jQuery('.success_'+page_type).hide();
					jQuery('.error_'+page_type).show();
				} else if (response[0] == 'no') {
					jQuery('.error_'+page_type).hide();
					jQuery('.success_'+page_type).show();
				}
				jQuery('.check_availability_page_btn').text("Check Availability");
				/*setTimeout(function(){ 
					jQuery('.success_'+page_type).hide();
					jQuery('.error_'+page_type).hide();
				 }, 3000);*/
				
			});
				
		}else{
			swal('Please enter a name. Name cannot be empty.')	
		}
	});
		
	
	jQuery('.create_shortcode_btn').click(function(){
		dap_member_show_loader();
		var id = jQuery('#saved_id').val();	
		var create_cancellation_page = jQuery('#create_cancellation_page').val();	
		var cancellation_data_id = jQuery('#cancellation_page_url').find(":selected").val();		
		if(cancellation_data_id == ''){
			cancellation_data_id = jQuery('#page_id').val();	
		}
		if(create_cancellation_page == '' && (cancellation_data_id == '' || cancellation_data_id == 0)){
			swal('Please select a page');
			return;	
		}
		
		var template = jQuery('#select_template').val();	
		var show_all_transactions = jQuery('#show_all_transactions').val();	
		var product_type = jQuery('#product_type').val();		
		var contact_us = jQuery('#cancellation_contact_us_text').val();		
		var contact_us_link = jQuery('#cancellation_contact_us_link').val();		
		var show_cancel = jQuery('#show_cancel').val();		
		var cancelled_text = jQuery('#cancelled_text').val();	
		var success_cancel_msg = jQuery('#success_cancel_msg').val();	
		var failed_cancel_msg = jQuery('#failed_cancel_msg').val();	
		var cancel_cancel_msg = jQuery('#cancel_cancel_msg').val();	
		var dateformat = 'YYYY-MM-DD';	
		var bgcolor = '#f9f9f9';	
		var payment = 'PAYPAL';	
		var showrenewal = 'Y';	
		var templatetextcolor = '#000';	
		var cancelimage = '';	
		
		/*cancel button style start*/
		var height = jQuery('#cancel_button_height').val();
		var background = jQuery('#cancel_background_clr').val();
		var border_color = jQuery('#cancel_border_clr').val();
		var color = jQuery('#cancel_text_clr').val();
		var font_size = jQuery('#cancel_font_size').val();
		var border_width = jQuery('#cancel_border_width').val();
		var border_style = jQuery('#cancel_bdr_style').val();
		var border_radius = jQuery('#cancel_border_radius').val();
		var font_weight = jQuery('#cancel_font_weight').val();
		var button_width = jQuery('#cancel_button_width').val();
		/*cancel button style end*/
		
		var cancelbuttonstyle = 'padding-top: '+height+'px;background: '+background+' ;border-color: '+border_color+';color: '+color+';font-size: '+font_size+'px;border-width: '+border_width+'px;border-style: '+border_style+';border-radius: '+border_radius+'px; font-weight:'+font_weight+';width:'+button_width+'px;padding-bottom: '+height+'px;';	
		var cancelbuttonstyleNew = height+';'+background+';'+border_color+';'+color+';'+font_size+';'+border_width+';'+border_style+';'+border_radius+';'+font_weight+';'+button_width+';'+height+'';	
		var cancelbuttontext = jQuery('#cancel_btn_text').val();	
		var upgradelink = '';	
		var upgradetext = 'UPGRADE';	
		var upgradetextcolor = 'blue';	
		var canceltext = jQuery('#cancel_btn_text').val();	
		var canceltextcolor = jQuery('#cancel_text_clr').val();	
		var cancelledtextcolor = 'red';	
		var notransfoundmsg = jQuery('#no_transaction_found').val();	
		var showpause = jQuery('#pause_resume_select').val();	
		var pausesuccess = jQuery('#success_paused_msg').val();	
		var pausefail = jQuery('#failed_paused_msg').val();	
		var pauseconfirm = jQuery('#confirm_paused_msg').val();	
		var pauseurl = '';	
		
		/*pause button style start*/
		var height = jQuery('#pause_button_height').val();
		var background = jQuery('#pause_background_clr').val();
		var border_color = jQuery('#pause_bdr_style').val();
		var color = jQuery('#pause_text_clr').val();
		var font_size = jQuery('#pause_font_size').val();
		var border_width = jQuery('#pause_border_width').val();
		var border_style = jQuery('#pause_bdr_style').val();
		var border_radius = jQuery('#pause_border_radius').val();
		var font_weight = jQuery('#pause_font_weight').val();
		var button_width = jQuery('#pause_button_width').val();
		/*pause button style end*/
		
		
		var pausebuttonstyle = 'padding-top: '+height+'px;background: '+background+' ;border-color: '+border_color+';color: '+color+';font-size: '+font_size+'px;border-width: '+border_width+';border-style: '+border_style+';border-radius: '+border_radius+'px; font-weight:'+font_weight+';width:'+button_width+'px;padding-bottom: '+height+'px;';	
		var pausebuttonstyleNew = height+';'+background+';'+border_color+';'+color+';'+font_size+';'+border_width+';'+border_style+';'+border_radius+';'+font_weight+';'+button_width+';'+height+'';	
		var pausebuttontext = jQuery('#pause_btn_text').val();	
		var pausetextcolor = jQuery('#pause_text_clr').val();	
		var resumesuccess = jQuery('#success_resume_msg').val();	
		var resumefail = jQuery('#failed_resume_msg').val();	
		var resumeconfirm = jQuery('#confirm_resume_msg').val();	
		var resumeurl = '';	
		
		/*resume button style start*/
		var height = jQuery('#resume_button_height').val();
		var background = jQuery('#resume_background_clr').val();
		var border_color = jQuery('#resume_bdr_style').val();
		var color = jQuery('#resume_text_clr').val();
		var font_size = jQuery('#resume_font_size').val();
		var border_width = jQuery('#resume_border_width').val();
		var border_style = jQuery('#resume_bdr_style').val();
		var border_radius = jQuery('#resume_border_radius').val();
		var font_weight = jQuery('#resume_font_weight').val();
		var button_width = jQuery('#resume_button_width').val();
		/*resume button style end*/
		
		var resumebuttonstyle = 'padding-top: '+height+'px;background: '+background+' ;border-color: '+border_color+';color: '+color+';font-size: '+font_size+'px;border-width: '+border_width+'px;border-style: '+border_style+';border-radius: '+border_radius+'px; font-weight:'+font_weight+';width:'+button_width+'px;padding-bottom: '+height+'px;';
		var resumebuttonstyleNew = height+';'+background+';'+border_color+';'+color+';'+font_size+';'+border_width+';'+border_style+';'+border_radius+';'+font_weight+';'+button_width+';'+height+'';	
		var resumebuttontext = jQuery('#resume_btn_text').val();		
		
		jQuery.post(ajaxurl, {
			action: 'dapSaveMemberCancelAjax',
			id: id,
			template: template,
			show_all_transactions: show_all_transactions,
			product_type: product_type,
			contact_us: contact_us,
			contact_us_link: contact_us_link,
			cancellation_data_id: cancellation_data_id,
			create_cancellation_page: create_cancellation_page,
			show_cancel: show_cancel,
			cancelled_text: cancelled_text,
			success_cancel_msg: success_cancel_msg,
			failed_cancel_msg: failed_cancel_msg,
			cancel_cancel_msg: cancel_cancel_msg,
			dateformat: dateformat,
			bgcolor: bgcolor,
			payment: payment,
			showrenewal: showrenewal,
			showrenewal: showrenewal,
			templatetextcolor: templatetextcolor,
			cancelimage: cancelimage,
			cancelbuttonstyle: cancelbuttonstyle,
			cancelbuttontext: cancelbuttontext,
			upgradelink: upgradelink,
			upgradetext: upgradetext,
			upgradetextcolor: upgradetextcolor,
			canceltext: canceltext,
			canceltextcolor: canceltextcolor,
			cancelledtextcolor: cancelledtextcolor,
			notransfoundmsg: notransfoundmsg,
			showpause: showpause,
			pausesuccess: pausesuccess,
			pausefail: pausefail,
			pauseconfirm: pauseconfirm,
			pauseurl: pauseurl,
			pausebuttonstyle: pausebuttonstyle,
			pausebuttontext: pausebuttontext,
			resumesuccess: resumesuccess,
			resumefail: resumefail,
			resumeconfirm: resumeconfirm,
			resumeurl: resumeurl,
			resumebuttonstyle: resumebuttonstyle,
			resumebuttontext: resumebuttontext,
			cancelbuttonstyleNew: cancelbuttonstyleNew,
			pausebuttonstyleNew: pausebuttonstyleNew,
			resumebuttonstyleNew: resumebuttonstyleNew,
		}, function(response) {
			response = JSON.parse(response);		
			jQuery('.get_shortcode').html(response.short_code_html);
			jQuery('#saved_id').val(response.id);
			jQuery('#page_id').val(response.page_id);
			jQuery('.shortcode_div').show();	
			dap_member_hide_loader();		
		})	
	});	
	
	
		
});



function members_cancellation_customizer(){
	
	jQuery('#cancel_btn_text').keyup(function() {
		jQuery('.cancel_btn').text(jQuery(this).val());
	});
	
	jQuery('#cancel_font_size').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('font-size',this.value + 'px');
	});
	
	jQuery('#cancel_border_width').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('border-width',this.value + 'px');
	});	
		 
	jQuery('#cancel_border_radius').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('border-radius',this.value + 'px');
	});		 
	
	jQuery('#cancel_button_width').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('max-width', this.value + 'px');
		jQuery('.cancel_btn').css('width', this.value + 'px');
	});
	
	jQuery('#cancel_button_height').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('padding-top', this.value + 'px');
		jQuery('.cancel_btn').css('padding-bottom', this.value + 'px');
	});
	
	jQuery('#cancel_background_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.cancel_btn').css('background-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#cancel_border_clr_div ').colorpicker().on('changeColor',function(){
		jQuery('.cancel_btn').css('border-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#cancel_text_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.cancel_btn').css('color', jQuery(this).colorpicker('getValue'));
	}); 
	                      	
	jQuery('#cancel_bdr_style').change(function(){
		jQuery('.cancel_btn').css('border-style', jQuery(this).val());
	});
	                      	
	jQuery('#cancel_font_weight').change(function(){
		jQuery('.cancel_btn').css('font-weight', jQuery(this).val());
	});
	
	
	
	/*Pause start*/
	
	jQuery('#pause_btn_text').keyup(function() {
		jQuery('.pause_btn').text(jQuery(this).val());
	});
	
	jQuery('#pause_font_size').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('font-size',this.value + 'px');
	});
	
	jQuery('#pause_border_width').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('border-width',this.value + 'px');
	});	
		 
	jQuery('#pause_border_radius').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('border-radius',this.value + 'px');
	});		 
	
	jQuery('#pause_button_width').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('max-width', this.value + 'px');
		jQuery('.pause_btn').css('width', this.value + 'px');
	});
	
	jQuery('#pause_button_height').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('padding-top', this.value + 'px');
		jQuery('.pause_btn').css('padding-bottom', this.value + 'px');
	});
	
	jQuery('#pause_background_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.pause_btn').css('background-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#pause_border_clr_div ').colorpicker().on('changeColor',function(){
		jQuery('.pause_btn').css('border-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#pause_text_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.pause_btn').css('color', jQuery(this).colorpicker('getValue'));
	}); 
	                      	
	jQuery('#pause_bdr_style').change(function(){
		jQuery('.pause_btn').css('border-style', jQuery(this).val());
	});
	                      	
	jQuery('#pause_font_weight').change(function(){
		jQuery('.pause_btn').css('font-weight', jQuery(this).val());
	});
	
	
	/*Pause end*/
	
	/*Resume start*/
	
	jQuery('#resume_btn_text').keyup(function() {
		jQuery('.resume_btn').text(jQuery(this).val());
	});
	
	jQuery('#resume_font_size').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('font-size',this.value + 'px');
	});
	
	jQuery('#resume_border_width').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('border-width',this.value + 'px');
	});	
		 
	jQuery('#resume_border_radius').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('border-radius',this.value + 'px');
	});		 
	
	jQuery('#resume_button_width').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('max-width', this.value + 'px');
		jQuery('.resume_btn').css('width', this.value + 'px');
	});
	
	jQuery('#resume_button_height').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('padding-top', this.value + 'px');
		jQuery('.resume_btn').css('padding-bottom', this.value + 'px');
	});
	
	jQuery('#resume_background_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.resume_btn').css('background-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#resume_border_clr_div ').colorpicker().on('changeColor',function(){
		jQuery('.resume_btn').css('border-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#resume_text_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.resume_btn').css('color', jQuery(this).colorpicker('getValue'));
	}); 
	                      	
	jQuery('#resume_bdr_style').change(function(){
		jQuery('.resume_btn').css('border-style', jQuery(this).val());
	});
	                      	
	jQuery('#resume_font_weight').change(function(){
		jQuery('.resume_btn').css('font-weight', jQuery(this).val());
	});
	
	
	/*Resume end*/
	
	
	
	
	/*jQuery(document).on('change','#achievement_border_style',function(){
		var vall = jQuery(this).val();
		jQuery('.achievement_level_outer').css('border-style',vall);
	});*/
		
			
}

function members_cancellation_customizer_default_old(){
	
	jQuery('#cancel_font_size').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('font-size',this.value + 'px');
	});
	
	jQuery('#cancel_border_width').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('border-width',this.value + 'px');
	});		 
	
	jQuery('#cancel_border_radius').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('border-radius', this.value + 'px');
	});
	
	jQuery('#cancel_button_width').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('max-width', this.value + 'px');
	});
	
	jQuery('#cancel_button_height').bootstrapSlider().change(function() {
		jQuery('.cancel_btn').css('max-height', this.value + 'px');
	});
	
	jQuery('#cancel_background_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.cancel_btn').css('background-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#cancel_border_clr_div ').colorpicker().on('changeColor',function(){
		jQuery('.cancel_btn').css('border-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#cancel_text_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.cancel_btn').css('color', jQuery(this).colorpicker('getValue'));
	}); 
	
	
	/****Pause start***/
	
	jQuery('#pause_font_size').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('font-size',this.value + 'px');
	});
	
	jQuery('#pause_border_width').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('border-width',this.value + 'px');
	});		 
	
	jQuery('#pause_border_radius').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('border-radius', this.value + 'px');
	});
	
	jQuery('#pause_button_width').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('max-width', this.value + 'px');
	});
	
	jQuery('#pause_button_height').bootstrapSlider().change(function() {
		jQuery('.pause_btn').css('max-height', this.value + 'px');
	});
	
	jQuery('#pause_background_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.pause_btn').css('background-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#pause_border_clr_div ').colorpicker().on('changeColor',function(){
		jQuery('.pause_btn').css('border-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#pause_text_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.pause_btn').css('color', jQuery(this).colorpicker('getValue'));
	}); 
	
	/****Pause end***/
	
	
	/****Resume start***/
	
	jQuery('#resume_font_size').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('font-size',this.value + 'px');
	});
	
	jQuery('#resume_border_width').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('border-width',this.value + 'px');
	});		 
	
	jQuery('#resume_border_radius').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('border-radius', this.value + 'px');
	});
	
	jQuery('#resume_button_width').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('max-width', this.value + 'px');
	});
	
	jQuery('#resume_button_height').bootstrapSlider().change(function() {
		jQuery('.resume_btn').css('max-height', this.value + 'px');
	});
	
	jQuery('#resume_background_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.resume_btn').css('background-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#resume_border_clr_div ').colorpicker().on('changeColor',function(){
		jQuery('.resume_btn').css('border-color', jQuery(this).colorpicker('getValue'));
	});
	
	jQuery('#resume_text_clr_div').colorpicker().on('changeColor',function(){
		jQuery('.resume_btn').css('color', jQuery(this).colorpicker('getValue'));
	}); 
	
	/****Resume end***/
	                      	
 
	/*jQuery(document).on('change','#achievement_border_style',function(){
		var vall = jQuery(this).val();
		jQuery('.achievement_level_outer').css('border-style',vall);
	});*/
		
			
}


function members_cancellation_customizer_default(){
/*	
	jQuery('#cancel_background_clr').val(jQuery('.cancel_btn').css('background-color'));
	jQuery('#cancel_bdr_style').val(jQuery('.cancel_btn').css('border-style'));
	jQuery('#cancel_border_width').val(jQuery('.cancel_btn').css('border-width'));
	jQuery('#cancel_border_clr').val(jQuery('.cancel_btn').css('border-color'));
	jQuery('#cancel_border_radius').val(jQuery('.cancel_btn').css('border-radius'));
	jQuery('#cancel_font_size').val(jQuery('.cancel_btn').css('font-size'));
	jQuery('#cancel_font_weight').val(jQuery('.cancel_btn').css('font-weight'));
	jQuery('#cancel_text_clr').val(jQuery('.cancel_btn').css('color'));
	jQuery('#cancel_button_width').val(jQuery('.cancel_btn').css('width'));
	jQuery('#cancel_button_height').val(jQuery('.cancel_btn').css('padding-top'));

	jQuery('#pause_background_clr').val(jQuery('.pause_btn').css('background-color'));
	jQuery('#pause_bdr_style').val(jQuery('.pause_btn').css('border-style'));
	jQuery('#pause_border_width').val(jQuery('.pause_btn').css('border-width'));
	jQuery('#pause_border_clr').val(jQuery('.pause_btn').css('border-color'));
	jQuery('#pause_border_radius').val(jQuery('.pause_btn').css('border-radius'));
	jQuery('#pause_font_size').val(jQuery('.pause_btn').css('font-size'));
	jQuery('#pause_font_weight').val(jQuery('.pause_btn').css('font-weight'));
	jQuery('#pause_text_clr').val(jQuery('.pause_btn').css('color'));
	jQuery('#pause_button_width').val(jQuery('.pause_btn').css('width'));
	jQuery('#pause_button_height').val(jQuery('.pause_btn').css('padding-top'));
	
	jQuery('#resume_background_clr').val(jQuery('.resume_btn').css('background-color'));
	jQuery('#resume_bdr_style').val(jQuery('.resume_btn').css('border-style'));
	jQuery('#resume_border_width').val(jQuery('.resume_btn').css('border-width'));
	jQuery('#resume_border_clr').val(jQuery('.resume_btn').css('border-color'));
	jQuery('#resume_border_radius').val(jQuery('.resume_btn').css('border-radius'));
	jQuery('#resume_font_size').val(jQuery('.resume_btn').css('font-size'));
	jQuery('#resume_font_weight').val(jQuery('.resume_btn').css('font-weight'));
	jQuery('#resume_text_clr').val(jQuery('.resume_btn').css('color'));
	jQuery('#resume_button_width').val(jQuery('.resume_btn').css('width'));
	jQuery('#resume_button_height').val(jQuery('.resume_btn').css('padding-top'));

	                      	
 */
	/*jQuery(document).on('change','#achievement_border_style',function(){
		var vall = jQuery(this).val();
		jQuery('.achievement_level_outer').css('border-style',vall);
	});*/
		
			
}
