// JavaScript Document
var pageft = {
		getObj:function (objID)
		{
			if (document.getElementById) {return document.getElementById(objID);}
			else if (document.all) {return document.all[objID];}
			else if (document.layers) {return document.layers[objID];}
		},
		pagefit: function (pid , curr , bname) {
		var basename = bname+".php";
		var url = document.location.search;  
		var arr = new Array('i5','i4','i3','i2','i1');
		var pnum = new Array(-2,-1,0,1,2);
		if(url.indexOf("?") != -1 && url != '') {
/*		        var paraString = url.substring(url.indexOf("?")+1,url.length);  
			    var parsep = paraString.split("=");
				*/

					var paraString = url.substring(1,url.length).split('&');
					var paras = '';
					for(i = 0 ; i < paraString.length ; i++) {
						 var para = paraString[i].split('=');
						   if(para[0] != 'p' ) {
							paras += '&'+paraString[i];
						   }
					}

				           if( isNaN(pid) || isNaN(curr)) {  
						        alert('参数错误!'); window.location.href=basename; 
						   }
						   for(i = 0 ; i < arr.length - pid ; i++) {
									    this.getObj(arr[i]).style.display = 'none';
						         }
						   for(var j = 1 ; j < 6 ; j++) {
							         this.getObj('i'+j).className = 'fy';
							    } 
						   if(curr > 3 ) {
							 
							       if(curr + 2 <= pid) {
										for(k= 1 ; k < 6 ; k++ ) {
											
											this.getObj('i'+k).href= basename+'?p='+ (curr + pnum[k-1]) + paras; 
											
											this.getObj('i'+k).innerHTML = curr + pnum[k-1] ;
											}
											this.getObj('i3').className = 'fy2';
									}else {
										for(var x = 1 ; x < 6 ; x++ ){
											var plast = (pid >= 5)?5:pid ;
										    this.getObj('i'+x).href= basename+'?p='+ (pid - plast + x) + paras; 
											
											this.getObj('i'+x).innerHTML = pid  - plast + x ;
										}
										if (pid == curr) {
										   this.getObj('i'+plast).className = 'fy2';
										} 
										if(pid == curr + 1) {
										   this.getObj('i4').className = 'fy2';
										}
										
								
									}
										
							} else {
								   this.getObj('i'+curr).className = 'fy2';
							}

				} else {
					      for(i = 0 ; i < arr.length - pid ; i++) {
									this.getObj(arr[i]).style.display = 'none';
						      }
						  for(var j = 1 ; j < 6 ; j++) {
							       this.getObj('i'+j).className = 'fy';
							  }
				          this.getObj('i'+curr).className = 'fy2';
				}
				
							if(curr == pid) {
								this.getObj('next').style.display = 'none';
								this.getObj('last').style.display = 'none';
							}
							if(curr == 1) {
								this.getObj('pre').style.display = 'none';
								this.getObj('index').style.display = 'none';				  
							}
							if(pid == 1 ) {
								this.getObj('pre').style.display = 'none';
								this.getObj('index').style.display = 'none';
								this.getObj('i1').style.display = 'none';
								this.getObj('next').style.display = 'none';
								this.getObj('last').style.display = 'none';
							}
							if(pid == 0) {
							    this.getObj('next').style.display = 'none';
								this.getObj('last').style.display = 'none'; 
							}
		} ,
				
		rewrite_page: function (pid, curr , basename, ext) {
		var url = document.location.search;  
		var arr = new Array('i5','i4','i3','i2','i1');
		var pnum = new Array(-2,-1,0,1,2);
		if(pid > 0) {
				           if( isNaN(pid) || isNaN(curr)) {  
						        alert('参数错误!'); window.location.href=basename; 
						   }
						   for(i = 0 ; i < arr.length - pid ; i++) {
									    this.getObj(arr[i]).style.display = 'none';
						         }
						   for(var j = 1 ; j < 6 ; j++) {
							         this.getObj('i'+j).className = 'fy';
							    } 
						   if(curr > 3 ) {
							 
							       if(curr + 2 <= pid) {
										for(k= 1 ; k < 6 ; k++ ) {
											
											this.getObj('i'+k).href= basename+ (curr + pnum[k-1])+"."+ext; 
											
											this.getObj('i'+k).innerHTML = curr + pnum[k-1] ;
											}
											this.getObj('i3').className = 'fy2';
									}else {
										for(var x = 1 ; x < 6 ; x++ ){
											var plast = (pid >= 5)?5:pid ;
										    this.getObj('i'+x).href= basename+ (pid - plast + x)+"."+ext; 
											
											this.getObj('i'+x).innerHTML = pid  - plast + x ;
										}
										if (pid == curr) {
										   this.getObj('i'+plast).className = 'fy2';
										} 
										if(pid == curr + 1) {
										   this.getObj('i4').className = 'fy2';
										}
										
								
									}
										
							} else {
								   this.getObj('i'+curr).className = 'fy2';
							}

				} else {
					      for(i = 0 ; i < arr.length - pid ; i++) {
									this.getObj(arr[i]).style.display = 'none';
						      }
						  for(var j = 1 ; j < 6 ; j++) {
							       this.getObj('i'+j).className = 'fy';
							  }
				          this.getObj('i'+curr).className = 'fy2';
				}
				
							if(curr == pid) {
								this.getObj('next').style.display = 'none';
								this.getObj('last').style.display = 'none';
							}
							if(curr == 1) {
								this.getObj('pre').style.display = 'none';
								this.getObj('index').style.display = 'none';				  
							}
							if(pid == 1 ) {
								this.getObj('pre').style.display = 'none';
								this.getObj('index').style.display = 'none';
								this.getObj('i1').style.display = 'none';
								this.getObj('next').style.display = 'none';
								this.getObj('last').style.display = 'none';
							}
							if(pid == 0) {
							    this.getObj('next').style.display = 'none';
								this.getObj('last').style.display = 'none'; 
							}
		} 	  
		
}

