You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

865 lines
21 KiB
JavaScript

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// JavaScript Document
///2009-08-24 debug 需要jquer1.3支持
///Created by IMT.
/// Last modified by IMT. 2010-08-12
//<![CDATA[
///<summary>
///图片预读
///ImgUrlList 为img 路径列表
///</summary>
function ImgAdvancePreloader(ImgUrlList)
{
//图片预读
var cc = ImgUrlList, cci = 0, url;
function ImgPreloader() {
url = cc.eq(cci).attr("href");
if (url && url.length < 1) {
for (; cci < cc.length; cci++) {
url = cc.eq(cci).attr("href");
if (url.length > 0) {
break;
}
}
}
if (!url) return;
imagePreloader = new Image; imagePreloader.src = url;
if (imagePreloader.complete) {
cci++;
ImgPreloader();
} else {
$(imagePreloader).unbind().bind('load', function() {
cci++;
ImgPreloader();
});
}
}
$(window).load(function() {
setTimeout(ImgPreloader, 1000);
});
}
//eCss: 播放的div组的css 统一css 并且页面中唯一使用;pId:点击向前的id;nId点击向后的id;sNum:显示个数(默认是3);
//sstime播放时间(毫秒)autoStarttrue 为自动播放(默认)false禁止自动播放playTime:自动播放时间(毫秒);方向left 或者right
function slideShowFn(eCss,pId,nId,sNum,sstime,autoStart,playTime,direction){
if(typeof eCss !="string" || (typeof pId !="string" && typeof nId !="string")) return false;
if(typeof $ =="function")
{
$(function(){
var ssctliste = $("."+eCss),ssctlist=[],ssi=0,tempsse,bdir= true;
if(typeof sstime != "number") sstime = 600; // defalut parameters set value
if(typeof sNum != "number")sNum = 2; else sNum --;
if(typeof autoStart != "boolean" )
{
autoStart = true;
}
else if(autoStart)
{
if(typeof playTime != "number") playTime = 1000;
if(direction == "right" ) bdir= false; else bdir= true ;
}
ssctliste.each(function(i){
tempsse = $(this);
ssctlist.push(tempsse);
tempsse.hover(function(){if(autoNextTimer)clearInterval(autoNextTimer);},function(){ssOutPlayControl()});
if(i > sNum)
{
tempsse.hide();
}
}
);
if(ssctlist.length > 0)
{
var pssbusy=false,nssbusy=false,sscount =ssctlist.length -1, autoNextTimer ;
if(typeof pId == "string")
{
$("#"+pId).css("cursor","pointer").click(function(){
pssbusy = true;
if(!nssbusy)
{
var te,ee,se, m_ssi =ssi;
if( ssi > 0 )
{
ssi-=1;
}
else
{
ssi = sscount;
}
if(m_ssi==0)
{
te = sscount;
}
else
{
te= m_ssi-1;
}
ee = ((m_ssi+sNum) > sscount) ? m_ssi- sscount+sNum -1 :m_ssi+sNum;
$(ssctlist[m_ssi]).before(ssctlist[te]);
ssctlist[te].show(sstime); //
ssctlist[ee].hide(sstime,function(){pssbusy=false});
}
}).hover(function(){if(autoNextTimer)clearInterval(autoNextTimer);},function(){ssOutPlayControl()});
}
if(typeof nId == "string")
{
$("#"+nId).css("cursor","pointer").click(function(){
nssbusy= true;
if(!pssbusy)
{
var te,ee,se, m_ssi =ssi;
if( ssi < sscount )
{
ssi+=1;
}
else
{
ssi= 0;
}
if(m_ssi==0)
{
ee = sscount;
}
else
{
ee= m_ssi-1;
}
te = ((m_ssi+sNum+1) > sscount) ? m_ssi- sscount+sNum:m_ssi+sNum+1;
ssctlist[m_ssi].hide(sstime,function(){ssctlist[ee].after(ssctlist[m_ssi]);nssbusy=false;} ); //
ssctlist[te].show(sstime);
}
}).hover(function(){if(autoNextTimer)clearInterval(autoNextTimer);},function(){ssOutPlayControl()});;
}
function ssOutPlayControl()
{
if(autoStart)
{
if(bdir&& typeof nId == "string")
{
autoNextTimer = setInterval(function(){ $("#"+nId).trigger("click");},playTime);
}
else if(typeof pId == "string")
{
autoNextTimer = setInterval(function(){ $("#"+pId).trigger("click")},playTime);
}
}
}
ssOutPlayControl();
}
});
}
}
///<summary>
///设置cookie
///</summary>
function setCookie(c_name,value,expiredays,domian,pth)
{
var exdate=new Date(),ckstr;
exdate.setDate(exdate.getDate() + expiredays);
ckstr = c_name+ "=" +escape(value)+";";
if(typeof expiredays != "undefined" )ckstr+="expires="+exdate.toGMTString()+";";
if(typeof domian== "string")ckstr+="domain="+ domian+";";
if(typeof pth == "string")
{
ckstr+="patch="+ pth+";";
}
else
{
ckstr += "patch=//;";
}
document.cookie = ckstr;
};
///<summary>
///获取cookie
///</summary>
function getCookie(c_name,domian)
{
var tcookie = document.cookie,reg = "/"+c_name+"=([^;]*)/"; //(\\d+)
if(tcookie.length <1)return false;
result = tcookie.match(eval(reg));
if(result)
{
if(result.length > 1)
{
return unescape(result[1]);
}
}
return false;
};
///<summary>
///js获取值
///</summary>
function AjGetData(u,qE,cB)
{
busy = true;
$.ajax({
type: "post",
dataType: "text",
processData: false,
url: u,
data: qE ,
success: function(msg){
busy = false;
if (typeof msg == "string")
{
if(msg.length >1)
{
cB(msg);
}
}
}
,
error: function(Request){
busy = false;
//Request.readyState
}
});
};
///绑定获取数据
///sE:输入框对象dFName 获取数据文件名称 包括路径hE:隐藏域id
function BindSelEGetData(sE,gFName,sN,hE,qE,sP,sP2)
{
$(function(){
if(typeof sE !="string"||sE=="") return false;
if(typeof gFName !="string"||gFName=="") return false;
if(typeof sN !="number") sN =3;
if(typeof qE !="string"||qE=="")qE = "rValue";
if(typeof sP !="string"||sP=="")sP = "|_";
if(typeof sP2 !="string"||sP2=="")sP2 = "#_";
var jsE = $("#"+sE),d =[],hD,str,tempA,eL,dE,jhE,Vsign=false,jseV,busy=false;
GAJData();
function GAJData()
{
jsE.unbind("keydown");
jsE.keydown(function(){setTimeout(function(){
var v = jsE.val();
if(jsE.val().length >= sN)
{
//
AjGetData(gFName,qE+"="+v,OpenRelDiv) ;
}
} ,200);
});
};
///<summary>
///添加数据到层
//</summary>
function AddDivLi(eData)
{
d.length = 0;
if(eData.indexOf(sP) > 0)
{
tempA = eData.split(sP);
if(eData.indexOf(sP2) > 0)
{
var _tempA;
hD=[];
hD.lenght =0;
for(ai = 0 ; ai < tempA.length;ai++)
{
_tempA = tempA[ai].split(sP2);
d.push(_tempA[0]);
hD.push(_tempA[_tempA.length-1]);
}
}
else
{
for(ai = 0 ; ai < tempA.length;ai++)
{
d.push(tempA[ai]);
}
}
}
else
{
d.push(eData);
}
if(d.length <1)return;
//a = ["Usa","Japan","China"];
str = " <ul class='drop1' style='margin-top:2px;' id='select_List'>";//<li><A href='javascript:;'>USA</A></li><li><A href='javascript:;'>Japan</a>
str += handleData(d);
str +="</ul>";
if(typeof dE !="undefined")
{
dE.empty();
dE.html(str);
dE.show();
}
else
{
ShowSelDiv(sE,str,"bottom","left","no");
}
eL =$("#select_List li");
//点击事件
if( typeof hD =="undefined" || hD.constructor != Array )
{
//d=null;
eL.click(function(){
jsE.val($(this).text());
jhE.val($(this).text());
dE.slideUp("fast");
});
}
else
{
eL.each(function(i){
$(this).click(function(){
jsE.val($(this).text());
jhE.val((hD[i]));
dE.slideUp("fast");
});
});//.click(function(){alert($(this).text())});
}
Vsign = false;
};
///<summary>
///在关联弹出层
///<summary>
///OpenRelDiv()
/// sE 弹出对象id ,eData:处理的数据hE:隐藏值id
function OpenRelDiv(eData)
{
// if(typeof sE !="string") return false;
// if(typeof eData !="string") return false;
jhE = $("#"+hE);
jsE.unbind("keydown");
AddDivLi(eData);
dE = $("#"+sE+"seldiv");//.hover(function(){$(this).show();},function(){$(this).hide();});
//eL =$("#select_List li");
// jsE = $("#"+sE);
jsE.keydown(function(){
setTimeout(function(){
jseV = jsE.val();
if( jseV.length < sN)
{
dE.hide();
dE.empty();
if(!Vsign )Vsign = true;
return;
}
dE.slideDown("normal");
if( Vsign && jseV.length >= sN&& !busy)//重新搜索
{
//清除对象
//dE.replaceWith();
dE.hide();
dE.empty();
AjGetData(gFName,qE+"="+jseV,AddDivLi);
// return;
}
if( eL.text().indexOf(jseV)>=0)
{
eL.each(function(){
if( $(this).html().indexOf("<a")>= 0 || $(this).html().indexOf("<A")>=0 )
{
$(this).find("a").html($(this).text().replace( jseV ,"<strong>"+ jseV +"</strong>"));
}
else
{
$(this).html($(this).text().replace( jseV ,"<strong>"+ jseV +"</strong>"));
}
});
}
else
{
dE.hide();
dE.empty();
Vsign = true;
}
} ,200);});
}
});
};//end-----BindSelEGetData
///处理数据 返回html
function handleData(d)
{
if( typeof d =="undefined" || d.constructor != Array )return "";
var lstr="";
for(i = 0 ;i< d.length;i++)
{
lstr+="<li><a href='javascript:;'>"+ d[i] +"</a></li>";
}
return lstr;
}
///<summary>
///显示选择层
///</summary>
///e :弹出位置对象str弹出内容eP弹出相对对象位置偏移xePy相对偏移yeD消隐方式 blur 离开焦点消除【默认】,click,点击消除等或no 不处理),dcss:弹出层样式
function ShowSelDiv(e,str,ePx,ePy,eD,dcss)
{
if(typeof e != "string") return;
var eofs,ele;
ele = $("#"+e);
eofs = ele.offset();
if(typeof ePx =="string")
{
if(ePx == "top")
ePx = ele.innerHeight()+2;
if(ePx == "bottom")
ePx = -( ele.innerHeight()+2);
}
else if(typeof ePx != "number")
{
ePx = 20;
}
if(typeof ePy == "string")
{
if(ePy == "left")
ePy = 0;
if(ePy == "right")
ePy = -ele.innerWidth();
}
else if(typeof ePy !="number")
{
ePy = 0 ;
}
if(typeof dcss != "string" )
{
dcss = "arrowDownTest";
}
appDivCke(eofs.top-ePx ,eofs.left-ePy ,e+"seldiv",str,dcss);
if(typeof eD=="undefined")//层事件
{
ele.one("blur",function(){$("#"+e+"seldiv").replaceWith()});//replaceWithempty();
}
else if(eD!="no")
{
ele.one(eD,function(){$("#"+e+"seldiv").replaceWith()});
}
};
///<summary>
///正则检测为空函数
///</summary>
///ckNullorEmpty(sE[,eStr,reg][,fc])
///<param type="string" name ="sE">检测对象id</param>
///<param type="string" name ="eStr">提示错误输出语句</param>
///<param type="string" name ="reg">正则语句</param>
///<param type="string" name ="dfStr">默认值句</param>
///<param type="number" name ="oE">错误输出容器对象id 如果不存在则弹出提示</param>
///<param type="number" name ="fc">是否出错焦点</param>
function RegCkElement(sE,eStr,reg,dfStr,oE,fc)
{
var ele = document.getElementById(sE);
if(!ele) return false;
if(typeof dfstr != "string")dfstr="";
if(typeof fc !="boolean") fc= true;
if(typeof ele.value == "string"&& ele.value.replace(/\s*/g, "") !="" && ele.value !=dfstr)
{
if(typeof reg =="string")
{
var pattern= eval(reg); //.replace(/\s*/g, "")
var flag=pattern.test(ele.value);
  if(!flag){
if(typeof eStr =="string")
{
ShowE(sE,eStr,oE);
}
if(fc)FocusE(ele);
return false;
}
}
return true;
}
if(typeof eStr =="string")
{
ShowE(sE,eStr,oE);
}
if(fc)FocusE(ele);
return false;
};
///<summary>
///检测数字
///</summary>
///sE 检测对象eStr:错误提示信息oE:单独定义显示错误的对象容器 fc 错误后是否聚焦 默认true
function IsEmptyOrNotNum(sE,eStr,dfStr,oE,fc)
{
var ele = document.getElementById(sE);
if(!ele) return false;
if(typeof dfstr != "string")dfstr="";
if(typeof fc !="boolean") fc= true;
if(typeof ele.value == "string"&& ele.value.replace(/\s*/g, "") !=""&&ele.value !=dfStr)
{
if(isNaN(ele.value))
{
if(typeof eStr =="string")
{
ShowE(sE,eStr,oE);
}
if(fc)FocusE(ele);
return false;
}
return true;
}
if(typeof eStr =="string")
{
ShowE(sE,eStr,oE);
}
if(fc)FocusE(ele);
return false;
}
///<summary>
///检测字符串
///</summary>
///sE 检测对象eStr:错误提示信息oE:单独定义显示错误的对象容器 fc 错误后是否聚焦 默认true
function StrIsNullOrEmpty(sE,eStr,dfStr,oE,fc)
{
var ele = document.getElementById(sE);
if(!ele) return false;
if(typeof dfstr != "string")dfstr="";
if(typeof fc !="boolean") fc= true;
if(typeof ele.value == "string" && ele.value.replace(/\s*/g, "") !=""&&ele.value!=dfStr)
{
return true;
}
if(typeof eStr =="string")
{
ShowE(sE,eStr,oE);
}
if(fc)FocusE(ele);
return false;
}
///<summary>
///设置对象焦点
///</summary>
function FocusE(e)
{
if(e)
{
if(e.getAttribute("visible")=="true"||e.style.display !="none")
{
e.focus();
}
}
};
///<summary>
///显示错误提示
///</summary>
function ShowE(sE,str,oE)
{
var ele;
// str = str.fontcolor("red");
// str = str.bold();
ele = document.getElementById(oE);
if(ele)
{
ele.style.display = "";
ele.innerHTML = str;
}
else{
str= AddArrowhtml(str);
OpenMsg(sE,str);
}
};
///信息提示框箭头html
function AddArrowhtml(s)
{
return s+"<div class='arrowDown'><img src='/css/images/whiteArrow.png'/></div>";
}
///<summary>
///弹出提示层
///</summary>
///e :弹出位置对象str弹出
function OpenMsg(e,str)
{
if(typeof e != "string") return;
var eofs,ele;
ele = $("#"+e);
eofs = ele.offset();
appDivCke(eofs.top-24,eofs.left ,e+"ediv",str,"arrowDownTest");
ele.one("blur",function(){$("#"+e+"ediv").replaceWith()});//replaceWithempty();
};
///<summary>
///添加漂浮提示框 必须jq加载完才可以调用
///</summary>
function appDivCke(t,l,n,estr,dcss)
{
$("body").prepend("<div class='"+ dcss +"' style='top:"+t+"px;left:"+l+"px;' id='"+n+"'>"+ estr +"</div>");
}
//切换板式 eId 对象id clshover 样式; hType 样式对象; hEName:隐藏对象 name hI 第几个hover hOc hover 或点击;
function TrunMenu(eId,cls,hType,hEName,hI,hOc)
{
if(arguments.length < 1 )
{
eId = "Trun_Menu";
}
if(typeof eId !="string" || eId.length < 1 ) eId = "Trun_Menu";
if(typeof cls !="string")cls = "active";
if(typeof hType !="string")hType = "li";
if(isNaN(hI))hI = 1;
if(typeof hOc != "boolean") hOc = false;
$().ready(function(){
var Tdiv =[],Ediv;
if(typeof hEName =="string")
{
Ediv = $("[name='"+hEName+"']");
}
$("#"+ eId +" li").each(function(i){
var Te,Oe,Hf,Odid;
Te = $(this);
Te.attr("TrunNum",i);
Oe = Te.text();
if(typeof Ediv != "object")
{
Odid = $("#"+Oe.replace(/\s*/g, "")).show();
}
else
{
Odid = Ediv.eq(i);
}
if(i == hI-1)
{
Odid.show();
if(hType == "li")
{
Te.addClass(cls);
}
else
{
Te.find("a").addClass(cls);
}
}
else
{
Odid.hide();
if(hType == "li")
{
Te.removeClass(cls);
}
else
{
Te.find("a").removeClass(cls);
}
}
Hf = Te.find("a").attr("href");
if(typeof Hf !="string" || Hf =="#" || Hf =="###" )
{
Hf="javascript:;";
}
Tdiv.push({CTe:Te,COe:Oe,Href:Hf,Did:Odid});
if(hType == "li")
{
if(hOc)
{
Te.hover(function(){
for(i=0;i<Tdiv.length;i++)
{
Tdiv[i].Did.hide();
Tdiv[i].CTe.html("<a href='"+ Tdiv[i].Href +"' >"+Tdiv[i].COe+"</a>");
Tdiv[i].CTe.removeClass(cls);
}
Te = $(this);
//Oe = Te.text(); //removeAttr
//$("#"+Oe.replace(/\s*/g, "")).show();
Tdiv[parseInt(Te.attr("TrunNum"))].Did.show();
Te.addClass(cls).html(Oe);
});
}
else
{
Te.click(function(){
for(i=0;i<Tdiv.length;i++)
{
//$("#"+ Tdiv[i].Did).hide();
Tdiv[i].Did.hide();
Tdiv[i].CTe.html("<a href='"+ Tdiv[i].Href +"' >"+Tdiv[i].COe+"</a>");
Tdiv[i].CTe.removeClass(cls);
}
Te = $(this);
//Oe = Te.text(); //removeAttr
//$("#"+Oe.replace(/\s*/g, "")).show();
Tdiv[parseInt(Te.attr("TrunNum"))].Did.show();
Te.addClass(cls).html(Oe);
});
}
}
else
{
if(hOc)
{
Te.hover(function(){
for(i=0;i<Tdiv.length;i++)
{
Tdiv[i].Did.hide();
//$("#"+ Tdiv[i].Did).hide();
Tdiv[i].CTe.find("a").removeClass(cls);
//Tdiv[i].CTe.html("<a href='"+ Tdiv[i].Href +"' >"+Tdiv[i].COe+"</a>");
}
Te = $(this);
// Oe = Te.text();
Tdiv[parseInt(Te.attr("TrunNum"))].Did.show();
// $("#"+Oe.replace(/\s*/g, "")).show();
Te.find("a").addClass(cls);
});
}
else
{
Te.click(function(){
for(i=0;i<Tdiv.length;i++)
{
Tdiv[i].Did.hide();
//$("#"+ Tdiv[i].Did).hide();
Tdiv[i].CTe.find("a").removeClass(cls);
//Tdiv[i].CTe.html("<a href='"+ Tdiv[i].Href +"' >"+Tdiv[i].COe+"</a>");
}
Te = $(this);
//Oe = Te.text();
Tdiv[parseInt(Te.attr("TrunNum"))].Did.show();
// $("#"+Oe.replace(/\s*/g, "")).show();
Te.find("a").addClass(cls);
});
}
}
});
});
};
//TrunMenu("Trun_Menu1");
//TrunMenu("product-search-nav","selected roundCornerTop","a");
//]]>