		
		function setSize( s ) {
			size = s;
		}
		
		function setProjectPath( path ) {
			projectPath = path;
		}
		
		function setPreviousPic( previous ) {
			previousPic = previous;
		}
		
		function setNextPic( next ) {
			nextPic = next;
		}
		
		function select( index ) {			
			currentPic = index + 1;
			var url = picList[index];				
			loading();	
			loadImage(url, imgLoaded);
		}

		function next( requestURL ) {
			// requestURL = cartoonPicDetail.do?pid=
			if( currentPic+1 <= size ) {
				currentPic = currentPic + 1;
				var url = picList[currentPic-1];
				loading();	
				loadImage(url, imgLoaded);
			} else {
				if( nextPic != "null" ) {
					location.reload(projectPath + requestURL + nextPic);
				}
			}
		}
		
		function previous( requestURL ) {
			// requestURL = cartoonPicDetail.do?pid=
			if( currentPic-1 > 0 ) {
				currentPic = currentPic - 1;
				var url = picList[currentPic-1];				
				loading();	
				loadImage(url, imgLoaded);
			} else {
				if( previousPic != "null" ) {
					location.reload(projectPath + requestURL + previousPic);
				}
			}
		}
	
		function loadImage(url, callback) {
			var img = new Image(); 
			img.src = url;
			if (img.complete) { 
		//		alert('img.complete');
				callback.call(img);
				return; 
			}
				
			img.onload = function () { 
				callback.call(img);
			};
		}
			
		function imgLoaded(){
		
			document.getElementById('loadingImgDiv').style.filter='Alpha(Opacity=0)';
			document.getElementById('loadingImgDiv').style.opacity='0'; 
		  	var imgW = this.width;
		  	var imgH = this.height;
		  	  
		  	if( imgW != 600 ) {		
				imgH = 600/imgW * imgH;
				imgW = 600;
		 	}
		  
		  	var middle = imgW/2;
		  
		  	document.getElementById("showPicDiv").style.width=imgW+"px";
		  	document.getElementById("showPicDiv").style.height=imgH+"px";
		  	document.getElementById("showPic").src=this.src;	 
		  	document.getElementById("rightDiv").style.width=imgW+"px";
		  	document.getElementById("rightDiv").style.height=imgH+"px";
		  	document.getElementById("leftDiv").style.width=middle+"px";
		  	document.getElementById("leftDiv").style.height=imgH+"px"; 	
	
			if( currentPic+1 <= size ) {
				document.getElementById("rightDiv").title="下一张";
			}else {
				if( nextPic != "null" ) {
					document.getElementById("rightDiv").title="下一个漫画";
				}else {		
					document.getElementById("rightDiv").title="后面已经没有其他图片了";
				}	
			}
			
			if( currentPic-1 > 0 ) {
				document.getElementById("leftDiv").title="上一张";
			}else {
				if( previousPic != "null" ) {
					document.getElementById("leftDiv").title="上一个漫画";
				}else {
					document.getElementById("leftDiv").title="前面已经没有其他图片了";
				}	
			}		
			
		}
		
		function loading() {	
			var img = document.getElementById("showPic");
			var imgW = img.width;
			var imgH = img.height;
			imgW = imgW/2 - 50;  
			imgH = imgH/2 - 50;
			var loadingDiv = document.getElementById("loadingImgDiv");
			loadingDiv.style.left=imgW+"px";
			loadingDiv.style.top=imgH+"px";
			document.getElementById('loadingImgDiv').style.filter='Alpha(Opacity=100)';
			document.getElementById('loadingImgDiv').style.opacity='1'; 
		}
