    
jQuery(document).ready(function($){ 
//  C H E C K    I F    E N A B L E D
if ( genolveO.genolve_enabled === 'TRUE' ) {
  gnlv_deac = function(evt){
	evt.preventDefault();
	var fwdlink       = $(this).prop('href');
	var modaldivTemplate = '<div id="gnlv-bswrap" class="twbs"><div class="modal" data-animation="false" style="display:none;" id="gnlv_modal_div" tabindex="-1" role="dialog" aria-labelledby="gnlv_modal_title" aria-hidden="true">  <div class="modal-dialog modal-dialog-centered modal-lg" role="document">    <div id="gnlv_modal_content" class="modal-content">      <div class="modal-header">       <h5 class="modal-title" id="gnlv_modal_title">THETITLE</h5>        <button type="button" class="close" data-dismiss="modal" aria-label="Close">          <span aria-hidden="true">&times;</span>        </button>      </div>      <div id="gnlv_modal_body" class="modal-body gnlv-modal">CONTENT</div></div></div></div></div>';
	var cb = '<br><input type="checkbox" name="QdeacNNN" id="QdeacNNN" class="Box ui-widget-content" value="THEVAL" > <label for="QdeacNNN" class="Box"> THETXT</label>';
	$('body').prepend(modaldivTemplate.replace(/THETITLE/,"Thanks for Trying Genolve!"));
	quesA = ['Did not get past API Key.', 'It conflicted with my theme.','Too hard to use.','Got Timeout, Gateway or other errors.','Found bugs.','Decided on another plugin.','Need language: '+navigator.language+'.'];
	themsg="Sorry it did not meet your needs and before you go, please tell us where it let you down:";
	for(ii=0; ii<quesA.length; ii++){
		themsg += cb.replace(/THETXT/,quesA[ii]).replace(/THEVAL/,quesA[ii].replace(/\s/g,"_")).replace(/NNN/g,ii);
	}

	themsg +='<br>I needed it to do:<input name="deacReason" id="deacReason" title="" class="form-control  ui-widget-content valid" value="" aria-invalid="false"><br>'
	themsg +='<input id="gnlvdeacsubmit" class="btn btn-lg btn-primary  btn-responsive" type="submit" value="Submit & Deactivate">&nbsp;&nbsp;&nbsp;<input id="gnlvdeacskip" class="btn btn-lg btn-link  btn-responsive" type="submit" value="Skip Survey">';
	$('#gnlv_modal_body').html(themsg);
	$('#gnlv_modal_div').modal('show');
	bsver = String($.fn.tooltip.Constructor.VERSION);
	console.log("bootstrap ver:"+bsver);
	$('#gnlvdeacskip').on('click',function(ev){
				console.log("going to:"+fwdlink);
				window.location=fwdlink
				});
	$('#gnlvdeacsubmit').on('click',function(ev){
		resp = $('#deacReason').val();
		$('input[id^=Qdeac]').each(function(){
				resp += $(this).is(':checked')?","+$(this).val():"";
				});
		// record use mode
		resp += "usemode:"+genolveO.genolve_use_mode;
		console.log("full form:"+resp);
		var myparamO={
			CMD:"STATUSUPDATE",
			param1:"feedback",
			param2:resp,
			beyonce_skip:true,
			faction:"control",
			keylist:"param1,param2,CMD,beyonce_skip",
			action:'genolve_proxy'};
		
		console.log("genolve-quickReg: AJAX to:"+genolveO.wpajaxurl);
		thecurreq = $.ajax({
							url : genolveO.wpajaxurl,
							type : 'post',
							dataType : 'json',
							data :myparamO,
							
							//                                              C O N N E C T E D
							success :function(result,textStatus, thecurreq) { 
								console.log("DONE going to:"+fwdlink);
								window.location=fwdlink
								},
							error: function(xhr, result, status){
								console.log("FAIL going to:"+fwdlink);
								window.location=fwdlink
								}
							});// end ajax
		}); // end submit
	} // end gnlv_deac
	// deactivate survey on deactivate
	$('#deactivate-genolve-toolkit').on('click',gnlv_deac);

} // end genolve enabled
	 

});


