function loading() {
	 C.ajax({
		type:'post',
		url:'ajax.php',
		data:'do=loading',
		sending:function() {
			C.html(C.$('#cen_left_2'),'正在载入数据...');
		},
		success:function(msg) {
			C.html(C.$('#cen_left_2'),msg);
		}
	 });

}
//搜索
function dosearch() {
	var keywords = C.val(C.$('#keyword'));
	C.ajax({
		type:'post',
		url:'ajax.php',
		data:'do=search&keywords='+keywords,
		sending:function() {
			C.html(C.$('#cen_left_2'),'正在为您搜索中,请稍等...');
		},
		success:function(msg) {
			if (msg=='0') {
				msg = '请输入关键词^_^';
			}else if(msg=='2') {
				msg = '没有搜索到相关结果^_^';
			}else{
				C.css(C.$('#cen_left_3'),{display:'none'});
				C.css(C.$('#cen_left_5'),{display:'none'});
			}
			C.html(C.$('#cen_left_2'),msg);
		}
	});
}
//ajax 翻頁
function ajaxpage(url,divname) {
	C.ajax({
		type:'post',
		url:url,
		data:url,
		sending:function(){
			C.html(C.$('#'+divname),'正在提交请求,请稍候...');
		},
		success:function(msg){
			C.html(C.$('#'+divname),msg);
		}
	});

}
function clearDialog() {
	C.remove(C.$('#responsecom'));
}
function dialog(msg,w,h) {
	var w=w||'',h=h||'',mWidth = document.documentElement.clientWidth,mHeight=document.documentElement.clientHeight,scroll=document.documentElement.scrollTop||document.body.scrollTop;
	var bjobj = document.createElement('div');
	C.css(bjobj,{position:'absolute',left:(mWidth-w)/2+'px',top:(mHeight/3+scroll)+'px',width:w+'px',height:h+'px'});
	C.attr(bjobj,{id:'responsecom'});
	C.html(bjobj,msg);
	setTimeout("clearDialog()",1500);
	C.append(document.body,bjobj);
}
//发表评论
function comment() {
	var articleid = C.val(C.$('#articleid'));
	var comauthor = C.val(C.$('#comauthor'));
	var comurl =   C.val(C.$('#comurl'));
	var comcontents = C.val(C.$('#comcontents'));
	if(C.trim(comauthor)=='' || C.trim(comcontents)=='') {
		dialog('漏写了啥东西哈,呵呵!^_^');
		return ;
	}
	C.ajax({
		type:'post',
		url:'ajax.php',
		data:'do=comment&articleid='+articleid+'&comauthor='+comauthor+'&comurl='+comurl+'&comcontents='+comcontents,
		success:function(msg){
			switch (msg) {
			case '0':   dialog('请不要本地提交数据^_^');
			break;
			case '1':	dialog('评论间隔为30秒,休息下^_^');
			break;
			case '2':	dialog('信息不完整或数据库出错^_^');
			break;
			default : 
					  var ele = C.$('#ajaxcomcontent');
					  var comdiv = document.createElement('div');
					  C.attr(comdiv,{'class':'comcontent'});
					  C.html(comdiv,msg);
					  if(ele[0].children.length==0) {
						C.append(ele,comdiv);
					  }else {
						C.before(ele[0].children.item(0),comdiv);
					  }				  
					  dialog('发表评论成功^_^');
					  C.css(C.$('#nocomment'),{display:'none'});
			break;
			}
		}
	});		
}//end function
//index.php右侧分类日志
function category(cateid) {
	C.ajax({
		type:'post',
		url:'ajax.php',
		data:'do=category&cateid='+cateid,
		sending:function(){
			C.html(C.$('#cen_left_2'),'正在提交请求,请稍候...');
		},
		success:function(msg){
			if(msg=='') {
				msg = '{该分类下没有文章!^_^}';
			}
			C.html(C.$('#cen_left_2'),msg);
		}
	});
}
//article.php右侧分类日志
function acategory(cateid) {
	C.ajax({
		type:'post',
		url:'ajax.php',
		data:'do=category&cateid='+cateid,
		sending:function(){
			C.html(C.$('#cen_left_2'),'正在提交请求,请稍候...');
		},
		success:function(msg){
			C.css(C.$('#cen_left_3'),{display:'none'});
			C.css(C.$('#cen_left_5'),{display:'none'});
			if(msg=='') {
				msg = '{该分类下没有文章!^_^}';
			}
			C.html(C.$('#cen_left_2'),msg);
		}
	});

}
function popping(src) {
	var msgWidth = 800,msgHeight = 600,img = new Image(),rate;
	var mWidth = document.documentElement.clientWidth,mHeight=document.documentElement.clientHeight,lHeight=document.body.clientHeight,scroll=document.documentElement.scrollTop||document.body.scrollTop;
	img.src = src;
	if(img.height>msgHeight-30) {
		rate = (msgHeight-30)/img.height;
		img.height = msgHeight-30;	
		img.width = img.width*rate;
	}
	if(img.width>msgWidth-10) {
		rate = (msgWidth-10)/img.width;
		img.width = msgWidth-10;
		img.height = img.height*rate;
	}
	var bgobj = document.createElement('div');
	C.css(bgobj,{position:'absolute',left:'0px',top:'0px',background:'#000',filter:'Alpha(Opacity=40,finishOpacity=70)',opacity:'0.1',width:mWidth+'px',height:lHeight+'px','z-index':'100'});
	C.append(document.body,bgobj);
	var msgobj = document.createElement('div');
	C.css(msgobj,{position:'absolute',left:(mWidth-img.width)/2+'px',top:((mHeight/7)+scroll)+'px','z-index':'101'});
	C.append(document.body,msgobj);

	var close = document.createElement('span');
	C.attr(close,{title:'关闭'});
	C.html(close,'关闭');
	C.bind(close,'click',function(){
		C.remove(bgobj);
		C.remove(msgobj);
	});
	C.css(close,{position:'relative',width:'20px',background:'#fff','left':(img.width-10)+'px',top:'-10px',cursor:'pointer'});
	C.append(msgobj,close);

	var imgobj = document.createElement('img');
	C.attr(imgobj,{src:img.src});
	C.css(imgobj,{padding:'padding:0 4px 0 4px',margin:'0',width:img.width+'px',height:img.height+'px'});
	C.append(msgobj,imgobj);
}
