function preloadImages()
{
	if (document.images)
	{
		var name = '';
		for(var i = 0; i < document.images.length;i++)
		{

		 var img = new Image();
		 img.src = document.images[i].src;
		 document.images[i].src = img.src;
		}
	}
}

 function findPosX(obj)
 {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
 }

 function findPosY(obj)
 {
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	window.status = printstring;
	return curtop;
 }

function carga()
{
	var x = document.getElementById('financiacion1');
	var xy = findPosX(document.getElementById('INF'));
 	var yx = findPosY(document.getElementById('INF'));
 	x = x.style;
 	x.left = xy-3;
 	x.top = yx + 40;
	x.display = '';
}

function printer(numero)
{
  var x = screen.availWidth -9;
  var y = screen.availHeight - 29;

  window.open('./informe.php?id='+numero,'fullscreen','maximize=yes,fullscreen=no,toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+x+',height='+y+',top=0,left=0');
}

function printer2(numero)
{
  var x = screen.availWidth -9;
  var y = screen.availHeight - 29;

  window.open('./informeacc.php?id='+numero,'fullscreen','maximize=yes,fullscreen=no,toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+x+',height='+y+',top=0,left=0');
}

function winIMG(URL,POS)
{
 window.open('img.php?id='+URL+'&pos='+POS,'Imagen','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1,height=1,left = 262,top = 20');
}

function borrar(SID,id)
{
	if(id != '')
	{
	 var aceptar = confirm("¿ Estas seguro que quieres borrarla ?");
	 if(aceptar) window.location.href="delete.php?SID="+SID+"&id="+id;
	}
	else
	{
	 var aceptar = confirm("¿ Estas seguro que quieres borrar las noticias seleccionadas ?");
	 if(aceptar) document.borrado.submit();
	}
}

function Show(elid)
{
	if(elid == true)
	{
	 document.getElementById('marca').style.display = 'table-row';
	 document.getElementById('modelo').style.display = 'table-row';
	 document.getElementById('version').style.display = 'table-row';
	 document.getElementById('ano').style.display = 'table-row';
	}
	else
	{
	 document.getElementById('marca').style.display = 'none';
	 document.getElementById('modelo').style.display = 'none';
	 document.getElementById('version').style.display = 'none';
	 document.getElementById('ano').style.display = 'none';
	}
}

function popUP()
{
 window.open('help.html','Ayuda','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=225,left = 262,top = 20');
}

function error(page)
{
 window.open('./html/'+page+'.html','Error','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=225,left = 262,top = 20');
}

function validar()
{
	if(document.login.usuario.value == '')
	{
		return false;
	}
	else if(document.login.pw.value == '')
	{
		return false;
	}
	else
	{
		return true;
	}
}

function UsrOnl(SID)
{
	window.open('online.php?SID='+SID,'Online','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=275,left = 600,top = 0');
}

function estado()
{
	document.comprueba.aceptar.value = 1;
}

var est = 0;
function Check(Num)
{
	var i = 0;
	while(i < Num)
	{
		if(est == 0)
		{
			document.getElementById(i).checked = true;
		}
		else
		{
			document.getElementById(i).checked = false;
		}
		i++;
	}

	if(est == 0)
	{
		est = 1;
		document.getElementById('todos').innerHTML = '[ Deseleccionar Todos ]';

	}
	else
	{
		est = 0;
		document.getElementById('todos').innerHTML = '[ Seleccionar Todos ]';
	}
}

function SelEl(num)
{
	document.contacto.depart.selectedIndex = num;
	document.contacto.nombre.focus();
}

function Img(url)
{
  window.open('./img/'+url,'Screens','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=780,left = 262,top = 20');
}

function mapa()
{
  window.open('mapa.php','Mapa','type=fullWindow,fullscreen=yes,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,left=600,top=600');
}

function muestramenu()
{
	var x,y = 0;
	var este = document.getElementById('accesorios');
	x = findPosX(este)-2;
	y = findPosY(este) + este.offsetHeight;
	var div = document.getElementById('opcionesMenu');
	div.style.display = '';
	div.style.top = y+'px';
	div.style.left = x+'px';
}

function ocultamenu()
{
	var div = document.getElementById('opcionesMenu');
	div.style.display = 'none';
}

function precarga()
{
 var vH=0;
 var not = document.getElementById('lasNoticias');
 var ult = document.getElementById('ultimosPro');
 vH = not.offsetHeight + ult.offsetHeight;

 var cest = document.getElementById('laCesta');
 var ofert = document.getElementById('lasOfertas');
 vH = vH - cest.offsetHeight - ofert.offsetHeight;

 if(vH < 0)
 {
 	ult.style.height = ult.offsetHeight + (-1 * (vH + 2)) + 'px';
 }
 else
 {
 	ofert.style.height = ofert.offsetHeight + vH + 'px';
 }
}

function addArticulo()
{
	if(document.carro.tallas.selectedIndex == 0 )
	{
		alert('Atención: Seleccione primero una talla.');
		document.carro.tallas.focus();
	}
	else document.carro.submit();
}

function muestraOtro(x,s2)
{
	if(x.value == '-1')
	{
		var x2 = document.getElementById(s2);
		x2.style.display = '';
		x2.focus();
	}
	else
	{
		var x2 = document.getElementById(s2);
		x2.style.display = 'none';
		x.focus;
	}
}