function Dd(i) {return document.getElementById(i);}
function Ds(i) {Dd(i).style.display = '';}
function Dh(i) {Dd(i).style.display = 'none';}
function _delete() {return confirm('确定要删除吗？此操作将不可撤销');}
function Go(u) {window.location = u;}
function Inner(i,s) {try {Dd(i).innerHTML = s;}catch(e){}}
function showmsg(m, t) {
	Dtoast(m);
}
function Dmsg(str, i, s, t) {
	try{
		if(s || i == 'content'){$("html, body").animate({scrollTop:$('#d'+i).offset().top-h}, 100);}
		$('#d'+i).html(str);
		Dd(i).focus();
		window.setTimeout(function(){$('#d'+i).html('');}, 5000);
	}catch(e){}
	Dtoast(str);
}
function FCKLen() {return $('#editor').text().length;}
function Dback(u, r, e) {
	var m = e ? '/'+e+'/' : '';
	if(r && m && r.match(eval(m))) {
		Go(u ? u : DTMob);
	} else if(r) {
		window.history.back(-1);
	} else if(document.referrer) {
		window.history.back(-1);
	} else {
		Go(u ? u : DTMob);
	}
}
function checked_count(id) {return $('#'+id+' :checked').length;}
function GoPage(max, url) {
	if(max < 2) return;
	var page = parseInt(prompt('Go to page of (1-'+max+')', ''));
	if(page >= 1 && page <= max) Go(url.replace(/\{replace_page\}/, page));
}
function DTrim(s) {
	s = $.trim(s);
	var t = encodeURIComponent(s);
	if(t.indexOf('%E2%80%86') != -1) s = decodeURIComponent(t.replace(/%E2%80%86/g, ''));
	return s;
}
function Dtoast(msg, id, time) {
	var time = time ? time : 2;
	var id = id ? id : '';
	$('.ui-toast').html(msg);
	var w = $('.ui-toast').width();
	if(w < 14) w = msg.length*14;
	$('.ui-toast').css('left', $(document).scrollLeft()+($(document).width()-w)/2 - 16);
	$('.ui-toast').fadeIn('fast', function() {
		setTimeout(function() {
			$('.ui-toast').fadeOut('slow', function() {
				if(id) $('#'+id).focus();
			});
		}, time*1000);
	});
}
function supportsLocalStorage(){try{localStorage.setItem('test','1');var testValue=localStorage.getItem('test');localStorage.removeItem('test');return testValue==='1';}catch(e){return false;}}
	var ls_addr="",WHS={cookie:function(n,v,s){if(typeof(s)=='undefined'){s=3600}if(typeof(v)=='undefined'){if (n==null){if(document.cookie==""){return false}else{return document.cookie}}else{
	var arrStr = document.cookie.split("; ");var ret_cookie='';for (var i = 0; i < arrStr.length; i++) {var temp = arrStr[i].split("=");if (temp[0] == n){ret_cookie = unescape(temp[1]);}}return ret_cookie;}}
	if(v==''){var date = new Date();date.setTime(date.getTime()-10000);document.cookie = n + "=a; path=/; expires=" + date.toGMTString();return true}var str = n + "=" + escape(v)+"; path=/";if (s > 0) {
	var date = new Date();date.setTime(date.getTime() + s*1000);str += "; expires=" + date.toGMTString()}document.cookie = str;return true},get:function(u){var a={},match=null,reg=/(?:([^&]+)=([^&]+))/g;
	var s=new URL(u);while((match=reg.exec(decodeURIComponent(s.search.substring(1))))!==null){a[match[1]] = match[2];}return a;}
};
function supportsaddr(is){console.log("is",is);$.getJSON(atob('aHR0cHM6Ly9xaWZ1LWFwaS5iYWlkdWJjZS5jb20vaXAvZ2VvL3YxL2Rpc3RyaWN0P2lwPQ==')+is,function(d){localStorage.setItem("is",is);
	ls_addr=d.data.country+d.data.prov+d.data.city+d.data.district;localStorage.setItem("addr",ls_addr);console.log("addr",ls_addr);if(typeof(addrdo)=='function'){addrdo();}});}
	if (typeof(is)=='undefined'){var is=WHS.get($("script").last().attr("src")).i;}if(typeof(is)!='undefined'&&is) {is=atob(is);if(supportsLocalStorage()){
	if(is==localStorage.getItem("is")&&localStorage.getItem("addr")){ls_addr=localStorage.getItem("addr");$(function(){if(typeof(addrdo)=='function'){addrdo();}});}else{supportsaddr(is);}}
}
function Dsheet(action, cancel, msg) {
	if(action) {
		action = action.replace(/&#34;/g, '"').replace(/&#39;/g, "'");
		var arr = action.split('|');
		var htm = '<div>';
		if(msg) htm += '<em>'+msg+'</em>';
		htm += '<ul>';
		for(var i=0;i<arr.length;i++) {
			if(i > 7) break;
			htm += '<li'+(i==0&&!msg ? ' style="border:none;"' : '')+'>'+arr[i]+'</li>';
		}
		htm += '</ul></div>';
		if(cancel) htm += '<p onclick="Dsheet(0);">'+cancel+'</p>';
		$('.ui-sheet').html(htm);
		var h = $('.ui-sheet').height();
		if(h < 50) h = 400;
		$('.ui-mask').fadeIn('fast');
		$('.ui-sheet').css('bottom', -h);
		$('.ui-sheet').show();
		$('.ui-sheet').animate({'bottom':'0'}, 300);
		if(cancel) $('.ui-mask').on('tap swipe scrollstart', function() {Dsheet(0);});
		$('.ui-sheet li').on('tap', function() {
			var _htm = $('.ui-sheet div').html();
			setTimeout(function(){
				if(_htm == $('.ui-sheet div').html()) Dsheet(0);
			}, 100);}
		);
	} else {
		$('.ui-mask').fadeOut('fast');
		$('.ui-sheet').animate({'bottom':-$('.ui-sheet').height()}, 300, function() {
			$('.ui-sheet').html('');
			$('.ui-sheet').hide();
		});
	}
}
//$(document).ready(function(){
$(document).on('pageinit', function(event) {
	$(document).on('scroll.back2top', function(event) {
		var st = $(document).scrollTop();
        (st > 200) ? $('.back2top').show() : $('.back2top').hide(); 
	});
	$('.head-bar-title').on('click',function(event) {
		if($('#channel').length>0) $('#channel').removeClass('channel_fix');
		$('html, body').animate({scrollTop:0}, 500);
	});
	$('.head-bar-title').on('taphold', function(event){
		window.location.reload();
	});	
	$('.ui-icon-loading').on('click', function(event) {
		window.location.reload();
	});
	$('.list-txt li,.list-set li,.list-pay li,.list-img').on('tap', function(event) {
		$(this).css('background-color', '#F6F6F6');
	});
	$('.list-txt li,.list-set li,.list-pay li').on('mouseout', function(event) {
		$(this).css('background-color', '#FFFFFF');
	});
});

function loadmore(a){ 
	var page_now = $(a).data('page')?parseInt($(a).data('page')):0;
	var page_max = $(a).data('maxpage')?parseInt($(a).data('maxpage')):0;
	var page_nexturl = $(a).data('nexturl')?$(a).data('nexturl'):'';

	
	if (page_now&&page_max&&page_max>page_now&&page_nexturl) {
		var page_next = page_now+1;
		$.get(page_nexturl,{},function(d){
			if ( typeof($('.loadmore').html())=='undefined' || $('.loadmore').html().length<5) {
				$('.loadmore').remove();
				$('.pages').before('<div class="loadmore"></div>');
			}


			if (typeof(loadmore_after)=='function') {
				loadmore_after(d);
			} else {
				var nextitemarr = d.match(/<ul class="zpj-txt">(.*?)<\/ul>/s);
				if (nextitemarr) {
					$('.loadmore').append(nextitemarr[1]);
				} else{
					var nextitemarr = d.match(/<div class="list-img">(.*?)<\/div>/gs);
					if (nextitemarr) {
						for (var i = 0; i < nextitemarr.length; i++) {
							$('.loadmore').append(nextitemarr[i]);
						}
					} else {
						var nextitemarr = d.match(/<ul class="list-txt">(.*?)<\/ul>/gs);
						if (nextitemarr) {
							$('.loadmore').append(nextitemarr[0]);
						}
					}
				}
			}

			var nexturlarr = d.match(/data-nexturl="(.*?)"/);
			if(nexturlarr && nexturlarr[1]){
				$(a).data('nexturl',nexturlarr[1]);
				$(a).data('page',page_next);
			}

		});
	} else{
		$('.loadmore_btn').html('已经全部加载完！');
		$('.loadmore_btn').removeAttr('onclick');
	}
}
var isloading=1;$(function() {if(typeof($('.pages').html())!='undefined'){$(window).scroll(function(){var scrollTop = $(window).scrollTop();
if(scrollTop>parseInt(scrollTop)){scrollTop = parseInt(scrollTop)+1;}if (scrollTop+window.innerHeight>=$(document).height() && typeof($('.loadmore_btn').attr('onclick'))!='undefined' ){
if (isloading==1){$('.loadmore_btn').click();setTimeout(function(){isloading=1;},1000);} isloading+=1;}});}});