/*
Version Number:    V-20100127-L1
*/
(function($){
$.extend($.browser,{
client:function(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,bodyWidth:document.body.clientWidth,bodyHeight:document.body.clientHeight};},
scroll:function(){return{width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight,bodyWidth:document.body.scrollWidth,bodyHeight:document.body.scrollHeight,left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop};},
screen:function(){return{width:window.screen.width,height:window.screen.height};},
isIE6:$.browser.msie&&$.browser.version==6,
isMinW:function(val){return Math.min($.browser.client().bodyWidth,$.browser.client().width)<=val;},
isMinH:function(val){return $.browser.client().height<=val;}});
$.widthForIE6=function(option){
var s=$.extend({max:null,min:null,padding:0},option||{});
var init=function(){
var w=$(document.body);
if($.browser.client().width>=s.max+s.padding){w.width(s.max+"px");}
else if($.browser.client().width<=s.min+s.padding){w.width(s.min+"px");}
else{w.width("auto");}}
init();$(window).resize(init);}
$.fn.hoverForIE6=function(option){
var s=$.extend({
current:"hover"},option||{});
var obj=this;
$.each(this,function(){
$(this).bind("mouseover",function(){
$(this).addClass(s.current);}).bind("mouseleave",function(){
$(this).removeClass(s.current);})})}
$.fn.jdSonny=function(option,callback){
var s=$.extend({current:"curr",delay:100,timer:null,index:null},option||{});
var obj=this;
$.each(this,function(n){
$(this).bind("mouseover",function(){
if(s.timer!=null)clearTimeout(s.timer);
s.index=(s.index==null)?0:s.index;
s.timer=setTimeout(function(){obj.eq(s.index).removeClass(s.current);s.index=n;obj.eq(s.index).addClass(s.current);},s.delay);})})}
$.fn.jdTab=function(option,callback){
$.each(this,function(){
var s=$.extend({event:"mouseover",delay:100,current:"curr",dom:"ul > li > a".split(" > "),attr:"href",timer:null,index:null},option||{});
var child1=$(this).find(s.dom[1]),child2=$(this).find(s.dom[2]),content=[];
child2.each(function(){
content.push($($(this).attr(s.attr)));});
child2.each(function(n){
if(s.action!="click"){$(this).click(function(){return false;})}
$(this).bind(s.event,function(){
clearTimeout(s.timer);
s.index=(s.index==null)?0:s.index;
s.timer=setTimeout(function(){child1.eq(s.index).removeClass(s.current);content[s.index].hide();s.index=n;child1.eq(s.index).addClass(s.current);content[s.index].show();},s.delay);})})})}})(jQuery);

(function ($) {
	$.fn.jdTab = function (option, callback) {
		if (typeof option == "function") {
			callback = option;
			option = {};
		}
		var s = $.extend({type:"static", auto:false, source:"data", event:"mouseover", currClass:"curr", tab:".tab", content:".tabcon", itemTag:"li", stay:5000, delay:100, mainTimer:null, subTimer:null, index:0}, option || {});
		var tabItem = $(this).find(s.tab).eq(0).find(s.itemTag), contentItem = $(this).find(s.content);
		if (tabItem.length != contentItem.length) {
			return false;
		}
		var reg = s.source.toLowerCase().match(/http:\/\/|\d|\.aspx|\.ascx|\.asp|\.php|\.html\.htm|.shtml|.js|\W/g);
		var init = function (n, tag) {
			s.subTimer = setTimeout(function () {
				hide();
				if (tag) {
					s.index++;
					if (s.index == tabItem.length) {
						s.index = 0;
					}
				} else {
					s.index = n;
				}
				s.type = (tabItem.eq(s.index).attr(s.source) != null) ? "dynamic" : "static";
				show();
			}, s.delay);
		};
		var autoSwitch = function () {
			s.mainTimer = setInterval(function () {
				init(s.index, true);
			}, s.stay);
		};
		var show = function () {
			tabItem.eq(s.index).addClass(s.currClass);
			switch (s.type) {
			  default:
			  case "static":
				var source = "";
				break;
			  case "dynamic":
				var source = (reg == null) ? tabItem.eq(s.index).attr(s.source) : s.source;
				tabItem.eq(s.index).removeAttr(s.source);
				break;
			}
			if (callback) {
				callback(source, contentItem.eq(s.index), s.index);
			}
			contentItem.eq(s.index).show();
		};
		var hide = function () {
			tabItem.eq(s.index).removeClass(s.currClass);
			contentItem.eq(s.index).hide();
		};
		tabItem.each(function (n) {
			$(this).bind(s.event, function () {
				clearTimeout(s.subTimer);
				clearInterval(s.mainTimer);
				init(n, false);
				return false;
			}).bind("mouseleave", function () {
				if (s.auto) {
					autoSwitch();
				} else {
					return;
				}
			});
		});
		if (s.type == "dynamic") {
			init(s.index, false);
		}
		if (s.auto) {
			autoSwitch();
		}
	};
})(jQuery);
(function ($) {
	$.fn.jdMarquee = function (option, callback) {
		if (typeof option == "function") {
			callback = option;
			option = {};
		}
		var s = $.extend({deriction:"up", speed:10, auto:false, width:null, height:null, step:1, control:false, _front:null, _back:null, _stop:null, _continue:null, wrapstyle:"", stay:5000, delay:20, dom:"div>ul>li".split(">"), mainTimer:null, subTimer:null, tag:false, convert:false, btn:null, disabled:"disabled", pos:{ojbect:null, clone:null}}, option || {});
		var object = this.find(s.dom[1]);
		var subObject = this.find(s.dom[2]);
		var clone;
		if (s.deriction == "up" || s.deriction == "down") {
			var height = object.eq(0).outerHeight();
			var step = s.step * subObject.eq(0).outerHeight();
		}
		if (s.deriction == "left" || s.deriction == "right") {
			var width = subObject.length * subObject.eq(0).outerWidth();
			object.css({width:width + "px"});
			var step = s.step * subObject.eq(0).outerWidth();
		}
		var init = function () {
			var wrap = "<div style='position:relative;overflow:hidden;z-index:1;width:" + s.width + "px;height:" + s.height + "px;" + s.wrapstyle + "'></div>";
			object.css({position:"absolute", left:0, top:0}).wrap(wrap);
			s.pos.object = 0;
			clone = object.clone();
			object.after(clone);
			switch (s.deriction) {
			  default:
			  case "up":
				object.css({marginLeft:0, marginTop:0});
				clone.css({marginLeft:0, marginTop:height + "px"});
				s.pos.clone = height;
				break;
			  case "down":
				object.css({marginLeft:0, marginTop:0});
				clone.css({marginLeft:0, marginTop:-height + "px"});
				s.pos.clone = -height;
				break;
			  case "left":
				object.css({marginTop:0, marginLeft:0});
				clone.css({marginTop:0, marginLeft:width + "px"});
				s.pos.clone = width;
				break;
			  case "right":
				object.css({marginTop:0, marginLeft:0});
				clone.css({marginTop:0, marginLeft:-width + "px"});
				s.pos.clone = -width;
				break;
			}
			if (s.auto) {
				initMainTimer();
				object.hover(function () {
					clear(s.mainTimer);
				}, function () {
					initMainTimer();
				});
				clone.hover(function () {
					clear(s.mainTimer);
				}, function () {
					initMainTimer();
				});
			}
			if (callback) {
				callback();
			}
			if (s.control) {
				initControls();
			}
		};
		var initMainTimer = function (delay) {
			clear(s.mainTimer);
			s.stay = delay ? delay : s.stay;
			s.mainTimer = setInterval(function () {
				initSubTimer();
			}, s.stay);
		};
		var initSubTimer = function () {
			clear(s.subTimer);
			s.subTimer = setInterval(function () {
				roll();
			}, s.delay);
		};
		var clear = function (timer) {
			if (timer != null) {
				clearInterval(timer);
			}
		};
		var disControl = function (A) {
			if (A) {
				$(s._front).unbind("click");
				$(s._back).unbind("click");
				$(s._stop).unbind("click");
				$(s._continue).unbind("click");
			} else {
				initControls();
			}
		};
		var initControls = function () {
			if (s._front != null) {
				$(s._front).click(function () {
					$(s._front).addClass(s.disabled);
					disControl(true);
					clear(s.mainTimer);
					s.convert = true;
					s.btn = "front";
					if (!s.auto) {
						s.tag = true;
					}
					convert();
				});
			}
			if (s._back != null) {
				$(s._back).click(function () {
					$(s._back).addClass(s.disabled);
					disControl(true);
					clear(s.mainTimer);
					s.convert = true;
					s.btn = "back";
					if (!s.auto) {
						s.tag = true;
					}
					convert();
				});
			}
			if (s._stop != null) {
				$(s._stop).click(function () {
					clear(s.mainTimer);
				});
			}
			if (s._continue != null) {
				$(s._continue).click(function () {
					initMainTimer();
				});
			}
		};
		var convert = function () {
			if (s.tag && s.convert) {
				s.convert = false;
				if (s.btn == "front") {
					if (s.deriction == "down") {
						s.deriction = "up";
					}
					if (s.deriction == "right") {
						s.deriction = "left";
					}
				}
				if (s.btn == "back") {
					if (s.deriction == "up") {
						s.deriction = "down";
					}
					if (s.deriction == "left") {
						s.deriction = "right";
					}
				}
				if (s.auto) {
					initMainTimer();
				} else {
					initMainTimer(4 * s.delay);
				}
			}
		};
		var setPos = function (y1, y2, x) {
			if (x) {
				clear(s.subTimer);
				s.pos.object = y1;
				s.pos.clone = y2;
				s.tag = true;
			} else {
				s.tag = false;
			}
			if (s.tag) {
				if (s.convert) {
					convert();
				} else {
					if (!s.auto) {
						clear(s.mainTimer);
					}
				}
			}
			if (s.deriction == "up" || s.deriction == "down") {
				object.css({marginTop:y1 + "px"});
				clone.css({marginTop:y2 + "px"});
			}
			if (s.deriction == "left" || s.deriction == "right") {
				object.css({marginLeft:y1 + "px"});
				clone.css({marginLeft:y2 + "px"});
			}
		};
		var roll = function () {
			var y_object = (s.deriction == "up" || s.deriction == "down") ? parseInt(object.get(0).style.marginTop) : parseInt(object.get(0).style.marginLeft);
			var y_clone = (s.deriction == "up" || s.deriction == "down") ? parseInt(clone.get(0).style.marginTop) : parseInt(clone.get(0).style.marginLeft);
			var y_add = Math.max(Math.abs(y_object - s.pos.object), Math.abs(y_clone - s.pos.clone));
			var y_ceil = Math.ceil((step - y_add) / s.speed);
			switch (s.deriction) {
			  case "up":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._front).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object <= -height) {
						y_object = y_clone + height;
						s.pos.object = y_object;
					}
					if (y_clone <= -height) {
						y_clone = y_object + height;
						s.pos.clone = y_clone;
					}
					setPos((y_object - y_ceil), (y_clone - y_ceil));
				}
				break;
			  case "down":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._back).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object >= height) {
						y_object = y_clone - height;
						s.pos.object = y_object;
					}
					if (y_clone >= height) {
						y_clone = y_object - height;
						s.pos.clone = y_clone;
					}
					setPos((y_object + y_ceil), (y_clone + y_ceil));
				}
				break;
			  case "left":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._front).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object <= -width) {
						y_object = y_clone + width;
						s.pos.object = y_object;
					}
					if (y_clone <= -width) {
						y_clone = y_object + width;
						s.pos.clone = y_clone;
					}
					setPos((y_object - y_ceil), (y_clone - y_ceil));
				}
				break;
			  case "right":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._back).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object >= width) {
						y_object = y_clone - width;
						s.pos.object = y_object;
					}
					if (y_clone >= width) {
						y_clone = y_object - width;
						s.pos.clone = y_clone;
					}
					setPos((y_object + y_ceil), (y_clone + y_ceil));
				}
				break;
			}
		};
		if (s.deriction == "up" || s.deriction == "down") {
			if (height >= s.height && height >= s.step) {
				init();
			}
		}
		if (s.deriction == "left" || s.deriction == "right") {
			if (width >= s.width && width >= s.step) {
				init();
			}
		}
	};
})(jQuery);
(function($) {
    $.extend({
        _jsonp: {
            scripts: {},
            //charset: 'utf-8',
            counter: 1,
            head: document.getElementsByTagName("head")[0],
            name: function(callback) {
                var name = '_jsonp_' + (new Date).getTime() + '_' + this.counter;
                this.counter++;
                var cb = function(json) {
                    eval('delete ' + name);
                    callback(json);
                    $._jsonp.head.removeChild($._jsonp.scripts[name]);
                    delete $._jsonp.scripts[name];
                };
                eval(name + ' = cb');
                return name;
            },
            load: function(url, name) {
                var script = document.createElement('script');
                script.type = 'text/javascript';
                script.charset = this.charset;
                script.src = url;
                this.head.appendChild(script);
                this.scripts[name] = script;
            }
        },

        getJSONP: function(url, callback) {
            var name = $._jsonp.name(callback);
            var url = url.replace(/{callback}/, name);
            $._jsonp.load(url, name);
            return this;
        }
    });
})(jQuery);

(function ($) {
	$.fn.jdTab = function (option, callback) {
		if (typeof option == "function") {
			callback = option;
			option = {};
		}
		var s = $.extend({type:"static", auto:false, source:"data", event:"mouseover", currClass:"curr", tab:".tab", content:".tabcon", itemTag:"li", stay:5000, delay:100, mainTimer:null, subTimer:null, index:0}, option || {});
		var tabItem = $(this).find(s.tab).eq(0).find(s.itemTag), contentItem = $(this).find(s.content);
		if (tabItem.length != contentItem.length) {
			return false;
		}
		var reg = s.source.toLowerCase().match(/http:\/\/|\d|\.aspx|\.ascx|\.asp|\.php|\.html\.htm|.shtml|.js|\W/g);
		var init = function (n, tag) {
			s.subTimer = setTimeout(function () {
				hide();
				if (tag) {
					s.index++;
					if (s.index == tabItem.length) {
						s.index = 0;
					}
				} else {
					s.index = n;
				}
				s.type = (tabItem.eq(s.index).attr(s.source) != null) ? "dynamic" : "static";
				show();
			}, s.delay);
		};
		var autoSwitch = function () {
			s.mainTimer = setInterval(function () {
				init(s.index, true);
			}, s.stay);
		};
		var show = function () {
			tabItem.eq(s.index).addClass(s.currClass);
			switch (s.type) {
			  default:
			  case "static":
				var source = "";
				break;
			  case "dynamic":
				var source = (reg == null) ? tabItem.eq(s.index).attr(s.source) : s.source;
				tabItem.eq(s.index).removeAttr(s.source);
				break;
			}
			if (callback) {
				callback(source, contentItem.eq(s.index), s.index);
			}
			contentItem.eq(s.index).show();
		};
		var hide = function () {
			tabItem.eq(s.index).removeClass(s.currClass);
			contentItem.eq(s.index).hide();
		};
		tabItem.each(function (n) {
			$(this).bind(s.event, function () {
				clearTimeout(s.subTimer);
				clearInterval(s.mainTimer);
				init(n, false);
				return false;
			}).bind("mouseleave", function () {
				if (s.auto) {
					autoSwitch();
				} else {
					return;
				}
			});
		});
		if (s.type == "dynamic") {
			init(s.index, false);
		}
		if (s.auto) {
			autoSwitch();
		}
	};
})(jQuery);
(function ($) {	
	$.fn.jdMarquee = function (option, callback) {
		if (typeof option == "function") {
			callback = option;
			option = {};
		}		
		var s = $.extend({deriction:"up", speed:10, auto:false, width:null, height:null, step:1, control:false, _front:null, _back:null, _stop:null, _continue:null, wrapstyle:"", stay:5000, delay:20, dom:"div>ul>li".split(">"), mainTimer:null, subTimer:null, tag:false, convert:false, btn:null, disabled:"disabled", pos:{ojbect:null, clone:null}}, option || {});
		var object = this.find(s.dom[1]);
		var subObject = this.find(s.dom[2]);
		var clone;
		if (s.deriction == "up" || s.deriction == "down") {
			var height = object.eq(0).outerHeight();
			var step = s.step * subObject.eq(0).outerHeight();
		}
		if (s.deriction == "left" || s.deriction == "right") {
			var width = subObject.length * subObject.eq(0).outerWidth();
			object.css({width:width + "px"});
			var step = s.step * subObject.eq(0).outerWidth();
		}
		var init = function () {
			var wrap = "<div style='position:relative;overflow:hidden;z-index:1;width:" + s.width + "px;height:" + s.height + "px;" + s.wrapstyle + "'></div>";
			object.css({position:"absolute", left:0, top:0}).wrap(wrap);
			s.pos.object = 0;
			clone = object.clone();
			object.after(clone);
			switch (s.deriction) {
			  default:
			  case "up":
				object.css({marginLeft:0, marginTop:0});
				clone.css({marginLeft:0, marginTop:height + "px"});
				s.pos.clone = height;
				break;
			  case "down":
				object.css({marginLeft:0, marginTop:0});
				clone.css({marginLeft:0, marginTop:-height + "px"});
				s.pos.clone = -height;
				break;
			  case "left":
				object.css({marginTop:0, marginLeft:0});
				clone.css({marginTop:0, marginLeft:width + "px"});
				s.pos.clone = width;
				break;
			  case "right":
				object.css({marginTop:0, marginLeft:0});
				clone.css({marginTop:0, marginLeft:-width + "px"});
				s.pos.clone = -width;
				break;
			}
			if (s.auto) {
				initMainTimer();
				object.hover(function () {
					clear(s.mainTimer);
				}, function () {
					initMainTimer();
				});
				clone.hover(function () {
					clear(s.mainTimer);
				}, function () {
					initMainTimer();
				});
			}
			if (callback) {
				callback();
			}
			if (s.control) {
				initControls();
			}
		};
		var initMainTimer = function (delay) {
			clear(s.mainTimer);
			s.stay = delay ? delay : s.stay;
			s.mainTimer = setInterval(function () {
				initSubTimer();
			}, s.stay);
		};
		var initSubTimer = function () {
			clear(s.subTimer);
			s.subTimer = setInterval(function () {
				roll();
			}, s.delay);
		};
		var clear = function (timer) {
			if (timer != null) {
				clearInterval(timer);
			}
		};
		var disControl = function (A) {
			if (A) {
				$(s._front).unbind("click");
				$(s._back).unbind("click");
				$(s._stop).unbind("click");
				$(s._continue).unbind("click");
			} else {
				initControls();
			}
		};
		var initControls = function () {
			if (s._front != null) {
				$(s._front).click(function () {
					$(s._front).addClass(s.disabled);
					disControl(true);
					clear(s.mainTimer);
					s.convert = true;
					s.btn = "front";
					if (!s.auto) {
						s.tag = true;
					}
					convert();
				});
			}
			if (s._back != null) {
				$(s._back).click(function () {
					$(s._back).addClass(s.disabled);
					disControl(true);
					clear(s.mainTimer);
					s.convert = true;
					s.btn = "back";
					if (!s.auto) {
						s.tag = true;
					}
					convert();
				});
			}
			if (s._stop != null) {
				$(s._stop).click(function () {
					clear(s.mainTimer);
				});
			}
			if (s._continue != null) {
				$(s._continue).click(function () {
					initMainTimer();
				});
			}
		};
		var convert = function () {
			if (s.tag && s.convert) {
				s.convert = false;
				if (s.btn == "front") {
					if (s.deriction == "down") {
						s.deriction = "up";
					}
					if (s.deriction == "right") {
						s.deriction = "left";
					}
				}
				if (s.btn == "back") {
					if (s.deriction == "up") {
						s.deriction = "down";
					}
					if (s.deriction == "left") {
						s.deriction = "right";
					}
				}
				if (s.auto) {
					initMainTimer();
				} else {
					initMainTimer(4 * s.delay);
				}
			}
		};
		var setPos = function (y1, y2, x) {
			if (x) {
				clear(s.subTimer);
				s.pos.object = y1;
				s.pos.clone = y2;
				s.tag = true;
			} else {
				s.tag = false;
			}
			if (s.tag) {
				if (s.convert) {
					convert();
				} else {
					if (!s.auto) {
						clear(s.mainTimer);
					}
				}
			}
			if (s.deriction == "up" || s.deriction == "down") {
				object.css({marginTop:y1 + "px"});
				clone.css({marginTop:y2 + "px"});
			}
			if (s.deriction == "left" || s.deriction == "right") {
				object.css({marginLeft:y1 + "px"});
				clone.css({marginLeft:y2 + "px"});
			}
		};
		var roll = function () {
			var y_object = (s.deriction == "up" || s.deriction == "down") ? parseInt(object.get(0).style.marginTop) : parseInt(object.get(0).style.marginLeft);
			var y_clone = (s.deriction == "up" || s.deriction == "down") ? parseInt(clone.get(0).style.marginTop) : parseInt(clone.get(0).style.marginLeft);
			var y_add = Math.max(Math.abs(y_object - s.pos.object), Math.abs(y_clone - s.pos.clone));
			var y_ceil = Math.ceil((step - y_add) / s.speed);
			switch (s.deriction) {
			  case "up":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._front).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object <= -height) {
						y_object = y_clone + height;
						s.pos.object = y_object;
					}
					if (y_clone <= -height) {
						y_clone = y_object + height;
						s.pos.clone = y_clone;
					}
					setPos((y_object - y_ceil), (y_clone - y_ceil));
				}
				break;
			  case "down":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._back).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object >= height) {
						y_object = y_clone - height;
						s.pos.object = y_object;
					}
					if (y_clone >= height) {
						y_clone = y_object - height;
						s.pos.clone = y_clone;
					}
					setPos((y_object + y_ceil), (y_clone + y_ceil));
				}
				break;
			  case "left":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._front).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object <= -width) {
						y_object = y_clone + width;
						s.pos.object = y_object;
					}
					if (y_clone <= -width) {
						y_clone = y_object + width;
						s.pos.clone = y_clone;
					}
					setPos((y_object - y_ceil), (y_clone - y_ceil));
				}
				break;
			  case "right":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._back).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object >= width) {
						y_object = y_clone - width;
						s.pos.object = y_object;
					}
					if (y_clone >= width) {
						y_clone = y_object - width;
						s.pos.clone = y_clone;
					}
					setPos((y_object + y_ceil), (y_clone + y_ceil));
				}
				break;
			}
		};
		if (s.deriction == "up" || s.deriction == "down") {
			if (height >= s.height && height >= s.step) {
				init();
			}
		}
		if (s.deriction == "left" || s.deriction == "right") {
			if (width >= s.width && width >= s.step) {
				init();
			}
		}
	};
})(jQuery);

var initScrollY=0;
var proIDs=new Array();

function compare(){
	if($("#compare").get(0)==null){
		$("body").append("<div id='compare'><h6><a title='清空' class='close' onclick='clearCompare()'></a>商品比较</h6><div class='comPro'><ul id='comProlist'></ul><img src='http://img01.509buy.com/compare_15.gif' id='compareImg' onclick='openCompare()'/></div></div>")
		$("#compare").css({position:"absolute",top:"220px",right:"0px"});
		isCoo();
	}
	if($.browser.msie){
		var defaultY=document.documentElement.scrollTop;
		var perceH=0.3*(defaultY-initScrollY);
		if(perceH>0){
			perceH=Math.ceil(perceH);
		}else{
			perceH=Math.floor(perceH);
		}
		$("#compare").get(0).style.top=parseInt($("#compare").get(0).style.top)+perceH+"px";
		initScrollY=initScrollY+perceH;
		setTimeout("compare()",50)
	}else{
		window.onscroll=function(){
			$("#compare").get(0).style.top=parseInt($("#compare").get(0).style.top)+"px";
			$("#compare").get(0).style.position="fixed";
		}
	}
}		
		
function clearCompare(){
	$("#comProlist").empty();
	$("#compare").hide();
	createCookie("compare","");
	proIDs=new Array();
}

function addToCompare(checkobj,checkid,checkProName){
	$("#compare").show();
	$(".comPro").show();
	var proIDsTemp=proIDs.join(".");
	if(proIDsTemp.indexOf(checkid)==-1){
		if(proIDs.length<3){
			proIDs.push(checkid);
			$("#comProlist").append("<li id='check_"+checkid+"'><a title='删除' class='close' onclick='reduceCompare("+checkid+")'></a>"+checkProName+"</li>");
			writeCompare(checkid,checkProName);
		}else{
			alert("对不起，最多可以选择三种商品进行对比！");
		}
	}else{
		alert("对不起，您已经选择此商品！");
		return;
	}
}

function reduceCompare(checkid){
	$("#check_"+checkid).remove();
	$.each(proIDs,function(i,n){
		if(checkid==n){
		proIDs.splice(i,1);}});
		var coo=readCookie("compare");
		var idindexstart=coo.indexOf(checkid);
		var idindexend=coo.indexOf("|||",idindexstart)+3;
		var delStr=coo.substring(idindexstart,idindexend);
		var innerStr=coo.replace(delStr,"")
		createCookie("compare",innerStr);
		if(proIDs.length==0){$(".comPro").hide();
	}
}

function openCompare(){
	switch(proIDs.length){
		case 1:
			alert("对不起，最少选择两种商品进行对比！");
			break;
		case 2:
			alert(proIDs[1]);
			window.open("http://www.509buy.com/product/compare.jspa?goodsId1="+proIDs[0]+"&goodsId2="+proIDs[1]);
			break;
		case 3:
			window.open("http://www.509buy.com/product/compare.jspa?goodsId1="+proIDs[0]+"&goodsId2="+proIDs[1]+"&goodsId3="+proIDs[2]);
			break;
		default:
			alert("请选择2-3件商品进行对比！");
			return;
	}
}

function writeCompare(checkid,checkProName){
	var compareList=readCookie("compare");
	if(compareList==null){
		compareList="";
	}
	compareList+=checkid+"||"+escape(checkProName)+"|||";
	createCookie("compare",compareList);
}

function isCoo(){
	var coo=readCookie("compare");
	if(coo){
		var cootemp=coo.split("|||");
		var compareListTemp="";
		for(var i=0;i<cootemp.length-1;i++){
			compareListTemp+="<li id='check_"+cootemp[i].split("||")[0]+"'><a title='删除' class='close' onclick='reduceCompare("+cootemp[i].split("||")[0]+")'></a>"+unescape(cootemp[i].split("||")[1])+"</li>";
			proIDs.push(cootemp[i].split("||")[0]);
		}
		$("#comProlist").html(compareListTemp);
		$("#compare").show();
		$(".comPro").show();
	}
}

function createCookie(name,value,days,Tdom){
	var Tdom=(Tdom)?Tdom:"/";
	if(days){
		var date=new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires="; expires="+date.toGMTString();
	}else{
		var expires="";
	}
	document.cookie=name+"="+value+expires+"; path="+Tdom;
}
function readCookie(name){
	var nameEQ=name+"=";
	var ca=document.cookie.split(';');
	for(var i=0;i<ca.length;i++){
		var c=ca[i];
		while(c.charAt(0)==' '){c=c.substring(1,c.length);}
		if(c.indexOf(nameEQ)==0){
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}


var timera=null;
var tag=1;
var Stag="stop";
var marqueeHeight;
var maxTop;
var minTop;
var marqueeObj;
var dpps;
var originalObj;
var cloneObj;

function marquee(Mtimes,mH,dP){
	marqueeHeight=mH;
	dpps=dP;
	clearTimeout(timera);
	Mtimes=Mtimes?Mtimes:2;
	marqueeObj=document.getElementById("NewProduct").getElementsByTagName("ul");
	maxTop=-marqueeHeight*Mtimes;
	minTop=marqueeHeight*Mtimes;
	if(marqueeObj.length==1){
		originalObj=marqueeObj[0];
		cloneObj=originalObj.cloneNode(true);
		originalObj.parentNode.appendChild(cloneObj);
		marqueeObj[0].style.top=0+"px";
		marqueeObj[1].style.top=minTop+"px";
	}
	if((tag==0&&marqueeObj[0].offsetTop==0)||marqueeObj[0].offsetTop/tag==-marqueeHeight){
		tag++;
		Stag="stop";
		clearTimeout(timera);
		timera=setTimeout("marquee("+Mtimes+","+mH+","+dP+")",5000);
	}else{
		Stag="continue";
		marqueeObj[0].style.top=marqueeObj[0].offsetTop-dpps+"px"
		marqueeObj[1].style.top=marqueeObj[1].offsetTop-dpps+"px"
		if(marqueeObj[0].offsetTop==maxTop){
			marqueeObj[0].style.top=minTop+"px";
			tag=-Mtimes;
		}
		if(marqueeObj[1].offsetTop==maxTop){
			marqueeObj[1].style.top=minTop+"px";
		}
		timera=setTimeout("marquee("+Mtimes+","+mH+","+dP+")",30)
	}
}
		
function SwitchTab(IDprefix,order,TagAmount,status){
	switch(status){
		case "S1":
			var TagObj=OOO(IDprefix+"Option","li");
			var TagArr=new Array();
			for(var i=0;i<TagObj.length;i++){
				TagArr.push(TagObj[i].id.split("_Option_")[1]);
			}
			for(var i=0;i<TagArr.length;i++){
				OOO(IDprefix+"Option_"+TagArr[i]).className=(TagArr[i]==order)?"curr":"";
				OOO(IDprefix+"Con_"+TagArr[i]).style.display=(TagArr[i]==order)?"":"none";
			}
			break;
		default:
			for(var i=0;i<TagAmount;i++){
				OOO(IDprefix+"Option_"+i).className=(i==order)?"curr":"";
				OOO(IDprefix+"Con_"+i).className=(i==order)?"default":"disNone";
			}
		return;
	}
}

function showSort(obj){
	$("#"+obj+" h3").click(function(){
		this.className=(this.className=="open")?"":"open";		
		$("#EFF_ul_"+this.id.substr(7)).get(0).className=(this.className=="open")?"open":"";
	});
}

function OOO(obj,ele){
	if(obj&&!ele){
		return document.getElementById(obj);
	}else if(obj&&ele){
		return document.getElementById(obj).getElementsByTagName(ele);
	}else{
		return false;
	}
}

var Dtimer=null;
var Dtimer2=null;
var Mdisplay=false;
var hideDiv;
var Container;
var button;
var jqShowObj;
var offset;
var height;
var width;
var btnHeight;
var btnWidth;

function initDMenu(obj,showobj,Dtimeout,Dspeed){
	hideDiv=$("<div style='z-index:10000;'></div>");
	Container=$("<div id=\"Container\"></div>");
	hideDiv.append(Container);
	button=$(obj);
	jqShowObj=$(showobj);
	offset=button.offset();
	height=jqShowObj.height();
	width=jqShowObj.width();
	btnHeight=button.height();
	btnWidth=button.width();
	$(document.body).prepend(hideDiv);

}
function showDMenu(){
	if(Mdisplay==true){
		return false;
	}else{
		Mdisplay=true;
		Container.css({margin:"0 auto",width:btnWidth+"px",height:btnHeight+"px"});
		hideDiv.css({position:"absolute",top:offset.top+16+"px",left:button.offset().left-35+"px",height:height+"px",width:width+"px"}).show();
		Container.css({border:"1px solid #666666"});
		Container.animate({marginTop:10,height:height+4,width:width+4,opacity:'100'},100,function(){
			jqShowObj.show();
			Container.append(jqShowObj);
			Container.css({border:"0px"});
			jqShowObj.mouseover(function(){
			clearTimeout(Dtimer);clearTimeout(Dtimer2);}).mouseout(function(){
				hideDMenu();
			});
		});
	}
}

function hideDMenu(){
	clearTimeout(Dtimer);
	clearTimeout(Dtimer2);
	Dtimer=setTimeout(function(){
	Container.css({border:"1px solid #666666"});
	$(document.body).prepend(jqShowObj);
	jqShowObj.hide();
	Container.empty();
	Container.animate({width:btnWidth,height:btnHeight,marginTop:'0',opacity:'0'},100,function(){
		Container.hide();
		hideDiv.hide();
		Mdisplay=false;});},100);
}

var display=false;
var display2=false;
var display3=false;
function showTip(proobj){
	var TipDivW=$(proobj).width();
	var TipDivH=$(proobj).height();
	var TipDiv=$("<div id='c01tip' style='z-index:20000;position:absolute;width:"+eval(TipDivW+5)+"px;height:"+eval(TipDivH+5)+"px;'><div style='position:absolute;margin:5px 0 0 5px;width:"+TipDivW+"px;height:"+TipDivH+"px;background:#BCBEC0;z-index:20001;'></div></div>")
	if(display==false){
		TipDiv.append($(proobj));
		$(document.body).prepend(TipDiv);
		$(proobj).show();
		display=true;}else{
		$("#c01tip").show();
	}
	$("#c01tip").css({top:parseInt(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("#c01tip").height())/2 )+"px",left:(document.documentElement.clientWidth-$("#c01tip").width())/2+"px"})
	$("#Tip_viewCart,#Tip_continue,.Tip_Close").click(function(){
		$("#c01tip").fadeOut();
	});
}

function showTip2(proobj){
	var TipDivW=$(proobj).width();
	var TipDivH=$(proobj).height();
	var TipDiv=$("<div id='c02tip' style='z-index:20000;position:absolute;width:"+eval(TipDivW+5)+"px;height:"+eval(TipDivH+5)+"px;'><div style='position:absolute;margin:5px 0 0 5px;width:"+TipDivW+"px;height:"+TipDivH+"px;background:#BCBEC0;z-index:20001;'></div></div>")
	if(display2==false){
		TipDiv.append($(proobj));
		$(document.body).prepend(TipDiv);
		$(proobj).show();
		display2=true;
	}else{
		$("#c02tip").show();
	}
	$("#c02tip").css({top:parseInt(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("#c02tip").height())/2 )+"px",left:(document.documentElement.clientWidth-$("#c02tip").width())/2+"px"})
	$(".Tip_Close").click(function(){
		$("#c02tip").fadeOut();});
	timer_5=setTimeout("showTime()",1000);
}

function showTip3(proobj){
	var TipDivW=$(proobj).width();
	var TipDivH=$(proobj).height();
	var TipDiv=$("<div id='c03tip' style='z-index:20000;position:absolute;width:"+eval(TipDivW+5)+"px;height:"+eval(TipDivH+5)+"px;'><div style='position:absolute;margin:5px 0 0 5px;width:"+TipDivW+"px;height:"+TipDivH+"px;background:#BCBEC0;z-index:20001;'></div></div>")
	if(display3==false){
		TipDiv.append($(proobj));
		$(document.body).prepend(TipDiv);
		$(proobj).show();
		display3=true;}
	else{
		$("#c03tip").show();
	}
	$("#c03tip").css({top:parseInt(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("#c03tip").height())/2 )+"px",left:(document.documentElement.clientWidth-$("#c03tip").width())/2+"px"})
	$("#Tip_notice,.Tip_Close").click(function(){
	$("#c03tip").fadeOut();});
}

function showTime(){
	clearTimeout(timer_5);
	var overtime=parseInt($("#timer_5").html())-1;
	if(overtime==0){
		$("#c02tip").fadeOut();
		return;
	}
	$("#timer_5").html(overtime);
	timer_5=setTimeout("showTime()",1000)
}

function showNotice(obj,noticetype,offX,offY){
	var noticeX=$(obj).offset().left;
	var noticeT=$(obj).offset().top;
	var noticeW=$(obj).width();
	var noticeH=$(obj).height();
	var offX=(!offX)?60:offX;
	var offY=(!offY)?2:offY;
	if($("#"+noticetype).get(0)==null){
		var newNotice=document.createElement("span");
		$(newNotice).attr("id",noticetype)
		$(newNotice).css({position:"absolute",top:noticeT+noticeH+offY+"px",left:noticeX-offX+"px",background:"#FFF9D9","z-index":"50000",padding:"5px",border:"1px solid #F88E00"});
		$(document.body).prepend($(newNotice));
		$(newNotice).html(obj.name);}else{
		$("#"+noticetype).css({top:noticeT+noticeH+offY+"px",left:noticeX-offX+"px"});
		$("#"+noticetype).show();
	}
}

function opennewWin(url,newwinT,newwinW,newwinH){
	window.open(url,newwinT,"width="+newwinW+",height="+newwinH+",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
}

function defineW(i){
	if($("#suitP"+i).width()>$("#suitPWrap"+i).width()){
	$("#suitPWrap"+i).get(0).style.overflowX="scroll";}
	var suitW=(Swidth>=1280)?708:472;
	if($("#suitP"+i).width()<suitW){
		$("#suitPWrap"+i).get(0).style.width=$("#suitP"+i).width()+"px";
	}
}

function buyFitting(obj){
	var newHref=obj.href;
	obj.getElementsByTagName("img")[0].src="http://img01.509buy.com/appendToCart_4.gif";
	obj.parentNode.innerHTML=obj.innerHTML;
	if($.browser.msie){
		window.open(newHref);
		return false;
	}
}

function gotop(){
	window.onscroll=function(){
		if(document.documentElement.scrollTop==0&&document.body.scrollTop==0){
			$("#gotop").get(0).style.display="none";
		}else{
			$("#gotop").get(0).style.display="";
			if($.browser.msie&&$.browser.version<"7.0"){
				$("#gotop").get(0).style.position="absolute";
				$("#gotop").get(0).style.top=getPosition(180);
			}
		}
	}
}

function getPosition(currObjH){
	return document.documentElement.scrollTop+document.documentElement.clientHeight-currObjH+"px";
}

$(function(){
	$("#My360buy,#ServiceCenter").mouseover(function(){
		this.className="dis";}).bind("mouseleave",function(){
		this.className="";})
		$("#Nav li").click(function(){
			$(this).siblings().removeClass("curr");
			this.className="curr";});
		initDMenu("#CartSwitch_wrap","#MyCart");
		$("#CartSwitch_wrap").mouseover(function(){
			clearTimeout(Dtimer);
			height=$("#MyCart").height();
			Dtimer=setTimeout("showDMenu()",100);}).bind("mouseleave",function(){
			clearTimeout(Dtimer);
			if(Mdisplay==true){
				Dtimer2=setTimeout("hideDMenu()",100);
			}
		});
	})
	
function ResumeError(){
	return true;
}

window.onerror=ResumeError;

if($.browser.msie&&$.browser.version<"7.0"){
	try{
		document.execCommand("BackgroundImageCache",false,true);
	}catch(err){
	}
}

