var tam,altura,arriba,ct,izq;

function cambiarFoto(ruta,foto)
{	
	document.getElementById("img_acambiar").src = '/imagenes/web/' + ruta + '/imagen_m_' + foto;
	document.getElementById('fotonueva').value='imagen_g_' + foto;
}

function cambiarFotoOferta(ruta,foto)
{	
	document.getElementById("img_acambiar").src = '/imagenes/web/' + ruta + '/imagen_g_' + foto;
}

function submitform()
{
  document.contacto.submit();  
}

function tramitarPedido()
{
  document.pedido.submit();  
}

function mandarPresupuesto()
{
  document.presupuesto.submit();  
}

function Chequear(el){
	for (var i=0;i < document.pedido.elements.length;i++){
		var elemento = document.pedido.elements[i];
		if (elemento.type == "checkbox"){
			if (elemento.name==el){
				elemento.checked = true;
			}
			else{
				elemento.checked = false;
			}
		}
	}
}

function filtrarTotal(fichero)
	{				
		if(window.XMLHttpRequest) {
			objXml = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera
		} else if(window.ActiveXObject) {
			objXml = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer		
		}					
		
		objXml.open("GET", fichero, true);  
		objXml.onreadystatechange=function() {
   		if (objXml.readyState==4) {       			
       			document.getElementById("est_pedido").innerHTML=objXml.responseText; 
  		}
 		}   		      				
		objXml.send(null);
}


function lanzar(fichero)
	{				
		if(window.XMLHttpRequest) {
			objXml = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera
		} else if(window.ActiveXObject) {
			objXml = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer		
		}					
		
		objXml.open("GET", fichero, true);  
		objXml.onreadystatechange=function() {
   		if (objXml.readyState==4) {       			
       			document.getElementById("est_pedido").innerHTML=objXml.responseText; 
  		}
 		}   		      				
		objXml.send(null);
		tam = 11;
		altura = 36;
		arriba = 10;
		izq = 0;
		ct =0;		
		cambiarTexto("s");
	}

function lanzar2(fichero)
	{				
		if(window.XMLHttpRequest) {
			objXml = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera
		} else if(window.ActiveXObject) {
			objXml = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer		
		}					
		
		objXml.open("GET", fichero, true);  
		objXml.onreadystatechange=function() {
   		if (objXml.readyState==4) {       			
       			document.getElementById("est_pedido").innerHTML=objXml.responseText; 
  		}
 		}   		      				
		objXml.send(null);		
	}


function cargarDescripcion(ids)
	{				
		if(window.XMLHttpRequest) {
			objXml = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera
		} else if(window.ActiveXObject) {
			objXml = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer		
		}					
		
		objXml.open("GET", "http://www.solucionesinteractivas.es/descripcionProducto.asp?id="+ids, true);  
		objXml.onreadystatechange=function() {
   		if (objXml.readyState==4) {       			
       			document.getElementById("datos_carga").innerHTML = objXml.responseText; 
  		}
 		}   		      				
		objXml.send(null);		
	}

function cargarEspecificaciones(ids)
	{				
		if(window.XMLHttpRequest) {
			objXml = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera
		} else if(window.ActiveXObject) {
			objXml = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer		
		}					
		
		objXml.open("GET", "http://www.solucionesinteractivas.es/especificacionesTecnicas.asp?id="+ids, true);  
		objXml.onreadystatechange=function() {
   		if (objXml.readyState==4) {       			
       			document.getElementById("datos_carga").innerHTML=objXml.responseText; 
  		}
 		}   		      				
		objXml.send(null);		
	}


function recalcular(id,cnt){		
    if (IsNumeric(cnt)){ 
		window.location = "compra.asp?acc=nuevacantidad&id=" + id + "&canti=" + cnt
    }else{    	
    	alert("La cantidad debe ser un NÚMERO")
    }    
}

function recalcularPresupuesto(id,cnt,precio){
alert("id="+id);
alert("cnt="+cnt);
alert("pr="+precio);


   /* if (IsNumeric(cnt)){ 
		window.location = "crearPresupuesto.asp?acc=nuevacantidad&id=" + id + "&canti=" + cnt
    }else{    	
    	alert("La cantidad debe ser un NÚMERO")
    }  

function recalcularPresupuesto(id,valor,cnt)
{	ORG 	
	if (document.getElementById("total_precio").value != "0" && document.getElementById("total_precio").value != "" && document.getElementById("ct"+id).value != ""){		
		document.getElementById("total_precio").value = parseInt(document.getElementById("total_precio").value) - parseInt(document.getElementById("pr"+id).value)*parseInt(document.getElementById("ct"+id).value); 			
				
	}
	document.getElementById("total_precio").value = parseInt(document.getElementById("total_precio").value) + parseInt(document.getElementById("pr"+id).value)*cnt	
	document.getElementById("ct"+id).value = cnt

/*DPES*/  

alert("T="+document.getElementById("pr"+id).value);

	if ( (document.getElementById("pr"+id).value != 0) && (document.getElementById("pr"+id).value != "") && (document.getElementById("ct"+id).value != "") ){		
		alert("ENTR");
		document.getElementById("pr"+id).value = ( parseInt(document.getElementById("pr"+id).value) - parseInt(document.getElementById("pr"+id).value) ) * parseInt(document.getElementById("ct"+id).value); 			
	}

	document.getElementById("pr"+id).value = parseInt(document.getElementById("pr"+id).value) + (parseInt(document.getElementById("pr"+id).value)*cnt )
	document.getElementById("ct"+id).value = cnt

alert("TOT="+document.getElementById("pr"+id).value);


	
}




function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function cambiarTexto(tipo)
	{			
		if (tipo == "s"){
			tam = tam + 1;
			altura = altura + 1;
			ct ++;
			if (ct == 2){
				arriba = arriba - 1;
				izq = izq - 1;
				ct = 0;
			}
		}
		if (tipo == "r"){
			tam = tam - 1;
			altura = altura - 1;
			ct ++;
			if (ct == 2){
				arriba = arriba + 1;
				izq = izq + 1;
				ct = 0;
			}
		}
		if (tam > 31 && tipo == "s")
		{
			tipo = "r";
		}
		if (tam > 11){								
			document.getElementById("est_pedido").style.fontSize = tam + 'px';
			document.getElementById("est_pedido").style.height = altura + 'px';
			document.getElementById("est_pedido").style.Top = arriba + 'px';			
			document.getElementById("est_pedido").style.color = '#939292';
			setTimeout("cambiarTexto('"+tipo+"')",10);
		}else{			
			document.getElementById("est_pedido").style.Top = '0px';
			document.getElementById("est_pedido").style.color = "#000000";
		}
	}
