var crossobj = null;
var contentheight = null;
var mtime = 20;
var pxspeed = 1;
var lastspeed = 1;
var hasstarted = false;
function mvv(){
	
	if(!crossobj) {
		if (ie_fx) {
			crossobj = document.getElementById ? document.getElementById("ChatBoxContent") : document.all.content;
			contentheight = crossobj.offsetHeight;
		} else if (ns_old) {
			crossobj = document.ChatBoxNs.document.ChatBoxContentNs;
			contentheight = crossobj.clip.height;
		}	

	}

	if(ie_fx) {
		if (parseInt(crossobj.style.top) >= (0-contentheight) && hasstarted) {
			crossobj.style.top = parseInt(crossobj.style.top)-pxspeed+"px";
		} else {
			crossobj.style.top = document.getElementById("ChatBox").style.height;
		}
	} else if (ns_old && hasstarted) {
		if (crossobj.top >= (0-contentheight)) {
			crossobj.top += pxspeed;
		} else {
			crossobj.top = 0;		
		}
	}

	hasstarted = true;
	setTimeout("mvv()",mtime);
}


function spdxx(whatAct) {

	if(whatAct == '+') {
		pxspeed = pxspeed + 1;
	}
	
	if(whatAct == '-') {
		pxspeed = pxspeed - 1;
	}

}

function halt(whatAct) {
	if(whatAct) {
		lastspeed = pxspeed;
		pxspeed = 0;
	} else {
		pxspeed = lastspeed;
	}		
}

function insertSml(whatSml) {
	document.ChatBoxForm.note.value += ' ' + whatSml + ' ';
	document.ChatBoxForm.note.focus();
}

function validateChatbox(sourceElement) {

	if(sourceElement.nick.value.replace(/\s/gi, '').length < 2) {
		alert('Debe escribir su nombre/nick.');
		return false;
	}

	if(sourceElement.note.value.replace(/\s/gi, '').length < 3) {
		alert('El texto del mensaje es demasiado corto.');
		return false;
	}

	return true;

}

//window.onload = mvv;

if(location.href.indexOf('action=add_chatbox') != -1) {
	alert('Su mensaje fue enviado');
}