var $ = jQuery;
function toggle_CA(event){$(event.srcElement).parent().find("div").show();}
$(function() {
	$('head link').last().after('<link rel="stylesheet" type="text/css" href="//pocketdentistry.com/tao-custom.css?ts=' + Date.now() + '"></link>');
	$('head script').last().after('<script type="text/javascript" src="//pocketdentistry.com/tao-custom-search.js?ts=' + Date.now() + '"></script>');
	$("#main-content br").remove();
	try {
		$("#main-content blockquote").next("div").css("clear","both");	
	} catch (e) {}
	try {
		$(".QA .CA a").click(function(){$(this).parent().find("div").show();return false;});
	} catch (e) {}
	try {
		if ($("#main-content div.post-full.single article").html()) {		
			$("#main-content div.post-full.single article").html($("#main-content div.post-full.single article").html().replace("&lt; div class='tao-gold-member'&gt;", "<div class='tao-gold-member'>"));		
		}	
	} catch (e) {}

	try {
		setTimeout(function() {
			if ($("#pmpro_paypalexpress_checkout").html()) {
				
				//--------- Payment Gateway and Method Selection START------------
				// var price = parseInt($("#pmpro_level_cost strong").text().replace('$','')) || 50;
				// var xChangeRate = 26000;
				
				// $.get("https://pocketdentistry.com/pg/xRate", function(data) {
				// 	$("#tao-vnd-price").html(new Intl.NumberFormat().format(price * data));
					
				// });
				// var paymentContent = "<input id='tao_payment_gateway' type='hidden' style='display:none;' name='tao-payment-gateway' value=''><input id='tao_payment_method' type='hidden' style='display:none;' name='tao-payment-method' value=''><h2 style='margin-top: 2em;' class='tao-payment-text'>Please select card type to checkout</h2><div class='tao-payment-btn-container'><div class='tao-gateway-div tao-method-container pk-gateway tao-gateway-submit' gw='Gpay' src='https://pocketdentistry.com/tao-resource/logo/gpay_logo.png'><img class='tao-payment-method' method='VISA' src='https://pocketdentistry.com/tao-resource/logo/visa.svg'/><img class='tao-payment-method' method='Master' src='https://pocketdentistry.com/tao-resource/logo/master.svg'/><img class='tao-payment-method' method='JCB' src='https://pocketdentistry.com/tao-resource/logo/jcb.svg'/> <img class='tao-payment-method' method='AMEX' src='https://pocketdentistry.com/tao-resource/logo/amex.svg'/> <img class='tao-payment-method' method='DISCOVER' src='https://pocketdentistry.com/tao-resource/logo/discover.png'/> <span>via</span> <img class='tao-payment-gateway' src='https://pocketdentistry.com/tao-resource/logo/gpay_logo.png'/></div> <div><span>--- OR ---</span></div><div class='tao-gateway-div tao-method-container pd-gateway pd-pre-btn' gw='PD' src='https://pocketdentistry.com/tao-resource/logo/paydollar.svg'><img class='tao-payment-method' method='VISA' src='https://pocketdentistry.com/tao-resource/logo/visa.svg'/><img class='tao-payment-method' method='Master' src='https://pocketdentistry.com/tao-resource/logo/master.svg'/><img class='tao-payment-method' method='JCB' src='https://pocketdentistry.com/tao-resource/logo/jcb.svg'/> <img class='tao-payment-method' method='AMEX' src='https://pocketdentistry.com/tao-resource/logo/amex.svg'/> <span>via</span> <img class='tao-payment-gateway' src='https://pocketdentistry.com/tao-resource/logo/paydollar.svg'/></div><div style='display:none;' id='pd-notice'><p style='color: #022f84; padding-bottom: 0px; margin-top: 20px; text-align: center; font-style: italic; font-weight: bold;'>The currency is denominated in VND for financial purposes. Kindly note that VND  <span id='tao-vnd-price'>" + new Intl.NumberFormat().format(price * xChangeRate) + " </span> is equivalent to USD " + price + ".</p><div class='tao-gateway-div  tao-gateway-submit tao-confirm-btn' gw='PD'><span>Proceed to pay&nbsp;</span> <span id='tao-by-method' style='display: none'> by <img id='tao-selected-method' /> </span> <span> via</span> <img id='tao-selected-gateway' /></div></div><p class='trust-tao'>Should you encounter any issues with the payment, please do not hesitate to contact us via this email address: clinicalpub@gmail.com.</p>";

				// $("#pmpro_paypalexpress_checkout").html(paymentContent);
				// $(".tao-gateway-submit").on("click", function() {
				// 	$('#tao_payment_gateway').val($(this).attr('gw'));
				// 	$('#pmpro_form').trigger("submit");
				// });
				// $(".tao-payment-method").on("click", function() {
				// 	$('#tao-selected-method').prop('src','');
				// 	$('#tao_payment_method').val($(this).attr('method'));
				// 	$('#tao-selected-method').prop('src', $(this).attr('src'));
				// });
				// $(".pd-pre-btn").on("click", function() {
				// 	var selectedGw = $(this).attr('gw');
				// 	$('#tao_payment_gateway').val(selectedGw);
				// 	if (selectedGw == 'PD') {
				// 		$('#tao-by-method').show();
				// 	} else {
				// 		$('#tao-by-method').hide();
				// 	}
					
				// 	$('#tao-selected-gateway').prop('src','');
				// 	$('#tao-selected-gateway').prop('src', $(this).attr('src'));
					
				// 	$('#pd-notice').hide();
				// 	$('#pd-notice').fadeIn();
				// });
				//--------- Payment Gateway and Method Selection END------------

				//--------- Submit and Check Out button START------------
				var paymentContent = "<div class='tao-gateway-div  tao-check-out-btn tao-confirm-btn'><span>Submit and Check Out&nbsp;</span></div>";
				$("#pmpro_paypalexpress_checkout").html(paymentContent);
				$(".tao-check-out-btn").on("click", function() {
					$("#pmpro_btn-submit").trigger("click");
				});
				//--------- Submit and Check Out button END------------
				
				// if ($(location).attr('search').indexOf("test=true") > 0) {
				
				// }
				
				// if ($(location).attr('host') == 'test.aneskey.com') {
				// 	location.href = "https://aneskey.com" + location.pathname;
				// }
			}
		}, 1000);
	} catch (e) {}

	try {
		$("#menu-top-menu li").each(function() {
			if ($(this).text().trim().indexOf("More References") == 0) {
				$(this).remove(); 
			}
		});
	} catch (e) {}
	try {
		$("#jetpack-sso-wrap").remove();
	} catch (e) {}
 	if ($(location).attr('host').indexOf("pocketdentistry.com") == 0) {
		 $("#copyright-text").html("<div style='background-color: white;'><div>Công ty Cổ phần Nguyên Phát Hà Nội</div><div>Số 10 ngõ 243a đường Xuân Khanh, Phường Xuân Khanh, Thị Xã Sơn Tây, Hà Nội</div><div>096451317</div><a href='http://online.gov.vn/Home/WebDetails/76289' target='_blank'><img style='height: 30px;' src='/logoSaleNoti.png'></img></a></div>");
		if ($(location).attr('pathname').indexOf("terms-and-condition") > 0) {
			$.get("https://pocketdentistry.com/get-country", function(data, status){
				if (data == "VN") {
					$("#tao-term-vn").show();
					$([document.documentElement, document.body]).animate({
						scrollTop: $("#tao-term-vn").offset().top
					}, 1000);
				}
			});
		}

	}
});