class Dotto{
	constructor(yoko,tate,name,source,canvas){
		this.yoko=yoko;
		this.tate=tate;
		this.namae=name;
		this.id="";
		this.img=document.createElement('img');
		this.img.src=source;
		this.canvas=canvas;
		this.koma=0;
		this.otos=new Array();
		this.kazu=0;
		this.kazu2=0;
	}
	oto(on){
		for(var os=0;os<arguments.length;os++){
			if(os>0){
				if(this.otos[arguments[os]]==undefined){
					this.otos[arguments[os]]=new Array();
					this.otos[arguments[os]].push(on);
				}else{					
					this.otos[arguments[os]].push(on);					
				}
			}			
		};
		
	};
	haikei(x,y,line,col){		
		if(line==undefined){
			line=0;
		};
		if(col==undefined){
			col=0;
		};
		this.canvas.drawImage(this.img,col*this.yoko,line*this.tate,this.yoko,this.tate,x,y,this.yoko,this.tate);
	};
	kyara(x,y,line,col){
		if(line==undefined){
			line=0;
		};
		if(col==undefined){
			col=0;
		};
		this.canvas.drawImage(this.img,col*this.yoko,line*this.tate,this.yoko,this.tate,x-(this.yoko/2),y-this.tate,this.yoko,this.tate);		
	};
	ani(x,y,line,repeat,action){
		if(line==undefined){
			line=0;
		};		
		if(this.otos[this.koma]!=undefined){			
			for(var kot=0;kot<this.otos[this.koma].length;kot++){
				this.otos[this.koma][kot].p();
			}
		};
		this.canvas.drawImage(this.img,this.koma*this.yoko,line*this.tate,this.yoko,this.tate,x-(this.yoko/2),y-this.tate,this.yoko,this.tate);
		
		this.koma++;
		if(repeat!=undefined){
			if(action!=undefined){
				if(action=='stop'){
					if(this.koma>repeat){
						this.koma=repeat;
					}
				}else if(action=='talk'){
					if(this.koma>=repeat){
						var ran=Math.floor(Math.random()*20);		
						if(ran<10){
							this.koma=repeat;
						}else if(ran<18){
							this.koma=repeat+2;
						}else{
							this.koma=repeat+1;
						}								
					}
					
				}
			}else{
				if(this.koma*this.yoko>=this.img.width){
					this.koma=repeat;
				}
			}
		}else{
			if(this.koma*this.yoko>=this.img.width){
				this.koma=0;				
			}
		}
	};
	talk(x,y,line){
		if(line==undefined){
			line=0;
		};				
		var ran=Math.floor(Math.random()*20);		
		if(ran<10){
			var frame=0;
		}else if(ran<18){
			var frame=2;
		}else{
			var frame=1;
		}		
		this.canvas.drawImage(this.img,frame*this.yoko,line*this.tate,this.yoko,this.tate,x-(this.yoko/2),y-this.tate,this.yoko,this.tate);
	};
};
class Chiiki{
	constructor(x1,y1,x2,y2){
		this.x1=x1;
		this.y1=y1;
		this.x2=x2;
		this.y2=y2;
		this.mix;
		this.max;
	};
	c(x,y){
		if(x>=this.x1&x<=this.x2&y>=this.y1&y<=this.y2){
			return true
		}else{
			return false
		}
	};
	d(x,y){
		var ty=y-this.y1;
		var ty2=y-this.y2;
		if(y>=this.y1&y<=this.y2&x>=(this.x1-ty)&x<=(this.x2-ty2)){
			return true
		}else{
			return false
		}
	};	
	mi(y){		
		this.mix=(this.x1-(y-this.y1));
		return this.x1-(y-this.y1)
	};
	ma(y){		
		this.max=(this.x2+(this.y2-y));
		return this.x2+(this.y2-y)
	};
};
class Oto{
	constructor(moto){
		this.o1=new Audio(moto);
		this.o2=new Audio(moto);
		this.o2.volume=0.6;
	};
	p(){
		if(this.o1.currentTime==this.o1.duration|this.o1.currentTime==0){
			this.o1.play();
		}else if(this.o2.currentTime==this.o2.duration|this.o2.currentTime==0){
			this.o2.play();
		}
	};
};

class Sou{
	constructor(namae){
		this.namae=namae;
		this.main=new Array();		
		this.temp=new Array();
	}
	tasu(){		
		for(var tt=0;tt<arguments.length;tt++){
			this.main.push(arguments[tt]);						
		}				
		
	}
	hiku(aitemu){
		for(var hik=0;hik<this.main.length;hik++){
			if(this.main[hik].id==aitemu){				
				this.main.splice(hik,1);				
			}			
		}		
	}
	koushin(){		
		var nagasa=this.main.length;
		while(this.temp.length<nagasa){		
			for(var h=0;h<this.main.length;h++){
				var count=0;				
				if(this.temp.length>0){					
					for(var i=0;i<this.main.length;i++){
						if(this.main[h].id!=this.main[i].id){						
							if(this.main[h].y>this.main[i].y){						
								count++;										
							}										
						}							
					}						
					
				}else{				
					for(var i=0;i<this.main.length;i++){
						if(this.main[h].id!=this.main[i].id){						
							if(this.main[h].y>this.main[i].y){						
								count++;									
							}								
						}							
					}					
				}

				if(count==0){			
					this.temp.push(this.main[h]);										
					this.main.splice(h,1);
					h--;
				}
			}			
		}		
		this.main=this.temp;				
		this.temp=new Array();
	}
};


class Balloon{
	constructor(fonts,width,height,canv){
		this.font=document.createElement('img');
		this.font.src=fonts;
		this.width=width;
		this.height=height;
		this.canv=canv;		
		this.prom=0;		
		this.posi=0;
		this.leposi=0;
		this.tleposi=0;
		this.dian=1;
		this.dialogs=new Array();
		this.diav=false;
		this.nx=true;
		this.ttx;		
	}	
	fukif(fukidasi){
		this.fukidasi=document.createElement('img');
		this.fukidasi.src=fukidasi;
	}
	letter(l,nex,sto){
		this.letters=l;
		this.nex=nex;
		this.sto=sto;
	}	
	dialog(d){
		this.dialogs=d;		
	}
	next(){		
		if(this.tleposi!=0&this.tleposi<this.ttx){
			this.leposi=this.tleposi;
		}else{
			this.dian++;
			this.leposi=0;	
		}		
	}
	reset(){		
		this.dian=1;
		this.leposi=0;		
		this.nx=true;
	}
	seri(txt,x,y,nagasa,takasa,alpha){			
		this.ttx=this.dialogs[txt+this.dian].length;
		if(this.dialogs[txt+(this.dian+1)]==undefined){
			this.diav=false;
		}else{
			this.diav=true;
		}		
		if(this.dialogs[txt+this.dian]!=undefined){			
			var tx=this.dialogs[txt+this.dian].toLowerCase();
			var line=0;
			var posi=0
			var mj=0;
			if(this.prom<10){
				this.prom++;
			}else{
				this.prom=0;
			}
			this.canv.save();
			if(alpha!=undefined){
				this.canv.globalAlpha=alpha;
			}else{
				this.canv.globalAlpha=0.6;
			}
			
			this.canv.drawImage(this.fukidasi,x-3,y-3);				
			
			for(var i=this.leposi;i<=tx.length;i++){			
				for(var j=0;j*this.width<this.font.width;j++){				
					if(tx.charAt(i)==this.letters[j]){
						if(posi>0){							
							posi+=4;
						}else{
							if(tx.charAt(i-1)=='。'||tx.charAt(i-1)=='！'||tx.charAt(i-1)=='、'||tx.charAt(i-1)=='ょ'||tx.charAt(i-1)=='1'||tx.charAt(i-1)=='（'||tx.charAt(i-1)=='）'||tx.charAt(i-1)=='：'||tx.charAt(i-1)=="「"||tx.charAt(i-1)=="」"){
								if(mj!=0){
									posi+=4;
								}
							}
						}						
						this.canv.drawImage(this.font,j*this.width,0,this.width,this.height,x+posi,y+(line*this.height),this.width,this.height);
						if(tx.charAt(i)=='ま'||tx.charAt(i)=='し'||tx.charAt(i)=='よ'||tx.charAt(i)=='し'||tx.charAt(i)=='ち'||tx.charAt(i)=='り'||tx.charAt(i)=='さ'||tx.charAt(i)=='そ'||tx.charAt(i)=='ら'||tx.charAt(i)=='き'||tx.charAt(i)=='こ'||tx.charAt(i)=='ゅ'||tx.charAt(i)=='よ'||tx.charAt(i)=='っ'||tx.charAt(i)=='ぇ'||tx.charAt(i)=='た'||tx.charAt(i)=='ー'){
							posi-=1;
						}else if(tx.charAt(i)=='き'||tx.charAt(i)=='ひ'){							
							if(tx.charAt(i+1)=='ゃ'||tx.charAt(i+1)=='ゅ'||tx.charAt(i+1)=='ょ'){							
								posi-=1;							
							}
						}else　if(j>=46&j<=70){
							if(tx.charAt(i)=='ぐ'){
								posi+=1;
							}else if(tx.charAt(i)=='じ'){
								posi-=1;
							}else{
								if(tx.charAt(i)=='び'||tx.charAt(i)=='ぴ'||tx.charAt(i)=='ぎ'){							
									if(tx.charAt(i+1)=='ゃ'||tx.charAt(i+1)=='ゅ'||tx.charAt(i+1)=='ょ'){							
										posi+=1;							
									}else{
										posi+=2;
									}
								}else{
									posi+=2;
								}
							}							
						}else if(tx.charAt(i)=="？"){							
								posi-=2;							
						}else if(tx.charAt(i)=='ゃ'||tx.charAt(i)=='く'||tx.charAt(i)=='ぉ'||tx.charAt(i)=='ぃ'||tx.charAt(i)=='ぅ'||tx.charAt(i)=='ぁ'){
							posi-=2;
						}else if(tx.charAt(i)=='ょ'||tx.charAt(i)=="。"||tx.charAt(i)=="（"||tx.charAt(i)=="）"||tx.charAt(i)=="「"||tx.charAt(i)=="」"){							
							posi-=3;
						}else if(tx.charAt(i)=="、"||tx.charAt(i)=="！"){														
							posi-=4;																						
						}else if(tx.charAt(i)=='：'){
							posi-=5;
						}else if(j>=78&j<=87){
							posi-=2;
							if(j==79){
								posi-=1;
							}
						}else if(tx.charAt(i)=='ぬ'||tx.charAt(i)=='ね'||tx.charAt(i)=='の'||tx.charAt(i)=='め'||tx.charAt(i)=='ゆ'||tx.charAt(i)=='や'||tx.charAt(i)=='わ'||tx.charAt(i)=='ん'||tx.charAt(i)=='か'||tx.charAt(i)=='れ'||tx.charAt(i)=='み'){
							posi+=1;
						}else if(tx.charAt(i)=="な"||tx.charAt(i)=="ふ"){
							posi+=2;
						}
					}											
				}
				
				mj++;				
				if(i>=tx.length-1){				
					this.tleposi=0;					
					if(this.dialogs[txt+(this.dian+1)]==undefined){
						this.nx=false;
					}else{
						this.nx=true;						
					}
					if(posi+(this.width+6)>=nagasa){
						line++;
						mj=0;							
						posi=0;						
					}else{
						posi+=2;					
					}					
				}else{	
					this.nx=true;
					if(posi+(this.width*3)>=nagasa&line*(this.height*2)>=takasa){								
						this.tleposi=i+1;
						i=tx.length;				
						posi+=4;								
					}else if(posi+(this.width+6)>=nagasa){
						line++;
						mj=0;
						if(line*this.height>=takasa){										
							i=tx.length;												
						}
						posi=0;						
					}else{
						posi+=3;					
					}					
				}				
			}		
			if(this.prom>5){
				if(this.tleposi==0&this.dialogs[txt+(this.dian+1)]==undefined){			
					this.canv.drawImage(this.font,this.sto*this.width,0,this.width,this.height,x+(posi+4),y+(line*this.height),this.width,this.height);
				}else{
					this.canv.drawImage(this.font,this.nex*this.width,0,this.width,this.height,x+posi+4,y+(line*this.height),this.width,this.height);
				}
			}	
			this.canv.restore();
			line=0;					
		}
	}
	koto(txt,x,y,nagasa,takasa,arufa){			
		this.ttx=txt.length;		
		var tx=txt.toLowerCase();
		var line=0;
		var posi=0
		var mj=0;
		if(arufa==undefined){
			arufa=0.9;
		}
		this.canv.save();		
		this.canv.globalAlpha=arufa;
		
		for(var i=this.leposi;i<=tx.length;i++){			
			for(var j=0;j*this.width<this.font.width;j++){				
				if(tx.charAt(i)==this.letters[j]){
					if(posi>0){							
						posi+=4;
					}else{
						if(tx.charAt(i-1)=='。'||tx.charAt(i-1)=='！'||tx.charAt(i-1)=='、'||tx.charAt(i-1)=='ょ'||tx.charAt(i-1)=='1'||tx.charAt(i-1)=='（'||tx.charAt(i-1)=='）'||tx.charAt(i-1)=='：'||tx.charAt(i-1)=="「"||tx.charAt(i-1)=="」"){
							if(mj!=0){
								posi+=4;
							}
						}
					}						
					this.canv.drawImage(this.font,j*this.width,0,this.width,this.height,x+posi,y+(line*this.height),this.width,this.height);
					if(tx.charAt(i)=='ま'||tx.charAt(i)=='し'||tx.charAt(i)=='よ'||tx.charAt(i)=='し'||tx.charAt(i)=='ち'||tx.charAt(i)=='り'||tx.charAt(i)=='さ'||tx.charAt(i)=='そ'||tx.charAt(i)=='ら'||tx.charAt(i)=='き'||tx.charAt(i)=='こ'||tx.charAt(i)=='ゅ'||tx.charAt(i)=='よ'||tx.charAt(i)=='っ'||tx.charAt(i)=='ぇ'||tx.charAt(i)=='た'||tx.charAt(i)=='ー'){
						posi-=1;
					}else if(tx.charAt(i)=='き'||tx.charAt(i)=='ひ'){							
						if(tx.charAt(i+1)=='ゃ'||tx.charAt(i+1)=='ゅ'||tx.charAt(i+1)=='ょ'){							
							posi-=1;							
						}
					}else　if(j>=46&j<=70){
						if(tx.charAt(i)=='ぐ'){
							posi+=1;
						}else if(tx.charAt(i)=='じ'){
							posi-=1;
						}else{
							if(tx.charAt(i)=='び'||tx.charAt(i)=='ぴ'||tx.charAt(i)=='ぎ'){							
								if(tx.charAt(i+1)=='ゃ'||tx.charAt(i+1)=='ゅ'||tx.charAt(i+1)=='ょ'){							
									posi+=1;							
								}else{
									posi+=2;
								}
							}else{
								posi+=2;
							}
						}							
					}else if(tx.charAt(i)=="？"){							
							posi-=2;							
					}else if(tx.charAt(i)=='ゃ'||tx.charAt(i)=='く'||tx.charAt(i)=='ぉ'||tx.charAt(i)=='ぃ'||tx.charAt(i)=='ぅ'||tx.charAt(i)=='ぁ'){
						posi-=2;
					}else if(tx.charAt(i)=='ょ'||tx.charAt(i)=="。"||tx.charAt(i)=="（"||tx.charAt(i)=="）"||tx.charAt(i)=="「"||tx.charAt(i)=="」"){							
						posi-=3;
					}else if(tx.charAt(i)=="、"||tx.charAt(i)=="！"){														
						posi-=4;																						
					}else if(tx.charAt(i)=='：'){
						posi-=5;
					}else if(j>=78&j<=87){
						posi-=2;
						if(j==79){
							posi-=1;
						}
					}else if(tx.charAt(i)=='ぬ'||tx.charAt(i)=='ね'||tx.charAt(i)=='の'||tx.charAt(i)=='め'||tx.charAt(i)=='ゆ'||tx.charAt(i)=='や'||tx.charAt(i)=='わ'||tx.charAt(i)=='ん'||tx.charAt(i)=='か'||tx.charAt(i)=='れ'||tx.charAt(i)=='み'){
						posi+=1;
					}else if(tx.charAt(i)=="な"||tx.charAt(i)=="ふ"){
						posi+=2;
					}
				}											
			}
			
			mj++;				
			if(i>=tx.length){				
				this.tleposi=0;									
			}else{					
				if(posi+(this.width*3)>=nagasa&line*(this.height*2)>=takasa){								
					this.tleposi=i+1;
					i=tx.length;				
					posi+=4;								
				}else if(posi+(this.width+6)>=nagasa){
					line++;
					mj=0;
					if(line*this.height>=takasa){										
						i=tx.length;												
					}
					posi=0;						
				}else{
					posi+=3;					
				}					
			}				
		}				
		this.canv.restore();
		line=0;					
		
	}
}

class BalloonEn{
	constructor(fonts,width,height,canv){
		this.font=document.createElement('img');
		this.font.src=fonts;
		this.width=width;
		this.height=height;
		this.canv=canv;		
		this.prom=0;		
		this.posi=0;
		this.leposi=0;
		this.tleposi=0;
		this.dian=1;
		this.dialogs=new Array();
		this.diav=false;
		this.nx=true;
		this.ttx;		
	}	
	fukif(fukidasi){
		this.fukidasi=document.createElement('img');
		this.fukidasi.src=fukidasi;
	}
	letter(l,nex,sto){
		this.letters=l;
		this.nex=nex;
		this.sto=sto;
	}	
	dialog(d){
		this.dialogs=d;		
	}
	next(){		
		if(this.tleposi!=0&this.tleposi<this.ttx){
			this.leposi=this.tleposi;
		}else{
			this.dian++;
			this.leposi=0;	
		}		
	}
	reset(){		
		this.dian=1;
		this.leposi=0;		
		this.nx=true;
	}
	seri(txt,x,y,nagasa,takasa,alpha){		
		this.ttx=this.dialogs[txt+this.dian].length;
		if(this.dialogs[txt+(this.dian+1)]==undefined){
			this.diav=false;
		}else{
			this.diav=true;
		}		
		if(this.dialogs[txt+this.dian]!=undefined){			
			var tx=this.dialogs[txt+this.dian].toLowerCase();
			var line=0;
			var posi=0;
			var mj=0;
			if(this.prom<10	){
				this.prom++;
			}else{
				this.prom=0;
			}
			this.canv.save();
			if(alpha!=undefined){
				this.canv.globalAlpha=alpha;
			}else{
				this.canv.globalAlpha=0.6;			
			};
			this.canv.drawImage(this.fukidasi,x-3,y-3);	
			
			for(var i=this.leposi;i<=tx.length;i++){			
				for(var j=0;j*this.width<this.font.width;j++){				
					if(tx.charAt(i)==this.letters[j]){											
						if(posi>0){
							posi+=2;			
						}else{
							if(tx.charAt(i-1)=='!'||tx.charAt(i-1)==','||tx.charAt(i-1)=='.'||tx.charAt(i-1)=="'"||tx.charAt(i-1)==':'||tx.charAt(i-1)=='-'){
							 if(mj!=0){
								posi+=2;								
							 }
							}
						}
						
						if(tx.charAt(i)=='m'||tx.charAt(i)=='w'){
							posi+=1;
						}else if(tx.charAt(i)=='!'||tx.charAt(i)==','||tx.charAt(i)=="'"||tx.charAt(i)=="."){
							posi-=1;
						}
						this.canv.drawImage(this.font,j*this.width,0,this.width,this.height,x+posi,y+(line*this.height),this.width,this.height);
						if(tx.charAt(i)=='m'||tx.charAt(i)=='n'||tx.charAt(i)=='w'){
							posi+=1;
						}else if(tx.charAt(i)=='!'||tx.charAt(i)==','||tx.charAt(i)=='1'||tx.charAt(i)=="'"||tx.charAt(i)=="."||tx.charAt(i)=='-'){
							posi-=1;
						}else if(tx.charAt(i)==':'){
							posi-=2;
						}
					}						
				}
				mj++;
				if(i>=tx.length-1){						
					this.tleposi=0;
					if(this.dialogs[txt+(this.dian+1)]==undefined){
						this.nx=false;
					}else{
						this.nx=true;
					}
					if(posi+(this.width+(this.width/2))>=nagasa){
						line++;
						mj=0;						
						posi=0;					
					}else{
						posi+=2;			
					}
				}else{
					this.nx=true;					
					if(posi+(this.width*3)>=nagasa&line*(this.height*2)>=takasa){								
							this.tleposi=i+1;
							i=tx.length;				
							posi+=4;		
							
					}else if(posi+(this.width+(this.width/2))>=nagasa){
						line++;
						mj=0;
						if(line*this.height>=takasa){										
							i=tx.length;											
						}
						posi=0;					
					}else{
						posi+=2;			
					}
				}				
			}		
			if(this.prom>5){
				if(this.tleposi==0&this.dialogs[txt+(this.dian+1)]==undefined){			
					this.canv.drawImage(this.font,this.sto*this.width,0,this.width,this.height,x+(posi-1),y+(line*this.height),this.width,this.height);
				}else{
					this.canv.drawImage(this.font,this.nex*this.width,0,this.width,this.height,x+posi,y+(line*this.height),this.width,this.height);				
				}
			}		
			this.canv.restore();
			line=0;		
		}		
	}	
	koto(txt,x,y,nagasa,takasa,arufa){		
		this.ttx=txt.length;		
		var tx=txt.toLowerCase();
		var line=0;
		var posi=0;
		var mj=0;		
		this.canv.save();
		if(arufa==undefined){
			arufa=0.9
		}
		this.canv.save();	
		this.canv.globalAlpha=arufa;				
		for(var i=this.leposi;i<=tx.length;i++){			
			for(var j=0;j*this.width<this.font.width;j++){				
				if(tx.charAt(i)==this.letters[j]){											
					if(posi>0){
						posi+=2;			
					}else{
						if(tx.charAt(i-1)=='!'||tx.charAt(i-1)==','||tx.charAt(i-1)=='.'||tx.charAt(i-1)=="'"||tx.charAt(i-1)==':'||tx.charAt(i-1)=='-'){
						 if(mj!=0){
							posi+=2;								
						 }
						}
					}					
					if(tx.charAt(i)=='m'||tx.charAt(i)=='w'){
						posi+=1;
					}else if(tx.charAt(i)=='!'||tx.charAt(i)==','||tx.charAt(i)=="'"||tx.charAt(i)=="."){
						posi-=1;
					}
					this.canv.drawImage(this.font,j*this.width,0,this.width,this.height,x+posi,y+(line*this.height),this.width,this.height);
					if(tx.charAt(i)=='m'||tx.charAt(i)=='n'||tx.charAt(i)=='w'){
						posi+=1;
					}else if(tx.charAt(i)=='!'||tx.charAt(i)==','||tx.charAt(i)=='1'||tx.charAt(i)=="'"||tx.charAt(i)=="."||tx.charAt(i)=='-'){
						posi-=1;
					}else if(tx.charAt(i)==':'){
						posi-=2;
					}
				}						
			}
			mj++;
			if(i>=tx.length){						
				this.tleposi=0;				
			}
			if(posi+(this.width*3)>=nagasa&line*(this.height*2)>=takasa){								
					this.tleposi=i+1;
					i=tx.length;				
					posi+=4;		
					
				}else if(posi+(this.width+(this.width/2))>=nagasa){
					line++;
					mj=0;
					if(line*this.height>=takasa){										
						i=tx.length;											
					}
					posi=0;					
				}else{
					posi+=2;			
				}
			
		}				
		this.canv.restore();
		line=0;						
	}		
}

var dorof;
var waku=new Object();
waku.yoko=window.innerWidth;
waku.tate=window.innerHeight;
waku.saizu=3;
waku.oyoko=200;
waku.otate=150;
waku.canyoko=waku.oyoko*waku.saizu;
waku.cantate=waku.otate*waku.saizu;
waku.gen='jp';
waku.sute='gengo';
waku.level=1;
waku.scn=1;waku.scnt=1;
waku.ani=1;
waku.ani1=5;
waku.dia=true;
waku.bgm=true;
var nezu={x:0,y:0,load:false,osu:true,osukazu:0};

var canvas=document.createElement('canvas');
canvas.height=waku.cantate;
canvas.width=waku.canyoko;
canvas.style.borderRadius='5px';
canvas.style.position='absolute';
canvas.style.left=(waku.yoko/2)-(waku.canyoko/2);
canvas.style.top=(waku.tate/2)-(waku.cantate/2);
var kyanba=canvas.getContext('2d');
kyanba.scale(waku.saizu,waku.saizu);
kyanba.imageSmoothingEnabled=false;
document.body.appendChild(canvas);

kyanba.fillStyle='#550055';
kyanba.fillRect(0,0,600,300);

kyanba.fillStyle='#999999';
kyanba.font='30px arial';
kyanba.fillText("loading",50,80);

var bgm=new Audio('panty/bgm.wav');
bgm.loop='true';
bgm.volume=0.8;
var bgmbad=new Audio('panty/bgmbad.wav');
bgmbad.loop='true';
var bgmfan=new Audio('panty/bgmfant.wav');
bgmfan.loop='true';
var kuri=new Oto('panty/click.wav');
var onuchu=new Oto('panty/nuchu.wav');
var osuta=new Oto('panty/suta.wav');
var osuta2=new Oto('panty/suta2.wav');
var okosu=new Oto('panty/kosu.wav');
var oban=new Oto('panty/ban.wav');
var opyun=new Oto('panty/dopyun.wav');
var obane=new Oto('panty/bane.wav');
var oiki=new Oto('panty/iki.wav');
var othud=new Oto('panty/thud.wav');
var osenba=new Oto('panty/sentaku_basami.wav');
var omado=new Oto('panty/hikimado.wav');
var odsuta=new Oto('panty/dorosuta.wav');

var ochu=new Oto('panty/kiss.wav');
var okane=new Oto('panty/bling.wav');
var onugu=new Oto('panty/nugu.wav');
var ohyu=new Oto('panty/wind.wav');
var okfue=new Oto('panty/keifue.wav');
var oberu=new Oto('panty/beru.wav');

var bggengo=new Dotto(200,150,'bg_gengo','panty/bg_gengo.png',kyanba);
bggengo.x=50;

var bgover=new Dotto(200,150,'bg_over','panty/bg_gameover.png',kyanba);

var bgchou=new Dotto(30,30,'chou','panty/bg_gengo_chou.png',kyanba);
bgchou.x=10;bgchou.y=100;

var bgdoro=new Dotto(200,150,'bg_doro','panty/bg_doro.png',kyanba);
var dorobp=new Dotto(50,50,'mobu','panty/mobu_bedpan.png',kyanba);
dorobp.oto(onuchu,1,6);
dorobp.oto(oban,2,7);
dorobp.oto(oiki,3);

var bg1=new Dotto(200,150,'bg1','panty/bg_1.png',kyanba);
var doro=new Dotto(50,50,'doro','panty/mobu.png',kyanba);
doro.id='doro';
doro.x=175;doro.y=140;doro.z=0;doro.tx=175;doro.ty=140;
doro.jou='stop';doro.houkou='hidari';doro.pan=false;
doro.renda=false; doro.up='';doro.koufun=0;doro.koufun1=50;doro.koufun2=100;doro.koufun3=200;
doro.keikan=false;doro.pan1=false;doro.pan2=false;doro.pan3=false;doro.floor=0;doro.end='';

var doropan=new Dotto(50,50,'doro','panty/mobu_pant.png',kyanba);

var doropover=new Dotto(50,50,'doro','panty/mobu_panover.png',kyanba);
doropover.oto(onuchu,1);
doropover.oto(oban,2);

var keikan=new Dotto(50,50,'keikan','panty/keikan.png',kyanba);
keikan.id='keikan';keikan.x=0;keikan.y=150;keikan.yng=false;keikan.xng=false;keikan.kazu=0;keikan.prompt=0;

var bgan=new Dotto(200,150,'bgan','panty/bg_an.png',kyanba);
var bgan0=new Dotto(200,150,'bgan','panty/bg_an0.png',kyanba);
var anne=new Dotto(50,50,'anne','panty/anne.png',kyanba);
anne.id='anne';
anne.x=60;
anne.y=88;
var annesupa0=new Dotto(70,80,'anne','panty/anne_supa0.png',kyanba);
annesupa0.oto(onuchu,8);
var annesupa2=new Dotto(50,50,'anne','panty/anne_supa2.png',kyanba);
annesupa2.oto(onuchu,1);
var annesupa3=new Dotto(50,50,'anne','panty/anne_supa3.png',kyanba);
annesupa3.oto(okosu,1);
annesupa3.oto(onugu,4);
annesupa3.oto(obane,8);
annesupa3.oto(othud,16);
var annesupa4=new Dotto(50,50,'anne','panty/anne_supa4.png',kyanba);
annesupa4.oto(osuta,2);
annesupa4.oto(othud,6);
annesupa4.oto(ochu,7,11);

var mobu=new Dotto(50,50,'mobu','panty/mobu.png',kyanba);
mobu.id='mobu';
mobu.x=0;mobu.y=145;mobu.houkou='migi';mobu.up='';mobu.sumaho=false;				
var mobusumaho=new Dotto(50,50,'mobu','panty/mobu_sumaho.png',kyanba);

var mobu1=new Dotto(50,50,'mobu','panty/mobu.png',kyanba);
mobu1.id='mobu1';
mobu1.x=70;mobu1.y=170;mobu1.houkou='hidari';mobu1.up='';mobu1.sumaho=false;
var mobu1sumaho=new Dotto(50,50,'mobu','panty/mobu_sumaho.png',kyanba);

var itbut=new Dotto(14,14,'it_buttons','panty/it_buttons.png',kyanba);

var bjp=new Chiiki(10,127,45,149);
var ben=new Chiiki(46,127,95,149);
var bshichou=new Chiiki(3,113,50,125);
var bstart=new Chiiki(65,110,130,126);
var bsupu=new Chiiki(162,131,187,145);
var bsuma=new Chiiki(101,131,124,145);
var btobasu=new Chiiki(2,102,18,120);
var bbgm=new Chiiki(1,1,16,17);
var bsdf=new Chiiki(52,100,63,118);

var ng1=new Chiiki(0,48,101,80);
var ng1b=new Chiiki(0,0,178,48);
var house1=new Chiiki(0,48,115,105);
var pan1=new Chiiki(115,68,122,82);
var front1=new Chiiki(0,90,113,110);
var side1=new Chiiki(200,7,124,107);
var nigeru1=new Chiiki(1,128,15,150);

var ssma=new Chiiki(1,120,12,133);
var sspu=new Chiiki(15,120,24,133);
var sama=new Chiiki(1,136,12,149);
var sapu=new Chiiki(14,136,24,149);
var sbac=new Chiiki(41,135,54,149);

var st1s=new Sou('stage1layer');
st1s.tasu(doro,mobu,keikan);
st1s.koushin();

var logs=new Array();
var letter=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','.',',','!','?',"'",'1','2','3','4','5','6','7','8','9','0','(',')',':','-'];
var moji=['あ','い','う','え','お','か','き','く','け','こ','さ','し','す','せ','そ','た','ち','つ','て','と','な','に','ぬ','ね','の','は','ひ','ふ','へ','ほ','ま','み','む','め','も','や','ゆ',"よ",'ら','り','る','れ','ろ','わ','を','ん','が','ぎ','ぐ','げ','ご','ざ','じ','ず','ぜ','ぞ','だ','ぢ','づ','で','ど','ば','び','ぶ','べ','ぼ','ぱ','ぴ','ぷ','ぺ','ぽ','ゃ','ゅ','ょ','。','、','！','？','0','1','2','3','4','5','6','7','8','9','っ','ぁ','ぃ','ぅ','ぇ','ぉ','（','）','「','」','：','ー'];
var hira=new Balloon('panty/hira.png',8,7,kyanba);
hira.letter(moji,100,74);
hira.dialog(logs);
hira.fukif('panty/a_balloon.png');

var hirab=new Balloon('panty/hira.png',8,7,kyanba);
hirab.letter(moji,100,74);
hirab.fukif('panty/a_balloon.png');

var roma=new BalloonEn('panty/alpha.png',5,7,kyanba);
roma.letter(letter,45,26);
roma.dialog(logs);
roma.fukif('panty/a_balloon.png');

var romab=new BalloonEn('panty/alpha.png',5,7,kyanba);
romab.letter(letter,45,26);
romab.fukif('panty/a_balloon.png');

var hira2=new Balloon('panty/hira.png',8,7,kyanba);
hira2.letter(moji,100,74);
hira2.dialog(logs);
hira2.fukif('panty/a_balloonb.png');

var roma2=new BalloonEn('panty/alpha.png',5,7,kyanba);
roma2.letter(letter,45,26);
roma2.dialog(logs);
roma2.fukif('panty/a_balloonb.png');

var se=hira;
var ko=hirab;
var se2=hira2;

logs['homejp']='いえ　へ';
logs['homeen']='Back home';

logs['xjp']='むらむら';
logs['xen']="ecstacy";

logs['intro1jp1']='どろ：　この　いえに　すんでる　じょせいはね、　30だい　だけど、　めがねっこで　ほそくて　めっちゃ　すたいるいい！　かわいい　ひんぬも　やばい！';
logs['intro1jp2']='どろ：　ひるは　すーぱーの　れじで　はたらいてて、　まじめに　みえるが　いけめんきゃくの　ちんこを　ちらちら　みてるんだ！';
logs['intro1jp3']='どろ：　しかも　こっそり　くりを　いじりながらの　むっつりけい　だよ！';
logs['intro1jp4']='どろ：　でさぁ、　いえ　かえると　18きんの　しょうせつを　かいてる、　えろい　でしょう？！　そんな　えろい　おんなの　ぱんてぃー　めっちゃ　ほしい！';
logs['intro1jp5']='どろ：　むらむらしちゃって　ここで　しこしこしちゃいそう！！　がまん　しなくちゃ';
logs['intro1en1']="Doro: The woman living in that house is in her 30's, she wears glasses and is so slender! And those little tits are so hot!";
logs['intro1en2']="Doro: During day she works at the cashier in a supermarket, nobody knows but she peeks handsome clients' cocks!";
logs['intro1en3']="Doro: And that's not all! She secretly pleasure herself while peeking! What an kinky woman huh?";
logs['intro1en4']="Doro: Besides that she writes naughty books at home, man I wanna her panties so much!";
logs['intro1en5']="Doro: I'm so excited I could fap right here! Have to control myself";

logs['doro1jp1']='どろ：　くんかくんか、　れじうちの　ときでも　こんな　えっちな　ぱんてぃー　はいてるかな。。。まじめで　しずかな　おねえさんに　みえるけど　じつは　せめせめの　えすよりの　おんなだったり？　せめられたいね。。。';
logs['doro1en1']="Doro: smells smells, I wonder if she wears kinky undies like this when in the cashier...she looks quiet and ordinary-looking but in fact she's a bold and aggressive women? I'd love to be humped by her...";

logs['dorojpno1']='どろ：　のーぱん　のーらいふ。。。しくしく。。。';
logs['doroenno1']="Doro: No panties no life....sniff sniff";

logs['1jp1']='どろ：（なれーしょん）じてんしゃの　さどるに　すわって、　あの　かわいい　けつの　あなと　まんこ　こすりながら　しごと　いくんだろう？';
logs['1jp2']='どろ：（なれーしょん）　ぬれぬれの　ぱんてぃーで　しごと　しちゃうだろう？';
logs['1en1']="Doro: (Narration) And she sit on that saddle and rubbing her little butt whole and her pussy she goes to work";
logs['1en2']="Doro: (Narration) She serves the clients with her panties all wet?";

logs['1jp3']='あんな：（ええ、　けっこう　いけめん。。。こっち　みてる、　ちゃんす　かも！！）';
logs['1jp4']='どろ：　。。。';
logs['1jp5']='あんな：　ごうけい　4854えん　に　なりました';
logs['1en3']="Anna: (wow he's cute, and it's looking at me, my chance!)";
logs['1en4']="Doro: ...";
logs['1en5']="Anna: That's a total of 4,854 yens";

logs['1jp6']='どろ：　あれ。。。3まんくらい　はいってた　き　が　したのに。。。';
logs['1jp7']='あんな：　ごほっ。。。だいじょうぶ　ですか？';
logs['1jp8']='どろ：　いや、　ぜんぜん。。。（こごえ）そういえば　きのう　でりへる　よんじゃって。。。やばい、　きゅうりょうびまで　とおいのに　ぜんぶ　もやしちゃった。。。';

logs['1en6']="Doro: Weird...I thought I had 30 thousand in my wallet...";
logs['1en7']="Anna: Any problem sir?";
logs['1en8']="Doro: No, never mind...(murmur) now I remember I called a hooker last night...man, I burned all my money and the payday is so far...";

logs['1jp9']='あんな：　ねぇ、　おにいさん。。。';
logs['1jp10']='どろ：　は　はい？';
logs['1jp11']='あんな：　わたしにね、　そのりっぱな　にくぼう　かしてくれたら　これを　なんとかしますよ。。。';
logs['1jp12']='どろ：　にに　に。。。（こごえ）　にくぼう？！';
logs['1jp13']='あんな：　こまってる　でしょう？　わたしの　ぺっとに　なってくれたら　きゅうりょうびまで　みつぎますよ。。。';

logs['1en9']="Anna: Hey there...";
logs['1en10']="Doro: Ye-yeah?";
logs['1en11']="Anna: If you borrow me your shaft I can do something with this bill...";
logs['1en12']="Doro: sh-sh...(whisper) shaft?";
logs['1en13']="Anna: You need money right? If you become my 'pet' I can feed you until your next payday...";

logs['1jp14']='どろ：　。。。';
logs['1en14']="Doro: ...";

logs['1jp15']='あんな：　わたしに　まかせて　あんしん　していいよ。。。しずかな　ばしょ　に　いこう。。。';
logs['1en15']="Anna: You can trust me...I'll take you into a more quiet place... ";

logs['1jp16']='あんな：　んっ、　わかい　おとこの　ちんこ　ずっと　ほしかったわ　しこしこ';
logs['1jp17']='どろ：　あんっ！';
logs['1jp18']='あんな：　びんかんだね、　すぐ　びんびんなっちゃって、　あんな　ねえさんの　まんこに　いれたい？';
logs['1jp19']='どろ：　いれたい。。。';
logs['1en16']="Anna: Mmm, I was just looking for a young cock fapfap";
logs['1en17']="Doro: Nnnn!!";
logs['1en18']="Anna: Wow, you're very sensitive, look how hard you are! You wanna fuck Anna-neesan?";
logs['1en19']="Doro: Nn, yeah...";

logs['1jp20']='あんな：　あんなねえさんを　きもちよーーくさせて　びっちょびちょの　まんこに　してたら　いれてもいいよ';
logs['1jp21']='あんな：　まず　おっぱいの　ちぇりーを　いっぱーーい　おいしく　たべてね';
logs['1en20']="Anna: If you make me feel soooo good my pussy get all dripping wet you can use that cock in me";
logs['1en21']="Anna: First you can start eating my cherries...";

logs['1jp22']='あんな：　んっ　いい　こ　だね。。。';
logs['1en22']="Anna: Yeah, good boy...";

logs['1jp23']='たいけんばんを　ぷれいして　ありがとう！';
logs['1en23']="Thanx for playing the trial version!";

	var ab={x1:112,y1:130,x2:242,y2:0,x1b:0,y1b:130,x2b:112,y2b:130,x3:90,y3:13,x4:160,y4:145};			
	var aaa =((ab.x4 - ab.x3)*(ab.y3 - ab.y1) - (ab.y4 - ab.y3)*(ab.x3 - ab.x1)) / ((ab.x4 - ab.x3)*(ab.y2 - ab.y1) - (ab.y4 - ab.y3)*(ab.x2 - ab.x1));
	var bbb = ((ab.x2 - ab.x1)*(ab.y3 - ab.y1) - (ab.y2 - ab.y1)*(ab.x3 - ab.x1)) / ((ab.x4 - ab.x3)*(ab.y2 - ab.y1) - (ab.y4 - ab.y3)*(ab.x2 - ab.x1));
	ab.x0=ab.x3 + bbb*(ab.x4 - ab.x3);	
	ab.y0= ab.y3 + bbb*(ab.y4 - ab.y3);
	
function seri2f(sc,sa,sd,f){	
	var s1={1:1,2:3,3:16,4:21,5:22};	
	if(f==undefined){
		if(sc==1){
			if(sd>=1&sd<2&sa==1){
				return true
			}else if(sd>=3&sd<15&sa==2){
				return true
			}else if(sd>=16&sd<20&sa==3){
				return true
			}else if(sd>=21&sd<21&sa==4){
				return true
			}else if(sd>=22&sd<23&sa==5){
				return true
			}else{
				return false
			}
		}else{
			return false
		}
	}else{
		if(sc==1){
			return s1[sa]
		}else if(sc==2){
			return s2[sa]
		}else{
			return s3[sa]
		}
	}
};

function zero(){
	dorobp.koma=0;
	mobusumaho.koma=0;
	mobu1sumaho.koma=0;	
	
	annesupa2.koma=0;
	annesupa3.koma=0;
	annesupa4.koma=0;	
};
function dororeda(){
	
	kyanba.fillStyle='#333399';
	kyanba.fillRect(0,0,600,300);
	
	if(waku.sute=='gengo'){
		bggengo.haikei(0,0);
		if(bggengo.x>-300){
			bggengo.x-=0.2;
		}else{
			bggengo.x=200;
		}
		bggengo.haikei(Math.floor(bggengo.x),0,0,10);
		
		if(bgchou.x>waku.oyoko+120){		
			bgchou.x=-50;
		}
		if(bgchou.koma==1){
			bgchou.x+=15;
			bgchou.ani(bgchou.x,bgchou.y+10);			
		}else if(bgchou.koma==2){
			bgchou.x+=3;
			bgchou.ani(bgchou.x,bgchou.y+3);
		}else if(bgchou.koma==3){
			bgchou.x+=1;
			bgchou.ani(bgchou.x,bgchou.y-20);
		}else{
			bgchou.x+=2;
			bgchou.ani(bgchou.x,bgchou.y-16);
		}		
		if(waku.gen=='jp'){
			bggengo.haikei(0,0,0,1);
		}else{
			bggengo.haikei(0,0,0,11);
		}
		
		if(bstart.c(nezu.x,nezu.y)){
			if(waku.gen=='jp'){
				bggengo.haikei(0,0,0,3);
			}else{
				bggengo.haikei(0,0,0,13);
			}
		}else{
			if(waku.gen=='jp'){
				bggengo.haikei(0,0,0,2);
			}else{
				bggengo.haikei(0,0,0,12);
			}
		}
		if(bshichou.c(nezu.x,nezu.y)){
			if(waku.gen=='jp'){
				bggengo.haikei(0,0,0,18);
			}else{
				bggengo.haikei(0,0,0,20);
			}
		}else{
			if(waku.gen=='jp'){
				bggengo.haikei(0,0,0,17);
			}else{
				bggengo.haikei(0,0,0,19);
			}
		}
		
		
		if(bjp.c(nezu.x,nezu.y)){
			bggengo.haikei(0,0,0,5);
		}else if(ben.c(nezu.x,nezu.y)){
			bggengo.haikei(0,0,0,6);
		}else{			
			bggengo.haikei(0,0,0,4);			
		}
		
		
		if(bsupu.c(nezu.x,nezu.y)){
			if(waku.gen=='jp'){
				bggengo.haikei(0,0,0,9);
			}else{
				bggengo.haikei(0,0,0,16);
			}
		}else if(bsuma.c(nezu.x,nezu.y)){
			if(waku.gen=='jp'){
				bggengo.haikei(0,0,0,8);
			}else{
				bggengo.haikei(0,0,0,15);
			}
		}else{
			if(waku.gen=='jp'){
				bggengo.haikei(0,0,0,7);
			}else{
				bggengo.haikei(0,0,0,14);
			}
		}		
		
		romab.koto('hoodie corp 2025',1,1,62,10,1);		
	}else if(waku.sute=='panty'){
		if(waku.level==1){
			if(!waku.dia){
				if(doro.koufun<doro.koufun1){
					doro.koufun+=0.2;
					if(doro.koufun>=doro.koufun1){
						doro.jou='45'
					}					
				}
			}
				
			if(doro.jou=='walk'){
				if(Math.abs(doro.x-doro.tx)>5){
					if(doro.x<doro.tx){
						if(!ng1.d(doro.x+5,doro.y)){
							if(house1.d(doro.x+5,doro.y)!=house1.d(doro.x,doro.y)){
								doro.jou='noboru';
								doro.koma=0;								
								if(house1.d(doro.x,doro.y)){
									doro.houkou='migi';
								}else{
									doro.houkou='hidari';
								}
								doro.up='';
							}else{
								doro.x+=5;
								doro.up='';
							}		
						}
					}else{
						if(!ng1.d(doro.x-5,doro.y)){
							if(house1.d(doro.x-5,doro.y)!=house1.d(doro.x,doro.y)){
								doro.jou='noboru';
								doro.koma=0;
								
								if(house1.d(doro.x,doro.y)){
									doro.houkou='migi';
								}else{
									doro.houkou='hidari';
								}
								doro.up='';
							}else{
								doro.x-=5;
								doro.up='';
							}						
						}
					}
					if(Math.abs(doro.x-doro.tx)<5){
						if(house1.d(doro.tx,doro.y)!=house1.d(doro.x,doro.y)){
							doro.jou='noboru';
							doro.koma=0;
							
							if(house1.d(doro.x,doro.y)){
								doro.houkou='migi';
							}else{
								doro.houkou='hidari';
							}
							doro.up='';
						}else{
							doro.x=doro.tx;					
						}
					}
				}else{			
					if(house1.d(doro.tx,doro.y)!=house1.d(doro.x,doro.y)){
						doro.jou='noboru';
						doro.koma=0;							
						if(house1.d(doro.x,doro.y)){
							doro.houkou='migi';
						}else{
							doro.houkou='hidari';
						}
						
						doro.up='';
					}else{
						doro.x=doro.tx;				
					}
				}
				if(doro.jou!='noboru'){
					if(Math.abs(doro.y-doro.ty)>5){
						if(doro.y<doro.ty){
							if(!ng1.d(doro.x,doro.y+5)){						
								if(house1.d(doro.x,doro.y)!=house1.d(doro.x,doro.y+5)){
									doro.jou='noboru';
									if(front1.c(doro.x,doro.y+5)){
										if(house1.d(doro.x,doro.y)){
											doro.up='down';
										}else{
											doro.up='up';
										}
									}else{
										doro.up='';
									}
								}else{
									doro.y+=5;					
									
								};
									
								
							}
						}else{
							if(!ng1.d(doro.x,doro.y-5)&!ng1b.d(doro.x,doro.y-5)){
								if(house1.d(doro.x,doro.y)!=house1.d(doro.x,doro.y-5)){
									doro.jou='noboru';									
									if(front1.c(doro.x,doro.y-5)){
										if(house1.d(doro.x,doro.y)){
											doro.up='down';
										}else{
											doro.up='up';
										}
									}else{
										if(house1.d(doro.x,doro.y)){
											doro.houkou='migi';
										}else{
											doro.houkou='hidari';
										}
										doro.up='';
									}
								}else{
									if(!ng1b.d(doro.x,doro.y-5)|!ng1.d(doro.x,doro.y-5)){
										doro.y-=5;				
									}										
								}
							}
						}
						if(Math.abs(doro.y-doro.ty)<5){
							if(house1.d(doro.x,doro.ty)!=house1.d(doro.x,doro.y)){
								doro.jou='noboru';							
								if(front1.c(doro.x,doro.y)){
									if(house1.d(doro.x,doro.y)){
										doro.up='down';
									}else{
										doro.up='up';
									}
								}else{
									if(house1.d(doro.x,doro.y)){
										doro.houkou='migi';
									}else{
										doro.houkou='hidari';
									}
									doro.up='';
								}
								
							}else{								
								doro.y=doro.ty;												
							}
						}
					}else{				
						if(house1.d(doro.x,doro.ty)!=house1.d(doro.x,doro.y)){
							if(!ng1b.d(doro.x,doro.ty)){
								doro.jou='noboru';								
								if(front1.c(doro.x,doro.y)){
									if(house1.d(doro.x,doro.y)){
										doro.up='down';
									}else{
										doro.up='up';
									}
								}else{
									if(house1.d(doro.x,doro.y)){
										doro.houkou='migi';
									}else{
										doro.houkou='hidari';
									}
									doro.up='';
								}
							}
						}else{
							doro.y=doro.ty;				
						}
					}
					if(doro.x==doro.tx&doro.y==doro.ty){
						doro.jou='stop';
					}
				};
			}
			if(doro.keikan){
				if(doro.jou!='taiho'){				
					if(Math.abs(doro.x-keikan.x)<60&Math.abs(doro.y-keikan.y)<40){
						doro.jou='taiho';
					}
				}				
			}
			if(nigeru1.c(doro.x,doro.y)){
				nezu.osu=false;
				waku.sute='dorobeya';
				if(!doro.pan){
					if(waku.bgm){
						bgm.pause();
						bgmbad.play();
						bgmbad.volume=0;						
					}
				}
			}
			st1s.koushin();
			
			bg1.haikei(0,0);
			
			bg1.haikei(0,0,0,1);
			
			if(itbut.kazu<5){
				if(!waku.dia){
					itbut.kyara(8,143,0,6);				
					ko.koto(logs['home'+waku.gen],18,133,50,8,1);
				};
			}else{
				if(itbut.kazu>10){
					itbut.kazu=0;
				}
			}
			
			if(doro.jou=='walk'){
				doro.kyara(doro.tx,doro.ty,3,0);
			}else{
				doro.kyara(doro.tx,doro.ty,3,1);
			};
			
			
			if(!doro.pan){
				bg1.haikei(0,0,0,2);
			};
			
			for(var mp=0;mp<st1s.main.length;mp++){
				switch(st1s.main[mp].namae){								
					case 'doro':
						if(house1.d(doro.x,doro.y)){
							if(doro.jou=='45'){
								if(doro.koma==3){
									onuchu.p();
								}
								doro.ani(doro.x,doro.y,26);
								doro.renda=true;
							}else if(doro.jou=='walk'){
								if(doro.houkou=='hidari'){
									doro.ani(doro.x,doro.y,1);
									doro.renda=true;
								}else{
									doro.ani(doro.x,doro.y,2);
									doro.renda=true;
								};
								if(doro.koma==1){
									odsuta.p();
								}
							}else if(doro.jou=='noboru'){
									if(doro.up==''){
										if(doro.houkou=='hidari'){
											doro.ani(doro.x,doro.y,4);
										}else{
											doro.ani(doro.x,doro.y,5);									
										}
									}else{
										if(doro.up=='up'){
											doro.ani(doro.x,doro.y,6);
										}else{
											doro.ani(doro.x,doro.y,7);
										}
									}
									if(doro.koma==3){
										okosu.p();
									}
									doro.renda=true;
									if(doro.koma==0){
										doro.jou='walk';		
										if(doro.up==''){
											if(house1.d(doro.x,doro.y)){									
												doro.x+=10;
												doro.houkou='migi';												
											}else{									
												doro.x-=10;
												doro.houkou='hidari';
											}									
										}else{
											
											if(house1.d(doro.x,doro.y)){
												if(Math.abs(doro.ty-doro.y)>5){
													doro.y+=5;
												}else{
													doro.y=doro.ty;
												}
											}else{									
												if(Math.abs(doro.ty-doro.y)>5){
													doro.y-=5;
												}else{
													doro.y=doro.ty;
												}
											}									
										}
										
									}
							}else if(doro.jou=='pan'){
								doropan.ani(doro.x,doro.y,0);
								if(doropan.koma==4){
									doro.pan=true;									
									doro.pan1=true;									
									osenba.p();
								}
								if(doropan.koma==0){
									doro.jou='stop';
									
								}
							}else if(doro.jou=='taiho'){
								doro.talk(doro.x,doro.y,10);
							}else{
								doro.kyara(doro.x,doro.y,0,0);
								doro.renda=true;
							}
						};
						break;
					default:
						break;
				}
			};
			
			bg1.haikei(0,0,0,3);
			
			for(var mp=0;mp<st1s.main.length;mp++){
				switch(st1s.main[mp].namae){
					case 'keikan':			
						if(doro.keikan){
							if(Math.abs(this[st1s.main[mp].id].x-doro.x)>20){
								
								if(this[st1s.main[mp].id].x<doro.x){
									if(house1.d(keikan.x+5,keikan.y)){
										keikan.xng=true;
									}else{
										this[st1s.main[mp].id].x+=5;
									}
								}else{
									if(house1.d(keikan.x-5,keikan.y)){
										keikan.xng=true;
									}else{
										this[st1s.main[mp].id].x-=5;
									}
								}
							}else{
								keikan.xng=true;								
							}
							if(Math.abs(this[st1s.main[mp].id].y-doro.y)>20){
								if(this[st1s.main[mp].id].y<doro.y){
									if(house1.d(keikan.x,keikan.y+5)){
										keikan.yng=true;
									}else{
										this[st1s.main[mp].id].y+=5;									
									}
								}else{
									if(house1.d(keikan.x,keikan.y-5)){
										keikan.yng=true;
									}else{
										this[st1s.main[mp].id].y-=5;
									}
								}
							}else{
								keikan.yng=true;
							}
							if(this[st1s.main[mp].id].koma==2){
								if(this[st1s.main[mp].id].prompt<3){
									this[st1s.main[mp].id].prompt++;
								}else{
									this[st1s.main[mp].id].prompt=0;
									okfue.p();
								}
							}
							
							if(Math.abs(this[st1s.main[mp].id].y-doro.y)<=20&Math.abs(this[st1s.main[mp].id].x-doro.x)<=20|keikan.xng&keikan.yng){
								if(this[st1s.main[mp].id].x>doro.x){
									this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,3,1);
								}else{
									this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,4,1);
								}
								if(keikan.kazu<20){
									keikan.kazu++;
								}else{
									nezu.osu=false;
									waku.sute='over';
									doro.end='taiho';
									if(waku.bgm){
										bgm.pause();
										bgmbad.play();
										bgmbad.volume=0;
									}
								}
							}else{
								if(this[st1s.main[mp].id].x>doro.x){
									this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,1);
								}else{
									this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,2);
								}
							}
						};
						break;
					case 'mobu':						
						if(this[st1s.main[mp].id].sumaho){
							if(this[st1s.main[mp].id].up!=''){								
								if(this[st1s.main[mp].id].up=='down'){									
									this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,0,11);
									if(!doro.keikan&this[st1s.main[mp].id+'sumaho'].koma>=11){
										doro.keikan=true;
									}									
								}else{
									this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,1,11);
									if(!doro.keikan&this[st1s.main[mp].id+'sumaho'].koma>=11){
										doro.keikan=true;
									}									
								}
							}else{								
								if(this[st1s.main[mp].id].houkou=='hidari'){																	
									this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,2,11);
									if(!doro.keikan&this[st1s.main[mp].id+'sumaho'].koma>=11){
										doro.keikan=true;
									}									
								}else{
									this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,3,11);
									if(!doro.keikan&this[st1s.main[mp].id+'sumaho'].koma>=11){
										doro.keikan=true;
									}									
								}
							}
						}else{							
							if(this[st1s.main[mp].id].up!=''){
								if(this[st1s.main[mp].id].koma==3&this[st1s.main[mp].id].y>0&this[st1s.main[mp].id].y<waku.otate+30){
									osuta2.p();
								}
								if(this[st1s.main[mp].id].up=='down'){
									if(this[st1s.main[mp].id].y>40&this[st1s.main[mp].id].y<doro.y&house1.d(doro.x,doro.y)){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,0,11);										
									}else if(this[st1s.main[mp].id].y>40&this[st1s.main[mp].id].y<doro.y&doro.jou=='45'){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,0,11);										
									}else{
										this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,8);
										this[st1s.main[mp].id].y+=2;
										this[st1s.main[mp].id].x-=2;
										if(this[st1s.main[mp].id].y>waku.otate+60){
											this[st1s.main[mp].id].up='up';
										}
									}
								}else{
									if(this[st1s.main[mp].id].y<waku.otate+20&this[st1s.main[mp].id].y>doro.y&house1.d(doro.x,doro.y)){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,1,11);										
									}else if(this[st1s.main[mp].id].y<waku.otate+20&this[st1s.main[mp].id].y>doro.y&doro.jou=='45'){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,1,11);										
									}else{
										this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,9);
										this[st1s.main[mp].id].y-=2;
										this[st1s.main[mp].id].x+=2;
										if(this[st1s.main[mp].id].y<-30){
											this[st1s.main[mp].id].up='down';
										}
									}
								}
							}else{						
								if(this[st1s.main[mp].id].koma==3&this[st1s.main[mp].id].x>-30&this[st1s.main[mp].id].x<waku.oyoko+30){
									osuta.p();
								}
								if(this[st1s.main[mp].id].houkou=='hidari'){
									if(this[st1s.main[mp].id].x<waku.oyoko-10&this[st1s.main[mp].id].x>doro.x&house1.d(doro.x,doro.y)){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,2,11);										
									}else if(this[st1s.main[mp].id].x<waku.oyoko-10&this[st1s.main[mp].id].x>doro.x&doro.jou=='45'){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,2,11);										
									}else{
										this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,1);
										this[st1s.main[mp].id].x-=3;
										if(this[st1s.main[mp].id].x<-100){							
											this[st1s.main[mp].id].houkou='migi';
										}
									}
								}else{
									if(this[st1s.main[mp].id].x>10&this[st1s.main[mp].id].x<doro.x&house1.d(doro.x,doro.y)){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,3,11);										
									}else if(this[st1s.main[mp].id].x>10&this[st1s.main[mp].id].x<doro.x&doro.jou=='45'){
										this[st1s.main[mp].id].sumaho=true;
										this[st1s.main[mp].id+'sumaho'].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,3,11);										
									}else{
										this[st1s.main[mp].id].ani(this[st1s.main[mp].id].x,this[st1s.main[mp].id].y,2);
										this[st1s.main[mp].id].x+=3;
										if(this[st1s.main[mp].id].x>waku.otate+100){
											this[st1s.main[mp].id].houkou='hidari';
										}
									}
								}
							}
						}												
						break;				
					case 'doro':
						if(!house1.d(doro.x,doro.y)&!doro.renda){
							if(doro.jou=='45'){
								if(doro.koma==3){
									onuchu.p();
								}
								doro.ani(doro.x,doro.y,26);
								doro.renda=true;
							}else if(doro.jou=='walk'){
								if(doro.houkou=='hidari'){
									doro.ani(doro.x,doro.y,1);
								}else{
									doro.ani(doro.x,doro.y,2);
								};
								doro.renda=true;
								if(doro.koma==1){
									odsuta.p();
								}
							}else if(doro.jou=='noboru'){
								if(doro.up==''){
									if(doro.houkou=='hidari'){
										doro.ani(doro.x,doro.y,4);								
									}else{
										doro.ani(doro.x,doro.y,5);								
									}												
								}else{
									if(doro.up=='up'){
										doro.ani(doro.x,doro.y,6);
									}else{
										doro.ani(doro.x,doro.y,7);
									}
								}
								doro.renda=true;
								if(doro.koma==3){
									okosu.p();
								}
								
								if(doro.koma==0){
									doro.jou='walk';		
									if(doro.up==''){
										if(!house1.d(doro.x,doro.y)){									
											doro.x-=5;
											if(doro.ty<doro.y){
												doro.y-=5;
											}
											doro.houkou='hidari';											
										}else{									
											doro.x+=5;
											if(doro.ty>doro.y){
												doro.y+=5;
											}
											doro.houkou='migi';											
										}
									}else{
										if(doro.up=='up'){
											doro.y-=5;
										}else{									
											doro.y+=5;
										}
									}
								}
							}else if(doro.jou=='taiho'){
								doro.talk(doro.x,doro.y,10);
								doro.renda=true;
							}else{
								doro.kyara(doro.x,doro.y,0,0);							
								doro.renda=true;
							}
						};
						break;
					default:
						break;
				}
			};
			
			doro.renda=false;
		}
		if(waku.dia){
			if(nezu.osu){
				se.seri('intro'+waku.level+waku.gen,7,122,185,15,0.7);		
				if(btobasu.c(nezu.x,nezu.y)){
					itbut.kyara(10,120,0,9);
				}else{
					itbut.kyara(10,120,0,8);
				}
				
				var tek=anne;				
				
				if(tek.kazu<2){
					tek.kazu++;				
				}else{
					tek.kazu=0;
					tek.kazu2++;
					if(tek.kazu2>3){
						tek.kazu2=0;
					}
				}
				kyanba.save();
				kyanba.fillStyle='#ffffff';
				kyanba.globalAlpha=0.6;
				kyanba.fillRect((waku.oyoko/2)-20,(waku.otate/2)-13,40,55);
				kyanba.restore();
				tek.kyara(waku.oyoko/2,(waku.otate/2)+40,0,tek.kazu2);
			}						
		}else{
			kyanba.save();
			kyanba.globalAlpha=0.5;
			kyanba.fillStyle='#ffffff';
			kyanba.fillRect(145,1,53,10);
			kyanba.fillStyle='#ff0000';
			if(waku.level==1){
				kyanba.fillRect(146,2,(50*doro.koufun)/doro.koufun1,8);
			}else if(waku.level==2){
				kyanba.fillRect(146,2,(50*doro.koufun)/doro.koufun2,8);
			}else {
				kyanba.fillRect(146,2,(50*doro.koufun)/doro.koufun3,8);
			}
			kyanba.restore();
			ko.koto(logs['x'+waku.gen],155,2,62,10,1);
		}
		if(bbgm.c(nezu.x,nezu.y)){
			if(waku.bgm){
				itbut.kyara(8,16,0,11);
			}else{
				itbut.kyara(8,16,0,13);
			}
		}else{
			if(waku.bgm){
				itbut.kyara(8,16,0,10);
			}else{
				itbut.kyara(8,16,0,12);
			}
		}
	}else if(waku.sute=='shichou'){
		if(waku.scn==1){
			if(waku.ani==1){
				bgan0.haikei(0,0);
				annesupa0.ani(100,100);
			}else{				
				bgan.haikei(0,0);			
				mobu.kazu++;
				if(mobu.kazu<20){
					mobu.talk(55,65,19);
				}else{
					mobu.talk(50,65,19);
					if(mobu.kazu>=40){
						mobu.kazu=0;
					}
				}
				
				bgan.haikei(0,0,0,1);
				
				if(waku.ani>2){
					if(waku.ani==3){
						annesupa2.ani(84,66);
					}else{
						anne.kyara(106,54,3,0);
						if(waku.ani==4){
							annesupa3.ani(107,52,0,17,'talk');
						}else {
							annesupa4.ani(107,52,0,8);
						}
					}
				}
				
				if(waku.ani<6){
					bgan.haikei(0,0,0,4);				
				}else{
					kyanba.save();
					kyanba.globalAlpha=0.5;
					bgan.haikei(0,0,0,4);				
					kyanba.restore();
				}				
				
				if(waku.ani==2){					
					bgan.haikei(0,0,0,5);					
				}								
				
				bgan.haikei(0,0,0,2);	
				mobu1.kazu++;
				if(mobu1.kazu<30){
					mobu1.talk(52,92,18);
				}else if(mobu1.kazu<50){
					mobu1.talk(47,97,18);				
				}else if(mobu1.kazu<70){
					mobu1.talk(43,101,18);				
				}else if(mobu1.kazu<90){
					mobu1.talk(22,105,19);				
				}else if(mobu1.kazu<110){
					mobu1.talk(-3,103,19);				
				}else if(mobu1.kazu<190){
					
				}else if(mobu1.kazu<210){
					mobu1.talk(-3,103,19);				
				}else if(mobu1.kazu<230){
					mobu1.talk(22,105,19);				
				}else if(mobu1.kazu<250){
					mobu1.talk(43,101,18);				
				}else if(mobu1.kazu<260){
					mobu1.talk(47,97,18);				
				}else{				
					if(mobu1.kazu>=270){
						mobu1.kazu=0;
					}
				}
				
				
				bgan.haikei(0,0,0,3);			
				if(waku.ani==2){
					anne.talk(122,91,2);
				}
				
				bgan.haikei(0,0,0,6);
				if(waku.ani==2){
					mobu.kyara(110,79,20,3);			
					doro.kyara(105,99,0,2);
				}
				
				bgan.haikei(0,0,0,7);
				
				mobu.talk(80,131,21);
				
				bgan.haikei(0,0,0,8);
				mobu.kyara(70,120,20,3);
				mobu.kyara(90,120,20,3);
				mobu.talk(42,138,20);
				mobu.kyara(65,138,0,2);
				
				if(mobu.houkou=='hidari'){				
					mobu.ani(mobu.x,155,1);
					if(mobu.x>-150){
						mobu.x-=3;
					}else{
						mobu.houkou='migi';
					}
				}else{
					mobu.ani(mobu.x,155,2);
					if(mobu.x<250){
						mobu.x+=3;
					}else{
						mobu.houkou='hidari';
					}
				}				
			}
			
		}
		
		if(waku.scn==1){
			se2.seri('1'+waku.gen,64,106,129,43,0.7);
		}
		
		if(bsdf.c(nezu.x,nezu.y)){
			if(seri2f(waku.scn,waku.ani,se2.dian)){
				itbut.kyara(58,117,0,3);		
			}
		}else{
			if(seri2f(waku.scn,waku.ani,se2.dian)){
				itbut.kyara(58,117,0,2);		
			}
		}
		
		if(ssma.c(nezu.x,nezu.y)){
			itbut.kyara(8,134,0,1);
		}else{
			itbut.kyara(8,134);
		}
		if(sspu.c(nezu.x,nezu.y)){
			itbut.kyara(18,134,0,3);
		}else{
			itbut.kyara(18,134,0,2);
		}		
		if(sama.c(nezu.x,nezu.y)){
			itbut.kyara(8,149,0,1);
		}else{
			itbut.kyara(8,149);
		}
		if(sapu.c(nezu.x,nezu.y)){
			itbut.kyara(18,149,0,3);
		}else{
			itbut.kyara(18,149,0,2);
		}		
		if(sbac.c(nezu.x,nezu.y)){
			itbut.kyara(48,149,0,5);
		}else{
			itbut.kyara(48,149,0,4);
		}
		romab.koto(''+waku.scn,30,124,62,10,1);
		romab.koto(''+waku.ani,30,138,62,10,1);
		if(bbgm.c(nezu.x,nezu.y)){
			if(waku.bgm){
				itbut.kyara(8,16,0,11);
			}else{
				itbut.kyara(8,16,0,13);
			}
		}else{
			if(waku.bgm){
				itbut.kyara(8,16,0,10);
			}else{
				itbut.kyara(8,16,0,12);
			}
		}
	}else if(waku.sute=='dorobeya'){
		bgdoro.haikei(0,0);
		if(doro['pan'+waku.level]){			
			dorobp.ani(142,66);			
			bgdoro.haikei(0,0,0,1);
			if(nezu.osu){
				se.seri('doro'+waku.level+''+waku.gen,7,122,185,15,0.7);				
				if(btobasu.c(nezu.x,nezu.y)){
					itbut.kyara(10,120,0,9);
				}else{
					itbut.kyara(10,120,0,8);
				}
			}
		}else{
			doro.ani(116,85,13);			
			if(nezu.osu){
				se.seri('doro'+waku.gen+'no',7,122,185,15,0.7);		
				if(btobasu.c(nezu.x,nezu.y)){
					itbut.kyara(10,120,0,9);
				}else{
					itbut.kyara(10,120,0,8);
				}
			}
		}
		
		if(bbgm.c(nezu.x,nezu.y)){
			if(waku.bgm){
				itbut.kyara(8,16,0,11);
			}else{
				itbut.kyara(8,16,0,13);
			}
		}else{
			if(waku.bgm){
				itbut.kyara(8,16,0,10);
			}else{
				itbut.kyara(8,16,0,12);
			}
		}
	}else if(waku.sute=='ecchi'){
		if(waku.level==1){
			if(se.dian<3){
				bgan0.haikei(0,0);
				annesupa0.ani(100,100);
			}else{				
				bgan.haikei(0,0);			
				mobu.kazu++;
				if(mobu.kazu<20){
					mobu.talk(55,65,19);
				}else{
					mobu.talk(50,65,19);
					if(mobu.kazu>=40){
						mobu.kazu=0;
					}
				}				
				bgan.haikei(0,0,0,1);
				
				if(se.dian>=16){
					if(se.dian<20){
						annesupa2.ani(84,66);
					}else{
						anne.kyara(106,54,3,0);
						if(se.dian<22){
							annesupa3.ani(107,52,0,17,'talk');
						}else {
							annesupa4.ani(107,52,0,8);
						}
					}
				}				
				
				bgan.haikei(0,0,0,4);
				
				if(se.dian<16){				
					bgan.haikei(0,0,0,5);					
				}				
				
				bgan.haikei(0,0,0,2);	
				mobu1.kazu++;
				if(mobu1.kazu<30){
					mobu1.talk(52,92,18);
				}else if(mobu1.kazu<50){
					mobu1.talk(47,97,18);				
				}else if(mobu1.kazu<70){
					mobu1.talk(43,101,18);				
				}else if(mobu1.kazu<90){
					mobu1.talk(22,105,19);				
				}else if(mobu1.kazu<110){
					mobu1.talk(-3,103,19);				
				}else if(mobu1.kazu<190){
					
				}else if(mobu1.kazu<210){
					mobu1.talk(-3,103,19);				
				}else if(mobu1.kazu<230){
					mobu1.talk(22,105,19);				
				}else if(mobu1.kazu<250){
					mobu1.talk(43,101,18);				
				}else if(mobu1.kazu<260){
					mobu1.talk(47,97,18);				
				}else{				
					if(mobu1.kazu>=270){
						mobu1.kazu=0;
					}
				}
				
				
				bgan.haikei(0,0,0,3);			
				if(se.dian<16){
					anne.talk(122,91,2);
				}
				
				bgan.haikei(0,0,0,6);
				if(se.dian<16){
					mobu.kyara(110,79,20,3);			
					doro.kyara(105,99,0,2);
				}
				
				bgan.haikei(0,0,0,7);
				
				mobu.talk(80,131,21);
				
				bgan.haikei(0,0,0,8);
				mobu.kyara(70,120,20,3);
				mobu.kyara(90,120,20,3);
				mobu.talk(42,138,20);
				mobu.kyara(65,138,0,2);
				
				if(mobu.houkou=='hidari'){				
					mobu.ani(mobu.x,155,1);
					if(mobu.x>-150){
						mobu.x-=3;
					}else{
						mobu.houkou='migi';
					}
				}else{
					mobu.ani(mobu.x,155,2);
					if(mobu.x<250){
						mobu.x+=3;
					}else{
						mobu.houkou='hidari';
					}
				}				
			}
		}
		if(nezu.osu){
			se.seri(waku.level+''+waku.gen,7,122,185,15,0.7);
			if(btobasu.c(nezu.x,nezu.y)){
				itbut.kyara(10,120,0,9);
			}else{
				itbut.kyara(10,120,0,8);
			}
		}
		
		if(bbgm.c(nezu.x,nezu.y)){
			if(waku.bgm){
				itbut.kyara(8,16,0,11);
			}else{
				itbut.kyara(8,16,0,13);
			}
		}else{
			if(waku.bgm){
				itbut.kyara(8,16,0,10);
			}else{
				itbut.kyara(8,16,0,12);
			}
		}
	}else if(waku.sute=='over'){
		bgover.kazu++;
		bgover.haikei(0,0);
		if(doro.end=='taiho'){
			doro.talk(96,142,14);
			bgover.haikei(0,0,0,1);
			keikan.talk(66,146,5);
		}else if(doro.end=='pan'){
			anne.talk(85,135,4);			
			doropover.ani(110,135);
		}
		romab.koto('hoodie corp 2025',135,140,62,10,1);		
		if(bgover.kazu>=30){
			nezu.osu=false;
			waku.sute='gengo';
			bgm.pause();
			bgmbad.pause();
			bgmfan.pause();
			waku.level=1;			
			doro.x=175;doro.y=140;doro.z=0;doro.tx=175;doro.ty=140;doro.floor=0;
			doro.jou='stop';doro.houkou='hidari';doro.pan=false;doro.pan1=false;doro.pan2=false;doro.pan3=false;
			doro.renda=false; doro.up='';doro.koufun=0;doro.keikan=false;		
			mobu.x=0;mobu.y=145;mobu.houkou='migi';mobu.up='';mobu.sumaho=false;
			
			keikan.x=0;keikan.y=150;keikan.yng=false;keikan.xng=false;keikan.kazu=0;doro.end='';			
			bgover.kazu=0;
			zero();
		}
	}
	if(!nezu.load){
		nezu.load=true;
	}
	
	if(!nezu.osu){
		if(nezu.osukazu<5){
			nezu.osukazu++;
			bgm.volume=(nezu.osukazu*2)/10;
			bgmbad.volume=(nezu.osukazu*2)/10;
			bgmfan.volume=(nezu.osukazu*2)/10;
		}else{
			bgm.volume=1;
			bgmbad.volume=1;
			bgmfan.volume=1;
			nezu.osukazu=0;			
			nezu.osu=true;		
		}
	}	
	
};
onmousemove=function(e){
	if(e.clientX<(waku.yoko/2)-(waku.canyoko/2)){
		nezu.x=0;
	}else if(Math.floor((e.clientX-((waku.yoko/2)-(waku.canyoko/2)))/waku.saizu)>waku.oyoko){
		nezu.x=waku.oyoko;
	}else{
		nezu.x=Math.floor((e.clientX-((waku.yoko/2)-(waku.canyoko/2)))/waku.saizu);
	}	
	if(e.clientY<(waku.tate/2)-(waku.cantate/2)){
		nezu.y=0;
	}else if(Math.floor((e.clientY-((waku.tate/2)-(waku.cantate/2)))/waku.saizu)>waku.otate){
		nezu.y=waku.otate;
	}else{
		nezu.y=Math.floor((e.clientY-((waku.tate/2)-(waku.cantate/2)))/waku.saizu);
	};	
};
onmousedown=function(e){
	kuri.p();
	
	if(e.clientX<(waku.yoko/2)-(waku.canyoko/2)){
		nezu.x=0;
	}else if(Math.floor((e.clientX-((waku.yoko/2)-(waku.canyoko/2)))/waku.saizu)>waku.oyoko){
		nezu.x=waku.oyoko;
	}else{
		nezu.x=Math.floor((e.clientX-((waku.yoko/2)-(waku.canyoko/2)))/waku.saizu);
	}	
	if(e.clientY<(waku.tate/2)-(waku.cantate/2)){
		nezu.y=0;
	}else if(Math.floor((e.clientY-((waku.tate/2)-(waku.cantate/2)))/waku.saizu)>waku.otate){
		nezu.y=waku.otate;
	}else{
		nezu.y=Math.floor((e.clientY-((waku.tate/2)-(waku.cantate/2)))/waku.saizu);
	};		
	
	waku.yoko=window.innerWidth;
	waku.tate=window.innerHeight;
	canvas.style.left=(waku.yoko/2)-(waku.canyoko/2);
	canvas.style.top=(waku.tate/2)-(waku.cantate/2);	
	if(nezu.load&nezu.osu){
		if(waku.sute=='gengo'){		
			if(bjp.c(nezu.x,nezu.y)){
				waku.gen='jp';	
				se=hira;
				ko=hirab;
				se2=hira2;
				document.title='パンどろ体験版';
			}else if(ben.c(nezu.x,nezu.y)){
				waku.gen='en';			
				se=roma;
				se2=roma2;
				ko=romab;
				document.title='Panthie Trial Version';
			}else if(bshichou.c(nezu.x,nezu.y)){		
				nezu.osu=false;
				waku.sute='shichou';				
				if(waku.bgm){
					bgmfan.play();
					bgmfan.volume=0;
				}
				zero();
			}else if(bstart.c(nezu.x,nezu.y)){			
				nezu.osu=false;
				waku.sute='panty';			
				if(waku.bgm){
					bgm.play();
					bgm.volume=0;
				}
				waku.dia=true;
			}else if(bsupu.c(nezu.x,nezu.y)){			
				if((waku.saizu+1)*waku.oyoko<waku.yoko&(waku.saizu+1)*waku.otate<waku.tate){
					waku.saizu++;
					waku.canyoko=waku.oyoko*waku.saizu;
					waku.cantate=waku.otate*waku.saizu;
					canvas.height=waku.cantate;
					canvas.width=waku.canyoko;						
					canvas.style.left=(waku.yoko/2)-(waku.canyoko/2);
					canvas.style.top=(waku.tate/2)-(waku.cantate/2);			
					kyanba.scale(waku.saizu,waku.saizu);
					kyanba.imageSmoothingEnabled=false;
				}
			}else if(bsuma.c(nezu.x,nezu.y)){		
				if(waku.saizu>1){
					waku.saizu--;
					waku.canyoko=waku.oyoko*waku.saizu;
					waku.cantate=waku.otate*waku.saizu;
					canvas.height=waku.cantate;
					canvas.width=waku.canyoko;						
					canvas.style.left=(waku.yoko/2)-(waku.canyoko/2);
					canvas.style.top=(waku.tate/2)-(waku.cantate/2);			
					kyanba.scale(waku.saizu,waku.saizu);
					kyanba.imageSmoothingEnabled=false;
				}			
			}
		}else if(waku.sute=='panty'){
			if(bbgm.c(nezu.x,nezu.y)){
				if(waku.bgm){
					bgm.pause();
					waku.bgm=false;
				}else{
					bgm.play();
					waku.bgm=true;
				}
			}else{
				if(waku.dia){
					if(btobasu.c(nezu.x,nezu.y)){
						se.reset();
						waku.dia=false;
					}else{
						if(se.nx){
							se.next();
						}else{
							se.reset();
							waku.dia=false;
						}
					}
				}else{
					doro.tx=nezu.x;
					doro.ty=nezu.y;
					if(waku.level==1){						
						if(doro.jou!='taiho'&doro.jou!='45'){
							if(pan1.d(doro.x,doro.y)&!doro.pan){		
								doro.jou='pan';					
							}else{
								if(ng1.d(doro.tx,doro.ty)){							
									ab={x1:ng1.x2,y1:ng1.y2,x2:ng1.x2+ng1.y2,y2:ng1.y1,x1b:ng1.x1,y1b:ng1.y2,x2b:ng1.x2,y2b:ng1.y2,x3:doro.x,y3:doro.y,x4:doro.tx,y4:doro.ty};
									aaa =((ab.x4 - ab.x3)*(ab.y3 - ab.y1) - (ab.y4 - ab.y3)*(ab.x3 - ab.x1)) / ((ab.x4 - ab.x3)*(ab.y2 - ab.y1) - (ab.y4 - ab.y3)*(ab.x2 - ab.x1));
									bbb = ((ab.x2b - ab.x1b)*(ab.y3 - ab.y1b) - (ab.y2b - ab.y1b)*(ab.x3 - ab.x1b)) / ((ab.x4 - ab.x3)*(ab.y2b - ab.y1b) - (ab.y4 - ab.y3)*(ab.x2b - ab.x1b))
									if(aaa>0&aaa<1){
										ab.x0=ab.x1+aaa*(ab.x2-ab.x1) ;			
										ab.y0=ab.y1+aaa*(ab.y2 - ab.y1) ;			
										if(doro.tx=ab.x0+5<waku.oyoko){
											doro.tx=ab.x0+5;
										}else{
											doro.tx=ab.x0;
										}
										doro.ty=ab.y0;
										
									}else if(bbb>0&bbb<1){			
										ab.x0=ab.x3 + bbb*(ab.x4 - ab.x3);			
										ab.y0= ab.y3 + bbb*(ab.y4 - ab.y3);
										doro.tx=ab.x0;
										doro.ty=ab.y0+2;					
									}else{	
										doro.tx=ng1.ma(doro.ty)+2;										
									}
								}else if(ng1b.d(doro.tx,doro.ty)){						
									ab={x1:ng1b.x2,y1:ng1b.y2,x2:ng1b.x2+ng1b.y2,y2:ng1b.y1,x1b:ng1b.x1,y1b:ng1b.y2,x2b:ng1b.x2,y2b:ng1b.y2,x3:doro.x,y3:doro.y,x4:doro.tx,y4:doro.ty};
									aaa =((ab.x4 - ab.x3)*(ab.y3 - ab.y1) - (ab.y4 - ab.y3)*(ab.x3 - ab.x1)) / ((ab.x4 - ab.x3)*(ab.y2 - ab.y1) - (ab.y4 - ab.y3)*(ab.x2 - ab.x1));
									bbb = ((ab.x2b - ab.x1b)*(ab.y3 - ab.y1b) - (ab.y2b - ab.y1b)*(ab.x3 - ab.x1b)) / ((ab.x4 - ab.x3)*(ab.y2b - ab.y1b) - (ab.y4 - ab.y3)*(ab.x2b - ab.x1b))
									if(aaa>0&aaa<1){
										ab.x0=ab.x1+aaa*(ab.x2-ab.x1) ;			
										ab.y0=ab.y1+aaa*(ab.y2 - ab.y1) ;			
										if(doro.tx=ab.x0+5<waku.oyoko){
											doro.tx=ab.x0+5;
										}else{
											doro.tx=ab.x0;
										}
										doro.ty=ab.y0;
										
									}else if(bbb>0&bbb<1){			
										ab.x0=ab.x3 + bbb*(ab.x4 - ab.x3);			
										ab.y0= ab.y3 + bbb*(ab.y4 - ab.y3);
										doro.tx=ab.x0;
										doro.ty=ab.y0+2;					
									}else{					
										if(!ng1.d(doro.tx,ng1b.y2+2)){
											doro.ty=ng1b.y2+2;
										}else{
											doro.tx=ng1b.ma(doro.ty);
										}										
									}
									if(ng1.d(doro.tx,doro.ty)){							
										ab={x1:ng1.x2,y1:ng1.y2,x2:ng1.x2+ng1.y2,y2:ng1.y1,x1b:ng1.x1,y1b:ng1.y2,x2b:ng1.x2,y2b:ng1.y2,x3:doro.x,y3:doro.y,x4:doro.tx,y4:doro.ty};
										aaa =((ab.x4 - ab.x3)*(ab.y3 - ab.y1) - (ab.y4 - ab.y3)*(ab.x3 - ab.x1)) / ((ab.x4 - ab.x3)*(ab.y2 - ab.y1) - (ab.y4 - ab.y3)*(ab.x2 - ab.x1));
										bbb = ((ab.x2b - ab.x1b)*(ab.y3 - ab.y1b) - (ab.y2b - ab.y1b)*(ab.x3 - ab.x1b)) / ((ab.x4 - ab.x3)*(ab.y2b - ab.y1b) - (ab.y4 - ab.y3)*(ab.x2b - ab.x1b))
										if(aaa>0&aaa<1){
											ab.x0=ab.x1+aaa*(ab.x2-ab.x1) ;			
											ab.y0=ab.y1+aaa*(ab.y2 - ab.y1) ;			
											if(doro.tx=ab.x0+5<waku.oyoko){
												doro.tx=ab.x0+5;
											}else{
												doro.tx=ab.x0;
											}
											doro.ty=ab.y0;
											
										}else if(bbb>0&bbb<1){			
											ab.x0=ab.x3 + bbb*(ab.x4 - ab.x3);			
											ab.y0= ab.y3 + bbb*(ab.y4 - ab.y3);
											doro.tx=ab.x0;
											doro.ty=ab.y0+2;					
										}
									}
								}						
								if(doro.jou!='noboru'){
									doro.jou='walk';
								}
								if(doro.x<doro.tx){
									doro.houkou='migi';
								}else{
									doro.houkou='hidari';
								}
							}
						}
					}
				}
			}
		}else if(waku.sute=='shichou'){
			if(bbgm.c(nezu.x,nezu.y)){
				if(!waku.bgm){
					bgmfan.play();
					waku.bgm=true;
				}else{
					bgmfan.pause();
					waku.bgm=false;
				}
			}else if(sbac.c(nezu.x,nezu.y)){
				nezu.osu=false;
				waku.sute='gengo';
				mobu.x=0;mobu.y=145;mobu.houkou='migi';mobu.up='';mobu.sumaho=false;
				bgmfan.pause();
				se2.reset();
				zero();
				waku.level=1;			
			}else if(ssma.c(nezu.x,nezu.y)){			
				if(waku.scn>1){
					waku.scn--;
				}else{
					waku.scn=waku.scnt;
				};
				waku.ani=1;
				se2.reset();
				zero();
			}else if(sspu.c(nezu.x,nezu.y)){
				if(waku.scn<waku.scnt){
					waku.scn++;
				}else{
					waku.scn=1;
				};
				waku.ani=1;
				se2.reset();
				zero();
			}else if(sama.c(nezu.x,nezu.y)){			
				if(waku.ani>1){
					waku.ani--;
				}else{
					waku.ani=waku['ani'+waku.scn];
				}
				zero();
				var dd=seri2f(waku.scn,waku.ani,se2.dian,'a');
				se2.dian=dd;
			}else if(sapu.c(nezu.x,nezu.y)){
				if(waku.ani<waku['ani'+waku.scn]){
					waku.ani++;
				}else{
					waku.ani=1;
					zero();
				}
				var dd=seri2f(waku.scn,waku.ani,se2.dian,'a');
				se2.dian=dd;
			}else if(bsdf.c(nezu.x,nezu.y)){
				if(seri2f(waku.scn,waku.ani,se2.dian)){
					if(se2.nx){
						se2.next()
					}
				}
			}
			
		}else if(waku.sute=='dorobeya'){
			if(bbgm.c(nezu.x,nezu.y)){
				if(!waku.bgm){
					if(doro['pan'+waku.level]){
						bgm.play();
					}else{
						bgmbad.play();
					}
					waku.bgm=true;
				}else{
					if(doro['pan'+waku.level]){
						bgm.pause();
					}else{
						bgmbad.pause();
					}
					waku.bgm=false;
				}
			}else if(btobasu.c(nezu.x,nezu.y)){
				se.reset();
				if(doro['pan'+waku.level]){					
					nezu.osu=false;
					waku.sute='ecchi';					
					doro.z=0;
					doro.jou='stop';doro.houkou='hidari';doro.pan=false;
					doro.renda=false; doro.up='';doro.koufun=0;doro.keikan=false;
					keikan.x=0;keikan.y=150;keikan.yng=false;keikan.xng=false;keikan.kazu=0;
					zero();
					if(waku.bgm){
						bgm.pause();
						bgmbad.pause();
						bgmfan.play();
						bgmfan.volume=0;
					}
				}else{
					nezu.osu=false;
					waku.sute='over';
				}
			}else{			
				if(se.nx){
					se.next();
				}else{
					se.reset();
					if(doro['pan'+waku.level]){					
						nezu.osu=false;
						waku.sute='ecchi';					
						doro.z=0;
						doro.jou='stop';doro.houkou='hidari';doro.pan=false;
						doro.renda=false; doro.up='';doro.koufun=0;doro.keikan=false;
						keikan.x=0;keikan.y=150;keikan.yng=false;keikan.xng=false;keikan.kazu=0;
						zero();
						if(waku.bgm){
							bgm.pause();
							bgmbad.pause();
							bgmfan.play();
							bgmfan.volume=0;
						}
					}else{
						nezu.osu=false;
						waku.sute='over';
					}
				}
			}
		}else if(waku.sute=='ecchi'){
			if(bbgm.c(nezu.x,nezu.y)){
				if(!waku.bgm){
					bgmfan.play();
					waku.bgm=true;
				}else{
					bgmfan.pause();
					waku.bgm=false;
				}
			}else if(btobasu.c(nezu.x,nezu.y)){
				nezu.osu=false;								
				if(waku.bgm){						
					bgmfan.pause();					
					bgm.play();					
					bgm.volume=0;
				}					
				doro.x=175;doro.y=140;doro.z=0;doro.tx=175;doro.ty=140;
				mobu.x=0;mobu.y=145;mobu.houkou='migi';mobu.up='';mobu.sumaho=false;
				
				waku.sute='over';
				bgmfan.pause();
				bgm.pause();
				doro.end='pan';
				
				doro.z=0;
				doro.jou='stop';doro.houkou='hidari';doro.pan=false;
				doro.renda=false; doro.up='';doro.koufun=0;doro.keikan=false;		
				se.reset();
				waku.level=1;
				
				doro.floor=0;	
				keikan.x=0;keikan.y=150;keikan.yng=false;keikan.xng=false;keikan.kazu=0;
				zero();				
			}else{				
				if(se.nx){
					se.next()
				}else{																
					nezu.osu=false;
					se.reset();						
					if(waku.bgm){
						bgmfan.pause();
						bgm.play();					
						bgm.volume=0;
					}						
					doro.x=175;doro.y=140;doro.z=0;doro.tx=175;doro.ty=140;
					mobu.x=0;mobu.y=145;mobu.houkou='migi';mobu.up='';mobu.sumaho=false;
					
					nezu.osu=false;
					waku.sute='over';
					bgmfan.pause();
					bgm.pause();
					doro.end='pan';
					
					doro.z=0;
					doro.jou='stop';doro.houkou='hidari';doro.pan=false;
					doro.renda=false; doro.up='';doro.koufun=0;doro.keikan=false;		
					se.reset();
					waku.level=1;
					
					keikan.x=0;keikan.y=150;keikan.yng=false;keikan.xng=false;keikan.kazu=0;
					zero();
				}
			}			
		};
	}
};


window.onload=function(){	
	dorof=setInterval(dororeda,100);	
	kyanba.font='5px arial';
};