/* slidemove */
(function(a){a.fn.slidemove=function(d){var c={_self:this,_intervalId:null};d=a.extend(c,d);a.fn.slidemove._options=d;var h=this;var b=this.find("ul:first");b.addClass("panel");this.append('<ul class="tab"></ul>');var g=this.find(".tab");var f=this.offset();var e=g.height();g.css({left:f.left,top:f.top+this.height()-e});a.each(b.children("li"),function(k,m){var j=a(m).children("a");g.append('<li name="TAB-'+k+'" class="ip-slidemove-tab">'+j.attr("title")+"</li>");var l=h.find("li[name=TAB-"+k+"]")});a.fn.slidemove._select(0);a.fn.slidemove._beginInterval();g.children("li").bind("mouseover",function(j){var l=a(this);var k=l.attr("name").match(/TAB-(\d+)/i);var i=parseInt(k[1]);a.fn.slidemove._endInterval();a.fn.slidemove._select(i)}).bind("mouseout",function(i){a.fn.slidemove._beginInterval()}).bind("click",function(k){var m=a(this);var l=m.attr("name").match(/TAB-(\d+)/i);var j=parseInt(l[1]);var i=b.find("li:eq("+j+")").children("a").attr("href");window.open(i)})};a.fn.slidemove._select=function(c){var g=a.fn.slidemove._options._self;var b=g.find("ul:first");a.each(b.children("li"),function(j,k){var h=a(k);if(h.css("display")!="none"){h.hide()}});var f=b.find("li:eq("+c+")");f.fadeIn("slow");var d=g.find("ul:last");a.each(d.children("li"),function(j,k){var h=a(k);h.attr("style","");if(a.containClass(h,"ip-slidemove-tab-a")){h.removeClass("ip-slidemove-tab-a");h.addClass("ip-slidemove-tab")}if(a.containClass(h,"actived")){h.removeClass("actived");h.addClass("normal")}});var e=d.find("li:eq("+c+")");e.addClass("ip-slidemove-tab-a actived")};a.fn.slidemove._beginInterval=function(){a.fn.slidemove._options._intervalId=setInterval(function(){var e=a.fn.slidemove._options._self;var d=e.find("ul:last").find("li[class*=actived]").attr("name").match(/TAB-(\d+)/i);var b=parseInt(d[1]);var c=e.find("ul:first li").size();if(b>(c-2)){a.fn.slidemove._select(0)}else{a.fn.slidemove._select(b+1)}},5000)};a.fn.slidemove._endInterval=function(){clearInterval(a.fn.slidemove._options._intervalId)};a.fn.slidemove._options=null})(jQuery);

/* 邮件订阅 */
function addsubscribe(o)
{
	var $o = $(o);
	var email = $o.find('input[name=email]').val();
	if (!$.isEmail(email)) {
		alert('输入的邮件地址格式错误！\n');
		return false;
	}

	$.ajax({
		url: 'user.php?act=email_list&job=add&email=' + email,
		type: 'GET',
		async: true,
		dataType: 'text',
		success: function(result, status) {
			alert(result);
		}
	});
}

/* 获取目录册 */
function getindexbook(o)
{
	window.open('uploads/products_content.exe');
}

/* execute */
$(function() {
	$('.slidemove').slidemove();
});

/* 热销产品 */
$(function() {
	$('.f-hotsale-section .head .tabs a').bind('mouseover', function() {
		var $this = $(this);
		var id = parseInt($this.text());
		
		$('a[name*=HOTS]').css({ display: 'none' });
		$('a[name*=HOTS]').removeClass('c');
		$('a[name=HOTS' + id + ']').fadeIn('normal');
		$('a[name=HOTS' + id + ']').addClass('c');

		$('.f-hotsale-section .head .tabs a').removeClass('c');
		$this.addClass('c');
	});
	$('.f-hotsale-section .head .tabs a:first').mouseover(); /* 触发第一次 */

	setInterval(function() {
		var a = $('.f-hotsale-section .head .tabs a.c');
		var id = a.attr('href').match(/#(\d+)/)[1];
		if (id >= $('.f-hotsale-section .head .tabs a').size()) {
			id = 1;
			$('.f-hotsale-section .head .tabs').find('a[href=#' + id + ']').mouseover();
		} else {
			id++;
			$('.f-hotsale-section .head .tabs').find('a[href=#' + id + ']').mouseover();
		}
	}, 3500);

	$('.f-hotsale-section .section2 .tabs a').bind('mouseover', function() {
		var $this = $(this);
		var matches = $this.find('img').attr('src').match(/no(\d+)(-?a?)/i);
		var id = parseInt(matches[1]);

		$.each($('.f-hotsale-section .section2 .tabs img'), function(n, val) {
			var $img = $(val);
			var img_id = $img.attr('src').match(/no(\d+)(-?a?)/i)[1];
			$img.attr({ src:'common/image/no' + img_id + '.png' });
			
			$('.f-hotsale-section .section2 .tabs a').removeClass('c');
			$this.addClass('c');
		});
		$this.find('img').attr({ src:'common/image/no' + id + '-a.png' });

		/* 换内容 */
		var cid = parseInt($this.attr('href').match(/#(\d+)/i)[1]);
		$('a[name*=HOTM_]').removeClass('c');
		$('a[name=HOTM_' + cid + ']').addClass('c');

		$('div[id*=HOTC_@]').removeClass('c');
		$('div[id=HOTC_@' + cid + ']').addClass('c');
	});

	setInterval(function() {
		var a = $('.f-hotsale-section .section2 .tabs a.c');
		var id = a.attr('href').match(/#(\d+)/)[1];
		if (id >= $('.f-hotsale-section .section2 .tabs a').size()) {
			id = 1;
			$('.f-hotsale-section .section2 .tabs').find('a[href=#' + id + ']').mouseover();
		} else {
			id++;
			$('.f-hotsale-section .section2 .tabs').find('a[href=#' + id + ']').mouseover();
		}
	}, 5000);

});

