if(navigator.userAgent.indexOf("Opera")!=-1){browser="opera";
}else if(navigator.userAgent.indexOf("MSIE 5")!=-1){browser="explorer6";
}else if(navigator.userAgent.indexOf("MSIE 6")!=-1){browser="explorer6";
}else if(navigator.userAgent.indexOf("MSIE 7")!=-1){browser="explorer7";
}else if(navigator.userAgent.indexOf("MSIE 8")!=-1){browser="explorer8";
}else if(navigator.userAgent.indexOf("MSIE")!=-1){browser="explorer";
}else if(navigator.userAgent.indexOf("Firefox")!=-1){browser="firefox";
}else if(navigator.userAgent.indexOf("Netscape")!=-1){browser="netscape";
}else if(navigator.userAgent.indexOf("Safari")!=-1){browser="safari";
}

var opanime_hidden;


//DIVタグのポップアップ機能
// popupDIV(id,position); position=stay,center,cursor,cursorcenter
// closeDIV(id);
grayscreen=null;
function popupDIV(divid,position,evt){
	var div=document.getElementById(divid);
	div.style.position="absolute";
	div.style.zIndex="100";
	if(position.match(/^(\-\d+|\d+|\+\d+)(c|r|l|m|)(x|,)(\-\d+|\d+|\+\d+)(c|b|t|m|)(\+s|\+g|\+sg|\+gs|)([WHOP]+)$/)){
		x=RegExp.$1-0;
		y=RegExp.$4-0;
		xmode=RegExp.$2;
		ymode=RegExp.$5;
		x-=div.parentNode.offsetLeft;
		y-=div.parentNode.offsetTop;
		if(xmode=="c") x+=getBrowserWidth()/2;
		if(ymode=="c") y+=getBrowserHeight()/2;
		if(xmode=="r") x+=getBrowserWidth();
		if(ymode=="b") y+=getBrowserHeight();
		if(xmode=="m") x+=evt.clientX+document.body.scrollLeft;
		if(ymode=="m") y+=evt.clientY+document.body.scrollTop;
		if(RegExp.$6=="+s" || RegExp.$6=="+gs" || RegExp.$6=="+sg"){
			x+=document.body.scrollLeft;
			y+=document.body.scrollTop;
		}
		div.style.left=x+"px";
		div.style.top=y+"px";
		if(RegExp.$6=="+g" || RegExp.$6=="+gs" || RegExp.$6=="+sg"){
			grayscreen=document.getElementById("grayscreen");
			if(grayscreen==undefined){
				grayscreen=document.createElement("div");
				grayscreen.id="grayscreen";
				document.body.appendChild(grayscreen);
			}
			grayscreen.style.position="absolute";
			grayscreen.style.backgroundColor="black";
			opup(grayscreen.id,20,0.9,1);
			grayscreen.style.left=document.body.scrollLeft+"px";
			grayscreen.style.top=document.body.scrollTop+"px";
			grayscreen.style.width=getBrowserWidth()+"px";
			grayscreen.style.height=getBrowserHeight()+"px";
			grayscreen.style.visibility="visible";
			grayscreen.style.zIndex="99";
		}
		d7=RegExp.$7;
		if(d7.match(/O/)){
			opup(div,10,1,1);
		}
		if(d7.match(/H/)){
			div.style.top=y+parseInt(div.style.height)/2+"px";
			dsh=div.style.height;
			div.style.height="0";
			vaLinear(div,'style.top',y,y+parseInt(dsh)/2,20,-1,1,'','px',-10,0,"","");
			vaLinear(div,'style.height',0,parseInt(dsh),20,1,1,'','px',-10,0,"","");
		}
		if(d7.match(/W/)){
			div.style.left=x+parseInt(div.style.width)/2+"px";
			dsw=div.style.width;
			div.style.width="0";
			vaLinear(div,'style.left',x,x+parseInt(dsw)/2,20,-1,1,'','px',-10,0,"","");
			vaLinear(div,'style.width',0,parseInt(dsw),20,1,1,'','px',-10,0,"","");
		}
		if(d7.match(/P/)){
			pstr="div=getElementById('"+div.id+"');";
			pstr+='div.style.top=y+parseInt(div.style.height)/2+"px";';
			pstr+='dsh=div.style.height;';
			pstr+='div.style.height="0";';
			pstr+='vaLinear(div,"style.top",y,y+parseInt(dsh)/2,20,-1,10,"","px",-10,0,"","");';
			pstr+='vaLinear(div,"style.height",0,parseInt(dsh),20,1,10,"","px",-10,0,"","");';
			div.style.left=x+parseInt(div.style.width)/2+"px";
			dsw=div.style.width;
			div.style.width="0";
			div.style.height="20";
			vaLinear(div,'style.left',x,x+parseInt(dsw)/2,20,-1,10,'','px',-10,0,pstr,"");
			vaLinear(div,'style.width',0,parseInt(dsw),20,1,10,'','px',-10,0,"","");
		}
		
		div.style.visibility="visible";
	}
	
}
function shiftDIV(dividc,divid,position,evt){
	var div=document.getElementById(dividc);
	vaLinear(div,'style.opacity',0,1,10,-1,1,'','',-10,true,"document.getElementById('"+div.id+"').style.visibility='hidden';","");
	popupDIV(divid,position,evt);
}
function closeDIV(divid){
	var div=document.getElementById(divid);
	vaLinear(div,'style.opacity',0,1,10,-1,1,'','',-10,true,"document.getElementById('"+div.id+"').style.visibility='hidden';","");
	if(grayscreen){
		vaLinear(grayscreen,'style.opacity',0,0.9,10,-1,1,'','',-10,true,"document.getElementById('grayscreen').style.visibility='hidden';","");
		opanime_hidden=grayscreen.id;
	}
}

//function bgaup(div,maxsteps,kheight,delay){
//	bganime(div,-1,maxsteps,1,kheight,delay);
//}
//function bgadown(div,maxsteps,kheight,delay){
//	bganime(div,-1,maxsteps,-1,kheight,delay);
//}
function bgareset(div){
	var div=document.getElementById(divid);
	div.style.backgroundPosition="0px 0px";
}
function bganime(divid,steps,maxsteps,updown,kheight,delay){
	var div=document.getElementById(divid);
	if(div.style.backgroundPosition==undefined){
		div.style.backgroundPosition="0px 0px";
	}
	var pos=-div.style.backgroundPosition.replace(/.* |[^\-0-9]/g,"")/kheight;
	if(steps==-1){
		steps=pos;
	}
	if(steps==pos){
		steps+=updown;
        if(!(0<=steps && steps<=maxsteps-1))return;
		div.style.backgroundPosition="0px -"+(steps*kheight)+"px";
		if(steps>0 && steps<maxsteps-1){
			setTimeout('bganime("'+divid+'",'+steps+','+maxsteps+','+updown+','+kheight+','+delay+');',delay);
		}
	}
	
}

//function hup(div,maxsteps,maxheight,delay){
//	hwanime(div,-1,maxsteps,1,"height",0,maxheight,delay);
//}
//function hdown(div,maxsteps,maxheight,delay){
//	hwanime(div,-1,maxsteps,-1,"height",0,maxheight,delay);
//}
//function wup(div,maxsteps,maxheight,delay){
//	hwanime(div,-1,maxsteps,1,"width",0,maxheight,delay);
//}
//function wdown(div,maxsteps,maxheight,delay){
//	hwanime(div,-1,maxsteps,-1,"width",0,maxheight,delay);
//}
//function hup2(div,maxsteps,minheight,maxheight,delay){
//	hwanime(div,-1,maxsteps,1,"height",minheight,maxheight,delay);
//}
//function hdown2(div,maxsteps,minheight,maxheight,delay){
//	hwanime(div,-1,maxsteps,-1,"height",minheight,maxheight,delay);
//}
//function wup2(div,maxsteps,minheight,maxheight,delay){
//	hwanime(div,-1,maxsteps,1,"width",minheight,maxheight,delay);
//}
//function wdown2(div,maxsteps,minheight,maxheight,delay){
//	hwanime(div,-1,maxsteps,-1,"width",minheight,maxheight,delay);
//}
function hreset(divid){
	var div=document.getElementById(divid);
	div.style.height=0;
	div.style.visibility="hidden";
}
function hreset2(divid,min){
	var div=document.getElementById(divid);
	div.style.height=min+"px";
}
function wreset(divid){
	var div=document.getElementById(divid);
	div.style.width=0;
	div.style.visibility="hidden";
}
function wreset2(divid,min){
	var div=document.getElementById(divid);
	div.style.width=min+"px";
}

function hwanime(divid,steps,maxsteps,updown,horw,minsize,maxsize,delay){
	var div=document.getElementById(divid);
	var obj=div.style;
	if(horw=="height"){
		obj=obj.height;
	}else{
		obj=obj.width;
	}
	if(obj==undefined || obj==""){
		obj=minsize+"px";
	}
	pos=Math.round((parseInt(obj)-minsize)/((maxsize-minsize)/maxsteps));
	if(steps==-1){
		steps=pos;
	}
	if(steps==pos){
		steps+=updown;
        if(!(0<=steps && steps<=maxsteps))return;
		if(horw=="height"){
			div.style.height=minsize+(steps/maxsteps*(maxsize-minsize))+"px";
		}else{
			div.style.width=minsize+(steps/maxsteps*(maxsize-minsize))+"px";
		}
		if(minsize==0){
			if(steps==0)div.style.visibility="hidden";
			else div.style.visibility="visible";
		}
		if(steps>0 && steps<maxsteps){
			setTimeout('hwanime("'+divid+'",'+steps+','+maxsteps+','+updown+',"'+horw+'",'+minsize+','+maxsize+','+delay+');',delay);
		}
	}
	
}

//function opup(div,maxsteps,maxopacity,delay){
//	opanime(div,-1,maxsteps,1,maxopacity,delay);
//}
//function opdown(div,maxsteps,maxopacity,delay){
//	opanime(div,-1,maxsteps,-1,maxopacity,delay);
//}
function opreset(div){
	var div=document.getElementById(divid);
	div.style.opacity="0.0";
	if(browser=="explorer6" || browser=="explorer7" || browser=="explorer8")div.style.filter="alpha(opacity=0)";
	
	
}
function opanime(divid,steps,maxsteps,updown,maxopacity,delay){
	var div=document.getElementById(divid);
	var obj=div.style;
    obj=obj.opacity;
	if(obj==undefined || obj==""){
		obj="0.0";
	}
	pos=Math.round(obj*1.0/(maxopacity/maxsteps));
	if(steps==-1){
		steps=pos;
	}
	if(steps==pos){
		steps+=updown;
        if(!(0<=steps && steps<=maxsteps))return;
        div.style.opacity=(steps/maxsteps*maxopacity);
        if(browser=="explorer6" || browser=="explorer7" || browser=="explorer8")div.style.filter="alpha(opacity="+div.style.opacity*100+")";
		if(opanime_hidden==divid){
			if(steps==0)div.style.visibility="hidden";
			else div.style.visibility="visible";
		}
		if(steps>0 && steps<maxsteps){
			setTimeout('opanime("'+divid+'",'+steps+','+maxsteps+','+updown+','+maxopacity+','+delay+');',delay);
		}
	}
	
}


function divss(divlist,changedelay,delay,step,frontend){
    var divv=divlist.split(",");
    var divc=divv.length;
    var div8=document.getElementById(divv[0]);
    var div9=document.getElementById(divv[(step+divc-1)%divc]);
    var div0=document.getElementById(divv[(step+0)%divc]);
    var div1=document.getElementById(divv[(step+1)%divc]);
    if(div8.divssfrontend!=frontend)return;
    if(div8.divssstop==1){return;}
    div8.divssfrontend++;
    div9.style.opacity="0";
    div9.style.visibility="hidden";
    div0.style.opacity="1";
    div0.style.zIndex="10";
    div0.style.visibility="visible";
    div1.style.opacity="0";
    div1.style.zIndex="11";
    div1.style.visibility="visible";
    opanime(div1.id,-1,changedelay/20,1,1,20);
    nextstr='divss("'+divlist+'",'+changedelay+','+delay+','+(step+1)+','+div8.divssfrontend+')';
    setTimeout(nextstr,delay);
    div8.divsslast2=div8.divsslast;
    div8.divsslast=step+1;
}
function skipdivss(divlist,changedelay,delay,step,chnagedelay2){
    var divv=divlist.split(",");
    var divc=divv.length;
    var div8=document.getElementById(divv[0]);
    var div9=document.getElementById(divv[div8.divsslast2%divc]);
    var div0=document.getElementById(divv[div8.divsslast%divc]);
    var div1=document.getElementById(divv[step%divc]);
    if(div9==null)div9=div8;
    if(div0==null)div0=div8;
    div8.divssfrontend++;
    div9.style.opacity="0";
    div9.style.visibility="hidden";
    div0.style.opacity="1";
    div0.style.zIndex="10";
    div0.style.visibility="visible";
    div1.style.opacity="0";
    div1.style.zIndex="11";
    div1.style.visibility="visible";
    opanime(div1.id,-1,chnagedelay2/20,1,1,20);
    nextstr='divss("'+divlist+'",'+changedelay+','+delay+','+(step)+','+div8.divssfrontend+')';
    setTimeout(nextstr,delay);
    div8.divssstop=1;
    div8.divsslast2=div8.divsslast;
    div8.divsslast=step;
}
function startdivss(divlist,changedelay,delay,firstdelay){
    var divv=divlist.split(",");
    var divc=divv.length;
    var div8=document.getElementById(divv[0]);
    var div0=document.getElementById(divv[div8.divsslast%divc]);
    var step=0;
    div8.divssstop=0;
    if(div0!=null){
        step=div8.divsslast;
    }else{
        div8.divsslast=0;
        div8.divssfrontend=0;
    }
    nextstr='divss("'+divlist+'",'+changedelay+','+delay+','+(step)+','+div8.divssfrontend+')';
    setTimeout(nextstr,firstdelay);
}
