// ** conjunto de funciones que carga contenido en la parte derecha **
// ***********************************************************************


//DEL MENU IZQ AL CONTENIDO
function handleHttpResponse() {
	if (http.readyState == 4) {    	
		der.innerHTML = http.responseText;		
	}    
}
//--
function actualizaContenido(strDirec, id) {
	http.open("GET", "getContenido.asp?strURL=" + strDirec + "&idContenido="+ id, true);    
	http.onreadystatechange = handleHttpResponse;
	http.send(null);  
}
//--
function getHTTPObject() {
	var xmlhttp;      
  
  /*@cc_on
  @if (@_jscript_version >= 5)
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
		xmlhttp = false;
	  }
	}
  @else
  xmlhttp = false;
  @end @*/
  
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {  
		try {
		  xmlhttp = new XMLHttpRequest();
		} catch (e) {
		  xmlhttp = false;
		}
	}
	return xmlhttp;
}    
//--
var http = getHTTPObject(); // We create the HTTP Object
// ***********************************************************************
function mostrarReferencia(id){
		if (document.getElementById("pk_info"+id).value == ""){
			document.getElementById("descripcion_referencia"+id).innerHTML = "";
//			document.getElementById("descripcion_referencia").style.display = "block";	
			return false;
		}
		var idReferencia = document.getElementById("pk_info"+id).value;
			parent.document.getElementById("producto_actual").value = id;
		http.open("GET", "./includes/getReferencia.asp?id=" + idReferencia, true);
		http.onreadystatechange = handleHttpResponseReferencia;
		http.send(null);
	
}

function handleHttpResponseReferencia() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		var cadena = http.responseText.split("|");
		var prod = parent.document.getElementById("producto_actual").value;
		document.getElementById("descripcion_referencia"+prod).innerHTML =  cadena[0] ;
		document.getElementById("precio_referencia"+prod).innerHTML =   cadena[1]  ;	
//		document.getElementById("descripcion_referencia").style.display = "block";	
	}    
}

//***********************
//Script de la busuqeda por marcas
function buscar_por_marca(){
	var id = document.getElementById('marcas').value;
	if (id == 0){
		alert('Debe seleccionar una marca');
		return;
	}
		document.location.href = "index.asp?page=pd&mc=1&id="+id;
}
function buscar(){
	var texto = document.getElementById('texto_busqueda').value;
	document.getElementById('parametro').value = texto;
	document.getElementById('busqueda').submit();
}


//************ SECCION PRODCUTOS **************************************************
//*********************************************************************************
function ampliaProducto(pagina,id,tipo,galeria,titulo){
	if (tipo == 1){
//		alert(tipo);
		var ref = document.getElementById("pk_info"+id).value;
		if (ref != ""){
			document.getElementById("formularioAmplia" + id).action = document.getElementById("formularioAmplia" + id).action + "&ref="+ref;
		}
	}
	document.getElementById("formularioAmplia" + id).numPagina.value=pagina
	document.getElementById("formularioAmplia" + id).numGaleria.value=galeria
	document.getElementById("formularioAmplia" + id).action = document.getElementById("formularioAmplia" + id).action + '&' + titulo;
	document.getElementById("formularioAmplia" + id).submit();
}


function paginacion(pagina){
//funcion para realizar la paginacion de los productos
	document.getElementById("formularioPaginacion").numPagina.value=pagina
	document.getElementById("formularioPaginacion").submit();
}

function volverCatalogo(pagina){
	document.getElementById("formularioVolver").numPagina.value=pagina
	document.getElementById("formularioVolver").submit();
}
//************* PEDIDOS ************************************************

function pedir(cual){	
	var p,i;
	i = document.getElementById('pk_info'+cual).value;
	p = document.getElementById('pk_pedidos').value;
//	i=eval('document.getElementById('pk_info''+cual'.value');
//	p=eval('document.pedidos'+cual+'.pk_pedidos'+cual+'.value');
	window.open('actualizer/pedidos/pedidos_va01.asp?pk_fotos='+cual+'&pk_info='+i+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=600,height=680,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function pedirIng(cual){	
	var p,i;
	i=eval('document.pedidos'+cual+'.pk_info'+cual+'.value');
	p=eval('document.pedidos'+cual+'.pk_pedidos'+cual+'.value');
	window.open('actualizer/pedidosIng/pedidos_va01.asp?pk_fotos='+cual+'&pk_info='+i+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function pedirFr(cual){	
	var p,i;
	i=eval('document.pedidos'+cual+'.pk_info'+cual+'.value');
	p=eval('document.pedidos'+cual+'.pk_pedidos'+cual+'.value');
	window.open('actualizer/pedidosFr/pedidos_va01.asp?pk_fotos='+cual+'&pk_info='+i+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function pedir2(cual){	
	var p,i;
	i=eval('document.pedidos'+cual+'.pk_info'+cual+'.value');
	p=eval('document.pedidos'+cual+'.pk_pedidos'+cual+'.value');
	window.open('../pedidos/pedidos_va01.asp?pk_fotos='+cual+'&pk_info='+i+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function pedirIng2(cual){	
	var p,i;
	i=eval('document.pedidos'+cual+'.pk_info'+cual+'.value');
	p=eval('document.pedidos'+cual+'.pk_pedidos'+cual+'.value');
	window.open('../pedidosIng/pedidos_va01.asp?pk_fotos='+cual+'&pk_info='+i+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function pedirFr2(cual){	
	var p,i;
	i=eval('document.pedidos'+cual+'.pk_info'+cual+'.value');
	p=eval('document.pedidos'+cual+'.pk_pedidos'+cual+'.value');
	window.open('../pedidosFr/pedidos_va01.asp?pk_fotos='+cual+'&pk_info='+i+'&pk_pedidos='+p,'pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function ver_pedidos(){
window.open('actualizer/pedidos/ver_pedidos.asp','pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function ver_pedidosIng(){
window.open('actualizer/pedidosIng/ver_pedidos.asp','pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}
function ver_pedidosFr(){
window.open('actualizer/pedidosFr/ver_pedidos.asp','pedido','scrollbars=yes,width=600,height=650,top=40,left=30,status=no,toolbar=no,menubar=no,location=no,titlebar=0,resizable=no, fullscreen = no ');
}

//***************************************************************************
// Funcion que muestra los temas
//***************************************************************************
function muestraTema(id,numero) {
	for (i=1;i<=numero;i++){
		if (id != i){
			if (document.getElementById("marcas"+ i).style.display == "block"){
				document.getElementById("marcas"+ i).style.display = "none";
			}
		}
	}
	if (document.getElementById("marcas"+ id).style.display == "block") { 
		document.getElementById("marcas"+ id).style.display = "none"; }
	else { 
		document.getElementById("marcas"+ id).style.display = "block";
		}
}
//****************** FIN DE PEDIDOS ****************************************
//***************************************************************************
// Funcion que muestra los temas
//Temas listados por id
//Falla en Firefox
//***************************************************************************
/*function muestraTema(id) {
	var	oItems = document.getElementsByTagName("div");  //cojo todos los div del documento
	var a = new Array();
	var b = new Array();
	var t;
	var j = 1;
	for (var obj in oItems){
		if (obj.substring(0,6) == "marcas"){  //meto los que son 'marcas' en un array
		a[j] = obj;
		t = obj.split("s"); //cojo el id que va detrás de 'marcas'
		b[j] = t[1];
		j = j + 1;
		}
	}
	if (a.length > 0 ){
		for (i=1;i<=j-1;i++){
			if (id != b[i]){
				if (document.getElementById(a[i]).style.display == "block"){
					document.getElementById(a[i]).style.display = "none";
				}
			}
		}
		if (document.getElementById("marcas"+ id).style.display == "block") { 
			document.getElementById("marcas"+ id).style.display = "none"; }
		else { 
			document.getElementById("marcas"+ id).style.display = "block";
		}
	} 
}
*/