//页面通用异步加载方法
function loadData(aUrl,jsonVal,pElmObj,type,isPost)
{
	if(type==true){
			javascript:scroll(0,0); 
	}
	jsonVal.reqUrl = aUrl;
	if(pElmObj===undefined || pElmObj==="" || pElmObj===null)
	 	pElmObj=$('#content');
	var sendType = "post";
	if(!isPost)
	  sendType = "get";
	jQuery.ajax({
		type: sendType,
		url: aUrl,
		cache:false,
		data:jsonVal,
		beforeSend: function(XMLHttpRequest){ 
			showLoading(pElmObj);
		},
		success: function(data, textStatus)
		{
			pElmObj.html(data);
			
		},
		complete: function(XMLHttpRequest, textStatus){
			//
		},
		error: function(){
			//请求出错处理
			$('#infoCenter').html("<div class='loadimg'>加载数据失败！</div>");
		}
    });
}

function showLoading(jObj)
{
	jObj.get(0).innerHTML="<div style='background:none;' style='margin:5px;'><img src='/web/images/common/loading.gif' />&nbsp;&nbsp;正在加载内容，请稍候... ...</div>";
}

/*以下为模拟登录和评论的js 暂时放在这里*/

//发表评论
function doComments(){
	var articleid=$("#articleid").val();
 	var commentDetail=$("#commentDetail").val();
	if(commentDetail==""||$.trim(commentDetail)==""){
		alert("评论内容不能为空");
		$("#commentDetail").focus();
		return false;
	}else{
		var isIngorename=0;//不匿名
		if($("#ignoreName")[0].checked==true){
			isIngorename=1;//匿名登录
		}
		commentDetail=encodeURI(encodeURI(commentDetail));
		$.ajax({
				type: "post",
				url:"/cgi-bin/news/ArticleAction?function=AjaxComments",
				dataType: 'json',
				cache:false,
				data: {"articleid":articleid,"msg":commentDetail,"isIngorename":isIngorename},
				beforeSend: function(XMLHttpRequest){
					//showLoading(jQuery('#divShow'));
				},
				success: function(json, textStatus)
				{
						if(json != null && json != "")
						{
							if(json[0].flag=="1")
							{
								alert("评论成功，已提交审核."); 
								$("#commentDetail").val("");
							}else if(json[0].flag=="0"){
								alert("对不起，您还没有登录，请先登录再评论.");
							}else if(json[0].flag=="-2"){
								alert("对不起，您的操作过于频繁，请稍候再试.");
							}else{
								alert("对不起，系统忙，请稍后再试");
							}
						}else{
							alert("对不起，系统忙，请稍后再试");
						}
	
				}
				
});
	}
}

//视频加载时的样式
function loadData1(aUrl,jsonVal,pElmObj,type,isPost)
{
	if(type==true){
			javascript:scroll(0,0); }
	jsonVal.reqUrl = aUrl;
	if(pElmObj===undefined || pElmObj==="" || pElmObj===null)
	 	pElmObj=$('#content');
	var sendType = "post";
	if(!isPost)
	  sendType = "get";
	jQuery.ajax({
		type: sendType,
		url: aUrl,
		cache:false,
		data:jsonVal,
		beforeSend: function(XMLHttpRequest){ 
			showLoading1(pElmObj);
		},
		success: function(data, textStatus)
		{
			pElmObj.html(data);
			
		},
		complete: function(XMLHttpRequest, textStatus){
			//
		},
		error: function(){
			//请求出错处理
			$('#infoCenter').html("<div class='loadimg'  style='background:#E7EAF1;color:#ffffff;'>加载数据失败！</div>");
		}
    });
}

function showLoading1(jObj)
{
	jObj.get(0).innerHTML="<div class='loadbox' style=' text-align:center;'><div class='loading' style='background:#E7EAF1;'><img src='/chart/video/038.gif' width='24' height='24' /></div></div>";
}

//产品加载时的样式
function loadData2(aUrl,jsonVal,pElmObj,type,isPost)
{
	if(type==true){
			javascript:scroll(0,0); }
	jsonVal.reqUrl = aUrl;
	if(pElmObj===undefined || pElmObj==="" || pElmObj===null)
	 	pElmObj=$('#content');
	var sendType = "post";
	if(!isPost)
	  sendType = "get";
	jQuery.ajax({
		type: sendType,
		url: aUrl,
		cache:false,
		data:jsonVal,
		beforeSend: function(XMLHttpRequest){ 
			showLoading2(pElmObj);
		},
		success: function(data, textStatus)
		{
			pElmObj.html(data);
			
		},
		complete: function(XMLHttpRequest, textStatus){
			//
		},
		error: function(){
			//请求出错处理
			$('#infoCenter').html("<div class='loadimg'>加载数据失败！</div>");
		}
    });
}

function showLoading2(jObj)
{
    var thtml="<DIV class=w537 id=right><DIV class=round_position><DIV class=left_round_top></DIV><DIV class=right_round_top></DIV></DIV><DIV class='top_tit top_b_color'><DIV class=top_bg><SPAN class='title titlebg'>正在加载产品信息...</SPAN></DIV></DIV>";
    var bhtml="<DIV class='space_height15 h5bg1 pr'><DIV class=left_round_bot></DIV><DIV class=right_round_bot></DIV></DIV></DIV>";
	jObj.get(0).innerHTML=thtml+"<div class='loadbox' style=' text-align:center;height:50px;'><div class='loading' style='background:#FFFFFF;'><img src='/web/images/common/loading.gif' />正在载入……</div></div>"+bhtml;
}

//页面通用异步加载方法
function sploadData(aUrl,jsonVal,pElmObj,type,isPost)
{
	if(type==true){
			javascript:scroll(0,1210); }
	jsonVal.reqUrl = aUrl;
	if(pElmObj===undefined || pElmObj==="" || pElmObj===null)
	 	pElmObj=$('#content');
	var sendType = "post";
	if(!isPost)
	  sendType = "get";
	jQuery.ajax({
		type: sendType,
		url: aUrl,
		cache:false,
		data:jsonVal,
		beforeSend: function(XMLHttpRequest){ 
			spshowLoading(pElmObj);
		},
		success: function(data, textStatus)
		{
			pElmObj.html(data);
			
		},
		complete: function(XMLHttpRequest, textStatus){
			//
		},
		error: function(){
			//请求出错处理
			$('#infoCenter').html("<div class='loadimg'>加载数据失败！</div>");
		}
    });
}

function spshowLoading(jObj)
{
	jObj.get(0).innerHTML="<div class='loadbox' style=' text-align:center;'><div class='loading' style='background:#FFFFFF;'><img src='/web/images/common/loading.gif' />正在载入……</div></div>";
}

	
