window.Procesar = function () {
	
	var monto = document.getElementById("monto");
	var saldo = document.getElementById("saldo");
	var pin = document.getElementById("PIN");
	if (monto.value == "") {
		alert (unescape ("Debe ingresar la cantidad del monto a pagar"));
		document.pagobanco.monto.focus ();
		return;
	}

	if (isNaN(monto.value)) {
		alert (unescape ("El campo de monto a pagar debe ser un dato numerico"));
		monto.focus ();
		return;
	}
	if (monto.value > saldo.value) {
		alert (unescape ("Debe ingresar una cantidad menor al saldo"));
		monto.focus ();
		return;
	}
	
	if (pin.value == "") {
		alert (unescape ("Debe ingresar el PIN recibido"));
		document.pagobanco.pin.focus ();
		return;
	}
	requestAJAX (PrePath + 'index.php?function=pago_facturas_bg&idServicio=' + document.pagobanco.idServicio.value + '&nip=' + document.pagobanco.nip.value +'&enviado=' + document.pagobanco.enviado.value + '&listabancos=' + document.pagobanco.listabancos.value + '&telefono=' + document.pagobanco.telefono.value + '&saldo=' + document.pagobanco.saldo.value + '&monto=' + document.pagobanco.monto.value + '&PIN=' + document.pagobanco.PIN.value+'&idinstitucion='+document.pagobanco.idinstitucion.value+'&idcanal='+document.pagobanco.idcanal.value+'&idterminal='+document.pagobanco.idterminal.value+'&idcliente='+document.pagobanco.idcliente.value+'&idordenpagoporta='+document.pagobanco.idordenpagoporta.value+'&fechatransaccion='+document.pagobanco.fechatransaccion.value+'&horatransaccion='+document.pagobanco.horatransaccion.value+'&fechamaximapago='+document.pagobanco.fechamaximapago.value+'&nombrepropietario='+document.pagobanco.nombrepropietario.value,'tu_cuenta_content');
	
}

function AgregarAmigo(nip,idservicio,idfeature) 
{
	numero = prompt('Introduzca el Numero del Mejor Amigo','Numero del mejor amigo');
	if (!esNumero(numero)) {
		alert (unescape ("No es un numero valido"));
		AgregarAmigo();
	}
	if (numero.length<9 || numero.length>9){
		alert (unescape ("Debe ser un numero de 9 digitos"));
		AgregarAmigo();
	}
	requestAJAX (PrePath + 'index.php?function=services2&nip='+nip+'&idServicio='+idservicio+'&state=A&feature='+idfeature+'&mejoramigo='+numero,'tu_cuenta_content');
}
function esNumero(cadena)
{
   k="0123456789";
   for (j=0;j<cadena.length;j++)
   {
	 if (k.indexOf(cadena.charAt(j)) == -1)
	 {
	   return false;
	 }
   }
   return true;
}

function Excel()
{ 
	var settings = 'height=' + '300' + ',';  
	settings += 'width=' + '300' + ',';  
	settings += 'top=' + '200' + ',';  
	settings += 'left=' + '200';
	
	win = window.open('https://www.porta.net/porta_web/WebSerTmp/calldetails_dl.php','Excel',settings);
	win.document.write('<?php header( "Content-Type: application/xls", true );?>');
	win.document.write('<?php header( "Content-Disposition: attachment; filename="detalle_llamada_xls"");?>');
	win.document.write('<?php header("Pragma: public");?>');
	win.document.write('<?php header("Cache-Control: max-age=0");?>');
	win.document.write('<html><head><title>Excel</title>');  
	win.document.write('</head><body>');  
	win.document.write('<table><tr><td><?php echo "Prueba de Html";?> prueba 2</td></tr></table>');  
	win.document.write('</body></html>');  
	win.document.close();  
	
	win.window.focus();  
}

function showDate(idFecha,idservice,fechaactual) {

var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}

if (!document.getElementById("divBgLegal")) {
var nodeDiv = document.createElement ("div");
nodeDiv.setAttribute ("id", "divBgLegal");
nodeDiv.setAttribute ("class", "nlegal_css");
nodeDiv.setAttribute ("style", "display: none");
document.body.appendChild (nodeDiv);
document.getElementById("divBgLegal").className = "nlegal_css";
}

if (document.getElementById(idFecha).parentNode != document.body)
document.body.appendChild(document.getElementById(idFecha));

document.getElementById("divBgLegal").style.width = myWidth + "px";
//document.body.style.overflow = "hidden";
document.getElementById("divBgLegal").style.display = "";
document.getElementById(idFecha).style.top = "200px";
document.getElementById(idFecha).style.left = (parseInt(myWidth)/2 - 200) + "px";
document.getElementById(idFecha).style.display = "";
id_service_roaming=idservice;
fechanueva(fechaactual);
}

function closeDate(idFecha) {
document.body.style.width = "auto";
document.body.style.height = "auto";
document.body.style.overflow = "auto";
document.getElementById("divBgLegal").style.display = "none";
document.getElementById(idFecha).style.display = "none";
document.getElementById('dp-s2').value='';
}

function pad(value, length) {
       length = length || 2;
       return "0000".substr(0,length - Math.min(String(value).length, length)) + value;
};

function fechanueva(fechaactual)
{
	var today = new Date(),
            lastMonth = new Date(today.getFullYear(), today.getMonth(), 1),
            nextMonth = new Date(today.getFullYear(), today.getMonth()+1, 1),
            opts = {                            
                formElements:{"dp-s2":"d-sl-m-sl-Y"},
                showWeeks:true,
                statusFormat:"l-cc-sp-d-sp-F-sp-Y",
                staticPos:true,
				positioned:"idcalendario",
               // rangeHigh:nextMonth.getFullYear() + "" + pad(nextMonth.getMonth()+1) + "10",
               // rangeLow:lastMonth.getFullYear() + "" + pad(lastMonth.getMonth()) + "01"       
			   rangeLow:fechaactual
                };           
    datePickerController.createDatePicker(opts);
}

	