// jsEffects.js


// 01. toggleInputBox
//------------------------------------------------------------------------------------------

function toggleInputBox(id,text){

var obj = document.getElementById(id);
	if(obj.value == text){
		obj.value = "";
	}else if(trim(obj.value) == ""){
		obj.value = text;
	}else{
		obj.value = trim(obj.value);
	}
	
}


// 03. trim
//------------------------------------------------------------------------------------------

function trim(str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}


// xx. Drop Menu Functions
//------------------------------------------------------------------------------------------

var timeout	= 500;
var timein = 0;
var closetimer	= 0;
var currentSub = 0;
var opentimer = 0;


function subOpen(id){
	cancelClose();
	opentimer = window.setTimeout('subOpen2(\''+id+'\')', timein);
	timein = 500;
}

function subOpen2(id){	
	if(opentimer){
		if(currentSub) currentSub.style.display = "none";
		currentSub = document.getElementById(id).getElementsByTagName("ul");
		currentSub = currentSub[0];
		currentSub.style.display = "block";
		//$(currentSub).slideDown("normal");
	}	
}

function subClose(){
	if(currentSub){
		currentSub.style.display = "none";
		//$(currentSub).slideUp("normal");
	}
}

function subCloseTimer(){
	closetimer = window.setTimeout(subClose, timeout);
}

function cancelClose(){
	subCancelOpen()
	if(closetimer){
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

function subCancelClose(){
	subCancelOpen()
	if(closetimer){
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

function subCancelOpen(){
	if(opentimer){
		window.clearTimeout(opentimer);
		opentimer = null;
	}
}

document.onclick = subClose;