var isIE6=false;
document.write("<!--[if lte IE 6]><script>isIE6=true;</scr"+"ipt><![endif]-->");

$(function(){
	//菜单效果
	$("#nav").lavaLamp({
		fx: "backout", //缓动类型
		speed: 700 //缓动时间
	});
	//关闭登录提示层
	$('#tips_close').click(function(){$('.login_tips').remove();})
	
	//首页diy入口按钮
	$('.diy_link').hover(function(){
		$(this).animate({top:30},300);
	},function(){
		$(this).animate({top:35},300);
	})
	//列表图片动画
	var $portfolioItem = $('.item');
	if(!$.browser.msie){
		$('.zoom-icon, .more-icon').css('opacity','0');
	}
	//鼠标悬停动画
	$portfolioItem.hover(function(){
		$(this).find('.scene_new').stop(true, true).animate({top: -10}, 500);
		$(this).find('.item-image').stop(true, true).animate({opacity: 0.8, top: -10}, 500).find('img.portfolio').stop(true, true).animate({opacity: 0.7},500);
		if($.browser.msie){
			$(this).find('.zoom-icon').stop(true, true).animate({left: 43},400).show();
			$(this).find('.more-icon').stop(true, true).animate({left: 110},400).show();
			
		}else{
			$(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: 43},400);
			$(this).find('.more-icon').stop(true, true).animate({opacity: 1, left: 110},400);
		}
		
	}, function(){
		if($.browser.msie){
			$(this).find('.zoom-icon').stop(true, true).animate({left: 31},400).hide();
			$(this).find('.more-icon').stop(true, true).animate({left: 128},400).hide();
		}else{
			$(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: 31},400);
			$(this).find('.more-icon').stop(true, true).animate({opacity: 0, left: 128},400);
		}
		$(this).find('.scene_new').stop(true, true).animate({top:0}, 500);
		$(this).find('.item-image').stop(true, true).animate({opacity: 1, top: 0}, 500).find('img.portfolio').stop(true, true).animate({opacity: 1},500);
	});
		
	//搜索栏
	/*function format(row) {
		return '<img src="'+MATERIAL_UPLOAD_DIR+'thumb/' + row[2] + '/20/' + row[0] + '.jpg" />'+ row[1];
	}
	$("#q").autocomplete(
		_APP_+'/Material/query', {
		multiple: true,
		dataType: "json",
		parse: function(data) {
			return $.map(data, function(row) {
				return {
					data: row,
					value: row[1],
					result: row[1]
				}
			});
		},
		formatItem: function(item) {
			return format(item);
		}
	}).result(function(e, item) {
		$("#q").append("<p>selected " + format(item) + "</p>");
	});*/
	$("#q").autocomplete(
		_APP_+'/Material/query', {
		max:10,
        width:160,
        scroll: false,
        formatItem:function(row){
            return row[1];
        },
        extraParams:{ajax:1}
    }).result(function(event, data, formatted) {
        $('#q').val(data[1]);
        window.location.href = _APP_+'/Material/detail/id_material/'+data[0];
    });
	$("#query_btn").click(function(){
		window.location.href = _APP_+'/Material/query/q/'+$("#q").val();
	});
	//头像上传
	$(".cont_title .ctitle_head").hover(function(){
		$(".upload_photo").show();
	},function(){
		$(".upload_photo").hide();
	})
	/***	列表	·	快速查看显示 start	***/
    $(".list_goods ul li,.cont_info ul li").hover(function(){
		 $(this).find(".hand_lens").show();
	 },function(){
		 $(this).find(".hand_lens").hide();
	 })
	
	 //弹出框显示
	 $('.hand_lens').click(function(){
		var left=$(this).parent('li').find('.pic').offset().left;
		var top=$(this).parent('li').find('.pic').offset().top;
		var rightpic=left+(parseInt("143"));
		var leftpic=left-(parseInt("320"));
		var w_w=$(window).width();
		$('.big_pic').hide();
		if(isIE6){
		  rightpic=left-60;
		}
		if(w_w>rightpic+320)
		{
		  $(this).parent('li').find('.big_pic').css("left",rightpic+"px").css("top",top+"px").fadeIn();
		}else{
		  $(this).parent('li').find('.big_pic').css("left",leftpic+"px").css("top",top+"px").fadeIn();
		}
	})
	//关掉弹出框
	$(".btn_closepic").click(function(){
		  $(".big_pic").hide();
	})
	/***	列表	·	快速查看显示 end	***/
});

//api中登录面板调用的函数
function panel_check_logfrm() {
    var k = $.trim($("#panel_account").val());
    var g = $.trim($("#panel_passwd").val());
    if (k == "") {
    	$("#panel_tips").addClass('error').html("账号不能为空");
    }else if (g == "") {
    	$("#panel_tips").addClass('error').html("密码不能为空");
    } else if (g.length < 6) {
    	$("#panel_tips").addClass('error').html("密码错误");
    }
    else
    {
		//登录
    	$.ajax({
            url: _APP_+"/Index/doLogin",
            type: "POST",
            data: {
    			login_account: k,
                login_passwd: g
            },
            dataType:"json",
            success: function(obj) {
                if (obj.status == 1){
                    $("#panel_tips").removeClass('error').addClass('success').html(obj.info);
                    window.location.href = $("#panel_back_url").val();
                }else
                	$("#panel_tips").addClass('error').html(obj.info);
            }
        })
    }
    return false;
}


