//发布按钮效果;
function publicfun(){
  var publicicon=document.getElementById('publicicon');
  publicicon.className="inputshow";
  publicicon.onmouseout=function publicfunh(){
  publicicon.className="input";
  }
}
// 鼠标指向列表背景变色
function $clist(e){
	var pr=document.getElementById(e).getElementsByTagName("div");
	for(var i=0;i<pr.length;i++){
		pr[i].onmouseover=function(){
			this.tmpClass=this.className;
			this.className+=" hover";
			}
		pr[i].onmouseout=function(){
			this.className=this.tmpClass;
			}
	}
}
//输入框各种状态
function infocuszc(a,b){
  var focusina=document.getElementById(a);
  var focusinb=document.getElementById(b);
  focusina.className="intextshow";
  focusinb.style.display="block";  
  focusina.onblur=function nofocus(){
  focusina.className="intext";
  focusinb.style.display="none";
  }
}
function infocus(a){
  var focusin=document.getElementById(a);
  focusin.className="intextshow";
  focusin.onblur=function nofocus(){
  focusin.className="intext";
  }
}
function inareafocus(a){
  var focusin=document.getElementById(a);
  focusin.className="inareashow";
  focusin.onblur=function nofocus(){
  focusin.className="inarea";
  }
}
/*隐藏层盖住背景*/
function showlayer(n,m){
	document.getElementById(''+n+'').style.display='block';
	document.getElementById(''+m+'').style.display='block';
    document.getElementById(''+m+'').style.height=document.documentElement.scrollHeight+"px";
	document.getElementById(''+n+'').style.left=(window.screen.width-600)/2+"px";
    document.getElementById(''+n+'').style.top=document.documentElement.scrollTop+document.documentElement.clientHeight/3+"px";
	}
/*拖动层*/
	var $$=function(id){return document.getElementById(id)};
Array.prototype.extend=function(C){for(var B=0,A=C.length;B<A;B++){this.push(C[B]);}return this;}
function divDrag(){
  var A,B,$$cn;
        var zIndex=8000;
        this.dragStart=function(e){
                e=e||window.event;
                if((e.which && (e.which!=1))||(e.button && (e.button!=1)))return;
                var pos=this.$$pos;
    $$cn=this.parent||this;
    if(document.defaultView){
     _top=document.defaultView.getComputedStyle($$cn,null).getPropertyValue("top");
     _left=document.defaultView.getComputedStyle($$cn,null).getPropertyValue("left");}
    else{
     if($$cn.currentStyle){_top=$$cn.currentStyle["top"];_left=$$cn.currentStyle["left"];}}
                pos.ox=(e.pageX||(e.clientX+document.documentElement.scrollLeft))-parseInt(_left);
                pos.oy=(e.pageY||(e.clientY+document.documentElement.scrollTop))-parseInt(_top);
    if(!!A){
      if(document.removeEventListener){
                        document.removeEventListener("mousemove",A,false);
                        document.removeEventListener("mouseup",B,false);}
     else{
                        document.detachEvent("onmousemove",A);
                        document.detachEvent("onmouseup",B);}}
    A=this.dragMove.create(this);
                B=this.dragEnd.create(this);
                if(document.addEventListener){
     document.addEventListener("mousemove",A,false);
                    document.addEventListener("mouseup",B,false);}
    else{
     document.attachEvent("onmousemove",A);
                    document.attachEvent("onmouseup",B);}
                $$cn.style.zIndex=(++zIndex);
                this.stop(e);
        }
        this.dragMove=function(e){
    e=e||window.event;
    var pos=this.$$pos;
    $$cn=this.parent||this;
    $$cn.style.top=(e.pageY||(e.clientY+document.documentElement.scrollTop))-parseInt(pos.oy)+'px';
    $$cn.style.left=(e.pageX||(e.clientX+document.documentElement.scrollLeft))-parseInt(pos.ox)+'px';
    this.stop(e);}
        this.dragEnd=function(e){
                var pos=this.$$pos;              
                e=e||window.event;
    if((e.which && (e.which!=1))||(e.button && (e.button!=1)))return;
    $$cn=this.parent||this;
    if(!!(this.parent)){this.style.backgroundColor=pos.color}
                if(document.removeEventListener){
                        document.removeEventListener("mousemove",A,false);
                        document.removeEventListener("mouseup",B,false);}
    else{
                        document.detachEvent("onmousemove",A);
                        document.detachEvent("onmouseup",B);}
    A=null;
    B=null;
                $$cn.style.zIndex=(++zIndex);
                this.stop(e);
        }
  this.shiftColor=function(){
   this.style.backgroundColor="#098CDB"; 
  }
        this.position=function (e){ 
                var t=e.offsetTop;
                var l=e.offsetLeft;
                while(e=e.offsetParent){ 
                                t+=e.offsetTop; 
                                l+=e.offsetLeft;}
                return {x:l,y:t,ox:0,oy:0,color:null}
        }
        this.stop=function(e){
                if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble=true;}
    if(e.preventDefault){e.preventDefault();}else{e.returnValue=false;}
        }
  this.stop1=function(e){
   e=e||window.event;
            if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble=true;}
  }
        this.create=function(bind){
                var B=this;
                var A=bind;
                return function(e){return B.apply(A,[e]);}
  }
        this.dragStart.create=this.create;
        this.dragMove.create=this.create;
        this.dragEnd.create=this.create;
  this.shiftColor.create=this.create;
  this.initialize=function(){
                for(var A=0,B=arguments.length;A<B;A++){
                        C=arguments[A];
      if(!(C.push)){C=[C];}
                        $$C=(typeof(C[0])=='object')?C[0]:(typeof(C[0])=='string'?$$(C[0]):null);
                        if(!$$C)continue;
                        $$C.$$pos=this.position($$C);
                        $$C.dragMove=this.dragMove;
                        $$C.dragEnd=this.dragEnd;
                        $$C.stop=this.stop;
      if(!!C[1]){$$C.parent=C[1];$$C.$$pos.color=$$C.style.backgroundColor;}
                        if($$C.addEventListener){
       $$C.addEventListener("mousedown",this.dragStart.create($$C),false);
       if(!!C[1]){$$C.addEventListener("mousedown",this.shiftColor.create($$C),false);}}
      else{$$C.attachEvent("onmousedown",this.dragStart.create($$C));
       if(!!C[1]){$$C.attachEvent("onmousedown",this.shiftColor.create($$C));}}
                }
  }
        this.initialize.apply(this,arguments);
}

function validate(a, b, c, d, e, f, g, h) {
	var error = document.getElementById(a);
	var username = document.getElementById(b).value;
	var reg = /^[0-9a-z\u4E00-\u9FA5]{1,64}$/;
	if(!reg.test(username)) {
		error.className = "error";
		error.innerHTML = "用户名只能使用汉字，小写字母和数字，不包含空格";
		return false;
	}
	
	var password = document.getElementById(c).value;
	if (password.length < 6) {
		error.className = "error";
		error.innerHTML = "密码必须包含 6 个或更多字符。";
		return false;
	}
	
	var comfirm = document.getElementById(d).value;
	if (comfirm != password) {
		error.className = "error";
		error.innerHTML = "密码不匹配。";
		return false;
	}
	
	if (e != null) {
		var url = document.getElementById(e).value;
		reg = /^(http|https).*$/;
		if(!reg.test(url)) {
			error.className = "error";
			error.innerHTML = "主页的URL不正确。";
			return false;
		}
	}
	
	if (f != null) {
		var contact = document.getElementById(f).value;
		if (contact == "" || contact.length > 255) {
			error.className = "error";
			error.innerHTML = "请输入联系人，最长255个字符。";
			return false;
		}
	}
	
	if (g != null) {
		var phone = document.getElementById(g).value;
		if (phone == "" || phone.length > 64) {
			error.className = "error";
			error.innerHTML = "请输入电话号码，最长64位。";
			return false;
		}
	}
	
	if (h != null) {
		var introduction = document.getElementById(h).value;
		if (introduction == "" || introduction.length > 140) {
			error.className = "error";
			error.innerHTML = "请输入网店简介，最长140个字符。";
			return false;
		}
	}
	
	return true;
}

//消息流;
    
function imagetoggle(othis){
		if(othis.className == 'attachmentimg small'){
			var w = $(othis).parent().attr("w");
			if(w=='')w=530;
			othis.onload = function(){
				$(this).parent().prev().show();
				$(this).parent().parent().attr("className", "picchangeh");
				this.className = 'attachmentimg large';
			};
			othis.src = 'http://looa.com/image.php/'+othis.name+'?width='+w+'&height='+w+'&image='+othis.name;
			//othis.blur();
			//othis.style.border=0;
			
		}else if(othis.className == 'attachmentimg large'){
			if(othis.angle==undefined){
				othis.onload = function(){
					$(this).parent().parent().attr("className", "picchange");
					$(this).parent().prev().hide();
				};
				othis.className = 'attachmentimg small';
				othis.src = 'http://looa.com/image.php/'+othis.name+'?width=100&height=100&image='+othis.name;
			}else{
				var newimage = new Image();
				newimage.src = 'http://looa.com/image.php/'+othis.name+'?width=100&height=100&image='+othis.name;
				newimage.name = othis.name;
				newimage.id = othis.id;
				newimage.onclick = function(){imagetoggle(this)};
				$(othis).replaceWith(newimage);
				$(newimage).parent().parent().attr("className", "picchange");
				$(newimage).parent().prev().hide();
				newimage.className = 'attachmentimg small';
			}
		}
}

function plchecklength(obj,nid){
	var content = document.getElementById("nickname")?"!"+document.getElementById("nickname").value+" "+obj.value:obj.value;
	var n=content.length;
	var msg=n>140?"你输入的内容超出限制~":"您还可以输入"+(140-n)+"个字";
	document.getElementById("pl_tx_"+nid).innerHTML = msg;
}
function showdiscuss(nid,type){
	if(type)var t=type;
	if($("#list_pl_"+nid).css("display")!="none")$("#list_pl_"+nid).hide();
	else{
		$("#list_pl_"+nid).show();
		$("#list_pl_"+nid).html("<dt> </dt><dd style='text-align:center'><img src='/theme/koua1/looaimages/wait.gif' align='middle' /></dd><tt></tt>");
		$.get("/ajax/showdiscuss/"+nid,{'type':t},function(str){
			$("#list_pl_"+nid).html(str);
			$('#showface_'+nid).click(function(){showface(nid);});
		});
	}
}
function reply(rid,nid,profile_id){
	if($("#list_pl_"+rid).css("display")!="none")$("#list_pl_"+rid).hide();
	else{
		$("#list_pl_"+rid).show();
		$("#list_pl_"+rid).html('<dt> </dt><dd style="text-align:center"><form id="pl_f_'+rid+'" name="pl_f_'+rid+'" style="margin:0; padding:0;"><table width="100%" style="background:transparent"><tr><td width="30" align="right" valign="top" class="xxlineface"><span id="showface_'+rid+'"><img src="/theme/koua1/looaimages/xxlineface.gif"/><img src="/theme/koua1/looaimages/xxlinexzimg5.gif" style="margin-top:4px;"/></span><p id="pl_face_'+rid+'" style="margin-left:5px;border:#D7D7D7 2px solid;width:260px;background:#FFF;padding:1px;position:absolute;z-index:8000;overflow-y:auto;overflow-x:hidden;height:130px;display: none;"></p></td><td><input onkeyup="plchecklength(this,'+rid+');" onfocus="plchecklength(this,'+rid+');" name="pl_content" id="pl_content_'+rid+'" type="text" class="xxin" value="'+"回复@"+$('#nickname_'+rid).html()+' " /><input onclick="publicdiscuss(this.form,'+nid+','+rid+')" type="button" class="xxsub" value="评论"/></td></tr></table><table width="100%" style="background:transparent;color:#8A8B8B;"><tr><td width="30" align="left"></td><td align="left" width="200"><input name="pl_option" id="pl_option" type="checkbox" value=1 style="vertical-align:bottom; *vertical-align:middle;" />  同时发一条消息</td><input name="rprofile_id" id="rprofile_id" type="hidden" value="'+profile_id+'" /><input name="conversation" id="conversation" type="hidden" value="'+nid+'" /><td align="left"><span id="pl_tx_'+rid+'"></span>  </td></tr></table></form></dd><tt></tt>');
		document.getElementById('pl_content_'+rid).focus();
		$('#showface_'+rid).click(function(){showface(rid);});
	}
}


function showface(nid){
				$('#pl_face_'+nid).toggle();
				$('#pl_face_'+nid).html('<ul>'
						+'<li><a href="#" value="足球" title="足球"><img alt="足球" src="/theme/koua1/looaimages/face/football.gif" /></a></li>'
						+'<li><a href="#" value="哨子" title="哨子"><img alt="哨子" src="/theme/koua1/looaimages/face/shao.gif" /></a></li>'
						+'<li><a href="#" value="红牌" title="红牌"><img alt="红牌" src="/theme/koua1/looaimages/face/redcard.gif" /></a></li>'
						+'<li><a href="#" value="黄牌" title="黄牌"><img alt="黄牌" src="/theme/koua1/looaimages/face/yellowcard.gif" /></a></li>'
						+'<li><a href="#" value="哈哈" title="哈哈"><img alt="哈哈" src="/theme/koua1/looaimages/face/laugh.gif" /></a></li>'
						+'<li><a href="#" value="呵呵" title="呵呵"><img alt="呵呵" src="/theme/koua1/looaimages/face/smile.gif" /></a></li>'
						+'<li><a href="#" value="泪"   title="泪"  ><img alt="泪"   src="/theme/koua1/looaimages/face/cry.gif" /></a></li>'
						+'<li><a href="#" value="汗"   title="汗"  ><img alt="汗"   src="/theme/koua1/looaimages/face/sweat.gif" /></a></li>'
						+'<li><a href="#" value="爱你" title="爱你"><img alt="爱你" src="/theme/koua1/looaimages/face/love.gif" /></a></li>'
						+'<li><a href="#" value="嘻嘻" title="嘻嘻"><img alt="嘻嘻" src="/theme/koua1/looaimages/face/tooth.gif" /></a></li>'
						+'<li><a href="#" value="哼"   title="哼"  ><img alt="哼"   src="/theme/koua1/looaimages/face/hate.gif" /></a></li>'
						+'<li><a href="#" value="心"   title="心"  ><img alt="心"   src="/theme/koua1/looaimages/face/heart.gif" /></a></li>'
						+'<li><a href="#" value="晕"   title="晕"  ><img alt="晕"   src="/theme/koua1/looaimages/face/dizzy.gif" /></a></li>'
						+'<li><a href="#" value="怒"   title="怒"  ><img alt="怒"   src="/theme/koua1/looaimages/face/angry.gif" /></a></li>'
						+'<li><a href="#" value="蛋糕" title="蛋糕"><img alt="蛋糕" src="/theme/koua1/looaimages/face/cake.gif" /></a></li>'
						+'<li><a href="#" value="花"   title="花"  ><img alt="花"   src="/theme/koua1/looaimages/face/flower.gif" /></a></li>'
						+'<li><a href="#" value="抓狂" title="抓狂"><img alt="抓狂" src="/theme/koua1/looaimages/face/crazy.gif" /></a></li>'
						+'<li><a href="#" value="困"   title="困"  ><img alt="困"   src="/theme/koua1/looaimages/face/sleepy.gif" /></a></li>'
						+'<li><a href="#" value="干杯" title="干杯"><img alt="干杯" src="/theme/koua1/looaimages/face/cheer.gif" /></a></li>'
						+'<li><a href="#" value="太阳" title="太阳"><img alt="太阳" src="/theme/koua1/looaimages/face/sun.gif" /></a></li>'
						+'<li><a href="#" value="下雨" title="下雨"><img alt="下雨" src="/theme/koua1/looaimages/face/rain.gif" /></a></li>'
						+'<li><a href="#" value="伤心" title="伤心"><img alt="伤心" src="/theme/koua1/looaimages/face/sad.gif" /></a></li>'
						+'<li><a href="#" value="月亮" title="月亮"><img alt="月亮" src="/theme/koua1/looaimages/face/moon.gif" /></a></li>'
						+'<li><a href="#" value="猪头" title="猪头"><img alt="猪头" src="/theme/koua1/looaimages/face/pig.gif" /></a></li>'
						+'<li><a href="#" value="蜡烛" title="蜡烛"><img alt="蜡烛" src="/theme/koua1/looaimages/face/candle.gif" /></a></li>'
						+'</ul>');
				$('#pl_face_'+nid+' ul li').css({width:"25px",float:"left","text-align":"left",padding:"1px",overflow:"hidden","line-height":"18px","font-size":"12px",height:"25px",margin:"2px 0 0 5px"});		
				$('#pl_face_'+nid+' ul li a').click(function(){
					var start = $('#pl_content_'+nid).selection().start;
					var length = $('#pl_content_'+nid).val().length;
					var head = start > 0 ? $('#pl_content_'+nid).val().substring(0, start) : '';
					var tail = start < length ? $('#pl_content_'+nid).val().substring(start, length) : '';
					var body = '['+$(this).attr("value")+']';
					$('#pl_content_'+nid).val(head + body + tail);
					$('#pl_content_'+nid).focus();
					$('#pl_content_'+nid).selectRange(start + body.length, start + body.length);
					$('#pl_face_'+nid).toggle();
					return false;
				});    
			}
function tuan_feedback(){
	var content = document.getElementById("feedback").value;
	var nickname = document.getElementById("toname").value;
	if(content == ''){alert('你还没填写内容！');return false;}
	if(content.length>140){alert('你输入的内容超出限制！');return false;}
	$.get("/ajax/tuanadddiscuss/",{'type':"notice",'content':"@"+nickname+" "+content}, function(r){
		if(r.v){
			document.getElementById("feedback").value='';
			lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">提交成功！</div>', 400, 60, 0, 'zz' );
			closeBg('openact');
		}else lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">'+r.msg+'</div>', 400, 60, 0, 'zz' );
	},'json');
}
function tuan_subscription(){
	var email = document.getElementById("email").value;
	if(email == ''){alert('邮件地址必须填写！');return false;}
	if(email.indexOf("@")===-1){alert('邮件地址不正确！');return false;}
	$.get("/ajax/tuansubscription/",{'city':"",'email':email}, function(r){
		if(r=='ok'){
			document.getElementById("email").value='';
			lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">订阅成功！</div>', 400, 60, 0, 'zz' );
			closeBg('openact');
		}else lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">'+r+'</div>', 400, 60, 0, 'zz' );
	},'text');
}

function tuan_publicdiscuss(){
	if(s_info.userid<1){
		location='/tuan/groupbuy_login';
	}
	var content = document.getElementById("pl_content_1").value;
	var nickname = document.getElementById("nickname").value;
	if(content == ''){alert('你还没填写内容！');return false;}
	if(content.length>140){alert('你输入的内容超出限制！');return false;}
	$.get("/ajax/tuanadddiscuss/",{'type':"notice",'content':"!"+nickname+" "+content}, function(r){
		if(r.v){
				try{
					document.getElementById("discuss_num").innerHTML = parseInt(document.getElementById("discuss_num").innerHTML) + 1 ;
				}catch(e){};
				document.getElementById("pl_content_1").value = '';
				if(document.getElementById("listdiv")){
					var newrow = '<table class="pllist" id="notice-'+r.v+'"><tr><td class="sp1"><a href="'+s_info.homeurl+'"><img src="'+s_info.img+'" class="avatar photo" width="48" height="48" alt="'+s_info.nickname+'" /></a></td><td class="pllistr" height="19px"><strong><a href="'+s_info.homeurl+'" class="nickname">'+s_info.nickname+'</a></strong><span style="margin-left: 285px;">几秒前</span><p class="pllistr">'+r.msg.replace(/(^\!\s*<span .*>.*<\/a>\s*<\/span>\s*)|(^\![^\s]+\s)/g,"")+'</p><p class="hfbox" style="width:345px"><a title="删除此条信息" style="padding-right: 25px; border-right: 1px solid rgb(204, 204, 204);" class="notice_delete" onclick="delnotice('+r.v+');" href="javascript:void(0)">删除</a><a href="javascript:void(0)" style="margin-right: 15px;" onclick="showdiscuss('+r.v+')">评论<span id="discuss_num_'+r.v+'"></span></a></p><td id=\"list_pl_'+r.v+'\" class=\"xxlist_pl\" style=\"display:none;\"></td></td></tr></table>';					
					//newrow = document.createTextNode(newrow);
				$("#listdiv").prepend(newrow);
				//$("#listdiv").html();
				}
				
				
				document.getElementById("pl_content_1").focus();
		}else lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">'+r.msg+'</div>', 400, 60, 0, 'zz' );
	},'json');
}

function publicdiscuss(form,nid,rid){
	if(form.pl_content.value == ''){alert('你还没填写内容！');return false;}
	if(form.pl_content.value.length>140){alert('你输入的内容超出限制！');return false;}
	//return 1;
	if(form.pl_option)var option = form.pl_option.checked?1:0;
	$.get("/ajax/addreply/"+nid,{'rprofile_id':form.rprofile_id.value,'content':form.pl_content.value,'option':option,'conversation':form.conversation.value}, function(r){
		if(r.v){
			if(rid==undefined){
				try{
				if(document.getElementById("discuss_num_"+nid).innerHTML=='')document.getElementById("discuss_num_"+nid).innerHTML=0;
				document.getElementById("discuss_num_"+nid).innerHTML = "("+(parseInt(document.getElementById("discuss_num_"+nid).innerHTML.replace(/[^\d]/g,"")) + 1)+")";
				if(document.getElementById("discuss_num_"+nid+"_1"))document.getElementById("discuss_num_"+nid+"_1").innerHTML = parseInt(document.getElementById("discuss_num_"+nid+"_1").innerHTML) + 1;
				}catch(e){};
				form.pl_content.value = '';
				if(document.getElementById("pl_"+nid)){
				var newrow = '<table id="reply_'+r.v+'" width="100%"><tr><td width="40" align="center" valign="top"><a href="'+s_info.homeurl+'"><img src="'+s_info.img+'" class="avatar photo" width="24" height="24" alt="'+s_info.nickname+'" /></a></td><td>  <blockquote><strong><a href="'+s_info.homeurl+'" class="nickname">'+s_info.nickname+'</a></strong><span>几秒前</span></blockquote>  <p class="xxlist_pld">'+r.msg+'</p><p class="xxlist_plh">'+"<a href=\"javascript:void(0);\" onclick=\"delconfirm("+r.v+","+nid+",'0',"+s_info.userid+");\">"+'删除</a>|<a href="javascript:void(0);" onclick="document.getElementById('+"'pl_f_"+nid+"').pl_content.value='回复@"+s_info.nickname+" :'\">回复</a></p></td></tr></table>";
				$("#pl_"+nid).prepend(newrow);
				}else{
					if(document.getElementById("commentlist")){
						showPage(1);
					}
				}
					
				form.pl_content.focus();
			}else{//好友回复
				lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">回复成功</div>', 400, 60, 0, 'zz' );
				$("#list_pl_"+rid).hide();q
			}
		}else lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">'+r.msg+'</div>', 400, 60, 0, 'zz' );
	},'json');
}
function deldiscuss(d){
	$.get("/ajax/deletereply/",{'id':d.id,'replied_id':d.rid,'rprofile_id':d.rp,'profile_id':d.p}, function(r){
		if(r.v){
			if(g("discuss_num_"+d.rid))g("discuss_num_"+d.rid).innerHTML = "("+(parseInt(g("discuss_num_"+d.rid).innerHTML.replace(/[^\d]/g,"")) - 1)+")";
			if(g("discuss_num_"+d.rid+"_1"))g("discuss_num_"+d.rid+"_1").innerHTML = parseInt(g("discuss_num_"+d.rid+"_1").innerHTML) - 1;
			$("#reply_"+d.id).remove();
			lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">删除成功~</div>', 400, 60, 0, 'zz' );
		}else lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">'+r.msg+'</div>', 400, 60, 0, 'zz' );
	},'json');
}		
function delnotice(id){
	var token = document.getElementById("del-token").value;
	lhgdialog.reg = {"b1":{"param":{"id":id,"token":token},"callfunc":function(d){
		$.get("/notice/delete/"+d.id,{'token':d.token}, function(r){
			if(r.v){
				$("#notice-"+d.id).remove();
				lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">删除消息成功~</div>', 400, 60, 0, 'zz' );
			}else lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">'+r.msg+'</div>', 400, 60, 0, 'zz' );
		},'json');
	},"value":"确定"}};
	
	lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">确定删除么？~</div>', 400, 60, 0, 'confirm');
}		
function delconfirm(id,rid,rp,p){
	lhgdialog.reg = {"b1":{"param":{"id":id,"rid":rid,"rp":rp,"p":p},"callfunc":function(d){deldiscuss(d);},"value":"确定"}};
	lhgdialog.opendlg( '提示', '<div style="text-align:center;padding-top:50px;padding-bottom:30px;font-size:14px;">确定删除么？~</div>', 400, 60, 0, 'confirm');
}		

function showPage(iNextPageToLoad) {
//    if (iNextPageToLoad <= iPageCount) {
		if(iNextPageToLoad<1)iNextPageToLoad=1;
		var id = document.getElementById("id").value;
        $.get("/conversation/"+id, {"isajax":"1","page":iNextPageToLoad}, function (r) { 
        	var divLoadArea = document.getElementById("commentlist");
			divLoadArea.innerHTML = r;
			loadevent();
        });    
//    }
}

 function loadevent() {
	var colLinks = document.getElementsByTagName("a");
	for (var i=0; i < colLinks.length; i++) {
		
		if (colLinks[i].id.indexOf("aPage") == 0) {
			colLinks[i].onclick = function (oEvent) {                    
				var sPage = this.id.substring(5);
				showPage(sPage);
				
				if (oEvent) {
					oEvent.preventDefault(); 
				} else {
					window.event.returnValue = false;
				}
			}
		}
		
	}
}
//热卖广场
$(document).ready(function(){
try{
$("#topnav dd").bind("mouseover", function(){this.className = "ms";});
$("#topnav dd").bind("mouseout", function(){this.className = "rline";});
}catch(e){}
});

//分享按钮效果;
function fxfun(id,index){
  var fxicon=document.getElementById(id);
  var fxiconh=document.getElementById(index);
  fxicon.className="fxh";
  fxiconh.style.display="block";
}
function fxfunh(id,index){
  var fxicon=document.getElementById(id);
  var fxiconh=document.getElementById(index);
  fxicon.className="fxhot";
  fxiconh.style.display="none";
}
//层效果;
function inlayer(a,b){
  var focusin=document.getElementById(a);
  var focusinb=document.getElementById(b);
  focusin.style.display="block";
  focusinb.className="bcur";
  focusin.onmouseout=function noinlayer(){
  focusin.style.display="none";
  focusinb.className="acur";
  }
  focusinb.onmouseout=function noinlayerb(){
  focusin.style.display="none";
  focusinb.className="acur";
  }
}
function tginlayer(a,b){
  var focusin=document.getElementById(a);
  var focusinb=document.getElementById(b);
  focusin.style.display="block";
  focusinb.className="gtbcur";
  focusin.onmouseout=function noinlayer(){
  focusin.style.display="none";
  focusinb.className="gtacur";
  }
  focusinb.onmouseout=function noinlayerb(){
  focusin.style.display="none";
  focusinb.className="gtacur";
  }
}

function getObj(objName){return(document.getElementById(objName));}

function ChangeChannel(module,orderid,num2,cla1,cla2,cla3){
for(var i=1;i<=num2;i++)
{
getObj("rb"+module+i).className=""+cla1+"";
if (orderid>1)
{
getObj("rb"+module+1).className=""+cla1+"";
}
if (orderid<num2)
{
Tempid=orderid+1
getObj("rb"+module+Tempid).className=""+cla1+"";
}
getObj("reb"+module+i).className="s2 "+cla3+"";
}
getObj("rb"+module+orderid).className=""+cla2+"";
getObj("reb"+module+orderid).className="s1 "+cla3+"";
}
//显示灰色JS遮罩层
function showBg(ct){
var bH=$("body").height();
var bW=$("body").width();
var objWH=getObjWh(ct);
$("#fullbg").css({width:bW,height:bH,display:"block"});
var tbT=objWH.split("|")[0]+"px";
var tbL=objWH.split("|")[1]+"px";
$("#"+ct).css({top:tbT,left:tbL,display:"block"});
$(window).scroll(function(){resetBg(ct)});
$(window).resize(function(){resetBg(ct)});
}
function getObjWh(obj){
var st=document.documentElement.scrollTop;
var sl=document.documentElement.scrollLeft;
var ch=document.documentElement.clientHeight;
var cw=document.documentElement.clientWidth;
var objH=$("#"+obj).height();
var objW=$("#"+obj).width();
var objT=Number(st)+(Number(ch)-Number(objH))/2;
var objL=Number(sl)+(Number(cw)-Number(objW))/2;
return objT+"|"+objL;
}
function resetBg(ct){
var fullbg=$("#fullbg").css("display");
if(fullbg=="block"){
var bH2=$("body").height();
var bW2=$("body").width();
$("#fullbg").css({width:bW2,height:bH2});
var objV=getObjWh(""+ct+"");
var tbT=objV.split("|")[0]+"px";
var tbL=objV.split("|")[1]+"px";
$("#"+ct).css({top:tbT,left:tbL});
}
}
//关闭灰色JS遮罩层和操作窗口
function closeBg(ct){
$("#fullbg").css("display","none");
$("#"+ct).css("display","none");
}
function gettime(num){
   var h,m,s;   
   h = Math.floor(num/3600);
   m = Math.floor((num%3600)/60);
   s = Math.floor(num%60);
   return [h,m,s];
}

function inlayer(a,b){
  var focusin=document.getElementById(a);
  var focusinb=document.getElementById(b);
  focusin.style.display="block";
  focusinb.className="bcur";
  focusin.onmouseout=function noinlayer(){
  focusin.style.display="none";
  focusinb.className="acur";
  }
  focusinb.onmouseout=function noinlayerb(){
  focusin.style.display="none";
  focusinb.className="acur";
  }
}
function tginlayer(a,b){
  var focusin=document.getElementById(a);
  var focusinb=document.getElementById(b);
  focusin.style.display="block";
  focusinb.className="gtbcur";
  focusin.onmouseout=function noinlayer(){
  focusin.style.display="none";
  focusinb.className="gtacur";
  }
  focusinb.onmouseout=function noinlayerb(){
  focusin.style.display="none";
  focusinb.className="gtacur";
  }
}
