//programer's QQ:361018729
//-----------------------首页隐藏广告---------------------------------	
$(document).ready(  
				  function(){
					  setTimeout("slide()",1000);
					  //slide();
					  setTimeout("test()",5000);
					  });
$(document).ready(function(){
						   $("#adsdiv_close").mouseover(function(){
							   $("#adsdiv_close").css("color","yellow");
							   }).mouseout(function(){
							   $("#adsdiv_close").css("color","red");
							   }).click(function(){
															//$("#adsdiv").css("display","none"); 
															$("#adsdiv").slideUp(1000);
															 });
						   });
		function hiden(){
		$("#adsdiv").hide();//hide()函数,实现隐藏,括号里还可以带一个时间参数(毫秒)例如hide(500)以500毫秒的速度隐藏,还可以带slow,fast
		}
		function slideToggle(){
		$("#adsdiv").slideToggle(500);//窗帘效果的切换,点一下收,点一下开,参数可以无,参数说明同上
		}
		function show(){
		//$("#adsdiv").show();//显示,参数说明同上
		$("#adsdiv").show(500);
		}
		function toggle(){
		$("#adsdiv").toggle(500);//显示隐藏切换,参数可以无,参数说明同上
		}
		function slide(){
		$("#adsdiv").slideDown(1000);//窗帘效果展开
		}
		function test(){
			$("#adsdiv").slideUp(1000);	
		}
//-----------------------首页隐藏广告---------------------------------	
		
	
	
//-----------------------公共调用---------------------------------	

function imgdivmover(obj){
	$(obj).css("backgroundColor","#BDBDBD");
}
function imgdivmout(obj){
	$(obj).css("backgroundColor","");
}

$(function(){
		   $("#searchchoice").change(function(){
											  if($("#searchchoice").val()==2){
												 	 $("#searchformweb").css("display","block");
													  $("#searchformgg").css("display","none");
												  }else{
													  $("#searchformweb").css("display","none");
													  $("#searchformgg").css("display","block");
													  }
											  });
		   });



//注册用户检查
function hidespan(){
	$("#usescheckspan").html("");
	$("#usescheckspan1").html("");
	$("#userregsubmit").attr("disabled",false);
	//$("#userregsubmit").Attributes("disabled",false);
	}
function checkreguser(){
	if(trim($("#username").val()).length==0){									  
											alert("请输入用户名！");
											return false;
											}
	$.ajax({
			   type: "post",  //以post方式与后台沟通
			   url : "http://www.cncmmo.com/newsite/index.php/Index/checkreguser", //与此php页面沟通
			   //dataType:'json',//从php返回的值以 JSON方式 解释
			   data:  'username='+trim($("#username").val()), //发给php的数据有两项，分别是上面传来的u和p   
			   success: function(data){
						if(data=="ok"){//不存在，可以注册
							$("#usescheckspan").html("<font color='red'>"+$("#username").val()+"</font>可以注册！");
						}else{//已经存在，不可以注册
							$("#usescheckspan").html("<font color='red'>"+$("#username").val()+"</font>已经被注册！");
							$("#usescheckspan1").html("<font color='red'>"+$("#username").val()+"</font>已经被注册！");
							//$("#userregsubmit").Attributes("disabled",true);
							$("#userregsubmit").attr("disabled",true);
							}
						
				  }//success   
			   });
	}
//注册用户检查	
	
//搜索
$(function(){
		  // alert( $("#searchbtn").val());
		   $("#searchbtn").click(function(){
										  //alert(123);
										  if(trim($("#keyword").val()).length==0){
											  
											  alert("请输入搜索关键字/词！");
											  return false;
											  }
										  });
		   });
//搜索

//登录状态

//1	"<table><tr><td align='right'><img src='images/loginflag.png' width='70' height='23' border='0' align='absmiddle'/></td><td align='left'>&nbsp;<label class='label'>账号:</label><input class='inputtxt' type='text' name='username' id='username' /></td><td><label class="label">密码:</label><input class="inputtxt" type="password" name="username" id="username" /></td><td><label class="label">验证码:</label><input class="inputtxt" type="password" name="username" id="username" style="width:50px"/></td><td><img src="" width="50" height="21"  align="absmiddle"/></td><td><input class="loginbtn" type="submit" value="" width="59" height="21"/></td><td><a href="#"><img src="images/registerbtn.png" width="59" height="21" border="0" align="absmiddle"/></a></td><td><a href="#" class="forgetpswd">忘记密码?</a></td></tr></table>"

//2 "你好：小强，欢迎回来。&nbsp;&nbsp;<a href="#">会员中心</a>&nbsp;&nbsp;<a href="#">退出登录</a>"

//登录状态

//提示框
function showbox(msg,showtime){
	alert(msg);
	/*$("body").append("<div id='alertdiv'></div>");
	$("#alertdiv").html(msg);
	
	var a = $(window).height();
    var b = $(window).width();
	var a1=$("#alertdiv").height();
	var b1=$("#alertdiv").width();
	$("#alertdiv").css("top",(a-a1)/2).css("left",(b-b1)/2);
	
	setTimeout($("#alertdiv").hide('slow'),showtime);*/
}
$(function(){
		   	
			
		   });
	
//删除左右两端的空格	
function trim(str){  
	return str.replace(/(^\s*)|(\s*$)/g, "");
}

	
//-----------------------公共调用---------------------------------	
	
	

//-----------------------info左右两边对齐---------------------------------	
		$(function(){
					//alert(12);
					var r=$("#info_details_div_right").height();
					var l=$("#info_details_div_left").height();
						if(r>=l){
							$("#info_details_div_left").height(r);
						}else{
							$("#info_details_div_right").height(l).css("background-color","#CECECE");	
						}
		});
//-----------------------info左右两边对齐--------------------------------
		
		
		
//-----------------------usercenter左右两边对齐---------------------------------	
$(function(){
				   
			var r=$("#usercenter_div_right").height();
			var l=$("#usercenter_div_left").height();
			//alert(r+"--"+l);
			if(r>=l){
			//alert(1);
				$("#usercenter_div_left").height(r);
			}else{
				//$("#usercenter_div_right").height(l));	
			}
});
//-----------------------usercenter左右两边对齐--------------------------------

islogin=false;
//--------------------------发表评论---------------------------------
//加载用户名，没有登录显示 匿名
$(function(){
		   $.ajax({ //一个Ajax过程  
											   type: "post",  //以post方式与后台沟通
											   url : "http://www.cncmmo.com/newsite/index.php/Index/loaduserstate", //与此php页面沟通
											   //dataType:'json',//从php返回的值以 JSON方式 解释
											   //data:  'vcode='+vcode+'&contents='+contents, //发给php的数据有两项，分别是上面传来的u和p   
											   success: function(data){
												   		if(data=="anonymous"){//没有登录
															islogin=false;
															$("#usernamefld").html("匿名");
															$("#userstate").load("http://www.cncmmo.com/newsite/Public/tpl/userstate_logout.php");
														}else{//已经登录
															islogin=true;
															if(data.indexOf("|")>0){
																$("#usernamefld").html(data.substring(0,data.indexOf("|")));
															}else{
																$("#usernamefld").html(data);
																}
															$("#topusername").html(data);
															$("#userstate").load("http://www.cncmmo.com/newsite/Public/tpl/userstate_login.php",{"username":data});
															}
												   		
												  }//success   
											   });
		   
		   });






//评论操作

//加载最后一个评论
function loadlastcomment(catid,aimid){
	$.ajax({
		   		type: "post",
		   		url : "http://www.cncmmo.com/newsite/index.php/Index/getlastcomment",
		    	data:  'catid='+catid+'&aimid='+aimid,
				success: function(data){
					$("#info_details_div_left_comment_last").html(data);
				}
		   });
}
$(function(){
		 
		   
		   
		   
		   
		   $("#postcommentbtn").click(function(){
											  
											  	 if(!islogin){
													 showbox("你还没有登录，请登录后再操作！",5);
													 return false;
													 }
											  	
											  
											 //验证码
												 var vcode=trim($("#vcode").val());
												 
												 //内容
												 var contents=trim($("#contents").val());
												 
												 
												 //其它项
												 var aimid=$("#aimid").val();
												 var catid=$("#catid").val();
												 
												 //内容为空												 
												 if(contents.length==0){
													showbox("评论内容不能为空",5);
												 	return;
												 }
												  
												 //内容多于字数												 
												 if(contents.length>200){
													showbox("评论内容不能超过200字",5);
												 	return false;
												 }
												 //验证码为空
												 if(vcode.length==0){
													showbox("验证码不能为空",5);
												 	return false;
												 }
												 
												 
											 $.ajax({ //一个Ajax过程  
											   type: "post",  //以post方式与后台沟通
											   url : "http://www.cncmmo.com/newsite/index.php/Index/addcomment", //与此php页面沟通
											   //dataType:'json',//从php返回的值以 JSON方式 解释
											   data:  'vcode='+vcode+'&body='+contents+'&catid='+catid+'&aimid='+aimid, //发给php的数据有两项，分别是上面传来的u和p   
											   success: function(data){
												   		if(data=="login"){
													   		showbox("你还没有登录，登录后操作！",5);
													  	}else if(data=="vcode"){
															showbox("验证码不正确，请重新输入！",5);
														}else if(data=="posterr"){
															showbox("评论失败，可能是评论人数太多，请尝试稍后操作！",5);
														}else{
															showbox("评论成功，感谢你的参与！",5);
															$("#info_details_div_left_comment_last").html(data);
														}
												   }   
											   });

																									 
												 
											});//$("#postcommentbtn").click
		   });
//--------------------------发表评论--------------------------------


//查看所有评论
$(function(){
		   $("#allcommentlink").click(function(){
											   var catid=$("#catid").val();
											   var aimid=$("#aimid").val();
											   $("#info_details_div_left_cover").css("display","block");
											   $("#info_details_div_left_listcomment").css("display","block");
											   	var a=$("#info_details_div_left").height();
												var b=$("#info_details_div_left_cover").height();
												var c=$("#info_details_div_left_listcomment").height();
											   	if(b<=a){
													$("#info_details_div_left_cover").height(a);													
												}
												if(c<=a){
													$("#info_details_div_left_listcomment").height(a);	
												}
												$("#commentlistholder").load("http://www.cncmmo.com/newsite/index.php/Index/showallcomment",{"catid":catid,"aimid":aimid});
											   });
		   
		   
		   $("#commentclosebtn").click(function(){
												$("#info_details_div_left_cover").css("display","none");
												$("#info_details_div_left_listcomment").css("display","none");
												});
		   });
			
//查看所有评论
