function jsf_animate_pos(id,vh,dur,sttime,from,to){
	var obj=document.getElementById(id);
	var now=(new Date()).getTime();
	var animtype="sin";

	var perc=(now-sttime)/dur;
	if (perc>1){perc=1;}

	 if (animtype=="linear"){
		pos=from+(to-from)*perc;
	 }else if (animtype=="sin"){
		ang=90*perc;
		p=Math.sin(ang*Math.PI/180);
		pos=from+(to-from)*p;
	 }

	if (perc==1){
		jsf_setpos(obj,to,vh);
	}else{
		jsf_setpos(obj,pos,vh);
		obj.timer=window.setTimeout("jsf_animate_pos('"+id+"','"+vh+"',"+dur+","+sttime+","+from+","+to+")",1);
	}
}
function jsf_setpos(obj,pos,vh){
	obj.style.position="relative";
	if (vh=='h'){
		obj.style.left=pos+"px";
	}else{
		obj.style.top=pos+"px";
	}
}
function jsf_animate_size(id,vh,dur,sttime,from,to){// todo 1. add sin wave to decelerate items + make so works for all horizontal 
	var obj=document.getElementById(id);
	var now=(new Date()).getTime();
	var animtype="linear";

	var perc=(now-sttime)/dur;
	if (perc>1){perc=1;}

	 if (animtype=="linear"){
		size=from+(to-from)*perc;
	 }else if (animtype=="sin"){
		ang=90*perc;
		p=Math.sin(ang*Math.PI/180);
		size=from+(to-from)*p;
	 }

	if (perc==1){
		jsf_setsize(obj,to,vh);
	}else{
		jsf_setsize(obj,size,vh);
		obj.timer=window.setTimeout("jsf_animate_size('"+id+"','"+vh+"',"+dur+","+sttime+","+from+","+to+")",1);
	}
}
function jsf_setsize(obj,size,vh){
	//obj.style.position="relative";
	if (vh=='h'){
		obj.style.width=size+"px";
	}else{
		obj.style.height=size+"px";
	}
}
function jsf_animate_opacity(id,dur,sttime,from,to){
	var obj=document.getElementById(id);
	var opacity=obj.style.opacity * 100;
	var now=(new Date()).getTime();
	opacity=from+(to-from)*(now-sttime)/dur;
	if (opacity<0)
		jsf_setopacity(obj,0)
	else if (opacity>100)
		jsf_setopacity(obj,100)
	else{
		jsf_setopacity(obj,opacity);
		obj.timer=window.setTimeout("jsf_animate_opacity('"+id+"',"+dur+","+sttime+","+from+","+to+")",1);	}
	
}
function jsf_setopacity(obj,opac){
	obj.style.filter='alpha(opacity='+opac+')'; // old mozilla and firefox
	obj.style.MozOpacity=opac/100; // other browsers
	obj.style.opacity=opac/100;
}
function jsf_img_faderepalce(imgurl,id,linkid,dur,imgholderid,link){
	var foreground=document.getElementById(id);
	if (imgholderid){
		var background=document.getElementById(imgholderid);
		if (background){
			background.style.backgroundImage='url('+foreground.src+')';
			background.style.backgroundRepeat='no-repeat';
			/*background.style.backgroundPosition='top center';*/
		}
	}
	jsf_setopacity(foreground,0);
	foreground.src=imgurl;
	//if (link){
	//	document.getElementById(linkid).setAttribute('href',link);
	//}
	if (foreground.timer){window.clearTimeout(foreground.timer);}
	var now=(new Date()).getTime();
	foreground.timer=window.setTimeout("jsf_animate_opacity('"+id+"','"+dur+"',"+now+",0,50)",10);
}

function jsf_slideon(id,dur,hv,start,end){
	var obj=document.getElementById(id);
	if (obj.timer) window.clearTimeout(obj.timer); 
	var now=(new Date()).getTime();
	obj.timer=window.setTimeout("jsf_animate_pos('"+id+"','"+hv+"',"+dur+",(new Date()).getTime(),"+start+","+end+")",1);
	
}
function jsf_fadeon(id,dur){
	var obj=document.getElementById(id);
	if (obj.timer) window.clearTimeout(obj.timer); 
	var now=(new Date()).getTime();
	obj.timer=window.setTimeout("jsf_animate_opacity('"+id+"','"+dur+"',"+now+",0,100)",1);
}

function jsf_fadeoff(id,dur){
	var obj=document.getElementById(id);
	if (obj.timer) window.clearTimeout(obj.timer); 
	var now=(new Date()).getTime();
	obj.timer=window.setTimeout("jsf_animate_opacity('"+id+"','"+dur+"',"+now+",100,0)",1);
}
function jsf_himeme(e){
	document.getElementById(e).style.display="none";
}
function jsf_togglevisibility(e) {	
	if (document.getElementById(e).style.display=="none"){
		document.getElementById(e).style.display="block";
		document.getElementById('urlbody').focus();/*purely to remove line from around button, focus must be an input form element to work*/
	}else{
		document.getElementById(e).style.display="none";
		document.getElementById('urlbody').focus();
	}
}
function jsf_togglebar(togglebutton,togglecontent) {	
	/*the outline is now removed from the button with css a:focus { outline: none; }
	document.getElementById(togglebutton).blur();
	document.getElementById(togglebutton).hideFocus=true;*/
	if (document.getElementById(togglecontent).style.display=="none"){
		document.getElementById(togglebutton).className="togbutopen";
		//document.getElementById(togglecontent).style.display="block";
		$("#"+togglecontent).slideDown(300);
		/*if (togglecontent=="togc_cont"){window.scrollBy(0,100);}
		window.scrollBy(0,100);
		if (togglecontent!="togc_dev"){window.scrollBy(0,120);}*/
	}else{
		document.getElementById(togglebutton).className="togbutshut";
		//document.getElementById(togglecontent).style.display="none";
		$("#"+togglecontent).slideUp(100);
		/*document.getElementById('pageinput').focus();*/
	}
}
function jsf_clicktab(e) {
	for (i=1; i<10; i++) {
		if (document.getElementById('tab'+i)==null){break;}
		if (e==i){
			document.getElementById('tab'+i).style.display="block";
			document.getElementById('tabbut'+i).className="pagetabon";
		}else{
			document.getElementById('tab'+i).style.display="none";
			document.getElementById('tabbut'+i).className="pagetaboff";
		}
	}
}
function jsf_newwin(url,winprops)  {
	mywin=window.open(url,"win",winprops);//mywin.moveTo(0,0);
	mywin.focus();
}

function jsf_helpwin(url)  {
	mywin=window.open(url,"_helpwin","toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=800,height=420");//mywin.moveTo(0,0);
	mywin.focus();
}

function jsf_selectall(id){
    document.getElementById(id).focus();
    document.getElementById(id).select();
}
function jsf_jumptohref(loc){
	window.location.href=loc.value;
}

