﻿// 月影社区 http://wf66.com/ ver8.3.6  //


//商城产品选择
function select_shop(json,xmlstr,guige){
var html="";
var xml = $.parseXML(xmlstr);
//写入所有商品规格
for(var i=0;i<$(xml).find("a").length;i++){
	html+="<label for=\"guige"+i+"\"><input type=\"radio\" id=\"guige"+i+"\" name=\"guige\" class=\"guige\" zhekou=\""+$(xml).find("d").eq(i).text()+"\" value=\""+i+"\""
	if(i==guige){html+="checked"}
	html+="><span class=\"lei\">"+$(xml).find("a").eq(i).text()+"</span></label>"
}
$(".guiges").html(html);

nub(json,xml,0);
//选择分类
$(".guige").click(function(){
	var _id=$(this).val();
	$(".danjia").text($(xml).find("b").eq(_id).text());
	$(".shengyu").text($(xml).find("c").eq(_id).text());
	nub(json,xml,0);})
$("#_nub").blur(function(){nub(json,xml,0);})
$("span.nubjia").click(function(){nub(json,xml,1);})
$("span.nubjian").click(function(){nub(json,xml,-1);})
$(".s_add").click(function(){nub(json,xml,0);})
}
//根据地区选择不同运费模版
function nub(json,xml,_nub){
	var mon2=json.mon2;
	var basic=json.basic;
	var zhekoutxt="";
	var diqu = $.parseXML("<xml>"+json.diqu+"</xml>");
	var selectadd=$(".s_add:checked").attr("add");
	var _id=$(".guige:checked").val();
	$(".danjia").text($(xml).find("b").eq(_id).text());
	$(".shengyu").text($(xml).find("c").eq(_id).text());
	var zhekou=$(xml).find("d").eq(_id).text()
	if(zhekou>-1&&zhekou<100&&json.us_admin>2){
		$(".lizhekou").css("display","block");
		$(".zhekou").text(zhekou);
		}else{$(".lizhekou").css("display","");}
	
	if(json.diqu.indexOf(selectadd)>-1&&selectadd!=""){
		for(var i=0;i<$(diqu).find("add").length;i++){
			if($(diqu).find("add").eq(i).text()==selectadd){
					basic=Number($(diqu).find("basic").eq(i).text())
					mon2=Number($(diqu).find("next").eq(i).text())
				}
		}
	}
	var yf=0;
	var danjia=Number($(".danjia").text());
	var shengyu=Number($(".shengyu").text());
	var _nub=Number($("#_nub").val())+_nub;
	if (_nub>shengyu){_nub=shengyu}
	if (_nub<1){_nub=1}
	$("#_nub").val(_nub);
	
	if(json.lei>0){	yf=_nub*mon2-mon2+basic}
	if(json.lei==1&&_nub>=json.nums){yf=0}
	if(json.lei==2&&_nub*danjia*zhekou/100>=json.mon){yf=0}
	var zkj=_nub*danjia-_nub*danjia*zhekou/100
	if(zhekou!=100){zhekoutxt=" VIP会员折扣"+zkj.toFixed(2)+"元"}
	$(".jine").text((_nub*danjia*zhekou/100+yf).toFixed(2)+'元 其中运费:'+yf+'元'+zhekoutxt+'');
	}


//缩略图替换 注意内容class应为content
function showpic(c,str){
$(c).find("img").click(function(){
fullScreen();
var oldtop=$(document).scrollTop();
window.scrollTo(0,0);
$("body").css("overflow","hidden").append("<div id=\"show\"><div><img src='"+this.src.toLowerCase().replace(str,"")+"' alt=\"点我关闭\"></div><dl class=\"bian2\"><dt></dt></dl></div>");
$("#show").before("<div class=\"show\"></div>");
var img=$(c).find("img");
if(img.length==1){$("#show").children("dl.bian2").remove()}
if(img.length>1){
for(var i=0;i<img.length;i++){
	if(img.eq(i).width()>100){$("#show").children("dl").children("dt").append("<dd><img src="+img.eq(i).attr("src")+"></dd>");}
	}
$("#show").children("dl").find("img").hover(function(){
	  $("#show").children("div").children("img").attr("src",this.src.toLowerCase().replace(str,""));
},function(){})
}
$("#show").children("div").click(function(){exitshowpic(oldtop)})
});
$(c).find("img").attr("alt","戳我试试").attr("title","戳我试试");
}

function exitshowpic(oldtop){$("#show").remove();$(".show").remove();$("body").css("overflow","auto");window.scrollTo(0,oldtop);exitFullScreen();}

/*自适应菜单*/
function tsetwidth(minwidth){
	$("img.nav2button").remove();
	$("h1.nav2title").remove();
	var w=$("body").width();
	if (w<minwidth){
	$("#menu").removeClass().addClass("nav2");
	$("#menu").before("<img src='images/mini/icon8.gif' class='nav2button'>");
	$("#menu").prepend("<h1 class='title3 nav2title'><i></i>网站导航</h1>");
	$("img.nav2button").click(function(){$("ul.nav2").css({"display":"block"})});
}else{
	$("#menu").removeClass().addClass("nav");
	}
$("#menu").find("li").click(function(){
	if ($(this).find("ul").length>0){
	var s=$(this).children("a").eq(0).attr("href");
	var _s=$(this).children("a").eq(0).attr("_href")
	if (w<minwidth){
	if(s!="#"){$(this).children("a").eq(0).attr({"href":"#","_href":s});	}
	}
	else
	{
	if(_s!=undefined){$(this).children("a").eq(0).attr("href",_s);}	
	}
	}
	})	
}
function pcnav(minwidth){
$(document).ready(function(){tsetwidth(minwidth)})
$(window).resize(function(){tsetwidth(minwidth)})
var newurl=decodeURI(window.location.href).replace(base(),"");
if (newurl.length==0){newurl="index.asp"}
$("#menu").find("[href$='"+newurl+"']").removeClass().addClass("select")
$("#menu").find("li").mouseover(function(){$(this).children("ul").css("display","block").stop().animate({"opacity":"1"},200);})
$(".nav").find("li").mouseout(function(){if($("#menu").attr("class")=="nav"){$(this).children("ul").stop().animate({"opacity":"0"},1000,function(){$(this).css("display","none");});}})
}

//自动浮动控制
function autotop(name){$(window).ready(function(){
$("body").append($(name).removeClass(name.replace(".","")).addClass(name.replace(".","")+"_temp").prop("outerHTML"));
$(name+"_temp").eq(1).css("display","none");
$(window).scroll(function(){autotopset(name);});
$(window).resize(function(){autotopset(name);});
})}
function autotopset(name){
i=$(name+"_temp");
i.eq(1).attr({"_top":i.offset().top}).css({"width":i.width()});
var me=i[0].getBoundingClientRect();
if($(document).scrollTop()-i.eq(1).attr("_top")<0){i.eq(1).css({"position":"static","display":"none"});}
if(me.top<0){i.eq(1).css({"position":"fixed","display":"block","top":"0px","left":i.offset().left})}
}

//自适应表单提示信息
function autoform(thisform){
$(thisform).find("li").mouseover(function(){
	if($(this).children("dd").width()+20>$(this).width()){
		var isTouchDevice="ontouchstart"in window||navigator.msMaxTouchPoints;
		if(isTouchDevice)
		{$(this).children("dd").attr("style","").stop().delay(4000).animate({"opacity":"0","top":"-80px"},"800");}
		else
		{var text=$(this).children("dd").css("display","none").text();$(this).find("[name]").attr("title",text);$(this).find("span").attr("title",text);}
	}else
	{$(this).children("dd").attr("style","");}
	})
}

/*根据<BODY>宽度,在指定最大与最小范围内,元素按100%宽显示,如超出则按限定宽度显示.最小值允许是100%.自适应宽度:样式名称,最大宽度,最小宽度*/
function autowidth(name,minwidth,maxwidth){$(document).ready(function(){$(name).width("100%");var pwidth=$("body").width();if(pwidth>maxwidth){$(name).width(maxwidth)}if(pwidth<minwidth){$(name).width(minwidth)}$(window).resize(function(e){$(this).unbind(e);autowidth(name,minwidth,maxwidth)})})}

/*当小于设置的最小宽度时,自动将当前元素宽度设定为100%,主要用于内容区或侧栏外框*/
function autowidth2(name,minwidth){$(document).ready(function(){if($("body").width()<minwidth){$(name).width("100%");}else{$(name).width("");}});$(window).resize(function(e){$(this).unbind(e);autowidth2(name,minwidth);});}

/*根据主元素最大宽度(应设为100%),自动按设定最小宽度+剩余宽度均分,参数:主元素,子元素,最小宽度,主要用于具体内容*/
function autowidth3(ul,li,minwidth){
$(document).ready(function(){var nums=parseInt($(ul).width()/minwidth);if($(ul).children(li).length<nums){nums=$(ul).children(li).length};
width=$(ul).width()/nums-($(ul).children(li).outerWidth(true)-$(ul).children(li).width());
$(ul).children(li).width(width-1/nums);$(window).resize(function(e){$(this).unbind(e);autowidth3(ul,li,minwidth);})})
}

/*当尺寸小于设定时,交换两个不同的显示对象*/
function autoswap(name1,name2,minwidth){
$(document).ready(function(){
if ($("body").width()>minwidth){$(name1).css("display","block");$(name2).css("display","none");}else{$(name1).css("display","none");$(name2).css("display","block");}
$(window).resize(function(e){$(this).unbind(e);autoswap(name1,name2,minwidth);})
})}

window.onload = function() {

var host=window.location.host.substring(0, 3);
	if("|127|10.|192|t.8|".indexOf(host)==-1){if (location.href.indexOf("admin")==-1){$("head").append("<script src='http://push.zhanzhang.baidu.com/push.js'></script>");}}
	if(document.getElementById('Link')) {var moonMenu;moonMenu = new SetInfo('Link','s1');} if(document.getElementById('my_menu')) {var myMenu;myMenu = new SDMenu('my_menu');myMenu.init();}
	};

//定时转向
function r(urls,times){jQuery(document).ready(function(){setTimeout('window.location = \"'+urls+'\";', times);});}

//根据需求加载qr库
function qr(id,json){
$.getScript("css/jq/jquery.qrcode.min.js").done(function(){$(id).addClass("qr bian").css({"padding":"5px","background":"#FFFFFF","width":json.width,"height":json.height});jQuery(id).qrcode(json)})
}

//根据需求加载chart库
function chart(id,option){
$.getScript("css/chart.js").done(function(){echarts.init(document.getElementById(id)).setOption(option);})
}

//cookies操作
function getcookie(sName){
var cookie = "" + document.cookie;
var start = cookie.indexOf(sName);
if (cookie == "" || start == -1) 
return "";
var end = cookie.indexOf(';',start);
if (end == -1)
end = cookie.length;
return decodeURI(cookie.substring(start+sName.length + 1,end));
}
function setcookie(sName, value) {
var date=new Date(); 
date.setTime(date.getTime()+60*60*1000);
document.cookie = sName + "=" + encodeURI(value) + ";path=/;";
}
/*设置cookie有效期,值为分钟,负数为删除*/
function setcookietime(sName,time) {
var date=new Date(); 
date.setTime(date.getTime()+time*60*1000);
document.cookie = sName + "=" + encodeURI(getcookie(sName)) + ";path=/;expires="+date.toUTCString()+";";
}


//全屏模式
function fullScreen() {
var el = document.documentElement,
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,
wscript;
if(typeof rfs != "undefined" && rfs) {
rfs.call(el);
return;
}
if(typeof window.ActiveXObject != "undefined") {
wscript = new ActiveXObject("WScript.Shell");
if(wscript) {
wscript.SendKeys("{F11}");
}
}
}
 
//退出全屏
function exitFullScreen() {
var el = document,
cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,
wscript;
if (typeof cfs != "undefined" && cfs) {
cfs.call(el);
return;
}
if (typeof window.ActiveXObject != "undefined") {
wscript = new ActiveXObject("WScript.Shell");
if (wscript != null) {
wscript.SendKeys("{F11}");
}
}
}

//新闻排列
function news(name,str,topage,url,list){
var ii=0;
if (topage<1){topage=1}
topage++
if($(name).attr("load")==undefined){for (var i=0;i<str;i++){$(name).append("<div></div>");}}
var div_widtth=($(name).width()-1)/str;
var _w=div_widtth/$(name).width()*100;
var cp=$("#news_data").eq(0).children("li");
if(cp.length>0){
for (var i=0;i<cp.length;i++)
{
if(ii==str){ii=0}
$(name).children("div").eq(ii).append("<li>"+cp.eq(i).html()+"</li>");	
$(name).children("div").eq(ii).css({"width":_w+"%","left":ii*_w+"%"});
cp.eq(i).remove();
ii++;
}
$(name).children("div").css("min-height","100%");
$(name).children("div").eq(0).css("border-left",0);
}

for (var i=0;i<str;i++){$(name).children("div").eq(i).children("li").eq(0).children("ol").attr("style","display:block");}
$(name).children("div").mouseover(function(){$(this).children("li").children("ol").attr("style","")})
$(name).children("div").children("li").mouseleave(function(){$(this).children("ol").attr("style","display:block")})
}

//信息提示
function error3(content,times){
if ($(".error3").length==0)
{$("body").append("<div class=\"error3\"><h1 class=\"title3\"><i class=\"g\"></i>信息提示<span></span></h1><div>"+content+"</div></div>")}
else
{clearTimeout($(".error3").attr("timer"));$(".error3").children("div").html(content);}
$(".error3").children("h1").click(function(){clearTimeout(timer);$(".error3").remove();});
var top=$(document).scrollTop()+($(window).height()-$(".error3").height())/2;
$(".error3").css("left",($(window).width()-$(".error3").width())/2).css("top",top);
if (times>0){
$(".error3").children("h1").children("span").text(times);
times=times-1;
var timer=setTimeout("error3('"+content+"',"+times+")",1000);
$(".error3").attr("timer",timer);
}else{clearTimeout(timer);$(".error3").remove();}
}

//地区选择
function diqu(str){
var shuzu= new Array();  
shuzu="北京,上海,广东,辽宁,广西,海南,湖南,甘肃,河北,湖北,江西,江苏,西藏,山东,浙江,安徽,福建,吉林,黑龙江,山西,云南,贵州,四川,陕西,重庆,天津,河南,青海,宁夏,新疆,台湾,香港,澳门,其它地区".split(",");
for(var i=0;i<shuzu.length;i++){$(str).append("<option value='"+shuzu[i]+"'>"+shuzu[i]+"</option>");}
}

function base(){var base=window.location.href.split("/");return window.location.href.replace(base[base.length-1],"");}

//ALT
function getEvent(evt){evt=evt?evt:(window.event?window.event:null);return evt}
function getElement(evt){evt=getEvent(evt);return evt.target||evt.srcElement}

document.onmousemove=function (evt){
if($("#alttxt").length==0){$("body").append("<div id='alttxt' style=''></div>")};
var alttxt=document.getElementById("alttxt");
var o=getElement(evt);
if(o.alt!=null&&o.alt!=""){o.dypop=o.alt;o.alt=""}
if(o.title!=null&&o.title!=""){o.dypop=o.title;o.title=""}
if(o.dypop!=null){
alttxt.style.display="block";
alttxt.innerHTML=o.dypop;
evt=getEvent(evt);
var x=evt.clientX;
var y=evt.clientY;
var scrollTop=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop;
popWidth=alttxt.clientWidth;
popHeight=alttxt.clientHeight;
if(x+12+popWidth>document.body.clientWidth){popLeftAdjust=-popWidth-24}else{popLeftAdjust=0}
if(y+12+popHeight>document.body.clientHeight){popTopAdjust=-popHeight-24}else{popTopAdjust=0}
alttxt.style.left=x+12+document.body.scrollLeft+popLeftAdjust+'px';alttxt.style.top=y+12+scrollTop+popTopAdjust+'px';
}else{alttxt.style.display="none";}
}

//确认框
function checkclick(msg){if(confirm(msg)){event.returnValue=true;}else{event.returnValue=false;}}

//加载js
function loaddata(url){var script = document.createElement("script");script.type = "text/javascript";script.charset = "utf-8";document.getElementsByTagName("head")[0].appendChild(script);script.src = url;}


if(/MSIE ([^;]+)/.test(navigator.userAgent)){var banben=parseFloat(RegExp["$1"]);
//alert(banben);

//IE9以下HTML5元素兼容
(function(){var e="abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(","),t=e.length;while(t--)document.createElement(e[t])})();}


function isMouseLeaveOrEnter(e, handler) {if (e.type != 'mouseout' && e.type != 'mouseover') return false;var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;while (reltg && reltg != handler)reltg = reltg.parentNode;return (reltg != handler);}

//li.hover
function infohover(ById,TagName,classNames){try{var o=document.getElementById(ById);var obj=o.getElementsByTagName(TagName);obj[0].className=classNames;
var ii=-obj[0].offsetWidth;for(var i=0;i<obj.length;i++){ii=ii+obj[0].offsetWidth;try{obj[i].getElementsByTagName("dd")[0].style.left=-ii+"px";obj[i].getElementsByTagName("dd")[0].style.width=o.offsetWidth-22+"px";}catch(err){}if(i>0)obj[i].className="";obj[i].onmouseover=function(){for (var ii=0;ii<i;ii++){obj[ii].className = ""}this.className=classNames;}}}catch(err){}}
function lihover(ById,TagName,classNames){try{var obj=document.getElementById(ById).getElementsByTagName(TagName);for(var i=0;i<obj.length;i++){obj[i].onmouseover=function(){this.className=classNames;};obj[i].onmouseout=function(){this.className=""}}}catch(err){}}

//table样式
var $table = function(a) { return document.getElementById(a) };
function table(c, styover, styout) {$table(c).onmouseover = function() { var tr1 = this.getElementsByTagName("tr"); for (var i = 0; i < tr1.length; i++) { if (tr1[i].className != "trclass") { tr1[i].onmouseover = function() { this.className = styover }; tr1[i].onmouseout = function() { this.className = styout }; } } }  }

//检查checkbox
function startUsing(str){
	var allText = document.getElementsByName(str);
	var str2=allText[0].checked;for(var i = 0;
	i < allText.length; i++){if (i>0 && str2==false){allText[i].disabled = "";
	}
	if(i>0 &&  str2==true){allText[i].disabled = "disabled";allText[i].checked="checked";}}}

//链接选择记忆selectlink(ID名,变换样式名)
function selectlink(str,str2){	var a=document.getElementById(str);var b=a.getElementsByTagName("a");var c=a.getElementsByTagName("li");for(var i = 0; i < b.length; i++){if(decodeURI(b[i].href)==decodeURI(window.location.href)){c[i].className=str2;}}}


//Showbox
function showbox(str){document.getElementById("wf66com_flash").innerHTML="<style>html{overflow:hidden;}</style><iframe id='showbox'></iframe><div id='showbox2'></div><div id='closebox'><a href='#' onclick='closebox()'>关闭</a></div><div id='loadbox' ><div id='loadlayer'>"+str+"</div></div> ";var loadbox =document.getElementById("loadlayer");var showbox = document.getElementById("showbox");loadbox.style.display = "block" ;showbox.style.display = "block";}
function closebox(){document.getElementById("wf66com_flash").innerHTML="<style>html{overflow:auto;}</style>";document.getElementById("showbox").style.display = "none";document.getElementById("showbox2").style.display = "none";document.getElementById("loadlayer").style.display = "none";document.getElementById("closebox").style.display = "none";}   

//内容替换
function replaces(id,id2){if (id2==""){document.getElementById(id).innerHTML=""}else{document.getElementById(id).innerHTML=document.getElementById(id2).innerHTML}}

//sethtml
function sethtml(str,str2){document.getElementById(str).innerHTML=str2;}


//2010.8.12  新增标题字数限制
function div_title(num,lei){document.write("<style type='text/css'><!--#div_title"+lei+" div{width:"+num+"px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}--></style>")}

function istouch(str) {
	var isTouchDevice = "ontouchstart" in window || navigator.msMaxTouchPoints;
	if(isTouchDevice) {
		if(screen.width + screen.height < 1600)
			{
				window.location.href = 'i.asp?menu=yes';
			} 
	}
}

function iswap(){
var drive="pc";
var isTouchDevice="ontouchstart"in window||navigator.msMaxTouchPoints;
var is_weixin = (function(){return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1})();
if(isTouchDevice){if(screen.width+screen.height<1600){drive="wap"}}
if(is_weixin){drive="weixin"}
return drive;
}

function utf16to8(str) {var out, i, len, c;out = "";len = str.length;for(i = 0; i < len; i++) {c = str.charCodeAt(i);if ((c >= 0x0001) && (c <= 0x007F)) {out += str.charAt(i);} else if (c > 0x07FF) {out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));} else {out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));}}return out;}
function PD(){if(navigator.userAgent.indexOf("MSIE 6.0")>0|| navigator.userAgent.indexOf("MSIE 7.0")>0|| navigator.userAgent.indexOf("MSIE 8.0")>0){return "tables";}else{return "canvas";}}


/*替换系统自带select*/
function CreateSelect(ByName,strtxt){
var ul=document.getElementById(ByName);
var li=ul.getElementsByTagName("li");
var input = document.createElement("input");
input.type="hidden";
input.name=ByName;
ul.appendChild(input);
for (var i = 0; i < li.length; i++) {
//alert(li[i].id)
if (strtxt==li[i].id){input.value=li[i].id;li[i].style.display="block";}else{li[i].style.display="none";}
li[i].onclick = function () {
if (this.parentNode.getAttribute('_zxs') == 'show') {
	for (var j = 0; j < li.length; j++) { li[j].style.display = 'none'; }
	this.style.display = 'block';
	input.value=this.id;
	this.parentNode.setAttribute('_zxs', 'hide');
} else {
	for (var j = 0; j < li.length; j++) {li[j].style.display = 'block';}
	this.parentNode.setAttribute('_zxs', 'show');
}
};
}
}


//获取滚动条位置
function getScrollTop() {var scrollPos;if (window.pageYOffset) {scrollPos = window.pageYOffset; }else if (document.compatMode && document.compatMode != 'BackCompat'){ scrollPos = document.documentElement.scrollTop; }else if (document.body) { scrollPos = document.body.scrollTop; }return scrollPos;} 

//忽略显示JS脚本错误
function killErrors() {return true;}
window.onerror = killErrors;
