/* * Version : 1.0 (Last Modified by Nojima, 2004-12-04) */ var weight = { "H":1.007947, "He":4.0026022, "Li":6.9412, "Be":9.0121823, "B":10.8117, "C":12.01078, "N":14.00672, "O":15.99943, "F":18.99840325, "Ne":20.17976, "Na":22.9897702, "Mg":24.30506, "Al":26.9815382, "Si":28.08553, "P":30.9737612, "S":32.0655, "Cl":35.4532, "Ar":39.9481, "K":39.09831, "Ca":40.0784, "Sc":44.9559108, "Ti":47.8671, "V":50.94151, "Cr":51.99616, "Mn":54.9380499, "Fe":55.8452, "Co":58.9332009, "Ni":58.69342, "Cu":63.5463, "Zn":65.4094, "Ga":69.7231, "Ge":72.641, "As":74.921602, "Se":78.963, "Br":79.9041, "Kr":83.7982, "Rb":85.46783, "Sr":87.621, "Y":88.905852, "Zr":91.2242, "Nb":92.906382, "Mo":95.942, "Tc":98, "Ru":101.072, "Rh":102.905502, "Pd":106.421, "Ag":107.86822, "Cd":112.4118, "In":114.8183, "Sn":118.7107, "Sb":121.7601, "Te":127.603, "I":126.904473, "Xe":131.2936, "Cs":132.905452, "Ba":137.3277, "La":138.90552, "Ce":140.1161, "Pr":140.907652, "Nd":144.243, "Pm":145, "Sm":150.363, "Eu":151.9641, "Gd":157.253, "Tb":158.925342, "Dy":162.5001, "Ho":164.930322, "Er":167.2593, "Tm":168.934212, "Yb":173.043, "Lu":174.9671, "Hf":178.492, "Ta":180.94791, "W":183.841, "Re":186.2071, "Os":190.233, "Ir":192.2173, "Pt":195.0782, "Au":196.966552, "Hg":200.592, "Tl":204.38332, "Pb":207.21, "Bi":208.980382, "Po":209, "At":210, "Rn":222, "Fr":223, "Ra":226, "Ac":227, "Th":232.03811, "Pa":231.035882, "U":238.028913, "Np":237, "Pu":244, "Am":243, "Cm":247, "Bk":247, "Cf":251, "Es":252, "Fm":257, "Md":258, "No":259, "Lr":262, "Rf":261, "Db":262, "Sg":266, "Bh":264, "Hs":277, "Mt":268, "Ds":281, "Rg":272,/*###*/ "D":2, "T":3, "Me":15.03462, "Et":29.06130, "Ph":91.13109, "Bz":105.1146 } function chemformMatch(str){ var cmp; if(str.match(/[^a-zA-Z\d\(\)\{\}\[\]\^\+\-\u30FB\uFF65\*]/)) return false; if(str.match(/[^A-Z][a-z]/)) return false; if(str.match(/[^a-zA-Z\d\)\}\^\u30FB\uFF65\*]\d|\D0/)) return false; if(str.match(/[^a-zA-Z\d\)\}\]]\^|\^[^1-9]|\D[\+\-]|\^\d+[^\d\+\-]|[^\d\^]\d*[\+\-]/)) return false; if(str.match(/\(\)|\{\}|\[\]/)) return false; if(str.match(/[\u30FB\uFF65\*]{2}/)) return false; if(str.charAt(0).match(/[a-z\^\+\-\u30FB\uFF65\*]|\d+[\+\-]/)) return false; while(true){ cmp = str; str = str.replace(/\([^\(\)\{\}\[\]\u30FB\uFF65\*]*\)/g, ""); str = str.replace(/\{[^\(\)\{\}\[\]\u30FB\uFF65\*]*\}/g, ""); str = str.replace(/\[[^\(\)\{\}\[\]\u30FB\uFF65\*]*\]/g, ""); if(cmp == str) break; } return str.match(/[\(\)\{\}\[\]]/) ? false : true; } function calculateWeight(str){ var i, j, k, n, chr, num_l; var num = new Array(); var sum = 0; str = str.replace(/\^\d+[\+\-]|[\[\]]/g, ""); str = str.split(/[\u30FB\uFF65\*]/); for(i = 0; i < str.length; i++){ if(str[i].charAt(0).match(/[1-9]/)){ num[0] = parseInt(str[i].match(/[1-9]\d*/)); } else num[0] = 1; num_l = 1; n = 1; //元素や原子団の記号の直後にある数 for(j = str[i].length - 1; j >= 0; j -= 1){ chr = str[i].charAt(j); if(chr.match(/[A-Z]/)){ for(k = 0; k < num_l; k++){ n *= num[k]; } k = weight[chr]; if(!k) return false; sum += n * k; n = 1; } else if(chr.match(/[a-z]/)){ for(k = 0; k < num_l; k++){ n *= num[k]; } j -= 1; k = weight[str[i].charAt(j) + chr]; if(!k) return false; sum += n * k; n = 1; } else if(chr.match(/\d/)){ k = j; while(str[i].charAt(k - 1).match(/\d/)) k -= 1; n = parseInt(str[i].substring(k, j + 1)); j = k; } else if(chr.match(/[\)\}]/)){ num[num_l] = n; num_l++; n = 1; } else if(chr.match(/[\(\{]/)){ num_l -= 1; n = 1; } else { return false; } } } return Math.round(sum * 100000000) / 100000000; }