$.extend({
	Confirm: function() {
		var template = multiline(function() {
			console.log()
		});
		return function(title, content, btns_num) {
			var title = title || '',
				content = content || '',
				btns_num = btns_num || 2,
				ok, cancel, result = {
					ok: function(func) {
						ok = func;
						return result;
					},
					cancel: function(func) {
						cancel = func;
						return result;
					}
				};
			var dom = $('<div>').html(template);
			btns_num == 1 ? dom.find('.jquery-confirm-cancel').remove() : dom.find('.jquery-confirm-ok').css('border-left', '1px solid #F2F2F2');
			dom.on('touchmove', function() {
				return false;
			});
			dom.find('.jquery-confirm-title').html(title);
			dom.find('.jquery-confirm-content').html(content);
			dom.find('.jquery-confirm-ok').on('click', function() {
				ok && ok();
				dom.remove();
			});
			dom.find('.jquery-confirm-cancel').on('click', function() {
				cancel && cancel();
				dom.remove();
			});
			dom.appendTo($('body'));
			return result;
		}

		function multiline(fn) {
			var reCommentContents = /\/\*!?(?:\@preserve)?[ \t]*(?:\r\n|\n)([\s\S]*?)(?:\r\n|\n)[ \t]*\*\//;
			if (typeof fn !== 'function') {
				throw new TypeError('Expected a function');
			}
			var match = reCommentContents.exec(fn.toString());
			if (!match) {
				throw new TypeError('Multiline comment missing.');
			}
			return match[1];
		};
	}()
});

function parseURL(url) {
	var a = document.createElement('a');
	a.href = url;
	return {
		source: url,
		protocol: a.protocol.replace(':', ''),
		host: a.hostname,
		port: a.port,
		query: a.search,
		params: (function() {
			var ret = {},
				seg = a.search.replace(/^\?/, '').split('&'),
				len = seg.length,
				i = 0,
				s;
			for (; i < len; i++) {
				if (!seg[i]) {
					continue;
				}
				s = seg[i].split('=');
				ret[s[0]] = s[1];
			}
			return ret;
		})(),
		file: (a.pathname.match(/\/([^\/?#]+)$/i) || [, ''])[1],
		hash: a.hash.replace('#', ''),
		path: a.pathname.replace(/^([^\/])/, '/$1'),
		relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [, ''])[1],
		segments: a.pathname.replace(/^\//, '').split('/')
	};
}

function totoptop() {
	var a = $("#mian_body").offset().top;
	move_scoll(a)
}

function move_scoll(a, b) {
	b || (b = 500);
	$("html, body").stop();
	$("html, body").animate({
		scrollTop: a
	}, b);
	return !1
}
$(function() {
	$(window).scroll(function() {
		500 < document.body.scrollTop || 500 <= document.documentElement.scrollTop ? $(".back_top").show() : $(".back_top").hide()
	})
});

function showmenu() {
	$(".main_column").hasClass("on") ? ($(".main_column").removeClass("on"), $(".main_column").show()) : ($(".main_column").addClass("on"), $(".main_column").hide())
}

function showtags() {
	$(".open_menu").hasClass("on") ? ($(".open_menu").removeClass("on"), $(".open_menu").show()) : ($(".open_menu").addClass("on"), $(".open_menu").hide())
}

function pagecheck(a, b) {
	window.location.href = 1 == b ? a + ".html" : a + "_" + b + ".html"
}

function shoucang(a, b) {
	try {
		window.external.addFavorite(b, a)
	} catch (c) {
		try {
			window.sidebar.addPanel(a, b, "")
		} catch (d) {
			$.Confirm(" ", "加入收藏失败，请手动进行添加", 1)
		}
	}
}

function buy() {
	var c_href = document.getElementById("c_href").value,
		key = document.getElementById("key").value;
	var host = parseURL(c_href).host;
	if (host != "t.cn" && host != "dwz.cn") return layer.open({
		content: '<P class="guanggao">请输入球球大作战专属推广链接！请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！</p>'
	}), 0;
	layer.open({
		type: 2,
		shadeClose: !1,
		time: 2E3
	});
	if (key.length == 0) {
		$.ajax({
			url: "./api/api_dd.php?url=" + c_href,
			dataType: "json",
			success: function(a) {
				layer.closeAll();
				var gg = "<br><a href=\"shop.html\" target=\"_blank\"><font color=\"blue\"><b>想得到更多的棒棒糖吗？点击购买球球补领号，一个可以补领10个棒棒糖！</b></font></a>";
				switch (a.code) {
				case 0:
					text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>购买时间：" + a.add_time + "<br>结束时间：" + a.end_time + "<br>上次帮您代点是在：" + a.last_time + gg;
					break;
				case -1:
					text = "尊敬的：" + a.account + "[" + a.id + "]，您好！您还没有购买代点服务！";
					break;
				case -2:
					text = "您还没有输入推广链接！请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！";
					break;
				case -3:
					text = "您的邀请链接输错了！请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！";
					break;
				case -4:
					text = "解析邀请链接地址失败！请重试！<br>或者您的邀请链接输错了，请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！";
					break;
				default:
					text = "未知！请重试！请刷新页面！" + gg;
				}
				layer.open({
					content: '<P class="guanggao">' + text + "</p>"
				})
			},
			error: function(a) {
				layer.closeAll();
				layer.open({
					content: '<P class="guanggao">连接服务器失败，请重试！</p>'
				})
			}
		})
	} else {
		$.ajax({
			url: "./api/api_buy.php?url=" + c_href + "&key=" + key,
			dataType: "json",
			success: function(a) {
				layer.closeAll();
				var gg = "";
				switch (a.code) {
				case 0:
					text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>您已成功提交代刷到系统中！<br>时长为" + a.keyday + "天，结束时间为：" + a.endtime + gg + "<br><br>球球大作战交流群①:49207683<br>球球大作战交流群②:555402552<br>球球大作战交流群③:538261939 <br>一起开黑，研究套路~";
					break;
				case 1:
					text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>您已成功续费了您的代刷！<br>续费时长为" + a.keyday + "天！<br>续费前结束时间为：" + a.oldendtime + "续费后结束时间为：" + a.newendtime + gg;
					break;
				case -1:
					text = "您还没有输入邀请链接！请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！";
					break;
				case -2:
					text = "您还没有输入卡密！请前去购买卡密！";
					break;
				case -3:
					text = "您的邀请链接输错了！请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！";
					break;
				case -4:
					text = "您输入的卡密已被使用";
					break;
				case -5:
					text = "更新密钥状态失败";
					break;
				case -6:
					text = "更新代刷ID失败失败";
					break;
				case -7:
					text = "更新密钥状态失败";
					break;
				case -8:
					text = "增加代刷数据失败";
					break;
				case -9:
					text = "您输入的卡密不存在！";
					break;
				case -10:
					text = "解析邀请链接地址失败！请重试！<br>或者您的邀请链接输错了，请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！";
					break;
				case -11:
					text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>您已经免费使用过试用卡了，若感觉好用，请购买付费VIP密钥！" + gg;
					break;
				default:
					text = "未知！请重试！请刷新页面！" + gg;
				}
				layer.open({
					content: '<P class="guanggao">' + text + "</p>"
				})
			},
			error: function(a) {
				layer.closeAll();
				layer.open({
					content: '<P class="guanggao">连接服务器失败，请重试！</p>'
				})
			}
		})
	}
}

function submit() {
	var c_href = document.getElementById("c_href").value;
	var host = parseURL(c_href).host;
	if (host != "t.cn" && host != "dwz.cn") return layer.open({
		content: '<P class="guanggao">请输入球球大作战专属推广链接！请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！</p>'
	}), 0;
	layer.open({
		type: 2,
		shadeClose: !1,
		time: 2E3
	});
	$.ajax({
		url: "./api/api_bob.php?url=" + c_href,
		dataType: "json",
		success: function(a) {
			layer.closeAll();
			var gg = "";
			switch (a.code) {
			case "0":
				text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>您的棒棒糖已刷取完毕，请前往游戏查看！<br>若未到账，请检查以下两点:<br>1.当天已经获得5个棒棒糖<br>2.本周已经获得了20个棒棒糖<br>" + gg;
				break;
			case "1":
				text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>您的棒棒糖今天已刷达上限，明天再来吧！" + gg;
				break;
			case "2":
				text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>您的棒棒糖今天已刷达上限，明天再来吧！" + gg;
				break;
			case "3":
				text = "尊敬的：" + a.account + "[" + a.id + "]，您好！<br>您的棒棒糖本周已刷达上限，明天再来吧！" + gg;
				break;
			case "-1":
				text = "您还没有输入邀请链接！请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！" + gg;
				break;
			case "-2":
			case "-5":
				text = "解析邀请链接地址失败！请重试！<br>或者您的邀请链接输错了，请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！" + gg;
				break;
			case "-3000":
				text = "-3000！刷棒棒糖失败！" + gg;
				break;
			default:
				text = "未知！请重试！请刷新页面！<br>或者您的邀请链接输错了，请打开球球大作战游戏->点击右上角加号->点击获取棒棒糖->点击复制链接,粘贴到本站即可！" + gg;
			}
			layer.open({
				content: '<P class="guanggao">' + text + "</p>"
			})
		},
		error: function(a) {
			layer.closeAll()
			layer.open({
				content: '<P class="guanggao">连接服务器失败，请重试！</p>'
			})
		}
	})
}

function bl() {
	var key = document.getElementById("key").value,
		user = document.getElementById("user").value,
		pwd = document.getElementById("pwd").value;
	if (key.length != 12) return confirm("请输入您购买的补领密钥（卡密）!", 1), 0;
	if (user.length == 0 && pwd.length == 0) {
		layer.open({
			type: 2,
			shadeClose: !1,
			time: 2E3
		});
		$.ajax({
			type: "post",
			url: "./api/api_bl.php?act=query",
			data: {
				"key": key,
			},
			dataType: "json",
			success: function(a) {
				layer.closeAll();
				switch (a.code) {
				case 0:
					text = "尊敬的：" + user + "您好！<br>您已成功提交到我们的代领到系统中！<br><欲得知进度，请手动查询>";
					break;
				case 1:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：待发货<br>请耐心等待，预计将在2小时内为您补领";
					break;
				case 2:
					text = "尊敬的：" + a.user + "您好！<br>您提交的用户名或密码错误！<br>请检查后重新使用此密钥提交";
					break;
				case 3:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：处理中<br>已经再补领中了！棒棒糖很快就到账啦！";
					break;
				case 4:
					text = "尊敬的：" + a.user + "您好！<br>您棒棒糖已经到账啦，赶快到游戏里面看看吧！";
					break;
				case 5:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：已取消<br>请重新使用此密钥提交";
					break;
				case 6:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：封禁补领<br>请等待封禁结束重新使用此密钥提交";
					break;
				case 7:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：待查询";
					break;
				case 8:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：已查询";
					break;
				case 9:
					text = "尊敬的：" + a.user + "您好！<br>这周你已经补领获得30颗棒棒糖了<br>下周请重新使用此密钥提交！";
					break;
				case 10:
					text = "尊敬的：" + a.user + "您好！<br>您提交的账号不存在<br>请检查后重新使用此密钥提交";
					break;
					break;
				case -1:
					text = "您还没有输入补领密钥！";
					break;
				case -2:
					text = "您还没有输入球球大作战用户名！";
					break;
				case -3:
					text = "您还没有输入球球大作战用户密码！";
					break;
				case -4:
					text = "您输入的补领密钥不存在";
					break;
				case -5:
					text = "您输入的补领密钥已被使用，请把用户名和密码清空只输入密钥查看进度";
					break;
				case -6:
				case -7:
					text = a.msg;
					break;
				case -8:
					text = "您输入的补领密钥还未使用，不能查询";
					break;
				case -9:
					text = "错误代码-9！";
					break;
				case -10:
					text = "尊敬的：" + a.user + "您好！<br>由于您在补领期间修改了密码，可能到账棒棒糖数量有偏差！<br><font color='red'>补领前棒棒糖数量为：" + a.total + "颗</font>";;
					break;
				default:
					text = "未知！请重试！请刷新页面！";
				}
				layer.open({
					content: '<P class="guanggao">' + text + "</p>"
				})
			},
			error: function(a) {
				layer.closeAll();
				layer.open({
					content: '<P class="guanggao">连接服务器失败，请刷新页面重试！</p>'
				})
			}
		})
	} else {
		if (user != null && user.length > 14) return $.Confirm(" ", "请正确输入您的球球大作战用户名!", 1), 0;
		if (pwd != null && pwd.length > 14) return $.Confirm(" ", "请正确输入您的球球大作战密码!", 1), 0;
		layer.open({
			type: 2,
			shadeClose: !1,
			time: 2E3
		});
		$.ajax({
			type: "post",
			url: "./api/api_bl.php?act=buy",
			data: {
				"key": key,
				"user": user,
				"pass": pwd,
			},
			dataType: "json",
			success: function(a) {
				layer.closeAll();
				switch (a.code) {
				case 0:
					text = "尊敬的：" + user + "您好！<br>您已成功提交到我们的代领到系统中！<br><欲得知进度，请手动查询>";
					break;
				case 1:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：待发货<br>请耐心等待，预计将在2小时内为您补领";
					break;
				case 2:
					text = "尊敬的：" + a.user + "您好！<br>您提交的用户名或密码错误！<br>请检查后重新使用此密钥提交";
					break;
				case 3:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：处理中<br>已经再补领中了！棒棒糖很快就到账啦！";
					break;
				case 4:
					text = "尊敬的：" + a.user + "您好！<br>您棒棒糖已经到账啦，赶快到游戏里面看看吧！<br><font color='red'>补领前棒棒糖数量为：" + a.total + "颗</font>";
					break;
				case 5:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：已取消<br>请重新使用此密钥提交";
					break;
				case 6:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：封禁补领<br>请等待封禁结束重新使用此密钥提交";
					break;
				case 7:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：待查询";
					break;
				case 8:
					text = "尊敬的：" + a.user + "您好！<br>订单当前进度为：已查询";
					break;
				case 9:
					text = "尊敬的：" + a.user + "您好！<br>这周你已经补领获得30颗棒棒糖了<br>下周请重新使用此密钥提交！<br><font color='red'>补领前棒棒糖数量为：" + a.total + "颗</font>";
					break;
				case 10:
					text = "尊敬的：" + a.user + "您好！<br>您提交的账号不存在<br>请检查后重新使用此密钥提交";
					break;
				case -1:
					text = "您还没有输入补领密钥！";
					break;
				case -2:
					text = "您还没有输入球球大作战用户名！";
					break;
				case -3:
					text = "您还没有输入球球大作战用户密码！";
					break;
				case -4:
					text = "您输入的补领密钥不存在";
					break;
				case -5:
					text = "您输入的补领密钥已被使用，请把用户名和密码清空只输入密钥查看进度";
					break;
				case -6:
				case -7:
					text = a.msg;
					break;
				case -8:
					text = "您输入的补领密钥还未使用，不能查询";
					break;
				case -9:
					text = "错误代码-9！";
					break;
				case -10:
					text = "尊敬的：" + a.user + "您好！<br>由于您在补领期间修改了密码，可能到账棒棒糖数量有偏差！<br><font color='red'>补领前棒棒糖数量为：" + a.total + "颗</font>";;
					break;
				default:
					text = "未知！请重试！请刷新页面！";
				}
				layer.open({
					content: '<P class="guanggao">' + text + "</p>"
				})
			},
			error: function(a) {
				layer.closeAll();
				layer.open({
					content: '<P class="guanggao">连接服务器失败，请刷新页面重试！</p>'
				})
			}
		})
	}
}
