';
this.fullDiv.setAttribute("id","cFunllDiv");
top.document.body.appendChild(this.fullDiv);
this.frameDiv.setAttribute("id","cFrameDiv");
top.document.body.appendChild(this.frameDiv);
this.frame=top.frames[this.frameName];
}
},
hide:function()
{
this.fullDiv.style.display="none";
this.frameDiv.style.display="none";
top.document.getElementById(this.frameName).src="";
},
show:function()
{
top.document.getElementById('float01-title').innerHTML=
'
'+
'
'+
'
'+this.title+'
'+
'
';
top.document.getElementById("cClose").onclick=function(o){return function(){o.fnClose()}}(this);
var iClientWidth=fnGetDocumentClient().width;
var iClientHeight=fnGetDocumentClient().height;
var iScrollWidth=fnGetDocumentScroll().width;
var iScrollHeight=fnGetDocumentScroll().height;
var iFullDivWidth=iScrollWidth;
var iFullDivHeight=iScrollHeight>iClientHeight?iScrollHeight:iClientHeight
with(this.fullDiv.style)
{
width=iFullDivWidth+"px"
height=iFullDivHeight+"px";
display="";
}
var iTop=(iClientHeight-this.height)*(1-0.818);
var iLeft=(iClientWidth-this.width)*0.5;
iTop=iTop>0?iTop:0;
iLeft=iLeft>0?iLeft:0;
var f=top.document.getElementById(this.frameName);
var ttt=this;
top.document.onkeydown=document.onkeydown=function(e)
{
e=e||top.event||event;
if(e.keyCode==27)
ttt.hide();
}
if(this.frameDiv["attachEvent"])//ie
{
f.onreadystatechange=function()
{
if(f.readyState === "complete")
{
ttt.frame.document.onkeydown=function()
{
if(ttt.frame.event.keyCode==27)
ttt.hide();
}
}
}
}
else
{
f.onload=function()
{
ttt.frame.document.onkeydown=function(e)
{
if(e.keyCode==27)
ttt.hide();
}
}
}
//alert(f)
//alert(this.src+"?"+this.param)
var u=this.src+"?"+this.param;
//$(f).attr('src',u);
f.src=u;
/*f.width=this.width+"px";
f.height=this.height+"px";
*/
with(this.frameDiv.style)
{
display="block";
}
}
}
var FloatFrame=function(){};
FloatFrame.autoLocal=function()
{
var cFrame=top.document.getElementById('cFrame');
var cFloatDiv=top.document.getElementById('cFrameDiv');
var div_cFrame=top.document.getElementById('div_cFrame');
cFrame.style.width="1px";
cFrame.style.heght="1px";
var cur=_.scroll();
with(cFrame.style)
{
width=cur.w+'px';
height=cur.h+'px';
}
var cli=_.client(top.document.documentElement);
var iTop=(cli.h-cur.h)/2+(top.document.documentElement.scrollTop||top.document.body.scrollTop);
var iLeft=(cli.w-cur.w)/2;
iTop=iTop>0?iTop:0;
iLeft=iLeft>0?iLeft:0;
with(cFloatDiv.style)
{
top=iTop+"px";
left=iLeft+"px";
}
var cur=_.scroll();
with(cFrame.style)
{
width=cur.w+'px';
height=cur.h+'px';
}
with(div_cFrame.style)
{
width=(cur.w+30)+'px';
}
};
var off;
$(function(){
off=new floatFrame({title:'',src:''});
});
function alertFloat(url)
{
off.src=url;
off.show();
}
function alertUserLogin()
{
alertFloat('user_login.asp');
}
function alertUserReg()
{
alertFloat('user_reg.asp');
}
function alertFeedBack(id)
{
off.src='ajax/feedback.asp';
off.param='id='+id;
off.show();
}
function userExit()
{
$.ajax({
url:'ajax/user_exit.asp',
type:'get',
success:function(data){load_webbar();}
});
}
function addCart(id)
{
off.src='ajax/add_cart.asp';
off.param='id='+id
off.show();
}
function cartOrder()
{
alertFloat('ajax/cartorder.asp');
}
function getCartCount()
{
$.ajax({url:'ajax/get_cartcount.asp',type:'get',success:function(data){$('#cartCount').html(data);}});
}
function load_webbar()
{
$.ajax({url:'ajax/web-bar.asp',type:'get',success:function(data){$('#web_bar').html(data);}});
}
function countdown(sec_i,lastEvent,objName)
{
function run()
{
sec_i--;
if(sec_i<1){
if(lastEvent()!='noclose')
{
top.off.hide();
}
}else{
document.getElementById(objName).innerHTML=sec_i;
setTimeout(run,1000);
}
}
setTimeout(run,1000);
}
function piczoom()
{
$(function(){
//$("img.jqzoom").jqueryzoom();
$("img.jqzoom").jqueryzoom({
xzoom: 300, //zooming div default width(default width value is 200)
yzoom: 300, //zooming div default width(default height value is 200)
offset: 40, //zooming div default offset(default offset value is 10)
position: "right" //zooming div position(default position value is "right")
});
});
}
function ajax_action(jso)
{
var ptext='ptext';
if(jso.flushName)
{
ptext=jso.flushName;
}
var t=$(this);
jso.param.r=Math.random();
$.ajax({
url:jso.url,
type:jso.type,
data:jso.param,
success:function(data){
$('#'+ptext).html(data);
},
error:function(data){
alert('error:'+data.responseText);
}
});
}
function loadevent(jso)
{
if(typeof(jso.click)=="undefined")
click='click';
else
click=jso.click;
$('a[t='+jso.param.actionAjax+'],input[t='+jso.param.actionAjax+']')[click](function(){
var t=$(this);
if(typeof(jso.event)!='undefined')
{
if(!jso.event(jso,t))//执行验证
{
return;
}
}
var url=jso.url;
jso.param.id=t.attr('tid');
ajax_action({url:url,type:jso.type,param:jso.param,flushName:jso.flushName});
});
}
function loadclick_cartdel(jso)
{
loadevent({url:jso.url,type:'post',param:{actionAjax:'del'},event:function(){return confirm('确定删除?\n删除后不可恢复。')}});
}
function loadchange_cartnum(jso)
{
loadevent({url:jso.url,click:'change',type:'post',param:{actionAjax:'num'},event:function(j,o){
var v=o.val().trim();
if(v.length==0 || isNaN(v))
{
alert('排序值必须是数字或小数');
return false;
}
j.param['num']=v;
return true;
}});
}
//----------------------------------------
(function(){
y=window._={
get:function(b,c){c=c||document;if(typeof b==="string")b=c.getElementById(b);return b},
init:function(e,b,d){b=b||{};d=d||{};for(var c in d)e[c]=b[c]||b[c]==0?b[c]:d[c]},
scroll:function(o)
{
o=o||document.documentElement;
return {w:o.scrollWidth,h:o.scrollHeight}
},
client:function(o)
{
o=o||document.documentElement;
return {w:o.clientWidth,h:o.clientHeight}
}
};
})();
/*p1的图片垂直居中,等比例缩放*/
jQuery.fn.loadthumb = function(options) {
options = $.extend({
_img:'',
maxW:100,
maxH:100,
model:3
},options);
var src=options._img.attr('src');
var par=options._img.parent();
var _self = this;
_self.hide();
var img = new Image();
$(img).load(function(){
imgDem = {};
imgDem.w = img.width;
imgDem.h = img.height;
imgDem = $.imgResize({"w": options.maxW ,"h": options.maxH},{"w":imgDem.w,"h":imgDem.h});
var imgMargins = $.imgCenter({"w": par.width() ,"h": par.height()},{"w":imgDem.w,"h":imgDem.h});
//options._img.css({width:imgDem.w,height:imgDem.h,marginLeft:imgMargins.l,marginTop:imgMargins.t});
if(options.model==1 || options.model==3)
options._img.css({width:imgDem.w,height:imgDem.h});
if(options.model==2 || options.model==3)
options._img.css({marginTop:imgMargins.t});//marginLeft:imgMargins.l,
_self.attr("src", src);
_self.fadeIn("slow");
}).attr("src", src); //.atte("src",options.src)要放在load后面,
return _self;
}
//重置图片宽度,高度插件 ( parentDem是父元素,imgDem是图片 )
jQuery.imgResize = function(parentDem,imgDem){
if(imgDem.w>0 && imgDem.h>0){
var rate = (parentDem.w/imgDem.w < parentDem.h/imgDem.h)?parentDem.w/imgDem.w:parentDem.h/imgDem.h;
//如果 指定高度/图片高度 小于 指定宽度/图片宽度 , 那么,我们的比例数 取 指定高度/图片高度。
//如果 指定高度/图片高度 大于 指定宽度/图片宽度 , 那么,我们的比例数 取 指定宽度/图片宽度。
if(rate <= 1){
imgDem.w = imgDem.w*rate; //图片新的宽度 = 宽度 * 比例数
imgDem.h = imgDem.h*rate;
}else{// 如果比例数大于1,则新的宽度等于以前的宽度。
imgDem.w = imgDem.w;
imgDem.h = imgDem.h;
}
}
return imgDem;
}
//使图片在父元素内水平,垂直居中,( parentDem是父元素,imgDem是图片 )
jQuery.imgCenter = function(parentDem,imgDem){
var left = (parentDem.w - imgDem.w)*0.5;
var top = (parentDem.h - imgDem.h)*0.5;
return { "l": left , "t": top};
}
/*图片横向滚动 可点击左右滚动,如精品推荐*/
jQuery.fn.imageScroller = function(params){
var p = params || {
next:"buttonNext",
prev:"buttonPrev",
frame:"viewerFrame",
width:100,
pm:10,
child:"a",
auto:true
};
var _btnNext = $("#"+ p.next);
var _btnPrev = $("#"+ p.prev);
var _imgFrame = $("#"+ p.frame);
var _width = p.width;
var _child = p.child;
var _auto = p.auto;
var _itv;
_width=_imgFrame.find(_child+":first").width()+p.pm;
var turnLeft = function(){
_btnPrev.unbind("click",turnLeft);
if(_auto) autoStop();
_imgFrame.animate( {marginLeft:-_width}, 'slow', '', function(){
_imgFrame.find(_child+":first").appendTo( _imgFrame );
_imgFrame.css("marginLeft",0);
_btnPrev.bind("click",turnLeft);
if(_auto) autoPlay();
});
};
var turnRight = function(){
_btnNext.unbind("click",turnRight);
if(_auto) autoStop();
_imgFrame.find(_child+":last").clone().show().prependTo( _imgFrame );
_imgFrame.css("marginLeft",-_width);
_imgFrame.animate( {marginLeft:0}, 'slow' ,'', function(){
_imgFrame.find(_child+":last").remove();
_btnNext.bind("click",turnRight);
if(_auto) autoPlay();
});
};
_btnNext.css("cursor","pointer").click( turnRight );
_btnPrev.css("cursor","pointer").click( turnLeft );
var autoPlay = function(){
_itv = window.setInterval(turnLeft, 5000);
};
var autoStop = function(){
window.clearInterval(_itv);
};
if(_auto) autoPlay();
};
/*垂直滚动,如:快速导航滚动*/
(function($) {
$.fn.extend({
Scroll: function(opt, callback) {
var sc = new RunScroll({ name: this.attr('id'), line: opt.line, column: opt.column, speed: opt.speed, timer: opt.timer, action:opt.action });
sc.Run();
}
})
})(jQuery);
var __ScrollTimeID={};
function RunScroll(pJso)
{
_.init(this,pJso,{
line:1,
column:1,
speed:800,
timer:5000,
name:'',
action:'Top'
});
if(!this.name)
{
//alert('Unspecified tagID [name].')
}
this.jq=$('#'+this.name);
}
RunScroll.prototype =
{
Run: function() {
var _this = this.jq.eq(0); //.find("ul:first");
var lineH;
var line;
if (this.action == 'Top' || this.action == 'Bottom') {
lineH = _this.find("li:first").height(); //获取行高
line = this.line ? parseInt(this.line, 10) : parseInt(this.jq.height() / lineH, 10);
} else {
lineH = _this.find("li:first").width(); //获取行高
line = this.line ? parseInt(this.line, 10) : parseInt(this.jq.width() / lineH, 10);
}
var speed = this.speed ? parseInt(this.speed, 10) : 500; //卷动速度,数值越大,速度越慢(毫秒)
var timer = this.timer ? parseInt(this.timer, 10) : 3000; //滚动的时间间隔(毫秒)
var lineColumn = this.column ? parseInt(this.column, 10) : 1; //每行显示几列
if (line == 0) line = 1;
var upHeight = -line * lineH / lineColumn;
var animateAction;
var animateAction1;
switch (this.action) {
case 'Top':
animateAction = { marginTop: upHeight };
animateAction1 = { marginTop: 0 };
break;
case 'Bottom':
animateAction = { marginBottom: upHeight };
animateAction1 = { marginBottom: 0 };
break;
case 'Left':
animateAction = { marginLeft: upHeight };
animateAction1 = { marginLeft: 0 };
break;
case 'Right':
animateAction = { marginRight: upHeight };
animateAction1 = { marginRight: 0 };
break;
}
var scrollUp = function() {
_this.animate(animateAction, speed, function() {
for (i = 1; i <= line; i++) {
_this.find("li:first").appendTo(_this);
}
_this.css(animateAction1);
});
}
//鼠标事件绑定
_this.hover(function() {
clearInterval(this.timeID);
}, function() {
this.timeID = setInterval(scrollUp, timer);
}).mouseout();
}
}
/*end 垂直滚动,如:快速导航滚动*/
$(function(){
load_webbar();
//精品推荐
$("#viewer").imageScroller({
next:"next",
prev:"prev",
frame:"viewerFrame",
pm:parseInt($('#viewerFrame').attr('pm')), //间距
child:"li",
auto:true//是否自动播放
});
//垂直居中,等比缩放
$(function(){
$('img[t=p1]').each(function(){
var t=$(this);
t.loadthumb({
'_img':t,
'maxW':t.width(),
'maxH':t.height(),
model:3//1:等比缩放 2:垂直居中 3:所有功能
});
});
})
//快速导航
$("ul[f=scroll1]").Scroll({ line: 1, column: 1, speed: 800, timer: 2000 });
$("ul[f=scroll2]").Scroll({ line: 9, column: 9, speed: 800, timer: 2000 });
})
/*banner图片切换*/
var timer = null;
var offset = 2500;
var index = -1;
//大图交替轮换
function slideImage(i){
var id = 'image_'+ target[i];
$('#'+ id)
.animate({opacity: 1}, 800, function(){
$(this).find('.word').animate({height: 'show'}, 'slow');
}).show()
.siblings(':visible')
.find('.word').animate({height: 'hide'},'fast',function(){
$(this).parent().animate({opacity: 0}, 800).hide();
});
}
//bind thumb a
function hookThumb(){
$('#thumbs li a')
.bind('click', function(){
if (timer) {
clearTimeout(timer);
}
var id = this.id;
index = getIndex(id.substr(6));
rechange(index);
slideImage(index);
timer = window.setTimeout(auto, offset);
this.blur();
return false;
});
}
//bind next/prev img
function hookBtn(){
$('#thumbs li img').filter('#play_prev,#play_next')
.bind('click', function(){
if (timer){
clearTimeout(timer);
}
var id = this.id;
if (id == 'play_prev') {
index--;
if (index < 0) index = 3;
}else{
index++;
if (index > 3) index = 0;
}
rechange(index);
slideImage(index);
timer = window.setTimeout(auto, offset);
});
}
//get index
function getIndex(v){
for(var i=0; i < target.length; i++){
if (target[i] == v) return i;
}
}
function rechange(loop){
var id = 'thumb_'+ target[loop];
$('#thumbs li a.current').removeClass('current');
$('#'+ id).addClass('current');
}
function auto(){
index++;
if (index > 3){
index = 0;
}
rechange(index);
slideImage(index);
timer = window.setTimeout(auto, offset);
}
$(function(){
try{
//change opacity
$('div.word').css({opacity: 0.85});
auto();
hookThumb();
hookBtn();
}catch(e){}
});
/*end banner图片切换*/
$(function(){
$(".products .productstit").click(function(){
$(this).addClass("proclick").siblings().removeClass("proclick");
$(".product .productsnr").css({"display":"none"});
$(".product .productsnr").eq($(this).index()).css({"display":"block"});
if($(this).index()==0){
$(".products .productsmore a").attr("href","products-list.asp?h=1");
}
else{
$(".products .productsmore a").attr("href","products-list.asp?t=1");
}
})
})