function showhide(este){
	if (este.style.display=='none'){
		este.style.display='';
	}
else {
	este.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 req(campo,sobrenombre,forma) {
	var lleno=true;
	if(campo.value==''){
		lleno=false;
		//break;
	}
	if (!lleno) {
		alert('Asegurese que el campo '+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 el campo '+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='#EA5357';
}

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" );
  document.body.all.tags('div')['html1'].focus();
 var newTable = document.body.all.tags('div')['html1'].document.createElement('TABLE');
 for(y=0; y<Filas; y++)
 {
 var newRow = newTable.insertRow();
 
 for(x=0; x<Columnas; x++)
 {
  newRow.bgColor='#f0f0f0';
  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.all.tags('div')['html1'].document.selection.type=='Control')
 {
 sel.pasteHTML(newTable.outerHTML);
 }
 else
 {
 sel = document.body.all.tags('div')['html1'].document.selection.createRange();
 sel.pasteHTML(newTable.outerHTML);
 }
 
 var r = document.body.all.tags('div')['html1'].document.body.createTextRange();
 var item=document.body.all.tags('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')[opt].document.execCommand(cmd,"","");
document.body.all.tags('div')[opt].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 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!");
field.focus();
field.select();
return false;
   }else{
   return true;
 }
}

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 nochr(field) {
var valid = "0123456789.ABCDEFGHIJKLMNOPQRSTVWXYZ,abcdefghijklmnopqrstvwxyz \""
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("Por favor, no introduzca caracteres especiales");
field.focus();
field.select();
   }
}
