va_maxarray=64;
va_step  =new Array(va_maxarray);
va_object=new Array(va_maxarray);
va_value =new Array(va_maxarray);
va_func  =new Array(va_maxarray);
va_min   =new Array(va_maxarray);
va_max   =new Array(va_maxarray);
va_steps =new Array(va_maxarray);
va_stepfunc=new Array(va_maxarray);
va_updown=new Array(va_maxarray);
va_isopa =new Array(va_maxarray);
va_unit  =new Array(va_maxarray);
va_hideat=new Array(va_maxarray);
va_afterdo=new Array(va_maxarray);
va_canceldo=new Array(va_maxarray);
va_prefix=new Array(va_maxarray);
for(i=0;i<va_maxarray;i++){
	va_step[i]=-1;
}

function va_start(divobject,valueobject,minvalue,maxvalue,func,stepfunc,maxsteps,updown,isopacity,prefix,unit,hideat,afterdo,canceldo){
	vaid=-1;
	for(i=0;i<va_maxarray;i++){
		if(va_step[i]==-1){
			vaid=i;
			break;
		}
	}
	if(vaid!=-1){
		va_object[vaid]=divobject;
		va_value[vaid]=valueobject;
		va_func[vaid]=func;
		va_stepfunc[vaid]=stepfunc;
		va_min[vaid]=minvalue;
		va_max[vaid]=maxvalue;
		va_steps[vaid]=maxsteps;
		va_updown[vaid]=updown;
		va_isopa[vaid]=isopacity;
		va_prefix[vaid]=prefix;
		va_unit[vaid]=unit;
		va_hideat[vaid]=hideat;
		va_afterdo[vaid]=afterdo;
		va_canceldo[vaid]=canceldo;
		var value=va_do("return va_object["+vaid+"]."+va_value[vaid]+";");
		if(value=="" || value==undefined){
			if(updown>0){
				va_do("va_object["+vaid+"]."+va_value[vaid]+"='"+va_min[vaid]+va_unit[vaid]+"';");
			}else{
				va_do("va_object["+vaid+"]."+va_value[vaid]+"='"+va_max[vaid]+va_unit[vaid]+"';");
			}
			value=va_do("return va_object["+vaid+"]."+va_value[vaid]+";");
		}
		va_step[vaid]=va_nearest_step(vaid,parseFloat(value));
		va_proceed(vaid);
	}
}
function va_proceed(vaid){
	var value=va_do("return va_object["+vaid+"]."+va_value[vaid]+";");
	nowstep=va_nearest_step(vaid,parseFloat(value));
	if(nowstep==va_step[vaid]){
		va_step[vaid]+=va_updown[vaid];
		if(va_step[vaid]<0 || va_step[vaid]>va_steps[vaid]){va_step[vaid]=-1;return;}
		var value=va_min[vaid]+(va_max[vaid]-va_min[vaid])*va_func[vaid](va_step[vaid]/va_steps[vaid]);
		if(value<va_min[vaid])value=va_min[vaid];
		if(value>va_max[vaid])value=va_max[vaid];
		va_do("va_object["+vaid+"]."+va_value[vaid]+"='"+va_prefix[vaid]+value+va_unit[vaid]+"';");
		if(va_step[vaid]==va_hideat[vaid]){
			va_object[vaid].style.visibility="hidden";
		}else{
			va_object[vaid].style.visibility="visible";
		}
		if(va_isopa[vaid]){
			if(browser=="explorer6" || browser=="explorer7" || browser=="explorer8")
				va_object[vaid].style.filter="alpha(opacity="+va_object[vaid].style.opacity*100+")";
		}
		if(va_step[vaid]<=0 || va_step[vaid]>=va_steps[vaid]){
			va_step[vaid]=-1;
			va_do(va_afterdo[vaid]);
		}else{
			setTimeout('va_proceed('+vaid+');',va_stepfunc[vaid](va_step[vaid]/va_steps[vaid]));
		}
	}else{
		va_step[vaid]=-1;
		va_do(va_canceldo[vaid]);
	}
}
function va_nearest_step(vaid,value){
	mindef=va_max[vaid];
	mindefstep=-1;
	for(i=0;i<=va_steps[vaid];i++){
		var x=(value-va_min[vaid])/(va_max[vaid]-va_min[vaid]);
		def=Math.abs(value-(va_min[vaid]+(va_max[vaid]-va_min[vaid])*va_func[vaid](i/va_steps[vaid])));
		if(def<mindef){
			mindef=def;
			mindefstep=i;
		}
	}
	return mindefstep;
}
function va_do(scr){
	var fct=new Function(scr);
	return fct();
}

function va(object,valuepath,minvalue,maxvalue,maxsteps,updown,valuefuncbystep,delayfuncbystep,prefix,unit,hideat,isopacity,afterdo,canceldo){
	/*
		object		object to move, such as document.getElementById("id") or this
		valuepath	value name string from object, such as "style.opacity"
		minvalue	minimum value of changing value
		maxvalue	maximum value of changing value
		maxsteps	maximum number of steps of animation
		updown		step up (value changes from minvalue to maxvalue) is 1, step down is -1
		valuefuncbystep	function passed step/maxsteps returns from 0 to 1 normalized value
		delayfuncbystep	function passed step/maxsteps returns delay value at the step
		unit		unit of value, such as "px" or "%"
		hideat		a step where object is hidden
		isopacity	1 if valuepath is "style.opacity", otherwise 0 (for Explorer compatibility)
		afterdo		script which will be executed when step reached 0 or maxsteps
		canceldo	script which will be executed when motion is interrupted
	*/
	if(typeof(object)=='string'){
		object=document.getElementById(object);
	}
	va_start(object,valuepath,minvalue,maxvalue,valuefuncbystep,delayfuncbystep,maxsteps,updown,isopacity,prefix,unit,hideat,afterdo,canceldo);
}
function vaLinear(object,valuepath,minvalue,maxvalue,maxsteps,updown,delay,prefix,unit,hideat,isopacity,afterdo,canceldo){
	va(object,valuepath,minvalue,maxvalue,maxsteps,updown,function(x){return x},new Function("return "+delay+";"),prefix,unit,hideat,isopacity,afterdo,canceldo)
}


function hup(div,maxsteps,maxheight,delay){
	vaLinear(div,'style.height',0,maxheight,maxsteps,+1,delay,'','px',0,0,"","");
}
function hdown(div,maxsteps,maxheight,delay){
	vaLinear(div,'style.height',0,maxheight,maxsteps,-1,delay,'','px',0,0,"","");
}
function wup(div,maxsteps,maxheight,delay){
	vaLinear(div,'style.width',0,maxheight,maxsteps,+1,delay,'','px',0,0,"","");
}
function wdown(div,maxsteps,maxheight,delay){
	vaLinear(div,'style.width',0,maxheight,maxsteps,-1,delay,'','px',0,0,"","");
}
function hup2(div,maxsteps,minheight,maxheight,delay){
	vaLinear(div,'style.height',minheight,maxheight,maxsteps,+1,delay,'','px',-10,0,"","");
}
function hdown2(div,maxsteps,minheight,maxheight,delay){
	vaLinear(div,'style.height',minheight,maxheight,maxsteps,-1,delay,'','px',-10,0,"","");
}
function wup2(div,maxsteps,minheight,maxheight,delay){
	vaLinear(div,'style.width',minheight,maxheight,maxsteps,+1,delay,'','px',-10,0,"","");
}
function wdown2(div,maxsteps,minheight,maxheight,delay){
	vaLinear(div,'style.width',minheight,maxheight,maxsteps,-1,delay,'','px',-10,0,"","");
}

function opup(div,maxsteps,maxopacity,delay){
	vaLinear(div,'style.opacity',0,maxopacity,maxsteps,+1,delay,'','',-10,true,"","");
}
function opdown(div,maxsteps,maxopacity,delay){
	vaLinear(div,'style.opacity',0,maxopacity,maxsteps,-1,delay,'','',-10,true,"","");
}

function bgaup(div,maxsteps,kheight,delay){
	vaLinear(div,'style.backgroundPositionY',kheight,kheight*maxsteps,maxsteps-1,-1,delay,'','px',-10,0,"","");
}
function bgadown(div,maxsteps,kheight,delay){
	vaLinear(div,'style.backgroundPositionY',kheight,kheight*maxsteps,maxsteps-1,+1,delay,'','px',-10,0,"","");
}

function getBrowserWidth(){
	if(false){
	}else if(document.documentElement.clientWidth!=0){
		return document.documentElement.clientWidth;
	}else if(window.innerWidth!=0){
		return window.innerWidth;
	}else if(document.body.clientWidth!=0){
		return document.body.clientWidth;
	}
}
function getBrowserHeight(){
	if(false){
	}else if(document.documentElement.clientHeight!=0){
		return document.documentElement.clientHeight;
	}else if(window.innerHeight!=0){
		return window.innerHeight;
	}else if(document.body.clientHeight!=0){
		return document.body.clientHeight;
	}
}
function setSwfContentsSize(control,min,max,aspect){
	var e=document.getElementById("flash");
	if(control=="width"){
		ew=getBrowserWidth();
		if(ew/aspect>getBrowserHeight())
			ew=getBrowserHeight()*aspect;
		if(ew<min)ew=min;
		if(ew>max)ew=max;
		e.width=ew;
		e.height=ew/aspect;
	}else if(control=="height"){
		eh=getBrowserHeight();
		if(eh*aspect>getBrowserWidth())
			eh=getBrowserWidth()/aspect;
		if(eh<min)eh=min;
		if(eh>max)eh=max;
		e.width=eh*aspect;
		e.height=eh;
	}else{
		e.width=getBrowserWidth();
		e.height=getBrowserHeight();
	}
}

