// TOGGLE VISIBILITY

function toggle( targetId ) {
   if ( document.getElementById ) {
    target = document.getElementById( targetId );
    if ( target.style.display == "none" ) {
     target.style.display = "";
    } else {
     target.style.display = "none";
    }
   }
}

function inputFocus(ref, defaultString) {
	if (ref.value == defaultString) {
		ref.value = '';
	}
}

function inputBlur(ref, defaultString) {
	if (ref.value == '')  {
		ref.value = defaultString;
	}
}

// MOVE

/*
	thanks to Dan Steinman for his niffty path tool
	http://www.dansteinman.com/dynduo/duopath/duopath.html
	
	coz precalculated is faster, faster, faster
*/

	var duoPath2Text = new Array(0,-15,-33,-52,-72,-93,-114,-133,-151,-167,-180,-191,-201,-208,-214,-218,-221,-223,-223,-223,-222,-222,-221,-221,-221);
	var duoPath2Visual = new Array(0,0,2,3,4,5,5,5,3,0,-4,-10,-17,-27,-38,-51,-67,-85,-104,-125,-146,-166,-185,-203,-218);
	
	var pathIndex=0; 
	var moveID=null;
	
	delay=10;

// ============================================

function move2Text(id)
{
	var moveElm = document.getElementById(id);
	
	if(moveElm.pathIndex==null) moveElm.pathIndex=0; 
	if(moveElm.moveID!=null) clearTimeout(moveElm.moveID);
	
	var xPos = duoPath2Text[moveElm.pathIndex++];
	
	moveElm.style.left=xPos+"px";
	
	if(moveElm.pathIndex<duoPath2Text.length-1)
	{
		moveElm.moveID=setTimeout("move2Text(\""+id+"\")",delay);
	}
	else
	{
		divList = moveElm.getElementsByTagName("div");
		for(var i=0;i<divList.length;i++)
		{
			if(divList[i].className=="back")
			{
				divList[i].style.display="block";
				moveElm.backElm = divList[i];
				break;
			}
		}
	}
	return false;
}


function move2Visual(id)
{

	var moveElm = document.getElementById(id);
	if(moveElm.moveID!=null) clearTimeout(moveElm.moveID);
	
	if(moveElm.backElm && moveElm.backElm.style.display=="block")
	{
		moveElm.backElm.style.display="none";
	}
	var xPos = duoPath2Visual[moveElm.pathIndex--];
	moveElm.style.left=xPos+"px";

	if(moveElm.pathIndex>0){
			
		moveElm.moveID=setTimeout("move2Visual(\""+id+"\")",delay);
	}
	return false;
}