// --------------------------
// 	  Selecciona una Option
// --------------------------
// Selecciona la Option de un Select que tenga el valor indicado
// - Entrada: Select y Valor
// -  Salida: Selecciona la Option correspondiente
function SelOption (Select, Valor) {
	for (i=0; i<Select.options.length; i++) {
		if (Select.options[i].value == Valor) // Si es la Elegida
			Select.selectedIndex = i;
	}
}

// --------------------------
// 	      Favoritos
// --------------------------
function Favoritos() {
	url = "http://www.atodomotor.com";
	var titulo = "A Todo Motor"; 
	var ns = "Para poner la web de A Todo Motor en tus Marcadores,\nacepta esta ventana y luego pulsa: [ Ctrl + D ]"; 
	var op = "Para poner la web de A Todo Motor en tus Preferidos de Opera, acepta esta ventana y luego pulsa: [ Ctrl + D ]";
	if (navigator.userAgent.indexOf("Opera")!=-1)
		alert (op)
	else
	{
		if (navigator.appName == "Netscape")
			alert (ns)
		else
			window.external.AddFavorite(url, titulo);
	}
}

// --------------------------
// 	      ARREGLO PNG
// --------------------------
function PNGs(){
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version < 7) && (version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") // Si es PNG
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display: inline-block;" + img.style.cssText
			 imgStyle = "vertical-align: middle;" + imgStyle
			 //if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 //if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	   if (document.getElementById('ContWeb')) // Si es con Contenido Web
	      document.getElementById('ContWeb').style.backgroundImage = "url(diseno/img/Fondo.jpg)";
	}
}

// --------------------------
// 		Tomar AJAX
// --------------------------
// Toma el Controlador de AJAX
// - Entrada: ...
// -  Salida: El Controlador de AJAX
function TomarAJAX() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

// --------------------------
// 		Respuesta Encuesta
// --------------------------
function RE(Enc, Cod) {
	window.location = './encuestas.php?E='+Enc+'&R='+Cod;
}

