var opennedSub = '';
var OpentimeOut;
var ClosetimeOut;

function closeLanguage(strLang){
	clearTimeout(ClosetimeOut);
	$(strLang).hide();
	$('li_'+strLang).setStyle({position:'static'});
	opennedSub = '';
	return false;
}

function openLanguage(strLang){
	clearWaiting();
	if(strLang == opennedSub)
		return false;
	if(opennedSub != '')
		closeLanguage(opennedSub);
	$(strLang).show();
	$('li_'+strLang).setStyle({position:'relative'});
	opennedSub = strLang;
	return false;
}

function startWaiting(action, what){
	
	if(action == 'open'){
		clearTimeout(OpentimeOut);
		OpentimeOut = setTimeout('openLanguage("' + what + '")',200);
	}
	if(action == 'close'){
		clearTimeout(ClosetimeOut);
		ClosetimeOut = setTimeout('closeLanguage("' + what + '")',1000);
	}
}

function stopWaiting(what){
	if(opennedSub == what){
		clearTimeout(ClosetimeOut);
		ClosetimeOut = setTimeout('closeLanguage("' + what + '")',1000);
	}
	if(opennedSub == ''){
		clearTimeout(OpentimeOut);
		clearTimeout(ClosetimeOut);
	}else{
		if(opennedSub != what){
			clearTimeout(OpentimeOut);
		}
	}
	return false;
		
	
}

function clearWaiting(){
	clearTimeout(OpentimeOut);
	clearTimeout(ClosetimeOut);
}