function abrirVentana(url, nombre, opciones){
	window.open(url, nombre, opciones);
}

// Precarga una imagen
function preCargaImg(imageURL) {
		image = new Image();
		image.src = imageURL;
		return image;
}

// Cambia el SRC de una imagen
function CambiarImg(buttonName,sourceImage) {
		buttonName.src = sourceImage.src;
		return true;
}

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 enlaces(id){        
        datos = 'http://www.sobrecoches.com/lib/enlaces/enlace.php?destiny='+id+"&ms="+new Date().getTime();
        ajax=objetoAjax();
        ajax.open("GET", datos);
        ajax.send(null);
}
function cambio_submenu(id){
	if (document.getElementById(id).style.display=='none' || document.getElementById(id).style.display=='')
		document.getElementById(id).style.display='block'
	else
		document.getElementById(id).style.display='none'
}

function cambiar_estado(var1,var2){
	if (document.getElementById(var2).style.display=='none' || document.getElementById(var2).style.display==''){
		document.getElementById(var2).style.display='block';
		document.getElementById(var1).style.display='none';
	}
}

function cambio_linea(var1,var2){
	document.getElementById(var2).style.borderBottom='1px solid #B4B4B4';
	document.getElementById(var1).style.borderBottom='0px';
}

function anadeOpcion(combo,texto, valor) {
	var elOptNew = document.createElement('option');
	elOptNew.text = texto;
	elOptNew.value = valor;  
	try {
	  document.getElementById(combo).add(elOptNew,null); // standards compliant; doesn't work in IE
	}
	catch(ex) {
	 	document.getElementById(combo).add(elOptNew); // IE only
	}
}


function comboModelos(objeto, idCombo) {
	if (objeto.readyState==4 || objeto.readyState=="complete") {
		  document.getElementById(idCombo).innerHTML =objeto.responseText;
	}
}
