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 mprod(fila) {
	if(fila.value=="1") {
		document.all.vlinea.style.visibility='visible';
		document.all.prds.size=5;
	}
else {
		document.all.vlinea.style.visibility='hidden';
		document.all.prds.size=1;
	}
}

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" );
var tcolor= prompt ("Introduzca el color de la tabla","#f0f0f0");
  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();
 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.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')['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 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();
   }
}

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();
   }
}

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(nn) {
destList = window.document.forms[nn].destList;
srcList = window.document.forms[nn].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(nn) {
var destList  = window.document.forms[nn].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(nn){
var list = window.document.forms[nn];
//if (list.destList.length!=0){
for (i=0; i<list.destList.length; i++) {
	list.destList.options[i].selected = true; 
}
//}
//list.submit()
}

function sall1(nn){
var list = window.document.forms[nn];
//if (list.destList.length!=0){
for (i=0; i<list.destList1.length; i++) {
	list.destList1.options[i].selected = true; 
}
//}
//list.submit()
}

function insertnre() {
destList = window.document.forms[0].destList;
var len = destList.length;
destList.options[len] = new Option(document.forms(0).nombre.value); 
destList.options[len].value = document.forms(0).email.value+'|'+document.forms(0).nombre.value; 
document.forms(0).nombre.value='';
document.forms(0).email.value='';
len++;
}

var tgs = new Array( 'div','td','tr','font','table');
//var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var szs = new Array( '9px','11px','13px','15px','17px','19px','21px','23px' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}
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;}
}

function agrandar(h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=200;
    top.outerHeight=h;
   }
   else top.resizeTo(200,h);
 }
}

