$(function(){
	//弹出登录窗口
	/*
	var t9 = new PopupLayer({trigger:"#ele9",popupBlk:"#blk9",closeBtn:"#close9",useOverlay:true,useFx:true,
		offsets:{
			x:0,
			y:-41
		}
	});
	t9.doEffects = function(way){
		if(way == "open"){
			this.popupLayer.css({opacity:0.3}).show(5,function(){
				this.popupLayer.animate({
					left:($(document).width() - this.popupLayer.width())/2,
					top:(document.documentElement.clientHeight - this.popupLayer.height())/2 + $(document).scrollTop(),
					opacity:0.8
				},5,function(){this.popupLayer.css("opacity",1)}.binding(this));
			}.binding(this));
		}
		else{
			this.popupLayer.animate({
				left:this.trigger.offset().left,
				top:this.trigger.offset().top,
				opacity:0.8
			},{duration:5,complete:function(){this.popupLayer.css("opacity",1);this.popupLayer.hide()}.binding(this)});
		}
	}*/
	
	//添加小区印象
	
	function addimpression(impression,housingid){
		if(impression=='' || impression=='请输入评语(4-6字)'){
			alert('请输入对该小区的印象');
			return false;
		}
		if(housingid==''){
			alert('系统错误');
			return false;
		}else{
			$.ajax({
				type:'POST',
				url:'activepost.php',
				data:'act=addimpression&impression='+encodeURIComponent(impression)+'&housing_id='+housing_id,
				success:function(result){
					 if(result.indexOf('no')!=-1){
						alert('对该小区评价失败');
						return false;
					}
					else{
						alert('对该小区评价成功');	
						$('#impression').val('');
						window.top.location.reload();
					}
				}
			});
		}
	}
	
	var housing_id = $('#housingid').val();
	//输入自定义文字添加到印象
	$('#pingjiabuttonid').bind('click',function(){
		var impression = $('#impression').val();
		addimpression(impression,housing_id);
	});
	
	//点击已有印象添加
	$("a[class^='yx']").bind('click',function(){
		addimpression($(this).text(),housing_id);
	});
	
	$('.resizeimg').resizeIMG({"height":"154","width":"154"});
});
