// JavaScript Document
$(function(){
	//alert('x');
	$nav();
	$banner();
	$reg();

});

function $nav(){
	if ($('#nav a.on').length == 0) {
		$('#nav a').first().addClass('on');
	}
	//移动小三角到当前页高亮栏目
	var obj = $('#nav li a.on');
	var x = obj.offset().left - obj.parent().parent().offset().left + obj.width()/2 +9;
	$('#nav ul').css('background-position',x+"px bottom");
	//小三角的滑动
	var dt;
	$('#nav li').children('a').hover(function(){
		clearTimeout(dt);
		var curobj = $(this);
		var curx = curobj.offset().left - curobj.parent().parent().offset().left + curobj.width()/2 +9;
		$('#nav ul').animate({
			'background-position': ""+curx+"px bottom"
		},200);
	},function(){
		dt = setTimeout(function(){
			$('#nav ul').animate({
				'background-position': ""+x+"px bottom"
			},200);
		},350);
	});
	//鼠标悬停二级菜单时小三角的滑动
	$('#nav .subnav').hover(function(){
		clearTimeout(dt);
		var curobj = $(this).prev();
		var curx = curobj.offset().left - curobj.parent().parent().offset().left + curobj.width()/2 +9;
		$('#nav ul').animate({
			'background-position': ""+curx+"px bottom"
		},200);
	},function(){
		dt = setTimeout(function(){
			$('#nav ul').animate({
				'background-position': ""+x+"px bottom"
			},200);
		},350);
	});

}

function $banner(){
	$('#banner .cont').kxbdSuperMarquee({
		time:3,
		distance:950,
		btnGo:{left:'.arr_r',right:'.arr_l'},
		direction:'left',
		navId:'.ctrl'
	});
}

function $reg(){
	$('#reg input').click(function(){
		if($(this).attr("checked")==true) {
			$('#reg button').removeAttr('disabled');
		}else {
			$('#reg button').attr('disabled','disabled');
		}
	});
}
