function makeRequest(url,div)
{

	document.getElementById('control').value=div;

	var n_url=url;

	document.getElementById(div).innerHTML="Cargando...";
        http_request = false;

        if (window.XMLHttpRequest)
		{ // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType)
			{
                http_request.overrideMimeType('text/xml');
            }
        }
		else if (window.ActiveXObject)
		{ // IE
            try
			{
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e)
			{
                try
				{
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request)
		{
            alert('Falla :( No es posible crear una instancia XMLHTTP');
            return false;
        }
        http_request.onreadystatechange = alertContents;
        http_request.open('GET', n_url, true);
        http_request.send(null);
}

function alertContents()
{

		div=document.getElementById('control').value


	if (http_request.readyState == 4)
	{
   		if (http_request.status == 200)
		{
			document.getElementById(div).innerHTML=http_request.responseText;
    	}
		else
		{
        alert('Hubo problemas con la petición.');
    	}
	}
}

function isNumber(obj)
{
	if(isNaN(obj.value))
	{
		obj.style.border = '#c10f0f solid 2px';
	}
	else
	{
		obj.style.border = '1px solid #7f9db9';
	}
}

// -----------------------------------------------------------------
// RRP: 02/03/2010
// Cambio de imagenes con efecto desvanecedor
// -----------------------------------------------------------------
function RunSlideShow(pictureName,imageFiles,displaySecs)
{
	var imageSeparator = imageFiles.indexOf(";");
	var nextImage = imageFiles.substring(0,imageSeparator);
	if (document.all)
	{
		document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
		document.getElementById(pictureName).filters.blendTrans.Apply();
	}
	
	document.getElementById(pictureName).src = nextImage;
	
	if (document.all)
	{
		document.getElementById(pictureName).filters.blendTrans.Play();
	}
	var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
	+ ';' + nextImage;
	setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
	displaySecs*1000);

	imageSeparator = futureImages.indexOf(";");
	nextImage = futureImages.substring(0,imageSeparator);
	
	if (slideCache[nextImage] == null) 
	{
		slideCache[nextImage] = new Image;
		slideCache[nextImage].src = nextImage;
	}
}

// -----------------------------------------------------------------
// RRP: 03/03/2010
// Funciones para muestra packs
// -----------------------------------------------------------------

// Cambio de imagen segun select
function Validar(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}
  
// Calculo del precio PACK segun el valor de cada producto y descuento por cantidad 
function precioproducto()
{
	var cantTot = document.getElementById("cantidad").value;

	if (cantTot == "" || cantTot == "0")
	{
		document.getElementById('divMsjCant').innerHTML = '<font color="#FF0000">* Ingrese la cantidad</font>';	
		document.getElementById("total").value = '0';		
	}
	else
	{
		document.getElementById('divMsjCant').innerHTML = '';	
		var arrRefer = new Array();
		arrRefer = document.getElementsByName("precio");
		var acumRefer = 0;
		for ( var i = 0; i < arrRefer.length; i++ ) 
		{
			acumRefer += parseFloat(arrRefer.item(i).value);
		}
		// Suma de valores de productos con 2 decimales
		var subTot = Math.round(acumRefer*100)/100;
		
		// Cantidades
		var C1 =  parseFloat(document.getElementById("cantPck_1").value);
		var C2 =  parseFloat(document.getElementById("cantPck_2").value);
		var C3 =  parseFloat(document.getElementById("cantPck_3").value);
		var C4 =  parseFloat(document.getElementById("cantPck_4").value);
		// Descuentos por cantidades
		var D1 =  parseFloat(document.getElementById("valRef_1").value);
		var D2 =  parseFloat(document.getElementById("valRef_2").value);
		var D3 =  parseFloat(document.getElementById("valRef_3").value);
		var D4 =  parseFloat(document.getElementById("valRef_4").value);
		
		var dcto = 0;
		if (cantTot >= C1)
			dcto = 	D1;
		if (cantTot >= C2)
			dcto = 	D2;
		if (cantTot >= C3)
			dcto = 	D3;
		if (cantTot >= C4)
			dcto = 	D4;

		dcto = dcto / 100;
		subTot = subTot - (subTot * dcto);
		document.getElementById("subtotal").value = subTot;
		var Total = cantTot * subTot;
		Total = Math.round(Total*100)/100;
		document.getElementById("total").value = Total;
	}
} 

// Calculo del precio PACK segun el valor asignado al pack por cantidad 
function preciopack()
{
	var cantTot = document.getElementById("cantidad").value;

	if (cantTot == "" || cantTot == "0")
	{
		document.getElementById('divMsjCant').innerHTML = '<font color="#FF0000">* Ingrese la cantidad</font>';	
		document.getElementById("total").value = '0';
	}
	else
	{
		document.getElementById('divMsjCant').innerHTML = ''; 
		
		// Cantidades
		var C1 =  parseFloat(document.getElementById("cantPck_1").value);
		var C2 =  parseFloat(document.getElementById("cantPck_2").value);
		var C3 =  parseFloat(document.getElementById("cantPck_3").value);
		var C4 =  parseFloat(document.getElementById("cantPck_4").value);	
		// Valores de los packs segun cantidades
		var V1 =  parseFloat(document.getElementById("valRef_1").value);
		var V2 =  parseFloat(document.getElementById("valRef_2").value);
		var V3 =  parseFloat(document.getElementById("valRef_3").value);
		var V4 =  parseFloat(document.getElementById("valRef_4").value);		
		
		var valp = 0;
		if (cantTot >= C1)
			valp = 	V1;
		if (cantTot >= C2)
			valp = 	V2;
		if (cantTot >= C3)
			valp = 	V3;
		if (cantTot >= C4)
			valp = 	V4;
			
		document.getElementById("subtotal").value = valp;		
		var Total = cantTot * valp;
		Total = Math.round(Total*100)/100;
		document.getElementById("total").value = Total;
	}
}


// Campo solo acepta numeros
var nav4 = window.Event ? true : false;
function acceptNum(evt){	
// Nota: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var key = nav4 ? evt.which : evt.keyCode;	
return (key <= 13 || (key >= 48 && key <= 57));
}


// Carga dinamica de la imagen mediante combo
function cargaimg(itprod, miId)
{
	var where_is_mytool=itprod;
	var mytool_array=where_is_mytool.split("*");
	cargaprecio(itprod, miId);
	return mytool_array[0];	
}

// Asignación de precio segun el producto
function cargaprecio(itprod, idprec)
{
	var divprec = itprod.split("*");
	// codigos
	divprec[0] = divprec[0].replace("http://www.efutgol.com/fotos/", "");
	var divCod = divprec[0].split(".");
	// precios
	var divId = idprec.split("_");
	// define el limite segun la cantidad de productos del pack
	var arrLimite = document.getElementsByName("precio");
	var i=0;
	for (i=0; i<=arrLimite.length; i++)
	{
		if (i == divId[1])
		{
			document.getElementById("precio_" + i).value = divprec[1];
			document.getElementById("codiprods_" + i).value = divCod[0]; 
		}
	}
}

// Reune los codigos 
function acumulaCods()
{
	var arrCodigo = document.getElementsByName("codiprods");
	var i=0;
	var recoje = "";
	for (i=0; i< arrCodigo.length; i++)
	{
		if(i == 0)
			recoje += arrCodigo.item(i).value;
		else
			recoje += "," + arrCodigo.item(i).value;
	}
	document.getElementById("acumcods").value = recoje;
}

// Imagen predefinida en Select en caso de no existir la imagen que se requiera 
function noImagen(idImg)
{
	document.getElementById(idImg).src = "http://www.efutgol.com/images/sinFoto-gra.jpg";
}


function seleccionaPck(idPack)
{	
	var divId = idPack.split("_");
	if(document.getElementById(idPack).checked)	
		document.getElementById("txtSel_" + divId[1]).value = "si";
	else
		document.getElementById("txtSel_" + divId[1]).value = "no";
}


