function CambiaEspacios(nuevacadena){
	while (Encuentra(nuevacadena,'{Ç}')==true){
		nuevacadena=nuevacadena.replace("{Ç}", " ");
	}
	return nuevacadena;	
}


function Cambiatildes(n){
	while ((Encuentra(n.value,'á')==true)||(Encuentra(n.value,'é')==true)||(Encuentra(n.value,'í')==true)||
		   (Encuentra(n.value,'ó')==true)||(Encuentra(n.value,'ú')==true)||(Encuentra(n.value,'Á')==true)||
		   (Encuentra(n.value,'É')==true)||(Encuentra(n.value,'Í')==true)||(Encuentra(n.value,'Ó')==true)||
		   (Encuentra(n.value,'Ú')==true)){
		
		n.value	= n.value.replace ("á", "a");
		n.value = n.value.replace ("é", "e");
		n.value = n.value.replace ("í", "i");
		n.value = n.value.replace ("ó", "o");
		n.value = n.value.replace ("ú", "u");
		n.value = n.value.replace ("Á", "A");
		n.value = n.value.replace ("É", "E");
		n.value = n.value.replace ("Í", "I");
		n.value = n.value.replace ("Ó", "O");
		n.value = n.value.replace ("Ú", "U");	           
	     
	}
	return n.value;	
}

function CambiatildesYblancos(n){
	while ((Encuentra(n.value,'á')==true)||(Encuentra(n.value,'é')==true)||(Encuentra(n.value,'í')==true)||
		   (Encuentra(n.value,'ó')==true)||(Encuentra(n.value,'ú')==true)||(Encuentra(n.value,'Á')==true)||
		   (Encuentra(n.value,'É')==true)||(Encuentra(n.value,'Í')==true)||(Encuentra(n.value,'Ó')==true)||
		   (Encuentra(n.value,'Ú')==true)||(Encuentra(n.value,' ')==true)){
		
		n.value	= n.value.replace ("á", "a");
		n.value = n.value.replace ("é", "e");
		n.value = n.value.replace ("í", "i");
		n.value = n.value.replace ("ó", "o");
		n.value = n.value.replace ("ú", "u");
		n.value = n.value.replace ("Á", "A");
		n.value = n.value.replace ("É", "E");
		n.value = n.value.replace ("Í", "I");
		n.value = n.value.replace ("Ó", "O");
		n.value = n.value.replace ("Ú", "U");
		n.value = n.value.replace (" ", "");
	     
	}
	return n.value;	
}

function Encuentra(cadena,token){
	
	var longitud=cadena.length;
	var encontrado=false;
	var cont=0;
	
	while (cont<longitud){
		if (cadena.charAt(cont)==token.charAt(0)){
			encontrado=true;
		}
		cont++;
	}
	
	return encontrado;
}

function AbreVentanacaract (url) {
	var ventana = document.open (url, '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=yes, left=40, top=00, width=880, height=700, resizable=0');
}
function AbreVentanaTela (url) {
	var ventana = document.open (url, '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=0, left=40, top=00, width=295, height=295, resizable=0');
}
function AbreConsulta (url) {
				var ventana = document.open (url, '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=no, left=200, top=200, width=600, height=250, resizable=no');
}
function AbreConsulta2 (url) {
				var ventana = document.open (url, '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=no, left=120, top=150, width=800, height=250, resizable=no');
}
function AbreVentanaTelas (url) {
	var ventana = document.open (url, '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=yes, left=0, top=0, width=740, height=500, resizable=no');
}
function AbreVentanaSofa (url) {
	var ventana = document.open (url, '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=yes, left=0, top=0, width=740, height=500, resizable=yes');
}
function AbreVentanaAyuda (url) {
	var ventana = document.open (url, '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=yes, left=20, top=0, width=970, height=550, resizable=yes');
}

function AbreVentanaImprimir () {
	var ventana = document.open ('./sofas-imprimir_presupuesto.asp', '_blank', 'toolbar=no, location=no, directories=no, status=no, scrollbars=yes, left=40, top=0, width=770, height=550, resizable=yes');
}

function imprimir () {
   if (window.print != null) {
      window.print()
   } else {
      alert('Desafortunadamente, tu navegador no soporta este método de impresión.\nPor favor, selecciona la opción de Imprimir del menú de Archivo de tu navegador.')
   }
}

function SeleccionaSofa (composicion, modelo) {
	if (! ((document.forms['Datos'].Composicion.value == composicion) && (document.forms['Datos'].Modelo.value == modelo)) ) {
		document.forms['Datos'].Composicion.value = composicion;
		document.forms['Datos'].Modelo.value = modelo;
		document.forms['Datos'].Cesta.value = 0;
		document.forms['Datos'].action = './sofas-presupuesto.asp';
		document.forms['Datos'].submit();
	}
}

function SeleccionaTela (serie, tela) {
	if (! ((document.forms['Datos'].Serie.value == serie) && (document.forms['Datos'].Color.value == tela)) ) {
		document.forms['Datos'].Serie.value = serie;
		document.forms['Datos'].Color.value = tela;
		document.forms['Datos'].Numero.value = 0;
		document.forms['Datos'].Cesta.value = 0;
		document.forms['Datos'].action = './sofas-presupuesto.asp';
		document.forms['Datos'].submit();
	}
}

function Recargar(){
	if(history.forward(1)){ 
 		window.location.reload(); 
		//location.href='./colchones-confirmar.asp';
 	}
}

function muestrafoto (foto){
	document.all.sof.src=foto;
	document.all.fotosofas.style.display = '';
}
function ocultafoto (){
	fotosofas.style.display = 'none';
	document.all.sof.src="./rinconeras-img/carga.gif";
}

function parpadeo(){
	i=0
    tabcolores = new Array ("#006600","#FF0000"); // #ffffff: Blanco #CE5852: Rojo #FF0000: Rojo Vivo #006600: Verde Feo
    if (i+1 == tabcolores.length) i=0; 
    else i++; 
    setTimeout("parpadeo()",1000); 
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	       document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(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];}
}