listaModelos = new Array();
function slctr(texto,valor){
	this.texto = texto
	this.valor = valor
}
function creaSelector(lista, id){
	eval(lista + ";");
	num = listaModelos.length;
	selector = document.getElementById('modelo')
	selector.length = 0;
	for(m=0; m<num; m++){
		valor = listaModelos[m].valor;
		label = listaModelos[m].texto;
		selector.appendChild(creaOpcion(valor, label));
	}
	
}

function creaOpcion(valor, label){
	opcion = document.createElement('option');
	opcion.setAttribute('value', valor);
	opcion.appendChild(document.createTextNode(label));
	return opcion;
}
var peticion = false
var proceso
function enviarPaquete(paquete,url){
	proceso = true
		if (window.XMLHttpRequest) {
			peticion = new XMLHttpRequest();
		}
		
		else if (window.ActiveXObject){
			try{
				peticion = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch(e){
				try{
					peticion = new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch(e){
				peticion = false;
				}
			}
		}
		if (peticion) {
				peticion.onreadystatechange = escuchaCambios;
				peticion.open("POST", url);
				peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
				//alert(paquete)
				peticion.send(paquete);
		}
}
var accion
var ruta
function escuchaCambios() {
    if (peticion.readyState == 4) {
	//alert(peticion.responseText)
        if (peticion.status == 200) {
		//alert(200)
			//alert(peticion.responseText)
			creaSelector(peticion.responseText)
		}
		else{
			proceso = false
		}
     }
}
function aborta(){
	//alert(peticion.statusText)
	peticion.abort()
	proceso = false
}

function iniciaFotos(){
	contFotos = document.getElementById('thumbnails');
	aFotos = contFotos.getElementsByTagName('img');
	for(m=0; m<aFotos.length;m++){
		aFotos[m].parentNode.onclick = function(){return false}
		aFotos[m].onclick = function(){
			cambiaFoto(this)
		}
	}
}

function cambiaFoto(src){
	srcImagen = document.getElementById('imagen').getAttribute('src');
	srcThumbnail = src.getAttribute('src');
	document.getElementById('imagen').setAttribute('src', srcThumbnail);
	src.setAttribute('src', srcImagen);
}
