$(function(){
	$('.lavaLamp').lavaLamp({fx: 'swing', speed: 333});
	$("#wapp .btn").click(function(){
		gid = $(this).attr('id');
		$("#wapp li div").attr('class','btn');
		$(this).attr('class','btn btn_on');
		$("#wapp .right ul").hide();
		$("#r"+gid).fadeIn();
		return false;
	});
	$('.newlist .fontset .small').click(function(){
		$(this).css('color','#0B3B8C');
		$('.newlist .fontset .big').css('color','#7E7E7E');
		$('.newlist .text *').css('font-size','14px');
	});
	$('.newlist .fontset .big').click(function(){
		$(this).css('color','#0B3B8C');
		$('.newlist .fontset .small').css('color','#7E7E7E');
		$('.newlist .text *').css('font-size','16px');
	});
	$('#login_type').change(function(){
		if($(this).val()==2){
			$('#btn_smscode').show();
		}else{
			$('#btn_smscode').hide();
		}
	});
	$('#btn_smscode').click(function(){
		if(tel = $('#username').val()){
			loading('正在发送短信，请稍候......');
			$.ajax({
				type:"GET",
				url:"/UserCenter/login.php?act=smscode",
				data:"username="+tel,
				dataType:'json',
				success:function(data){
					if (data.cid == 1) {
						PushMsg(data.msg, '#password');
					}else{
						PushMsg(data.msg, '#username');
					}
				}
			});
		}else{
			PushMsg('对不起，请输入手机号！','#username');
		}
	});
	$('#UserNav a').click(function(){
		$('#UserNav a').attr('class','');
		$(this).attr('class','on');
		id = $(this).attr('alt');
		$('.UserEdit').hide();
		$('#'+id).show(300);
		if ($(this).attr('href') == '#') {
			return false;
		}
	});
});

function backmenu(id,title,url,height){
	height = height?height:0;
	var backtophtml = '<div id="'+id+'" title="'+title+'">'+title+'</div>';
	$(backtophtml).appendTo($('body'));
	$('#'+id).click(function(){
		if (url == ''||url==undefined) {
			$('body,html').animate({scrollTop: 0}, 800);
			return false;
		}else{
			if (url == 'back') {
				history.go(-1);
			}
			else if(url=='index'){
				window.location.href = '/';
			}else{
				window.location.href = url;
			}
		}
	});
	if(url!=''&&url!=undefined){
		$('#'+id).css('display','block');
	}
	$(window).bind("scroll", function(){
		var st = $(document).scrollTop(), winh = $(window).height();
		if (!window.XMLHttpRequest) {
	        $('#'+id).css("top", st + winh - height - 166);
	    }
		if (url == '' || url == undefined) {
			if ($(this).scrollTop() > 100) {
				$('#' + id).fadeIn();
			}
			else {
				$('#' + id).fadeOut();
			}
		}
	});
}

