function showhide1(what){
if (what.style.display=='none'){
what.style.display='';
}
else{
what.style.display='none'
}
}

function mlinea(fila) {
	if(fila.options[fila.selectedIndex].value=="10"||fila.options[fila.selectedIndex].value=="2"||fila.options[fila.selectedIndex].value=="3"||fila.options[fila.selectedIndex].value=="5") {
		document.all.vlinea.style.visibility='visible';
	}
else {
		document.all.vlinea.style.visibility='hidden';
	}
}


function vacio(campo,idcampo) {
	var lleno=true;
	if(campo.value==''){
		lleno=false;
	}
	if (!lleno) {
		alert('Asegurese que '+idcampo+' ha sido llenado');
		field.focus();
		field.select();
	}
}

function req(campo,sobrenombre,forma) {
	var lleno=true;
	if(campo.value==''){
		lleno=false;
		//break;
	}
	if (!lleno) {
		alert('Asegurese que '+sobrenombre+' ha sido llenado');
		return false;
	}
else {
	//return requerido(email,frmupdate);
	return true;
	}
}

function requerido(campo,forma) {
	var lleno=true;
	if(campo.value==''){
		lleno=false;
		//break;
	}
	if (!lleno) {
		alert('Asegurese que '+campo.name+' ha sido llenado');
		return false;
	}
else {
	forma.submit();
	return true;
	}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function muestr(fila){
fila.bgColor='#f0f0f0';
}
function esc(fila){
fila.bgColor='';
}
function muestrr(fila){
fila.bgColor='#f0f0f0';
}

var estadoH = "hidden";
var estadoV = "visible";
function sw(layer1,layer2){
	if (document.all){	//IE browser
		eval("document.all." + layer1 + ".style.visibility = estadoH");
		eval("document.all." + layer2 + ".style.visibility = estadoV");	
	}
	else if (document.layers){	//IE browser
		document.layers[layer1].visibility = estadoH;
		document.layers[layer2].visibility = estadoV;
	}
	else {	//NN 6.0
		document.getElementById(layer1).style.visibility = estadoH;
		document.getElementById(layer2).style.visibility = estadoV;
	}
}
function cretb(){
var Filas=  prompt ("Introduzca el número de filas de la Tabla", "5" );
var Columnas=  prompt ("Introduzca el numero de columnas de la Tabla", "5" );
var tcolor= prompt ("Introduzca el color de la tabla","#f0f0f0");
  document.body.getElementsByTagName('div')['html1'].focus();
 var newTable = document.body.getElementsByTagName('div')['html1'].document.createElement('TABLE');
 for(y=0; y<Filas; y++)
 {
 var newRow = newTable.insertRow();
 newRow.vAlign = 'top';
 
 for(x=0; x<Columnas; x++)
 {
  newRow.bgColor=tcolor;
  
  var newCell = newRow.insertCell();
 
 if ((y==0)&&(x==0)) newCell.id='ura';
 }
}
 
 newTable.border = 1
 newTable.cellSpacing=0
 newTable.cellpadding=0
 newTable.style.fontSize=11
 newTable.width = Columnas * 50;
 if (document.body.getElementsByTagName('div')['html1'].document.selection.type=='Control')
 {
 sel.pasteHTML(newTable.outerHTML);
 }
 else
 {
 sel = document.body.getElementsByTagName('div')['html1'].document.selection.createRange();
 sel.pasteHTML(newTable.outerHTML);
 }
 
 var r = document.body.getElementsByTagName('div')['html1'].document.body.createTextRange();
 var item=document.body.getElementsByTagName('div')['html1'].document.getElementById('ura');
 item.id='';
 r.moveToElementText(item);
 r.moveStart('character',r.text.length);
 r.select();
}

function cmdExec(cmd,opt) {
document.body.all.tags ("div")['html1'].document.execCommand(cmd,"",opt);
document.body.all.tags ("div")['html1'].focus();
}

function AddLink()
{//Identify selected text
var sText = document.selection.createRange();
if (!sText==""){
    //Create link
     document.execCommand("CreateLink");
     //Replace text with URL
     if (sText.parentElement().tagName == "A"){
       //sText.parentElement().innerText=sText.parentElement().href;
       //document.execCommand("ForeColor","false","#0000ff");
     }    
  }
else{ 
    alert("Selecciona el texto primero!");
  }   
}
function validarn2(field) {
var valid = "0123456789.,"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Debe ingresar solo números!");
field.focus();
field.select();
   }
}

function versuma(which,tipo) {
var sac = 0;
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,3)=="PED") {
if (tempobj.checked==true) {
	sac += 1;
	}
	}
	}
if (sac == 0) {
alert("Debe seleccionar al menos 1 "+tipo);
return false;
}
else
return true;
}

function Iimage() {
	window.open("Iimages.asp","Fotos","scrollbars=yes,maximize=no,width=500,height=400");
  }
function InsertImage(archivo) {
 // Clear the selection if it's an image (would cause an error otherwise)
	archivo = '<img src="' + archivo + '" border="0">';
	document.all.tags('div')['html1'].innerHTML=document.all.tags('div')['html1'].innerHTML+archivo;
	document.body.all.tags('div')['html1'].focus();
//}
}


function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList; 
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {
//Check if this value already exist in the destList or not
//if not then add it otherwise do not add it.
var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
      }
   }
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].text); 
destList.options[len].value = srcList.options[i].value; 
len++;
         }
      }
   }
}

function deleteFromDestList() {
var destList  = window.document.forms[0].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
destList.options[i] = null;
      }
   }
}

function sall(){
var list = window.document.forms[0];
//if (list.destList.length!=0){
for (i=0; i<list.destList.length; i++) {
	list.destList.options[i].selected = true; 
}
//}
list.submit()
}

var estadoH = "hidden";
var estadoV = "visible";

function mostrar(layer1){
if (document.all){	//IE browser
		eval("document.all." + layer1 + ".style.visibility = estadoV");
		
	}
	else if (document.layers){	//NN browser
		document.layers[layer1].visibility = estadoV;
		
	}
	else {	//NN 6.0
		document.getElementById(layer1).style.visibility = estadoV;}
}

function ocultar(layer1){
if (document.all){	//IE browser
		eval("document.all." + layer1 + ".style.visibility = estadoH");
		
	}
	else if (document.layers){	//NN browser
		wait(2);
		document.layers[layer1].visibility = estadoH;
		
	}
	else {	//NN 6.0
		document.getElementById(layer1).style.visibility = estadoH;}
}
/*********funciones creadas por Luis en Consultoria *******************/
function enviar_form(forma) {

	for (i=0;i<forma.length;i++) {
		var objeto=forma.elements[i];
		if (objeto.id=="required") {
				alert(objeto.name);
			if (objeto.value.length=="0") {
				alert('Los campos marcados con asterisco (*) deben ser Ingresados');
				return false;
			}
		}
		if (objeto.id=="combo") {
			if (objeto.value==0 || objeto.value=="") {
				alert('Los campos marcados con asterisco (*) deben ser Ingresados');
				return false;
			}
		}
	}
}

function checkrequired(which) {
  var pass=true;
  for (i=0;i<which.length;i++) {
    var tempobj=which.elements[i];
    if (tempobj.id=="required") {
      if (((tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="file")&&
          tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
          tempobj.selectedIndex==0)) {
        pass=false;
        break;
      }
	 /* if (tempobj.type=="select") { //&&tempobj.options[tempobj.selectedIndex].value=="0") {
		  	alert(tempobj.name);
			pass=false;
			break;
	  }*/
	  
    }
  }
  if (!pass) {
    alert('Los campos marcados con asterisco (*) deben ser Ingresados');
    return false;
  } else {
  return true;
  }
}
function check_Email(myForm) {
	if (document.reguser.TxEmail.value.search(/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/ig)){
		alert("Por favor, verifique su dirección de correo electrónico");
		return (false);
	}
}

function Mod10(ccNumb) {  // v2.0
var valid = "0123456789"  // Valid digits in a credit card number
var len = ccNumb.length;  // The length of the submitted cc number
var iCCN = parseInt(ccNumb);  // integer of ccNumb
var sCCN = ccNumb.toString();  // string of ccNumb
sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
var iTotal = 0;  // integer total set at zero
var bNum = true;  // by default assume it is a number
var bResult = false;  // by default assume it is NOT a valid cc
var temp;  // temp variable for parsing string
var calc;  // used for calculation of each digit

// Determine if the ccNumb is in fact all numbers
for (var j=0; j<len; j++) {
  temp = "" + sCCN.substring(j, j+1);
  if (valid.indexOf(temp) == "-1"){bNum = false;}
}

// if it is NOT a number, you can either alert to the fact, or just pass a failure
if(!bNum){
  /*alert("Not a Number");*/bResult = false;
}

// Determine if it is the proper length 
if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
  bResult = false;
} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
  if(len >= 15){  // 15 or 16 for Amex or V/MC
    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
      calc = parseInt(iCCN) % 10;  // right most digit
      calc = parseInt(calc);  // assure it is an integer
      iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
      i--;  // decrement the count - move to the next digit in the card
      iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
      calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
      calc = calc *2;                                 // multiply the digit by two
      // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
      switch(calc){
        case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
      }                                               
    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
    iTotal += calc;  // running total of the card number as we loop
  }  // END OF LOOP
  if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
    bResult = true;  // This IS (or could be) a valid credit card number.
  } else {
    bResult = false;  // This could NOT be a valid credit card number
    }
  }
}
// change alert to on-page display or other indication as needed.
if(!bResult){
  alert("Por favor, verifique el número de la tarjeta de crédito");
}
  return bResult; // Return the results
}

function calculardeposito(rate,monto,tipo) { 
if (tipo==1) {
	document.remesa.IntAmmount2.value='BsF. ' + Math.round((rate*monto)*100)/100;
	} else {
	document.remesa.IntAmmount2.value='US$ ' + parseFloat(monto-(rate*monto/100));
	}
	return true
}
function validarn(field) {
var valid = "0123456789."
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Debe ingresar solo números y punto (.) como separador decimal!");
field.value=field.value.substring(0, i-1);
field.focus();
field.select();
return false;
	}
   return true
}
function validarletras(field) {
var valid = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ.abcdefghijklmnñopqrstuvwxyz-_ áéíóúü"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Debe ingresar solo Letras (A-Z, a-z)!");
field.value=field.value.substring(0, i-1);
field.focus();
return false;
	}
   return true
}

function reasegura() {
	if(window.confirm('Esta seguro que desea enviar esta transacción?')) { 
		return true;
	} 
	return false
}
function timeout()
{
//var agree=confirm("Su sesion ha expirado, haga click en OK para ir a \"Mi Cuenta\" ");
//if (!agree)
      window.location = 'login2.asp';
}
function timeout1()
{
//var agree=confirm("Su sesion ha expirado, haga click en OK para ir a \"Mi Cuenta\" ");
//if (!agree)
      window.location = 'main.asp';
}