//id：表示する場所のElementId
//disp_spot_num：1ページあたりの表示制限数
function PageManager(page_links_id, obj_name, url, disp_spot_num){
	this.obj_name = obj_name;
	this.page_links_id = page_links_id;
	this.disp_area_ids = new Array();
	this.disp_spot_num = disp_spot_num;
	this.disp_page_num = 1;
	this.srch_type;
	this.srch_val = new Array();
	this.url = url;
	this.total=0;
}


//ページリンク作成
//total：総データ数
//disp_page_num：現在表示しているページ番号
function PageManager_createMnListPageLinks(total, disp_page_num){
	var i, plinks="";
	this.total = total;
	
	//総ページ数の判定
	var total_page_num = Math.ceil(total / this.disp_spot_num);
	
	for(i=1; i<=total_page_num; i++){
		if(disp_page_num == i){
			plinks += i;
		}else{
			plinks += '<span style="color: #0000ff; border-bottom: solid 1px #0000ff; cursor:pointer;" onclick="'
					+ this.obj_name +'.chPage('+ i +')">'+ i +'</span>';
		}
		if(i != total_page_num){ plinks += "・" };
	}
	document.getElementById(this.page_links_id).innerHTML= plinks;
}

function PageManager_removeMnListPageLinks(){
	document.getElementById(this.page_links_id).innerHTML="";
}

function PageManager_setSrchVal(srch_str, ctg_id, sctg_id, area_id, lang){
	this.srch_val = {
		'srch_str': srch_str,
        'ctg_id': ctg_id,
        'sctg_id': sctg_id,
        'area_id': area_id,
        'lang': lang
    }
}

function PageManager_addDispArea(id){
	this.disp_area_ids.push(id);
}

function PageManager_removeDispArea(){
	var i=0;
	while(this.disp_area_ids[i]!=null){
		document.getElementById(this.disp_area_ids[i]).innerHTML = "";
		i++;
	}
}

function PageManager_chPage(page_num){
	//this.removeMnListPageLinks();
	loading("block");
	document.getElementById("mn_map").style.display = "none";
	//document.getElementById("mn_list_area").style.display = "none";
	
	this.disp_page_num = page_num;
	this.createMnListPageLinks(this.total, page_num);
	var url = this.url +"/srch_str/"+ this.srch_val.srch_str +"/ctg_id/"+ this.srch_val.ctg_id
				+"/sctg_id/"+ this.srch_val.sctg_id +"/area_id/"+ this.srch_val.area_id +"/limit/"
				+ this.disp_spot_num +"/offset/"+ this.disp_spot_num*(page_num-1);
	new Ajax.Request(url, { method: 'get', onComplete: chMnMapMarker });
}

function PageManager_getSrchStr(){
	return this.srch_val.srch_str;
}
function PageManager_getCtgId(){
	return this.srch_val.ctg_id;
}
function PageManager_getSctgId(){
	return this.srch_val.sctg_id;
}
function PageManager_getAreaId(){
	return this.srch_val.area_id;
}
function PageManager_getPageNum(){
	return this.disp_page_num;
}
function PageManager_setPageNum(page_num){
	this.disp_page_num = page_num;
}
function PageManager_getLang(){
	return this.srch_val.lang;
}
	
new PageManager(); //ダミー（Netscape Navigator Ver2, Ver3のバグへの対処）
//メソッドの設定
PageManager.prototype.createMnListPageLinks = PageManager_createMnListPageLinks;
PageManager.prototype.removeMnListPageLinks = PageManager_removeMnListPageLinks;
PageManager.prototype.setSrchVal = PageManager_setSrchVal;
PageManager.prototype.addDispArea = PageManager_addDispArea;
PageManager.prototype.removeDispArea = PageManager_removeDispArea;
PageManager.prototype.chPage = PageManager_chPage;
PageManager.prototype.getSrchStr = PageManager_getSrchStr;
PageManager.prototype.getCtgId = PageManager_getCtgId;
PageManager.prototype.getSctgId = PageManager_getSctgId;
PageManager.prototype.getAreaId = PageManager_getAreaId;
PageManager.prototype.getPageNum = PageManager_getPageNum;
PageManager.prototype.setPageNum = PageManager_setPageNum;
PageManager.prototype.getLang = PageManager_getLang;


