optimize this code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
function ponCerosIzq(n,r){var i=new String("");for(null==r&&(r=4);r>n.length;r--)i+="0";return i+n}function pasarMayusculas(n){var r="",t=n.split("");for(i=0;i<=t.length-1;i++)t[i]=t[i].toUpperCase(),r+=t[i];return r}function aleatorio(n,r){return numPosibilidades=r-n,aleat=Math.random()*numPosibilidades,aleat=Math.floor(aleat),parseInt(n)+aleat}function cogeBit(n,r){return n.charAt(r)}function ponBit(n,r,i){return r>n.length-1?n:n.substr(0,r)+i+n.substr(r+1)}function Hex2Dec(n){return parseInt("0x"+n,16).toString(10)}function Bin2Dec(n){return parseInt(n,2).toString(10)}function Dec2Bin(n){return n<1?"":Dec2Bin((n-n%2)/2)+n%2}function Hex2Bin(n){var r="",t="";t=(t=n).replace(/\s/g,"");for(i=0;i<=t.length-1;i++)r+=ponCerosIzq(Math.base(t[i],2,16),4);return r=r.replace(/\d{4}/g,"$& ").replace(/\s$/,"")}function Bin2Hex(n){var r="",t="",t=n.replace(/\s/g,"");for(binSinEspaciosArray=t.split(""),i=0;i<=t.length-1;i+=4)r+=parseInt(binSinEspaciosArray[i]+binSinEspaciosArray[i+1]+binSinEspaciosArray[i+2]+binSinEspaciosArray[i+3],2).toString(16);return r=pasarMayusculas(r)}Math.base=function(n,r,i){return parseInt(n,i||10).toString(r)};
</script>

<script type="text/javascript">

function arrange_crc(crc){var x=cogeBit(crc,0);var y=cogeBit(crc,8);var x2="0";var y2="0";if(x=="0"){if(y=="0"){x2="0";y2="1"}else{x2="0";y2="1"}}else{if(y=="0"){x2="0" You should write your response with 700 or more words.
user