document.charset="UTF-8"
// JavaScript Document 消息展示js

var ope_rep={//notice展示部分 处理留言的js操作
	saveRaply : function(txt_id){
		if(rootour.user_id==null)
		{//先判断时候登陆
		    enterrep();
			return;//如果未登录,退出
		}
		var reply_txt=$("#"+txt_id).val();
		if(reply_txt.length==0){
			message.alert("请输入留言内容!");
			$("#"+txt_id).get(0).focus();
			return;
		}
		var notice_id=$("#"+txt_id).attr("name");
		
		ope_rep.doReply(reply_txt,notice_id,txt_id);
	},//Ajax添加留言
	saveRaplyS : function(){//notice.jsp 添加
                                                
		if(login.init())//先判断时候登陆
		   return;
		var reply_txt=$("#replay_txt").val();
		var notice_id=$("#notice_id").val();
		
		ope_rep.doReply(reply_txt,notice_id,null);
	},//Ajax添加留言
	showReply : function(reply_txt,notice_id,txt_id){
		//留言层上数据更改
		var innerStr='<li>'+ope_rep.getIsExImg()+
					'<div class="flow_left martop2 line_height2">'+
						'<p class="edit_cont"><span><a class="blue_link" href="/profile/'+rootour.user_id+'-1.html">'+rootour.user_name+'</a></span>&nbsp;:<a href="#">'+reply_txt+'</a></p>'+
					'</div>'+
					'<div class="clear_flow botline marleri"/></li>';
		$("#reply_ul_"+notice_id).prepend(innerStr);
		
		var rep_ct_str=$("#rep_ct_"+notice_id).text();
		var rep_ct=1;
		if(rep_ct_str!="")
			rep_ct=parseInt(rep_ct_str)+1;//获得评论的数量
		var innerHTML='<font id="rep_ct_'+notice_id+'">'+rep_ct+'</font>条留言，<a class="blue_link" href="/notice.jsp?notice_id='+notice_id+'">点击查看</a>';
		$("#rep_alr_"+notice_id).html(innerHTML);
		//留言(0)更改
		$("#rep_ct_btm_"+notice_id).html(rep_ct);
		
		$("#"+txt_id).val("");
	},//Ajax添加留言展示
	
	showReplyS : function(reply_txt,notice_id,txt_id){
		//留言层上数据更改
		var innerStr='<li>'+
					'<div class="xuline-x2 heightauto_100">'+ope_rep.getIsExImgS()+
					'	<div class="martop2 edit_con02">'+
					'		<div class="line_height2">'+
					'			<span class="flow_left s14">'+
					'			<a href="/profile/'+rootour.user_id+'-1.html" class="s14blue_link">'+rootour.user_name+'</a>'+
					'			<a class="s14grey_link">: </a>'+reply_txt+
					'			</span>'+
					'		</div>'+
					'		<div class="line_height clear_flow f_grey">	'+
					'			<span class="flow_left marright_20">1分钟内</span>'+
					'		</div>'+
					'		<div class="clear_flow"></div>'+
					'	</div>'+
					'</div></li>';
		$("#reply_ul").prepend(innerStr);
		
		var rep_ct_str=$("#rep_ct").text();
		var rep_ct=1;
		if(rep_ct_str!="")
			rep_ct=parseInt(rep_ct_str)+1;//获得评论的数量
		$("#rep_ct").text(rep_ct);
		
		$("#replay_txt").val("");
		
	},//Ajax添加留言展示
	
	getIsExImg : function(){
		return '<div class="flow_left marginall_5_10"><img class="img-side img_size_30" src="'+rootour.user_img+'" /></div>';
	},
	getIsExImgS : function(){
	
		return '<div class="flow_left marginall_20 dis_inline"><img class="img-side img_size" src="'+rootour.user_img+'" /></div>';
	},
	doReply : function(reply_txt,notice_id,txt_id){
	    message.info("正在提交请稍候.......");
		var rdata="reply_txt="+reply_txt+"&act=reply"+"&notice_id="+notice_id;
		$.ajax({type:"POST", 
	        url:"/notice", 
	        data:rdata, 
	        dataType:"text",
	        success:function (data) {
	        	if(data=="true"){
	        		message.close();
	        		message.alert("您的留言已经发布 !");
	        		if(txt_id!=null)//列表中留言
	        			ope_rep.showReply(reply_txt,notice_id,txt_id);
	        		else{//消息页面留言
	        			ope_rep.showReplyS(reply_txt,notice_id);
	        		}
	        	}
	        }
		});
	}
}
//message.alert('<input type="text" value="上方">');
//document.getElementById("on").disabled=false; 
var noticeOperate={//NOTICE展示，鼠标焦点显示QQ群发、编辑
	show : function(notice_id){
		$("#noticeOpe_"+notice_id).show();
	},
	hide : function(notice_id){
		$("#noticeOpe_"+notice_id).hide();
	}
}
var notcieBG={//notice获得焦点时,背景色变换
	init : function(){
		
	},
	reshowBG : function(current){
		notcieBG.hintAll();
		$(current).addClass("currentBG");
	},
	hintAll : function(){
		$(".currentBG").removeClass("currentBG");
	}
}
var exUser={//显示用户基本信息的弹出层
	user_id : null,
	notice_id : null,
	json : null,
	html : null,//得到用户说明html
	current : null,//触发的用户头像
	headImg : null,
	isLock : false,
	init : function(user_id,notice_id,current){
		exUser.user_id=user_id;
		exUser.notice_id=notice_id;
		//1、获得鼠标位置，判断显示位置;2、显示用户层;3、用userid获取user和user附属表；4、将数据显示
		if($("#userDetail_"+exUser.notice_id).attr("isLoad")){//加载过后,下次直接显示,不再读取后台
			$("#userDetail_"+exUser.notice_id).show();
		}
		else if(!exUser.isLock){//是否有锁
			exUser.current=current;
			//exUser.load();//头像变为loading状态
			exUser.ajax();
		}
	},
	hideAll : function(){
		$(".personal_information").each(function(){
			$(this).hide();
		});	
	},
	load : function(){
		$(exUser.current).addClass("loadHeadImg");
		exUser.headImg=$(exUser.current).attr("src");
		///$(exUser.current).attr("src","/images/homepage/loading.gif");
	},
	removeLoad : function(){
		$(exUser.current).removeClass("loadHeadImg");
		//$(exUser.current).attr("src",exUser.headImg);
	},
	ajax : function(){
		exUser.isLock=true;
		$.ajax({type:"POST", 
	        url:"/noticeExhibit", 
	        data:"act=userInfo&user_id="+exUser.user_id, 
	        dataType:"json",
	        success:function (data) {
	        	exUser.json=data;
	        	exUser.show();
	        	exUser.isLock=false;
	        }
		});
	},
	show : function(){
		exUser.getHtml();
		$("#userDetail_"+exUser.notice_id).html(exUser.html);
		$("#userDetail_"+exUser.notice_id).show();
		$("#userDetail_"+exUser.notice_id).attr("isLoad",true);//加载过后,下次直接显示,不再读取后台
		//exUser.removeLoad();
	},
	getHtml : function(){
		exUser.html=""+
		'<div class="flow_left marginall2 dis_inline img_size">'+
		'	<a href="/profile/'+exUser.json.user_id+'-1.html">'+
		'	<img class="img-side img_size" src="'+exUser.json.headImgUrl+'" />'+
		'	</a>'+
		'</div>'+
		'<div class="margin_top flow_left width_175">'+
		'	<ul class="display_block">'+
		'		<li class="line_height20"><span class="icon_honest"><a class="blue_link" href="/profile/'+exUser.json.user_id+'-1.html" target="_parent">'+exUser.json.nickName+'</a></span></li>'+
		'		<li class="line_height20"><span class="display_block flow_left">'+exUser.json.province+' '+exUser.json.city+'</span></li>'+
		'		<li class="clear_flow line_height20"><a href="#">'+exUser.json.companyName+'</a></li>'+
		'	</ul>'+
		'</div>';
	},
	getOperationArea : function(){
		if(exUser.json.operationArea.replace(/(^\s*)|(\s*$)/g, "")!="")
			return '负责<font class="font_grey">'+exUser.json.operationArea+'</font>区域';
		else
			return '';
	}
	
}
var exReplys={//显示信息的留言层
	notice_id : null,
	json : null,
	html : null,
	init : function(notice_id){
		exReplys.notice_id=notice_id;
		$("#replys_load_"+exReplys.notice_id).show();
		exReplys.ajax();
	},
	toggle : function(notice_id){//点击显示产品详情
		$("#items_"+notice_id).toggle();
		if($("#items_"+notice_id).css("display")=="block"){//展开操作
			exReplys.init(notice_id);
		}else{
			$("#replys_load_"+exReplys.notice_id).hide();
		}
	},
	ajax : function(){
		$.ajax({type:"POST", 
	        url:"/noticeExhibit", 
	        data:"act=getReplys&notice_id="+exReplys.notice_id, 
	        dataType:"json",
	        success:function (data) {
	        	exReplys.json=data;
	        	exReplys.show();
	        }
		});
	},
	show : function(){
		//alert("show");
		exReplys.getHtml();
		$("#replys_load_"+exReplys.notice_id).hide();
		$("#items_"+exReplys.notice_id).html(exReplys.html);
		$("#items_"+exReplys.notice_id).show();
	},
	getHtml : function(){
		exReplys.html=""+
		'<div class="edit_rep sidebother padding_top_5 margin_bot">'+
		'	<div id="rep_alr_'+exReplys.notice_id+'" class="line_height2 text_right marright">'+
		'	'+exReplys.getReplyHead()+
		'	</div>'+
		'	<ul id="reply_ul_'+exReplys.notice_id+'">'+
		'	'+exReplys.getReplysBody()+
		'	</ul>'+
		'	<div class="edit_dis clear_flow">'+
		'		<span class="edir_input"><input id="reply_txt_'+exReplys.notice_id+'" name="'+exReplys.notice_id+'" type="text" /></span>'+
		'		<span class="edit_bot">'+
		"			<input type='image' id='on'  src='/images/homepage/bottom_comment.jpg'  onclick=\"ope_rep.saveRaply('reply_txt_'+"+exReplys.notice_id+")(this.disabled=true)\" />"+
		'		</span>'+
		'	</div>'+
		'</div>'; 
	},
	getReplyHead : function(){//留言头
		var replyHead="";
		if(exReplys.json.value.length==0)
			replyHead+='赶紧抢先留言吧!';
		else
			replyHead+='<font id="rep_ct_'+exReplys.notice_id+'">'+exReplys.json.value.length+'</font>条留言，<a class="blue_link" ef="/notice/'+exReplys.notice_id+'.html">点击查看</a>';
		return replyHead;	
	},
	getReplysBody : function(){//留言体
		var replys="";
		if(exReplys.json.value.length>0){
			for(var i in exReplys.json.value){
				replys+=''+
				'<li>'+
				'	<div class="flow_left marginall_5_10">'+
				'		<img class="img-side img_size_30" src="'+exReplys.json.value[i].headImgUrl+'" />'+
				'	</div>'+
				'	<div class="flow_left martop_5 line_height2">'+
				'		<p class="edit_cont"><a class="blue_link" href="/profile/'+exReplys.json.value[i].user_id+'-1.html">'+exReplys.json.value[i].nickName+'</a>&nbsp;:&nbsp;'+exReplys.json.value[i].content+'<font class="font_grey">&nbsp;('+exReplys.json.value[i].replyTime+')</font></p>'+
				'	</div>'+
				'	<div class="clear_flow botline marleri"></div>'+
				'</li>';
			}
		}
		return replys;	
	}
}
var exPlanGroups={//显示信息的出团计划层
	notice_id : null,
	json : null,
	html : null,
	init : function(notice_id){
		exPlanGroups.notice_id=notice_id;
		$("#groupPlan_load_"+exPlanGroups.notice_id).show();
		exPlanGroups.ajax();
	},
	toggle : function(notice_id){//点击显示产品详情
		if($("#isshow_img_"+notice_id).attr("src")=="/images/homepage/hide.gif"){//闭合操作
			$("#itemf_"+notice_id).hide();
			$("#isshow_img_"+notice_id).attr("src","/images/homepage/show.gif");
		}
		else{//展开操作
			exPlanGroups.display(notice_id);
		}
	},
	display : function(notice_id){
		$("#itemf_"+notice_id).show();
		$("#isshow_img_"+notice_id).attr("src","/images/homepage/hide.gif");
		$("#isshow_img_"+notice_id).attr("onmouseover","void(0)");
		exPlanGroups.init(notice_id);
	},
	ajax : function(){
	    var cookieUId=document.getElementById('cookieUId').value;
		$.ajax({type:"POST", 
	        url:"/noticeExhibit", 
	        data:"act=getPlanGroups&notice_id="+exPlanGroups.notice_id+"&cookieUId="+cookieUId, 
	        dataType:"json",
	        success:function (data) {
	        	exPlanGroups.json=data;
	        	exPlanGroups.show();
	        }
		});
	},
	show : function(){
		exPlanGroups.getHtml();
		$("#groupPlan_load_"+exPlanGroups.notice_id).hide();
		$("#groupPlan_ps_"+exPlanGroups.notice_id).html(exPlanGroups.html);
		if(exPlanGroups.json.value.length>0){
			$("#groupPlan_ps_"+exPlanGroups.notice_id).show();
		}
	},
	getHtml : function(){
		if(exPlanGroups.json.value.length>0){
			exPlanGroups.html=""+
			'<ul class="line_height2 blue_bg2">'+
			'	<span class="edit_table width_140">出发日期</span>'+
			//'	<span class="edit_table width_62"></span>'+
			'	<span class="edit_table width_62">行程天数</span>'+
			'	<span class="edit_table width_100">价格</span>'+
			//'	<span class="edit_table width_32"></span>'+
			'	<span class="edit_table width_65">计划人数</span>'+
			'	<span class="edit_table width_65">剩余空位</span>'+
			'	<span class="edit_table width_80">提前报名天数</span>'+
			'</ul>';
			for(var i in exPlanGroups.json.value){
			    var cookieUId=document.getElementById('cookieUId').value;
				//var price = (exPlanGroups.json.value[i].price==0)?'待定':exPlanGroups.json.value[i].price;
				var peopleNum = (exPlanGroups.json.value[i].peopleNum>=999)?'不限':(exPlanGroups.json.value[i].peopleNum==0)?'不限':(exPlanGroups.json.value[i].peopleNum>=5)?'大于5':exPlanGroups.json.value[i].peopleNum;
				//var enrollEndDate =(exPlanGroups.json.value[i].enrollEndDate=='0')?'未填':exPlanGroups.json.value[i].enrollEndDate;
				var leaveSeat = (exPlanGroups.json.value[i].leaveSeat>=999)?'不限':(exPlanGroups.json.value[i].leaveSeat==0)?'不限':(exPlanGroups.json.value[i].leaveSeat>=5)?'大于5':exPlanGroups.json.value[i].leaveSeat;
				var price=exPlanGroups.json.value[i].price;
				if(getCookie("user_id")==null){
				//if(price.indexOf("dengluchakan")>=0){
				//alert(price.indexOf("dengluchakan"))
				price="登录查看";
				 exPlanGroups.html+=""+
				'<ul class="line_height2">'+
				'	<span class="edit_table width_140" style="">'+exPlanGroups.json.value[i].startDate+'</span>'+
				'	<span class="edit_table width_62" style="">'+exPlanGroups.json.value[i].day+'</span>'+
				'   <span class="edit_table width_100" style=""> <a href="#" class="s12blueline_link" onclick="enter();">'+price+'</a></span>'+
				'	<span class="edit_table width_65" style="">'+peopleNum+'</span>'+
				'	<span class="edit_table width_65" style="">'+leaveSeat+'</span>'+
				'	<span class="edit_table width_80" style="">'+exPlanGroups.json.value[i].enrollEndDate+'</span>'+
				'</ul>';
				// }
				}
				else{
				exPlanGroups.html+=""+
				'<ul class="line_height2">'+
				'	<span class="edit_table width_140" style="">'+exPlanGroups.json.value[i].startDate+'</span>'+
				'	<span class="edit_table width_62" style="">'+exPlanGroups.json.value[i].day+'</span>'+
				'   <span class="edit_table width_100" style="">'+price+'</span>'+
				'	<span class="edit_table width_65" style="">'+peopleNum+'</span>'+
				'	<span class="edit_table width_65" style="">'+leaveSeat+'</span>'+
				'	<span class="edit_table width_80" style="">'+exPlanGroups.json.value[i].enrollEndDate+'</span>'+
				'</ul>';
			  }
			}
		}
	}
}


//推荐报价home页面
function price(){
 $("#ask").hide();
 $("#price").show();
 $("#baojia").attr("class","flow_left black2 s14 linebg2 whitebg");
 $("#xunjia").attr("class","flow_left black2 s14 linebg2");
}

//推荐询价home页面
function ask(){
 $("#price").hide();
 $("#ask").show();
 $("#baojia").attr("class","flow_left black2 s14 linebg2");
 $("#xunjia").attr("class","flow_left black2 s14 linebg2 whitebg");
}

//推荐报价profile页面
function price1(){
 $("#ask").hide();
 $("#price").show();
 $("#baojia").attr("class","flow_left s14 black2 pro_sub whitebg");
 $("#xunjia").attr("class","flow_left s14 black2 pro_sub");
}

//推荐询价index页面
function ask1(){
 $("#price").hide();
 $("#ask").show();
 $("#baojia").attr("class","flow_left s14 black2 pro_sub");
 $("#xunjia").attr("class","flow_left s14 black2 pro_sub whitebg");
}






