// JavaScript Document
var Request={ 
 QueryString:function(val) { 
 var uri = window.location.search; 
 var re = new RegExp("" +val+ "=([^&?]*)", "ig"); 
 return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null); 
 }};
 
 var loading="<p style='text-align:center'><img src='images/loading.gif'/></p>";
 var errmsg="<p style='text-align:center'>暂无可用数据！</p>";
 var url='ajax.asp';
 //读取首页显示的新闻
function getNews(containerId,newsType,newsCount){
	var option={method:'get',
			parameters:{action:'topNews',tp:newsType,ncount:newsCount},
			onCreate:function(){
				$(containerId).update(loading);
				}
		};
	new Ajax.Updater({success:containerId,failure:containerId},url,option);
}

//读取新闻公告列表
function getNewsList(containerId,page,tp,yr){
		var option={method:'get',
			parameters:{action:'newsList',page:page,tp:tp,yr:yr},
			onCreate:function(){
				$(containerId).update(loading);
				},
			onSuccess:function(rp){
				$(containerId).update(rp.responseText);
				}
			};
		new Ajax.Request(url,option);
	}
	
//读取新闻详细信息
function getNewsInfo(containerId,id){
	var option={method:'get',
		parameters:{action:'newsInfo',id:id},
		onCreate:function(){
			$(containerId).update(loading);
			}
		};
		new Ajax.Updater({success:containerId,failure:containerId},url,option);
	}

function getEnterpriseInfo(containerId,id){
	var option={method:'get',
		parameters:{action:'newsInfo',id:id},
		onCreate:function(){
			$(containerId).update(loading);
			},
		onSuccess:function(rp){
			$(containerId).update(rp.responseText+'<div style="text-align:center">【<a href="javascript:location.reload();">返回</a>】</div>')
			}
		};
		new Ajax.Request(url,option);
	}
//读取本地的文件
function readFile(containerId,url){
		var url=url+'.html';
		var option={method:'get',
			evalJS:'force',
			onCreate:function(){
				$(containerId).update(loading);
				},
			onSuccess:function(data){
				$(containerId).update(data.responseText)
				},
			onFailure:function(){
				$(containerId).update(errmsg);
				return;
				}
			};
		new Ajax.Request(url,option);
	}
//读取产品列表
function getProductsList(containerId,page,cid){
		var pre="<div style='margin-left:20px;'><img src='images/p_taix.gif'/></div>"
		document.cache_list=$(containerId).innerHTML;
		var option={method:'get',
			parameters:{action:'plist',page:page,cid:cid},
			onCreate:function(){
				$(containerId).update(loading);
				},
			onSuccess:function(rp){
				$(containerId).update(pre+rp.responseText);
				}
			};
		new Ajax.Request(url,option);
	}
	
//	获取产品的详细信息
	function getProductInfo(id)
	{
		document.cache_info=$('content').innerHTML;
		var option={method:'get',
			parameters:{action:'pinfo',id:id},
			onCreate:function(){
				$('content').update(loading);
				},
			onSuccess:function(rp){
				$('content').update(rp.responseText);
				}
			};
		new Ajax.Request(url,option);
	}

function backToList(){
		$('content').update(document.cache_info);
	}

function backToIndex(){
	$('content').update(document.cache_list);
	}
	
function getYearList(currentYear){
	var option={method:'get',
		parameters:{action:'years',yr:currentYear},
		onCreate:function(){
			$('yr').update(loading);
			},
		onSuccess:function(rp){
			$('yr').update(rp.responseText);
			}
		};
	new Ajax.Request(url,option);
	}
	
function getActiveList(){
	var option={method:'get',
		parameters:{action:'active'},
		onCreate:function(){
			$('content').update(loading);
			},
		onSuccess:function(rp){
			$('content').update(rp.responseText);
			}
		};
	new Ajax.Request(url,option);
	}

//获取首页最新图片
function getLatestPic(){
	var option={method:'get',
		parameters:{action:'getpic'},
		onCreate:function(){
			$('latestpic').update(loading);
			},
		onSuccess:function(rp){
			$('latestpic').update(rp.responseText);
			},
		onFailure:function(rp){
			document.write(rp.responseText);
			}
		};
		new Ajax.Request(url,option);
	}

function getEntList(containerId,page)
{
	var option={method:'get',
		parameters:{action:'entlist',page:page},
		onCreate:function(){
			$(containerId).update(loading);
			}
		};
	new Ajax.Updater({success:containerId,failure:containerId},url,option);
}

//获取招聘信息
function getWantInfo(){
	var option={method:'get',
			parameters:{action:'want'},
			onCreate:function(){
				$('mycontent').update(loading);
				},
			onSuccess:function(rp){
				$('mycontent').update(rp.responseText);
				}
		};
	new Ajax.Request(url,option);
	}

//获取党群活动信息
function getFlagList(page){
	var option={method:'get',
		parameters:{action:'flaglist',page:page},
		onCreate:function(){
			$('mycontent').update(loading);
			}
		};
	new Ajax.Updater('mycontent',url,option);
	}
//获取党群活动信息
function getFlagInfo(id){
	var option={method:'get',
			parameters:{action:'flaginfo',id:id},
			onCreate:function(){
				$('mycontent').update(loading);
				},
			onSuccess:function(rp){
				$('mycontent').update(rp.responseText);
				}
		};
		new Ajax.Request(url,option);
	}
