// javascript document
//public auto show and auto hide this ad.
function showad(classname){
$(classname).slidedown(1)
}
function hidead(classname){
$(classname).stop(true,true)
$(classname).slideup(100)
}
function delayhide(classname,time){
$(classname).delay(time).slideup(2000)
}
//public numbertextbox validation
function numbertextvalidation(obj){
var tempnumber=number($(obj).val());
if(string(tempnumber)=="nan"){
tempnumber=0;
$(obj).val(tempnumber)
}
$(obj).keyup(function(){
if(string(number($(this).val()))=="nan"){
$(this).val(tempnumber)
}else{
tempnumber=number($(this).val());
}
})
}
/*public delayrun*/
function delayruner(fun,time){
this.run=fun;
this.time=time;
var temptimer;
this.begin=function(){
temptimer=settimeout(this.run,this.time)
}
this.cancel=function(){
cleartimeout(temptimer);
}
}
function rollover_delay(fun,time,obj){
this.run=fun;
this.time=time;
this.obj=$(obj);
var delayruner1=new delayruner(this.run,this.time)
this.obj.hover(function (){
delayruner1.begin()
},function(){
delayruner1.cancel()
})
}
//public init hover menu
function initmenu(menubt,submenu,delaytime){
var z=$(submenu).parent().css("z-index")
this.hidemenu=function hidemenu(){
$(menubt).removeclass("now")
$(submenu).fadeout("fast");
$(submenu).parent().css("z-index",z)
}
$(submenu).css("display","none");
this.showmenu=function showmenu(){
$(menubt).addclass("now")
$(submenu).stop(true,true)
$(submenu).fadein("fast");
$(submenu).parent().css("z-index","999")
}
rollover_delay(this.showmenu,delaytime,menubt)
$(submenu).hover(function (){
delayruner1.cancel()
},this.hidemenu)
var delayruner1=new delayruner(this.hidemenu,200)
$(menubt).hover(function(){
delayruner1.cancel()
},function(){
delayruner1.begin()
})
}
//public init show photos
function initphtoshower(mainobj,subject,motion,delay,buttoncolor,motionspeed,callback){
//广告区域对象,子元素,动画效果(up,left,right,down),
//alert(mainobj)
var imgcount=$(mainobj).find(subject).length;
if(imgcount>1){
var btshtmlstr="";
this.mainobj=mainobj;
this.subject=subject;
this.motion=motion;
this.delay=delay;
this.buttoncolor=buttoncolor;
this.motionspeed=motionspeed;
this.timer=null;
var tempnum=1;
//var timer1=null
var stoped=false;
$(mainobj).css("overflow","hidden")
$(mainobj).css("position","relative")
var w=$(mainobj).width();
var h=$(mainobj).height();
this.w=w
this.h=h
initctrlbutton(mainobj)
for(var i=1;i<=imgcount;i++){
btshtmlstr+="
"+i+"
";
}
$(mainobj).append(""+btshtmlstr+"
")
if(motion=="up" || motion=="down"){
$(mainobj).children("*").wrapall("");
$(mainobj).find(subject).css("display","block");
}else if(motion=="left" || motion=="right"){
$(mainobj).children().wrapall("");
$(mainobj).find(subject).css("display","inline-block");
$(mainobj).find(subject).css("float","left");
}
this.buttons=$(mainobj+" .adcontrol .button");
$(mainobj+" .adcontrol .button").hover(function(){
tempnum=number($(this).text())
animatepicto(mainobj,tempnum,motion,buttoncolor)
stoped=true;
if(callback != null && callback != undefined) {
callback();
}
},function(){
stoped=false;
})
animatepicto(mainobj,tempnum,motion,buttoncolor)
clearinterval(this.timer1)
function bannermainrun(){
if(!stoped){
tempnum=tempnum+1
if(tempnum>imgcount){
tempnum=1
}
animatepicto(mainobj,tempnum,motion,buttoncolor,motionspeed);
if(callback != null && callback != undefined) {
callback();
}
}
}
this.timer1=setinterval(bannermainrun,this.delay)
this.autoconsize=function(){
$(this.mainobj).find(this.subject).width(this.w)
$(this.mainobj).find(this.subject).height(this.h)
}
}
}
initphtoshower.prototype.setbuttonsize=function(size,fontsize,color){
$(this.mainobj+" .adcontrol .button").css("width",size+"px")
$(this.mainobj+" .adcontrol .button").css("height",size+"px")
$(this.mainobj+" .adcontrol .button").css("line-height",size+"px")
$(this.mainobj+" .adcontrol .button").css("font-size",fontsize+"px")
}
initphtoshower.prototype.hidebutton=function(){
$(this.mainobj+" .adcontrol").css("display","none")
}
initphtoshower.prototype.showbutton=function(){
$(this.mainobj+" .adcontrol").css("display","block")
}
function initctrlbutton(mainobj){
$(mainobj+" .adcontrol .button").css("background","#ccc");
}
function animatepicto(mainobj,n,motion,buttoncolor,motionspeed){
n=n-1
var top;
var left;
$(mainobj+" .con").stop(true);
initctrlbutton(mainobj)
$(mainobj+" .adcontrol .button:eq("+n+")").css("background",buttoncolor)
if(motion=="up" || motion=="down"){
top="-"+(n*$(mainobj).height())+"px"
$(mainobj+" .con").animate({
margintop:top
},motionspeed)
}
if(motion=="left" || motion=="right"){
left="-"+(n*$(mainobj).width())+"px"
$(mainobj+" .con").animate({
marginleft:left
},motionspeed)
}
}
/*tabcontrol*/
function tabcontrolobj(ttobj,container,callback){
$(container).css("position","relative")
$(container+" .cons").css("position","absolute")
var h=$(container).height();
$(container+" .onecon").height(h)
$(ttobj+" a").hover(function(){
$(ttobj+" a").removeclass("now")
$(this).addclass("now")
var top=$(this).index(ttobj+" a")*h
$(container+" .cons").stop(true);
$(container+" .cons").animate({
top:"-"+top+"px"
},500);
if(callback != null && callback != undefined) {
callback();
}
},function (){
})
}
/*tabcontrol - click*/
function tabctrlobj_clk(ttobj,container){
$(container).hide()
$(container+":eq(0)").show()
$(ttobj+" a").click(function(){
$(ttobj+" a").removeclass("now")
$(this).addclass("now")
var n=$(this).index(ttobj+" a")
$(container).hide()
$(container+":eq("+n+")").show()
return false;
})
}
/*accordion*/
function accordion(btobj,conobj){
$(btobj).prepend("+ ");
$(btobj).css({cursor:"pointer"})
$(conobj).css({display:"none"})
$(btobj).click(function(){
if($(conobj).css("display")=="none"){
$(btobj+" .ico").html("-")
//$(conobj).css({display:"block"})
$(conobj).slidedown(300)
}else{
$(btobj+" .ico").html("+")
//$(conobj).css({display:"none"})
$(conobj).slideup(300)
}
})
}
function accordions(btobjs,conobjs){
for(var i=0;i<$(btobjs).length;i++){
accordion(btobjs+":eq("+i+")",conobjs+":eq("+i+")")
}
}
/*toptoolbar*/
function inittoolbar(){
var interval;
var scrolltop=0;
var navfixed=false;
function showtoptoolbar(){
$(".toptoolbar .pagewidth").append($("#searchform"))
$(".toptoolbar .pagewidth").append($("#shoppingcarttips"))
$(".toptoolbar").stop(true,true)
$(".toptoolbar").fadein()
}
function hidetoolbar(){
$(".toptoolbar").stop(true,true)
$(".toptoolbar").fadeout()
$("#searchformbox").prepend($("#searchform"))
$(".userbtandcart").append($("#shoppingcarttips"))
}
function testnavpos(){
scrolltop=$(document).scrolltop();
if (($.browser.msie) && ($.browser.version == "6.0")){
$(".toptoolbar").css("top",scrolltop+"px");
}
if(scrolltop>=90 && navfixed==false){
showtoptoolbar()
navfixed=true;
}
if(scrolltop<90 && navfixed){
hidetoolbar()
navfixed=false;
}
}
interval=setinterval(testnavpos,100);
}
/*public different data | 将页面对象中不同的内容取出放置到一个数组中*/
function different(obj){
var arr=new array();
var i=0;
var d=true;
$(obj).each(function(index, element) {
d=true;
if(arr.length==0){
arr[0]=$(element).html()
}else{
for(i in arr){
if(arr[i]==$(element).html()) {
d=false
}
}
if(d){
arr.push($(element).html())
}
}
});
return arr;
}
/*public date string to ymd*/
function datestr(datestring){
if(datestring==null){
datestring="1月1日"
}
var datereg1=/\d*-\d*-\d*/
var datereg2=/\d*\/\d*\/\d*/
var datereg3=/\d*年\d*月\d*日/
var datereg4=/\d*月\d*日/
var yearindex=0
var monthindex=0
var dayindex=0
if(datereg1.exec(datestring)){
yearlen=datestring.search("-");
monthlen=datestring.substring(yearlen+1,datestring.length).search("-")
daylen=datestring.substring(yearlen+monthlen+2,datestring.length).length
}
if(datereg2.exec(datestring)){
yearlen=datestring.search("/");
monthlen=datestring.substring(yearlen+1,datestring.length).search("/")
daylen=datestring.substring(yearlen+monthlen+2,datestring.length).length
}
if(datereg3.exec(datestring)){
yearlen=datestring.search("年");
monthlen=datestring.substring(yearlen+1,datestring.length).search("月")
daylen=datestring.substring(yearlen+monthlen+2,datestring.length).search("日")
}
if(datereg4.exec(datestring)){
yearlen=-1
monthlen=datestring.substring(yearlen+1,datestring.length).search("月")
daylen=datestring.substring(yearlen+monthlen+2,datestring.length).search("日")
}
this.year=number(datestring.substr(0,yearlen))
this.month=number(datestring.substr(yearlen+1,monthlen))
this.day=number(datestring.substr(yearlen+monthlen+2,daylen))
this.datestring=datestring
}
//date string compare
function datestrcompare(d1,d2){//a>b return true
var r=0;
var d1str=new datestr(d1)
var d2str=new datestr(d2)
if(d1str.year>d2str.year){
r=1//1大于2
this.maxdate=d1str
}else if(d1str.year==d2str.year){
if(d1str.month>d2str.month){
r=1//1大于2
this.maxdate=d1str
}else if(d1str.month==d2str.month){
if(d1str.day>d2str.day){
r=1//1大于2
this.maxdate=d1str
}else if(d1str.day==d2str.day){
r=0//1大于2
this.maxdate=d1str
}else{
r=-1
this.maxdate=d2str
}
}else{
r=-1
this.maxdate=d2str
}
}else{
r=-1
this.maxdate=d2str
}
this.greater=r;
this.datestring=d2str.datestring
}
function sortdatestr(arr){
var temparr=arr
var tempdate="1月1日"
var i=0;
var j=1;
var c=arr.length
for(i=0;i=1){
tempdate=temparr[j]
temparr[j]=temparr[j-1]
temparr[j-1]=tempdate
//alert(temparr[j-1]+":"+temparr[j]+"--"+tempdate)
}
}
}
return(temparr)
}
function richdatestr(){
this.maxdate=function(d1,d2){
var tempdatestr=new datestrcompare(d1,d2)
return tempdatestr.maxdate.datestring
}
this.gtdate=function(d1,d2){
var tempdatestr=new datestrcompare(d1,d2)
return tempdatestr.greater
}
}
var richdate=new richdatestr()
//alert(richdate.gtdate("5月14日","6月14日"))
//left and right scorlling interactive
function scorllinit(mainobj,c){//c:每次滚动的个数
this.mainobj=$(mainobj)
this.w=this.mainobj.width()
this.conbox_w=this.w-40
var liwidth=this.mainobj.find("ul li").outerwidth();
var count=this.mainobj.find("ul li").length
if(count>1){
var nown=0;
if(c==undefined){
var c=this.conbox_w/liwidth
}
//this.mainobj.css("cursor","pointer")
this.mainobj.css({position:"relative",overflow:"hidden",zoom:"1"})
this.mainobj.find("ul").wrapall("")
this.mainobj.find(".con").append("")
this.h=this.mainobj.height()
this.mainobj.find(".btl").css({width:"20px",height:this.h+"px",position:"absolute",left:"1px",top:"0",lineheight:this.h+"px",cursor:"pointer"})
this.mainobj.find(".btr").css({width:"20px",height:this.h+"px",position:"absolute",right:"1px",top:"0",lineheight:this.h+"px",cursor:"pointer"})
this.mainobj.find(".btr").click(function(){
nown=nown+1
if(c>1){
if(nown>parseint(count/c)){
nown=0
}
}else{
if(nown>=parseint(count/c)){
nown=0
}
}
$(this).parent().find(".con").animate({
marginleft:"-"+nown*liwidth*c+"px"
},300)
})
this.mainobj.find(".btl").click(function(){
nown=nown-1
if(c>1){
if(nown<0){
nown=parseint(count/c)
}
}else{
if(nown<0){
nown=parseint(count/c)-1
}
}
$(this).parent().find(".con").animate({
marginleft:"-"+nown*liwidth*c+"px"
},300)
})
}else{
mainobj.find(".btl").css("display","none")
mainobj.find(".btr").css("display","none")
}
}
function imglisttoscorll(mainobj,listobj,n,c){
var count=$(mainobj+" "+listobj).length
var w=$(mainobj).width()
$(mainobj+" "+listobj).wrapall("")
for(var i=0;i")
}else{
$(mainobj+" "+listobj+":gt("+(n*i-1)+"):lt("+n+"):not(li "+listobj+")").wrapall("")
}
$(mainobj+" li").append("")
$(mainobj+" li").width(w)
}
scorllinit(mainobj,c)
}
//超出高度出现滚动条
function overflowscorll(obj,height){
$(obj).each(function(index, element) {
if($(element).height()>=height){
$(element).css("height",height+"px");
$(element).css("overflow-y","scroll");
}else{
//$(element).css("height",height+"px");
}
});
}
// tbodyscorlling... 表格内容区域加滚动条
function tbodyscorllinit(tableobj_class,height){
var $tab=$(tableobj_class);
if($(tableobj_class+" tbody").height()>height){
var tdwidths=new array()
$(tableobj_class+":eq(0) thead tr").append(" | ")
$tab.find("thead tr:eq(0) th").each(function(index, element) {
tdwidths[index]=($(element).width())
});
$tab.after($tab.clone());
$(tableobj_class+":eq(0)").css("border-bottom","none")
$(tableobj_class+":eq(1)").css("border-top","none")
$(tableobj_class+":eq(0) tbody").empty()
$(tableobj_class+":eq(1) thead").empty()
$(tableobj_class+":eq(1) tbody tr:eq(0) td").each(function(index, element) {
$(element).width(tdwidths[index])
});
$(tableobj_class+":eq(1)").wrapall("")
var tabwidth=$(tableobj_class+":eq(1)").parent(".con").outerwidth()
if($.browser.msie && $.browser.version==6.0){
$(tableobj_class+":eq(1)").width(tabwidth-34)
$(tableobj_class+":eq(1)").parent(".con").outerwidth(tabwidth-17)
}else{
$(tableobj_class+":eq(1)").width(tabwidth-17)
}
$(tableobj_class+":eq(1) tbody tr:eq(0) td").each(function(index, element) {
$(tableobj_class+":eq(0) thead th:eq("+index+")").width($(element).width())
});
}
}
function tbodyscorll(t_p,h){//t_c= table parent ,h=height
var c=$(t_p).length
for(var i=0;i=1){
sec=sec-1;
ontimer_fun(sec)
}else{
clearinterval(tm)
end_fun()
}
}
this.run()
}
//数据求和
function sumjqobj(obj){
var rs=0
$(obj).each(function(index, element) {
rs+=number($(this).text())
});
return rs;
}
//多级价格相关:
function defmultiprice(){
$(".multiprice").each(function(index, element) {
$(element).find(".oneprice").hide()
$(element).find(".oneprice .fd").hide()
$(element).find(".oneprice:eq(0)").show();
var pricecount=$(element).find(".oneprice").length
if(pricecount<=1){
$(element).find(".djjico").hide()
}else{
var aunit=$(element).parents("li").find(".unit").text()
if(aunit==""){
aunit=$(element).parents("tr").find(".unit").text()
}
var djjtxt=""
for(var i=1;i"
}
$(element).find(".djjico .ts").html(djjtxt)
$(element).find(".djjico img").hover(function(){
$(this).parent().find(".ts").stop()
$(this).parent().find(".ts").fadein(300)
$(this).parent().css("z-index","9999")
},function(){
$(this).parent().find(".ts").stop()
$(this).parent().find(".ts").fadeout(300)
$(this).parent().css("z-index","1")
})
}
});
}
function makefdts(obj,aunit){
var pricecount=$(obj).find(".oneprice").length
var djjtxt=""
if(pricecount>1){
for(var i=1;i"
}
}
return djjtxt;
}
function buildmulpricetip(){
var djjtxt="";
var mulnum = $(".infolist").find(".multiprice").length;
var aunit = $(".infolist").find(".multiprice:eq(0) .unit").text();
if(mulnum > 1){
var pricecount= $(".infolist").find(".multiprice:eq(0)").find(".oneprice").length;
if(pricecount>1){
for(var i=1;i"
}
}
}else{
var pricecount=$(".multiprice").find(".oneprice").length
if(pricecount>1){
for(var i=1;i"
}
}
}
return djjtxt;
}
function checkmultiprice(obj){
if($(obj).parents("li").find(".djjico").css("display")!="none"){
var pnum = $(obj).parents("li").find(".multiprice").length;
for(var j=0;j1){
var mul = $(obj).parents(".skuinfo").find(".multiprice").length;
for(var j=0;j 0){
//判断是否购物车
if($(obj).parents("tr").parents("table").find(".cartitem").length > 0){
var foreachnum = 0;
if($("#settlementway").val() == "cash"){
foreachnum=1;
}else if($("#settlementway").val() == "prepay"){
foreachnum=2;
}
var mul = $(obj).parents("tr").find(".multiprice").length;
for(var j=0;j1){
for (var i=0;i1){
for (var i=0;i"+data.resultdata[index].substationname+""
substationareadetaillist+=""+data.resultdata[index].substationname+"金牛制冷";
}else{
substationarealist+= ""
substationareadetaillist+=""+data.resultdata[index].substationname+"金牛制冷";
}
}
$("#substation_area_list").html(substationarealist);
$(".son_ul").html(substationareadetaillist);
}
}
});
}
function reloadsubstation(changeurl,substationno){
$.ajax({
type: "get",
url: changeurl+"?substationno="+substationno,
success: function(data){
if(data.success){
location.reload();
}
}
});
}
//end