function calculasaldo(envio){
	ajaxLoader('calculasaldocupones.php','saldos',gvv("cupon")+"&moviles="+gvv("movil")+"&sms="+encodeURIComponent(gvv("mensaje"))+"&idioma="+gvv("idioma")+"&snd="+envio+"&time="+Math.random(),loading+"<input type='hidden' id='inputSaldo' value='1' \/>");
	if (envio) setTimeout("checkSent();",500);
}

function wordCount() {
	valcontrol= 1600; textoArea = goo("movil");
	textoArea.value = textoArea.value.replace (/[; ]/g,',');
	while (textoArea.value.search(/,,/g)!=-1) textoArea.value = textoArea.value.replace (/,,/g,',');
	if (textoArea.value.length >= valcontrol) textoArea.value = textoArea.value.substr(0,valcontrol);
	textoArea = document.getElementById("movil").value;
	numeroCaracteres = textoArea.length;
	inicioBlanco = /^,/; finBlanco = / $/; variosBlancos = /[,]+/g; 
	textoArea = textoArea.replace(inicioBlanco,"");
	textoArea = textoArea.replace(finBlanco,"");
	textoArea = textoArea.replace(variosBlancos,",");
	textoAreaDividido = textoArea.split(",");
	numeroPalabras = textoAreaDividido.length;
	if (numeroCaracteres==0) numeroPalabras=0;
	svv("numbercount",numeroPalabras);
}

function contar(){
	esp = Array(8); esp[0] = "{"; esp[1] = "}"; esp[2] = "["; esp[3] = "]"; esp[4] = "~"; esp[5] = "|"; esp[6] = "\\"; esp[7] = "€"; dobles = 0; m = goo("mensaje");
	for (n=0;n<m.value.length;n++){
		for (xx=0;xx<=7;xx++) if (m.value.substr(n,1)==esp[xx]) dobles++;
	};
	svv("contador",cantcar-(gvv("mensaje").length + parseInt(dobles)));
	if (gvv("contador") < 0) {
		svv("mensaje",gvv("mensaje").substr(0,cantcar-parseInt(dobles)));
		svv("contador",cantcar-(gvv("mensaje").length + parseInt(dobles)));
	}
}

function ver(programa,param,nw){
	if (nw==1){
		hwnd = window.open(programa+'?id='+param+'&idioma='+gvv('idioma')+'&x='+screen.width+'&y='+screen.height+'&open=1&hora='+Math.random()); 
	}else{
		hss('slidioma','none'); hss('DivOver','inline');
		ajaxLoader(programa,'DivOver',param+'&idioma='+gvv('idioma')+'&x='+screen.width+'&y='+screen.height+'&open=0&hora='+Math.random(), loading);
	}
}

function nover(){
	hss('slidioma','inline'); hss('DivOver','none'); sii('DivOver','');
}
	
function Desconectar(){
	svv("codcupon",""); svv("cupon",""); svv("movil",""); svv("mensaje",""); calculasaldo(); return;
}
