function setcual(texto){ var cual = checkselected('comprar','wiznext'); if (cual!= -1){return true; }else{ alert(texto); return false; }}
function setrpt(texto){ var cual = checkselected('rptpay','ptr'); if (cual!= -1){return true; }else{ alert(texto); return false; }}

function setmd5(){
	var pActual = gvv("ps");
	if(pActual!=''){
		if (left(pActual,5)!=":md5:") pActual = ":md5:"+hex_md5(pActual); svv("ps",pActual);
	}
}

function mandarReportes(texto){
	var enviar = 1;
	if ( gvv("nombre").length <= 5 ) { enviar=0; c=0}else{c=1}; PintaFondo("nombre",c);
	if ( gvv("banco").length <= 5 ) { enviar=0; c=0}else{c=1}; PintaFondo("banco",c);
	if ( gvv("tipotrans").length <= 5 ) { enviar=0; c=0}else{c=1}; PintaFondo("tipotrans",c);
	if ( gvv("fecha").length <= 5 ) { enviar=0; c=0}else{c=1}; PintaFondo("fecha",c);
	if ( enviar==1){ return true; }else{ alert(texto); return false; }
}

function costos(texto,show,minimo,textomin){
	if (!isdefined("minimo")) minimo = 999999999999;
	if (!isdefined("textomin")) textomin = "";
	ids = gvv('pr_ids').split(",");
	can = gvv('pr_can'); tot=0;
	reqP= Array();c=0;
	for (id=0;id<can;id++){ 
		vr = parseFloat(gvv('pr'+ids[id]));
		if (isNaN(vr)) vr=0; tot+=vr; 
		if (vr>0 && vr <minimo) {alert(textomin);goo('pr'+ids[id]).focus(); return false}
		reqP[c]=ids[id]+":"+vr;c++;
	}; svv('ctl',reqP);
	if (show==1) if (tot>0){ return true;}else{alert(texto); return false;};
}

function cardselected(texto){ var cual = checkselected('tipocard','wiznext'); if (cual!= -1){ return true; }else{ alert(texto); return false; }}

function validavoucher(texto){ if (goo('voucherid').value.length>7) { return true; }else{ alert(texto); return false; }}

function validaempresa(texto1, texto2, texto3, texto4){ 
	if (parseFloat(goo('cpuntos').value)<=0){return alert(texto3); false; }
	if (parseFloat(goo('cpuntos').value)>parseFloat(goo('apuntos').value)){return alert(texto4); false; }
	if (goo('idempresa').value.length>0 && goo('sidempresa').value.length>0) { alert(texto1); return false; }
	if (goo('idempresa').value.length==0 && goo('sidempresa').value.length==0){	alert(texto2); return false; }
	return true;
}

function tbl_desc(cual) {
		return;
	ids = gvv('pr_ids').split(","); can = gvv('pr_can');
	for (id=0;id<can;id++) hss('dpr'+ids[id],'none');
	if (cual!=0) hss('dpr'+cual,'inline');
}

function calCosto(programa){
	if (!isdefined(programa) || programa=='' ) programa = "comprar_data.php";
	ids = gvv('pr_ids').split(","); 
	can = gvv('pr_can'); 
	pro = gvv('promoid');
	pgo = gvv('ttpgo');
	for (id=0;id<can;id++){
		c=gvv('pr'+ids[id]); v=gii('cpr'+ids[id]);
		ajaxLoader(programa,'cpr'+ids[id],Math.random()+"&scr=calccosto&access="+access+"&promoid="+pro+"&pgo="+pgo+"&cant="+c+"&tconx="+gvv('adonde')+"&prid="+ids[id],v+"<input type='hidden' value='1' id='vpr"+ids[id]+"' />");
	}; setTimeout("totalize()",200);
}

function totalize(){
	ids = gvv('pr_ids').split(","); can = gvv('pr_can'); tot=totm=totf=totx=totd=0;
	for (id=0;id<can;id++){
		v=gvv('vpr'+ids[id]); if (v==1) { setTimeout("totalize()",100); return; }
	}
	for (id=0;id<can;id++){
		vr =gvv('ccpr' +ids[id]); vrm=gvv('ccpre'+ids[id]); vrf=gvv('ccfee'+ids[id]);
		vrd=gvv('ccdct'+ids[id]); vrx=gvv('cctax'+ids[id]); svv('vpr'+ids[id],1);
		tot +=parseFloat(vr); totm+=parseFloat(vrm); totf+=parseFloat(vrf);
		totd+=parseFloat(vrd);totx+=parseFloat(vrx); tott=totm+totf;
	}
	tot=Math.round(tot*100)/100; totm=Math.round(totm*100)/100; totf=Math.round(totf*100)/100; tott=Math.round(tott*100)/100; totx=Math.round(totx*100)/100; totd=Math.round(totd*100)/100;
	var fmtTot = new oNumero(tot); var fmtTotm = new oNumero(totm); var fmtTotf = new oNumero(totf); var fmtTott = new oNumero(tott); var fmtTotx = new oNumero(totx); var fmtTotd = new oNumero(totd);
	sii('cptot',fmtTot.formato(2, true)); 
	if (totd!=0) { sii('cpnomd',gvv('ndcto')+": "); sii('cptotd',fmtTotd.formato(2, true)); } else {sii('cptotd','');sii('cpnomd','');}
	if (totx!=0) { sii('cpnomx',gvv('ccprx')+": "); sii('cptotx',fmtTotx.formato(2, true)); } else {sii('cptotx','');sii('cpnomx','');}
	if (totm!=0) { sii('cpnomm',gvv('ccprm')+": "); sii('cptotm',fmtTotm.formato(2, true)); } else {sii('cptotm','');sii('cpnomm','');}
	if (totf!=0) { sii('cpnomf',"PayPal fee: "); sii('cptotf',fmtTotf.formato(2, true)); } else {sii('cptotf','');sii('cpnomf','');}
	if (totm!=0 && totf!=0) { sii('cpnomt',"Total "+gvv('ccprm')+": "); sii('cptott',fmtTott.formato(2, true)); } else {sii('cptott','');sii('cpnomt','');}
}

function highlight(browser,producto,valor){
	valor = parseFloat(valor); var e=document.getElementsByName("dctos");
	for(var i=0;i<e.length;i++){
		arrID = (browser=='IE')?e[i].value.split("_"):arrID = e[i].id.split("_");
		if (arrID[1]==producto && (valor >= parseFloat(arrID[2]) && valor <= parseFloat(arrID[3])))	e[i].style.backgroundColor = bgsel;	else e[i].style.background = 'none';
	}
}

function validaCIF(cif,fld,texto){
	if (!valcif(cif,fld)){ alert(texto); return false;} else {return true;}
}

function validaVAT(vat,fld,texto){
	if (!checkVATNumber(vat)){ alert(texto);goo(fld).focus(); return false;} else {return true;}
}
function hp(pannel1,pannel2,pannel3){
	tbl_desc('0'); 
	hss('h12',pannel1);
}

function hb(display){
	hss("wizDivBack",display);
	hss("wizDivNext",display);
	hss("wizDivCancel",display);
	if (display=='inline') display='block';
	hss("rayaabajo",display);
	return true;
}

function calCostoFinal(pais,access){
	ids = gvv('pr_ids').split(","); 
	can = gvv('pr_can'); 
	pro = gvv('promoid');
	pgo = gvv('ttpgo');
	for (id=0;id<can;id++){
		c=gvv('pr'+ids[id]); v=gii('cpr'+ids[id]);
		ajaxLoader('vercosto.php','tablaPaises',Math.random()+"&pais="+pais+"&access="+access+"&promoid="+pro+"&pgo="+pgo+"&cant="+c+"&prid="+ids[id],"");
	}
}

