function como_comprar(){
window.open('como_comprar.html', 'Comocomprar', 'width=780,height=390,left=15,top=30,scrollbars=0');
}
function sizetext(){
if(document.form1.refprod.value=='4820')
 document.getElementById('Negra').selected=true;
if(navigator.platform.indexOf('Win')==-1){//Macintosh:
	 document.form1.cantidad.size=4;
	 document.form1.preciototal.size=8;
	 }
for(i=1;i<=8;i++){
 txt_i=eval("document.form1.texto"+i);
 if((typeof txt_i!='undefined'&&document.form1.tamanyo.value.indexOf("diámetro")==-1)||document.form1.refprod.value.indexOf("Multicolor")!=-1) 
  ajusta(i); // Ajuste de sellos rectangulares (los circulares no admiten tipo ni tamaño de fuente) o multicolor.
 }
// Ajuste de sellos circulares de diámetro < 45 mm, no multicolor: 
// se reducen las líneas perimétricas y centrales (de 45 y 18 ptos. respect. inicialmente):
if(document.form1.tamanyo.value.indexOf("diámetro")!=-1&&document.form1.refprod.value.indexOf("Multicolor")==-1){
 if(document.form1.ancho_mancha.value*1<45){
  for(i=1;i<=5;i++){
   txt_i=eval("document.form1.texto"+i);
	 if(typeof txt_i!='undefined'){ 
	  if(i==1||i==2) txt_i.maxLength=35; // Líneas perimétricas.
	   else txt_i.maxLength=16; // Líneas centrales.
    txt_i.size = txt_i.maxLength + 15;
		}
	 }
  }
 if(document.form1.ancho_mancha.value*1<35){
  for(i=1;i<=5;i++){
   txt_i=eval("document.form1.texto"+i);
	 if(typeof txt_i!='undefined'){
	  if(i==1||i==2) txt_i.maxLength=30; // Líneas perimétricas.
	   else txt_i.maxLength=14; // Líneas centrales.
    txt_i.size = txt_i.maxLength + 15;
		}
	 }
  } 
 }
}
function ajustabotones(){// Safari => botones Comprar con anchura 100px en vez de 85px:
if(navigator.platform.indexOf('Win')==-1&&navigator.appName=='Netscape'){
 i=1; 
 comprar_i=eval('document.getElementById("comprar'+ i +'")'); 
 while(comprar_i!=null){
  comprar_i.style.width='100'; 
	i++; 
	comprar_i=eval('document.getElementById("comprar'+ i +'")');
	}
 }
}
function ajusta(i){
txt_i=eval("document.form1.texto"+i);
tam_i=eval("document.form1.tam_fuente"+i);
anchura = document.form1.ancho_mancha.value * 1;
if(typeof txt_i!='undefined' && typeof tam_i!='undefined' && typeof document.form1.ancho_mancha!='undefined'){
if(tam_i.value=='Grande'){txt_i.maxLength=17; str=txt_i.value; txt_i.value=str.substring(0,17);}
	else txt_i.maxLength=26;
if(anchura<=65){
	if(tam_i.value=='Grande'){txt_i.maxLength=15; str=txt_i.value; txt_i.value=str.substring(0,15);}
	 else txt_i.maxLength=22;
 }
if(anchura<=55){
	if(tam_i.value=='Grande'){txt_i.maxLength=13; str=txt_i.value; txt_i.value=str.substring(0,13);}
	 else txt_i.maxLength=18;
 }
if(anchura<=45){
	if(tam_i.value=='Grande'){txt_i.maxLength=11; str=txt_i.value; txt_i.value=str.substring(0,11);}
	 else txt_i.maxLength=16;
 }
if(anchura<=35){
	if(tam_i.value=='Grande'){txt_i.maxLength=9; str=txt_i.value; txt_i.value=str.substring(0,9);}
	 else txt_i.maxLength=14;
 }
if(anchura<=25){
	if(tam_i.value=='Grande'){txt_i.maxLength=7; str=txt_i.value; txt_i.value=str.substring(0,7);}
	 else txt_i.maxLength=12;
 }
if(anchura<=15){
	if(tam_i.value=='Grande'){txt_i.maxLength=5; str=txt_i.value; txt_i.value=str.substring(0,5);}
	 else txt_i.maxLength=10;
 }
txt_i.size = txt_i.maxLength + 8;
}
}
function enable_next(){
// Usado (YA NO) en textos de sellos rectangulares:  onkeyup='enable_next()' (y en onmousemove del body).
ref=document.form1.refprod.value;
if(document.form1.nombreprod.value!='SELLO FECHADOR + TEXTO'&&ref!='4930'&&ref!='4940'&&ref!='5215'&&ref!='5415'&&ref!='46045'){
 for(i=1;i<=7;i++){
  txt_i=eval("document.form1.texto"+i);
  isig=i+1;
  txt_isig=eval("document.form1.texto"+isig);
  if(typeof txt_isig!='undefined'){
    if(Trim(txt_i.value)!='') txt_isig.disabled=false;
	   else {txt_isig.value=''; txt_isig.disabled=true;}
   }
  else break;
  }
 }	
}
function plazoentrega(){
if((typeof document.form1.idioma_mes!='undefined'&&document.form1.idioma_mes.value!='castellano')||(typeof document.form1.color!='undefined'&&document.form1.color.value!='Negro'&&document.form1.color.value!='indiferente'))
 document.form1.plazo_entrega.value = '10 días.';
else document.form1.plazo_entrega.value = document.form1.plazoentrega_ini.value; 
if(document.form1.refprod.value==4820){
 if((typeof document.form1.idioma_mes!='undefined'&&document.form1.idioma_mes.value!='castellano')||(typeof document.form1.color_tinta!='undefined'&&document.form1.color_tinta.value!='Negra'))
  document.form1.pu.value = 16.43;
 else document.form1.pu.value = 13.43;
 }
}
function ver_colores(){
window.open('sellos_printy_colores.html', 'Sellos_colores', 'width=500,height=310,left=100,top=100'); 
//Otro modo:
//href='sellos_printy_colores.html'; window.open(this.href, 'Sellos_colores', ...); 
}
function muestra_fuentes(){
window.open('sellos_fuentes.html', 'Sellos_fuentes', 'width=500,height=530,left=50,top=10,scrollbars=1');
}
function muestra_ejemplos(){
window.open('sellos_ejemplos.html', 'Sellos_ejemplos', 'width=390,height=490,left=100,top=10'); 
}
function muestra_ejemplos2(){
window.open('sellos_ejemplos2.html', 'Sellos_ejemplos2', 'width=390,height=490,left=100,top=100'); 
}
function muestra_ejemplos3(){
window.open('sellos_ejemplos3.html', 'Sellos_ejemplos3', 'width=390,height=320,left=100,top=100'); 
}
function muestra_ejemplos4(){
window.open('sellos_ejemplos4.html', 'Sellos_ejemplos4', 'width=390,height=140,left=100,top=100');
}
function muestra_ejemplo5(){
window.open('sellos_ejemplos5.html', 'Sellos_ejemplos5', 'width=390,height=180,left=100,top=100');
}
function muestra_ejemplo6(){
window.open('sellos_ejemplos6.html', 'Sellos_ejemplos6', 'width=390,height=180,left=100,top=100');
}
function muestra_ejemplos7(){
window.open('sellos_ejemplos7.html', 'Sellos_ejemplos7', 'width=390,height=180,left=100,top=100');
}
function muestra_ejemplo8(){
window.open('sellos_ejemplos8.html', 'Sellos_ejemplo8', 'width=280,height=180,left=100,top=100');
}
function muestra_ejemplo_bi(){
window.open('sellos_ejemplos_bi.html', 'Sellos_ejemplos_bi', 'width=390,height=200,left=100,top=100');
}
function muestra_ejemplob_bi(){
window.open('sellos_ejemplo-b_bi.html', 'Sellos_ejemplob_bi', 'width=390,height=200,left=100,top=100');
}
function muestra_ejemplo2_bi(){
window.open('sellos_ejemplos2_bi.html', 'Sellos_ejemplos2_bi', 'width=390,height=200,left=100,top=100');
}
function muestra_ejemplos3_bi(){
window.open('sellos_ejemplos3_bi.html', 'Sellos_ejemplos3_bi', 'width=390,height=190,left=100,top=100');
}
function muestra_ejemplos4_bi(){
window.open('sellos_ejemplos4_bi.html', 'Sellos_ejemplos4_bi', 'width=390,height=190,left=100,top=100');
}
function muestra_ejemplo6_bi(){
window.open('sellos_ejemplos6_bi.html', 'Sellos_ejemplos6_bi', 'width=390,height=180,left=100,top=100');
}
function ver_multicolor(){
window.open('sellos_multicolor_almohad.html', 'Multicolor_almohad', 'width=500,height=460,left=60,top=70');
}
function ejemplos_multicolor(){
window.open('sellos_multicolor_logos.html', 'Multicolor_logos', 'width=650,height=490,left=40,top=50');
}
function plazo_multicolor(){
if(typeof document.form1.idioma_mes!='undefined'&&document.form1.idioma_mes.value!='castellano')
 document.form1.plazo_entrega.value = '10 días.';
else document.form1.plazo_entrega.value = '5 días.'; 
}
function precio_multicolor(){
if(document.form1.num_almohad.value=='1')
 document.form1.pu.value = document.form1.precio_1_almohad.value;
else document.form1.pu.value = document.form1.precio_2_almohad.value;
actualizaprecio();
}
function compra_multicolor(){
//(Trim está definida en cesta_comprar.js)
lineasvacias=true;
for(i=1;i<=8;i++){
 txt_i=eval("document.form1.texto"+i);
 if(typeof txt_i!='undefined')
  if(Trim(txt_i.value)!='') lineasvacias=false;
}	
nombre=document.form1.nombreprod.value;		
if(document.form1.cantidad.value*1==0) alert('Cantidad errónea.');
 else if(document.form1.envio.checked==false && lineasvacias==true) 
 	 		 alert('Escriba un texto para su sello o marque la casilla\nde envío de fichero con diseño propio.');
 		else{
		 ref=document.form1.refprod.value; cant=document.form1.cantidad.value;
		 precio=document.form1.pu.value; tot=document.form1.preciototal.value; 
	   caract = '- Tamaño máx.: ' + document.form1.tamanyo.value;
		 if(typeof document.form1.color!='undefined') 
		  caract += '\n- Color sello: ' + document.form1.color.value;
		 if(typeof document.form1.idioma_mes!='undefined')
		  caract += '\n- Idioma de los meses: ' + document.form1.idioma_mes.value;
		 caract += '\n- Cantidad de almohadillas: ' + document.form1.num_almohad.value;
		 caract += '\n- Texto: ';	
		 text=''; colortxt=''; font=''; sizefont='';
		 for(i=1;i<=8;i++){
	    txt_i=eval("document.form1.texto"+i);
	    if(typeof txt_i!='undefined' && Trim(txt_i.value)!=''){
		   lin='\nLínea ' + i + ': ';
	 	   text += lin + Trim(txt_i.value);
	 	   colortxt_i=eval("document.form1.color_texto"+i);
		   colortxt += lin + colortxt_i.value;
	 	   font_i=eval("document.form1.tipo_fuente"+i);
		   font += lin + font_i.value;
	 	   size_i=eval("document.form1.tam_fuente"+i);
	 	   sizefont += lin + size_i.value;
		   }
		  }	 
		 if(text!='')
		  caract += text + '\n- Color: ' + colortxt + '\n- Fuente: ' + font + '\n- Tamaño fuente: ' + sizefont;
		 else caract += '(ninguno)';
		 if(document.form1.envio.checked) env='SI'; else env='No';
		 caract += '\n- Envío de fichero con diseño propio o logotipo: ' + env;	
		 if(env=='SI') caract += '\n(en el precio se incluye un suplemento de 9.95 euros\npor su verificación y comprobación)';		 			 
		 comprar(nombre, ref, precio, cant, tot, caract);
	  }
}
function compra_numerador(){
if(document.form1.cantidad.value*1==0) alert('Cantidad errónea.'); 
else{
 nombre=document.form1.nombreprod.value;
 ref=document.form1.refprod.value; cant=document.form1.cantidad.value;
 precio=document.form1.pu.value; tot=document.form1.preciototal.value; 
 caract = '- Número de dígitos: ' + document.form1.numero_digitos.value;
 caract += '\n- Medida de los caracteres: ' + document.form1.medida_caracteres.value;
 caract += '\n- Color sello: ';
 if(ref=='Printy 4846' || tipo_numerador=='48313' || tipo_numerador=='5546' || tipo_numerador=='5558' || tipo_numerador=='55510') caract += 'Negro';
 else caract += 'Cromado (metálico)';
 caract += '\n- Color almohadilla (tinta): ' + document.form1.color_tinta.value;
 comprar(nombre, ref, precio, cant, tot, caract);
 }
}
function compra_fechador_numerador(){
if(document.form1.cantidad.value*1==0) alert('Cantidad errónea.'); 
else{
 nombre=document.form1.nombreprod.value;
 ref=document.form1.refprod.value; cant=document.form1.cantidad.value;
 precio=document.form1.pu.value; tot=document.form1.preciototal.value; 
 caract = '- Medida de los caracteres: 4 mm';
 caract += '\n- Color almohadilla (tinta): ' + document.form1.color_tinta.value;
 if(ref=='55460PL'){ 
  caract += '\n- Tamaño de la mancha: máx. 56x33 mm';
  caract += '\n- Texto: ';		
  text=''; font='';
  for(i=1;i<=4;i++){
	 txt_i=eval("document.form1.texto"+i);
	 if(Trim(txt_i.value)!=''){
	  lin='\nLínea ' + i + ': ';
	  text += lin + Trim(txt_i.value);
	  font_i=eval("document.form1.tipo_fuente"+i);
	  font += lin + font_i.value;
	  }
	 }			 
  if(text!='') caract += text + '\n- Fuente: ' + font;
  }
 if(ref=='55460PL' && text=='') alert('Escriba un texto para su sello');
 else comprar(nombre, ref, precio, cant, tot, caract);
 }
}
function comprasello(){
//(Trim está definida en cesta_comprar.js)
lineasvacias=true;
for(i=1;i<=8;i++){
 txt_i=eval("document.form1.texto"+i);
 if(typeof txt_i!='undefined')
  if(Trim(txt_i.value)!='') lineasvacias=false;
}	
nombre=document.form1.nombreprod.value;		
if(document.form1.cantidad.value*1==0) alert('Cantidad errónea.');
 else if(nombre=='SELLO DE TEXTO' && document.form1.envio.checked==false && lineasvacias==true) 
 	 alert('Escriba un texto para su sello o marque la casilla\nde envío de fichero con diseño propio.');
 	else if(nombre=='SELLO FECHADOR + TEXTO' && lineasvacias==true)
  	alert('Escriba un texto para su sello.');		  	 
	 else{
		 ref=document.form1.refprod.value; cant=document.form1.cantidad.value;
		 precio=document.form1.pu.value; tot=document.form1.preciototal.value; 
	   caract = '- Tamaño: ' + document.form1.tamanyo.value + '\n-';
		 if(typeof document.form1.color!='undefined') 
		  caract += ' Color sello: ' + document.form1.color.value + ';';
		 caract += '\n- Color almohadilla (tinta): ' + document.form1.color_tinta.value;
		 if(typeof document.form1.idioma_mes!='undefined')
		  caract += '\n- Idioma de los meses: ' + document.form1.idioma_mes.value;
		 if(document.form1.color_tinta.value=='para luz ultravioleta')
		  caract += '\n(con cada sello se suministrará un envase de 1/4 litro de tinta)';
		 if(document.form1.tamanyo.value.indexOf("diámetro")==-1){
		  //Sellos rectangulares:		  
			if(document.form1.nombreprod.value!='SELLO FECHADOR' && document.form1.nombreprod.value!='SELLO NUMERADOR' && document.form1.nombreprod.value.indexOf("TEXTOS COMERCIALES")==-1){
			 //(NI los sellos rectangulares sólo FECHADORES (SIN TEXTO) NI los NUMERADORES NI los de TEXTOS COMERCIALES admiten personalización de texto):
			 caract += '\n- Texto: ';
			 if(document.form1.texto1.value.indexOf("textos más frecuentes")==-1){
			  //Texto introducido por cliente (NO elegido de los más frecuentes):
		    text=''; font=''; sizefont='';
			  for(i=1;i<=8;i++){
	       txt_i=eval("document.form1.texto"+i);
	       if(typeof txt_i!='undefined' && Trim(txt_i.value)!=''){
		      lin='\nLínea ' + i + ': ';
	 		    text += lin + Trim(txt_i.value);
	 		    font_i=eval("document.form1.tipo_fuente"+i);
			    font += lin + font_i.value;
	 		    size_i=eval("document.form1.tam_fuente"+i);
	 		    sizefont += lin + size_i.value;
		     }
			  }			 
			 if(text!='')
		     caract += text + '\n- Fuente: ' + font + '\n- Tamaño fuente: ' + sizefont;
			  else caract += '(ninguno)';
			 }else{ //Texto elegido de los más frecuentes:
			   text = document.form1.texto1.value;
				 caract += text;
				 }
		  }
		 }else{ //Sellos circulares (NO admiten tipo ni tamaño de fuente):
			 text='';
			 for(i=1;i<=5;i++){
	      txt_i=eval("document.form1.texto"+i);
				if((typeof txt_i!='undefined')&&(Trim(txt_i.value)!='')){
			   lin='\nLínea ' + i;
				 if(i==1||i==2) lin+=' (perimétrica): ';
				  else lin+=' (central): ';
	 		   text += lin + Trim(txt_i.value);
				} 
			 }
			 caract += '\n- Texto: '; 	
			 if(text!='') caract += text;
			  else caract += '(ninguno)';
		 }		 
		 if(document.form1.nombreprod.value=='SELLO DE TEXTO' && text.indexOf("textos más frecuentes")==-1){
		  if(document.form1.envio.checked) env='SI'; else env='No';
		  caract += '\n- Envío de fichero con diseño propio o logotipo: ' + env;	
			if(env=='SI') caract += '\n(en el precio se incluye un suplemento de 9.95 euros\npor su verificación y comprobación)';
		 }				 
		 comprar(nombre, ref, precio, cant, tot, caract);
	  }
}
