var img_close = "<img align='absmiddle' width='12px' src='images/accesorios/cerrar.png' border='0px' style='position:relative; top:4px;'>";
var div_id_tecnologia = "";
var div_id_seguridad = "";

var tipo_menu = 0;

function objetoAjax(){
	var xmlhttp=false;
	
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	
	catch (e) {
		
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		
		catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

//******************************************************************//
//******************************************************************//
//******************************************************************//
/*
function changeBackground() {

			var fondos = {
			'800':'images/fondos_contenido/fondo.jpg',
			'1024':'images/fondos_contenido/fondo.jpg',
			'1280':'imagen1280.jpg',
			'default':'imagenparaotrasresoluciones.jpg'
			}
		 
			var ancho = screen.width;
			 
			if (parseInt(ancho) > parseInt(800) && parseInt(ancho) < parseInt(1280)) {
			
				document.getElementById("uniroca_cuerpo").style.backgroundImage = "url("+ fondos[ancho] +")";			
			}else {
			
				document.body.style.backgroundImage = "url("+ fondos['default'] +");";
			}
}
*/
//******************************************************************//
//******************************************************************//
//******************************************************************//

function seleccion_pais(valor){

	var i = 1;

	while(document.getElementById("info_"+i)){
	
		document.getElementById("info_"+i).style.visibility = "hidden";
		document.getElementById("pais_"+i).style.visibility = "hidden";
		document.getElementById("logo_"+i).style.visibility = "visible";
		
		i = i +1;
	}
	
	
	document.getElementById("info_" + valor).style.visibility = "visible";
	document.getElementById("pais_" + valor).style.visibility = "visible";
	document.getElementById("logo_" + valor).style.visibility = "hidden";

}

//******************************************************************//
//******************************************************************//
//******************************************************************//

function nombre_resistencia(id){

	document.getElementById('nombre_convencion').innerHTML = id;

}

function quitar_resistencia(){

	document.getElementById('nombre_convencion').innerHTML = "";

}

function nombre_acceso(id, pos){

	document.getElementById('div_cabecera').style.marginLeft = (460 + pos) + "px";
	document.getElementById('nombre_cabecera').innerHTML = id;

}

//******************************************************************//
//******************************************************************//
//******************************************************************//

function cambiar_suela(id){

	suela_id = id.split("_");

	//donde se mostrará lo resultados
	divResultado = document.getElementById('resultado_caracteristicas');
	
	ajax=objetoAjax();

	ajax.open("POST", "redireccionar_suela.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar los nuevos registros en esta capa
			divResultado.innerHTML = ajax.responseText
		}
	}
	//muy importante este encabezado ya que hacemos uso de un formulario
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("id="+ suela_id[1])
}


//******************************************************************//
//******************************************************************//
//******************************************************************//

function close_tecnologia(id){
document.getElementById(id).innerHTML = "";
document.formulario.campo_tecnologia.value = "";
filtro_calzadoh();
}


function close_seguridad(id, valor){

var elementos = new Array ();
var i = 0;

document.getElementById(id).innerHTML = "";

elementos = document.formulario.campo_seguridad.value.split(",")

for (i=0; i <= elementos.length; i++){

	if (elementos[i] == valor)
			break;
}

elementos.splice(i,1);
document.formulario.campo_seguridad.value = elementos.join(",");

filtro_calzadoh();
}


//******************************************************************//

function filtro_tecnologia(id, name){

if (div_id_tecnologia != "")
	document.getElementById(div_id_tecnologia).innerHTML = "";
div_id_tecnologia = id;
document.getElementById(id).innerHTML = img_close;

document.formulario.campo_tecnologia.value = name;
filtro_calzadoh();
}

function filtro_seguridad(id, name){

var elementos = new Array ();
var flag_elemento = 0;
var i = 0;

/*if (div_id_seguridad != "")
	document.getElementById(div_id_seguridad).innerHTML = "";*/

div_id_seguridad = id;
document.getElementById(id).innerHTML = img_close;

if (document.formulario.campo_seguridad.value == "")
	document.formulario.campo_seguridad.value = name;
else{
	
	elementos = document.formulario.campo_seguridad.value.split(",")
	
	for (i=0; i <= elementos.length; i++){

		if (elementos[i] == name){
				flag_elemento = 1;
				break;
		}
	}
	
	if(flag_elemento == 0)
		document.formulario.campo_seguridad.value = document.formulario.campo_seguridad.value + "," + name;
	}
	
filtro_calzadoh();
}


function filtro_calzadoh(){

	//donde se mostrará lo resultados
	divResultado = document.getElementById('resultado');
	
	document.getElementById('loading_img').style.visibility = "visible";
	
	//valores de los inputs
	item_menu = document.formulario.item.value;
	genero = document.formulario.genero.value;
	
	valor_tecnologia=document.formulario.campo_tecnologia.value;
	valor_seguridad=document.formulario.campo_seguridad.value;
	valor_usos=document.formulario.campo_usos.value;

	ajax=objetoAjax();

	ajax.open("POST", "redireccionar.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar los nuevos registros en esta capa
			document.getElementById('loading_img').style.visibility = "hidden";
			divResultado.innerHTML = ajax.responseText
			
			$('#scrollbar1').tinyscrollbar();
		}
	}
	//muy importante este encabezado ya que hacemos uso de un formulario
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("item="+item_menu+"&genero="+genero+"&tecnologia="+valor_tecnologia+"&seguridad="+valor_seguridad+"&usos="+valor_usos)
}

/****************************************************************************/
/****************************************************************************/
/****************************************************************************/

var posicion_scroll = 0;

function subir_productos(){

var valor_items = parseInt(document.getElementById("cantidad_items").innerHTML)
valor_items = valor_items/4;

alert(valor_items)

if (posicion_scroll < Math.ceil(valor_items-1)){
	
	posicion_scroll = posicion_scroll + 1;
	document.getElementById("contenedor_productos").scrollTop = 155 * posicion_scroll;
	//document.getElementById("scroll_bar").style.top = (parseInt(document.getElementById("scroll_bar").style.top) + Math.round(86/(Math.ceil(valor_items-1)))) + "px";
	}
}



function bajar_productos(){

var valor_items = parseInt(document.getElementById("cantidad_items").innerHTML)
valor_items = valor_items/4;

if (posicion_scroll > 0){
	
	posicion_scroll = posicion_scroll - 1;
	document.getElementById("contenedor_productos").scrollTop = 155 * posicion_scroll;
	//document.getElementById("scroll_bar").style.top = (parseInt(document.getElementById("scroll_bar").style.top) - Math.round(86/(Math.ceil(valor_items-1)))) + "px";
	}

}

/****************************************************************************/
/****************************************************************************/
/****************************************************************************/

/****************************************************************************/
/****************************************************************************/
/****************************************************************************/

function subir_suelas(valor){

var valor_items = valor;
valor_items = valor_items/6;

if (posicion_scroll < Math.ceil(valor_items-1)){
	
	posicion_scroll = posicion_scroll + 1;
	document.getElementById("contenedor_suelas").scrollTop = 270 * posicion_scroll;
	document.getElementById("scroll_bar").style.top = (parseInt(document.getElementById("scroll_bar").style.top) + Math.round(86/(Math.round(valor_items-1)))) + "px";
	}
}



function bajar_suelas(valor){

var valor_items = valor;
valor_items = valor_items/6;

if (posicion_scroll > 0){
	
	posicion_scroll = posicion_scroll - 1;
	document.getElementById("contenedor_suelas").scrollTop = 270 * posicion_scroll;
	document.getElementById("scroll_bar").style.top = (parseInt(document.getElementById("scroll_bar").style.top) - Math.round(86/(Math.round(valor_items-1)))) + "px";
	}

}

/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
	
