
function borrandodatos(){
       if (confirm ("¿ Deseas eleminar esta fotografia? "))
	     { return true ;}
		 else 
		 { return false ;}
		 }		   
	   

		 function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function borrandodatos(){
       if (confirm ("¿ Deseas eliminar estos datos? "))
	     { return true ;}
		 else 
		 { return false ;}
		 }		   
function cambia(archivo) {
           if (archivo != "") {
             document.location=archivo;
                    } }

function calcula()
 {
   var i
    for (i=0 ;i< formulario.importe.length; i++){
       if (document.formulario.importe[i].checked)
	           break;
    }
    total1 = formulario.importe[i].value
    posicier = formulario.dni.value ;
 	posicion= (posicier * total1 ) * 1.15;
    formulario.let.value = posicion;
	coloresnuevos.dni.value=formulario.dni.value ;
	coloresnuevos.importe.value=total1 ;
  }
  
  
function buyItem(newItem, newPrice, newQuantity) {
		if (newQuantity <= 0) {
			rc = alert('La cantidad ingresada es incorrecta');
			return false;
		}
		if (confirm('¿Agregar '+newQuantity+' '+newItem+' al carrito?')) {
			index = document.cookie.indexOf("TheBasket");
			countbegin = (document.cookie.indexOf("=", index) + 1);
        		countend = document.cookie.indexOf(";", index);
	        	if (countend == -1) {
        	    		countend = document.cookie.length;
        		}
	                document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+","+newPrice+"#"+newQuantity+"]";
		}
		return true;
	}

	function resetShoppingBasket() {
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket=.";
	}

				
function alterError(value) {
		if (value<=0.99) {
			newPounds = '0';
		} else {
			newPounds = parseInt(value);
		}
		newPence = parseInt((value+.0008 - newPounds)* 100);
		if (eval(newPence) <= 9) newPence='0'+newPence;
		newString = newPounds + '.' + newPence;
		return (newString);
	}
function showItems() {
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<form><table border="1" cellspacing="1" width="540" bgcolor="f5f5f5" class="td">');

document.writeln('<TR><TD width="250"><b>Producto</b></TD><TD width="80" align="right"><b>Cantidad</b></TD><TD width="120" align="right"><b>Costo x unidad</b></TD><td width="100" align="right"><b>Costo total</b><TD width="90">&nbsp;</TD></TR>');
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				var tax = itemtotal / 100 * (20 - 0);
    				tax = Math.floor(tax * 100)/100
				totprice = totprice + itemtotal + tax;
				itemlist=itemlist+1;
document.writeln('<tr><td>'+theitem+'</td><td align=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td align=right>'+alterError(itemtotal)+'</td><td align=center><input TYPE="button" NAME="remove" VALUE="Quitar" onclick="javascript:removeItem('+itemlist+')"></td></tr>');
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
			}
		}

		document.writeln('<tr><td colspan=3><b>Gastos de Envio</b></td><td align=right>20%</td><td>&nbsp;</td></tr>');

		document.writeln('<tr><td colspan=3><b>Total</b></td><td align=right>MNX '+alterError(totprice)+'</td><td>&nbsp;</td></tr>');
		document.writeln('</TABLE>');
	}

function removeItem(itemno) {
		newItemList = null;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				theitem = fulllist.substring(itemstart, itemend);
				itemlist=itemlist+1;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
				}
			}
		}
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket="+newItemList;
		top.location = "estado.php";
	}

function clearBasket() {
		if (confirm('¿Confirma que desea reestablecer el carrito?')) {
			index = document.cookie.indexOf("TheBasket");
			document.cookie="TheBasket=.";
			top.location = "estado.php";
		}
	}
	
					
function Enviar(form) {
for (i = 0; i < form.elements.length; i++) {
if (form.elements[i].type == "text" && form.elements[i].value == "") {
alert("Por favor complete todos los campos del formulario"); form.elements[i].focus();
return false; }
}
form.submit();
}

function Total() {
		document.writeln(alterError(totprice));
	}

	
function bderecho(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
alert(" El boton derecho del raton no funciona ");
return false;
}
return true;
}