/*******************************************************************
半角変換
http://www.losttechnology.jp/Tips/inputhankaku.html
********************************************************************/
function chkCode(id) {
	var work='';
	for(var lp=0; lp<id.value.length; lp++) {
		var unicode = id.value.charCodeAt(lp);
		if((0xff0f<unicode) && (unicode<0xff1a)) {
			work += String.fromCharCode(unicode-0xfee0);
		}else if((0xff20<unicode) && (unicode<0xff3b)) {
			work += String.fromCharCode(unicode-0xfee0);
		}else if ((0xff40<unicode) && (unicode<0xff5b)) {
			work += String.fromCharCode(unicode-0xfee0);
		}else {
			work += String.fromCharCode(unicode);
		}
	}
	id.value = work;
}
/*******************************************************************
３桁
********************************************************************/
function checkSum(i) {
	i = Math.floor(i);
	return String(i).replace(/[0-9]+/gm, function(chr) {
		var k, cnt=0, n="";
		for(k=chr.length-1; k>=0; k--) {
			n = chr.charAt(k) + n;
			cnt++;
			if(!(cnt%3) && k) {
				n = "," + n;
			}
		}
		return n;
	});
}
/*******************************************************************
定期預金ランキング
********************************************************************/
var tdata = function() {
	var data = new Object(), data_base, maxnum, maxnum_base, d_base;
	var idx = 'teiki_parts_mabank';
	var qobj = {
'size':12, 
'clrtd':'000000', 
'bgtd':'ffffff', 
'border':'aaaaaa', 
'clrh1':'ffffff', 
'bgh1':'0000ff', 
'clrth':'333333', 
'bgth':'00ffff'
};
	var xary = ['総合','大手銀行','銀行','その他']; 
	return {
		load:function() {
			var hObj = createXMLHttpRequest();
			if(hObj) {
				hObj.open("GET", "./teiki.json", true);
				hObj.onreadystatechange = function() { 
					if(hObj.readyState==4) {
						var t = hObj.responseText.replace('teiki.jsonTeiki', '');
						data_base = eval("(" + t + ")");
						maxnum = maxnum_base = data_base.item[0].count;
						d_base = data_base.item[0].date;
						data_base.item.shift();
						return;
					}
				}
				hObj.send(null);
			}
			tdata.navi(0);
		},
		//
		echodata:function(num, sel) {
			for(var i in data_base) {
				data[i] = data_base[i];
			}
			data.item.sort(function(b, a) {return a.rate-b.rate});
			data.item = tdata.search(num, sel);
			var bodys = new Array();
			for(var i=0; i<maxnum; i++) {
				bodys.push('<tr><td class="b"><a href="' + data.item[i].url + '" class="out">' + data.item[i].bank + data.item[i].subs + '</a><div>' + data.item[i].title + '</div></td><td style="text-align:right;">' + data.item[i].rate + '%<div class="s">(' + checkSum(data.item[i].rate*1000000/100*0.8) + '円)</div></td><td>' + data.item[i].plus.replace(/\&quot;/gm, '') + '</td></tr>');
			}
			var th = '<tr><th>銀行名・商品名</th><th title="下段の（）内の金額は１年間預けた場合の１００万円あたりの受取利息（税引き後）です。目安としてご利用ください。">*年利</th><th style="width:50%;">備考</th></tr>';
			$("teiki_data").innerHTML = th + bodys.join("\n") + th;
			tdata.navi(sel);
		},
		search:function(num, sel) {
			if(!sel || sel==0) {
				maxnum = maxnum_base;
				return data.item;
			}else {
				var datas = new Object(), i1=0, cat;
				for(var i in data.item) {
					if(data.item[i].category==xary[sel]) {
						datas[i1] = data.item[i];
						i1++;
					}
				}
				maxnum = i1;
				return datas;
			}
		},
		navi:function(sel) {
			var body = new Array();
			for(var i=0; i<xary.length; i++) {
				body.push((i==sel) ? '<b style="padding:1px; border-top:1px solid #' + qobj.border + ';border-left:1px solid #' + qobj.border + ';border-right:1px solid #' + qobj.border + '; background:#' + qobj.bgtd + ';">' + xary[i] + '</b>' : '<a href="' + document.URL + '#teiki_tab" onclick="tdata.echodata(0, ' + i + ');" style="padding:1px; border-top:1px solid #' + qobj.border + ';border-left:1px solid #' + qobj.border + ';border-right:1px solid #' + qobj.border + ';">' + xary[i] + '</a>');
			}
			$('teiki_tab').innerHTML = body.join(' ');
			$('teiki_tab2').innerHTML = body.join(' ');
		}
	};
}();
/*******************************************************************
トップページ：スライドショー
http://pcq.furu.org/thread.php?thread=107567
http://allabout.co.jp/internet/hpcreate/closeup/CU20070717A/
********************************************************************/
var slide = function() {
	var imgnum = 0;
	var ie = document.all;
	var ary, len, timer, fade_cnt, fade_timer;
	return {
		fadein:function(id, jd) {
			if(id) {
				if(jd!=1) {
					slide.stop();
				}
				fade_cnt = 0;
			}
			$('a_head_img').style.opacity = $('sub_head').style.opacity = fade_cnt*0.01;
			if(ie) {
				$('a_head_img').style.filter = $('sub_head').style.filter = 'alpha(opacity=' + fade_cnt + ')';
			}
			if(fade_cnt==0) {
				name = $(id + '_img').alt;
				$('a_head_img').innerHTML = '<a href="./category/' + id + '/" title="' + name + '"><img src="./img/cat_' + id + '.jpg" alt="' + name + '" /></a>';
				$('sub_head').innerHTML = name;
			}else if(fade_cnt>=100) {
				return;
			}
			fade_cnt += 3;
			fade_timer = setTimeout("slide.fadein()", 1);
		},
		load:function(ids) {
			slide.stop();
			ary = ids.split(',');
			len = ary.length;
			timer = setInterval("slide.show()", 4000);
		},
		show:function() {
			if(imgnum>len) {
				imgnum = 0;
			}
			slide.fadein(ary[imgnum], 1);
			imgnum++;
		},
		stop:function() {
			clearInterval(timer);
			clearInterval(fade_timer);
		}
	};
}();
/*******************************************************************
display "block" or "none"
********************************************************************/
function hides(id) {
	var a = $(id).style;
	a.display = (a.display=="none") ? "block" : "none";
}
function hideShow(id, jd) {
	var a = $(id).style;
	a.display = ((a.display=="none" && jd!=2) || jd==1) ? "block" : "none";
	if(id=='main_plus') {
		$(id + '1').style.display = "none";
	}else if(id=='repo_body') {
		$('step_navi_').style.display = "none";
	}else if(id=='re_form') {
		$('re_form_').style.display = "none";
	}
}
function hideShowRadio(id, i) {
	var a = $(id).style;
	a.display = (i==1) ? "block" : "none";
	if((id=='addFamily0' || id=='addFamily_0') && $("kyouiku_jd")) {
		$("kyouiku_jd").style.display = (i==1 || $("family02").checked==true || $("family_02").checked==true) ? "block" : "none";
	}
}
function hideStep(id, sum) {
	if($('repo_body')) {
		$('repo_body').style.display = "block";
	}
	var b_n = (id=='open') ? "block" : "none";
	for(var i=0; i<=sum; i++) {
		if($('step' + i)) {
			$('step' + i).style.display = b_n;
		}
	}
	if($('step' + id)) {
		$('step' + id).style.display = "block";
	}
}
/*******************************************************************
メッセージフォーム
********************************************************************/
var msg;
function setbg(e, id) {
	msg = e.defaultValue;
	var color = (!id) ? '#e5fff3' : '#fafafa';
	$("email").style.background = color;
	if(!id && e.value==msg) {
		$("email").value = '';
		$("email").style.color = '#191919';
	}else if(id && e.value=='') {
		$("email").value = msg;
		$("email").style.color = '#666';
	}
	if(!$("message_id_").innerHTML) {
		$("message_id_").innerHTML = '<input name="mail" id="mail" value="' + $("message_body").value + '" type="hidden" />';
	}
}
function setformsend() {
	var hObj = createXMLHttpRequest();
	var txt = $("email").value;
	var mail = ($("mail")) ? $("mail").value : '';
	if(hObj && txt && msg && txt!=msg && mail) {
		$("message_form").style.display = 'none';
		$("message_form_").innerHTML = '<img src="./img/load.gif" alt="load" />';
		var ds = "email=" + encodeURI(txt) + "&id=js&mail=" + mail;
		var fUrl = "./form.html";
		hObj.open("POST", fUrl, true);
		hObj.onreadystatechange = function() { 
			if(hObj.readyState==4) {
				t = hObj.responseText;
				if(!t) {
					return;
				}
				data = eval("(" + t + ")");
				if(data) {
 					$("post_form").innerHTML = "<p>受け付けました。ありがとうございました。</p>" + data;
				}
 			}
		}
		hObj.setRequestHeader("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
		hObj.send(ds);
	}
}
function showForm() {
	hideShow('forms', 1);
	$('re_sim_x').style.display = "none";
}
/*******************************************************************
無料ソフト全般 http://ma-bank.net/tool/
********************************************************************/
function tool_all_check(n, sum) {
	sum = (sum>0) ? sum : 3;
	for(var i=0; i<sum; i++) {
		$('yen1' + i).innerHTML = $('yen' + n).value;
	}
}
var AddDebtJd;
function tool_all_debt(id) {
	if($("addDebt0")) {
		$("addDebt0").style.display = 'block';
	}
	if(id==0 && AddDebtJd==1) {
		return;
	}
	$('addDebt' + id).innerHTML = [
'<dl class="tables" id="addDebtKz' + id + '">',
'<dt>現在の借入残高</dt>',
'<dd>',
'<input name="debt[' + id + '][val]" class="w_val" />万円 ',
'<select name="debt[' + id + '][per]"><option>金利</option>' + tool_all_per() + '</select> ',
'<select name="debt[' + id + '][nen]"><option>返済完了年</option>' + tool_all_years(35) + '</select> ',
'<a href="javascript:void(0);" onclick="tool_all_debt_del(' + id + ')" onkeypress="tool_all_debt_del(' + id + ')">削除する</a>',
'</dd>',
'</dl>',
'<div id="addDebt' + (id + 1) + '"><a href="javascript:void(0);" onclick="tool_all_debt(' + (id + 1) + ')" onkeypress="tool_all_debt(' + (id + 1) + ')" class="ya">借入金を追加する</a></div>'
].join("\n");
	AddDebtJd = 1;
}
function tool_all_debt_del(id) {
	$('addDebtKz' + id).innerHTML = '';
	if(id==0) {
		AddDebtJd = '';
	}
}
function tool_all_radio(id, i) {
	if($(id + 'y')) {
		$(id + 'y').disabled = (i==1) ? false : true;
	}
}
function tool_all_year(id) {
	if(id=='_') {
		return tool_all_years();
	}
	var d = new Date();
	var str = new Array(), year = d.getFullYear();
	for(var i=0; i<=70; i++) {
		var add = (i!=70) ? '' : '～';
		str.push('<option value="' + (year - i) + '">' + add + (year - i) + '年 （' + i + '才' + add + '）</option>');
	}
	return str.join("\n");
}
function tool_all_years(num) {
	var d = new Date();
	var str = new Array(), year = d.getFullYear();
	var x = (num) ? [1, num] : [0, 30];
	for(var i=x[0]; i<=x[1]; i++) {
		str.push('<option value="' + (year + i) + '">' + (year + i) + '年 （' + i + '年後）</option>');
	}
	return str.join("\n");
}
function tool_all_per() {
	var str = new Array();
	for(var i=1; i<=30; i++) {
		var is = tool_all_per_dot(i);
		str.push('<option value="' + is + '">' + is + '％</option>');
	}
	return str.join("\n");
}
function tool_all_per_dot(v) {
	return (v%2==1) ? v / 2 : (v / 2) + '.0';
}
var AddFamilyJd, AddFamilyJd_;
function tool_all_family(id) {
	if($("addFamily0")) {
		$("addFamily0").style.display = 'block';
	}
	if($("kyouiku_jd")) {
		$("kyouiku_jd").style.display = 'block';
	}
	if(id==0 && AddFamilyJd==1) {
		return;
	}
	$('addFamily' + id).innerHTML = [
'<dl class="tables" id="addFamilyKz' + id + '">',
'<dt>誕生年</dt>',
'<dd><select name="family[' + id + ']">' + tool_all_year() + '</select> <a href="javascript:void(0);" onclick="tool_all_family_del(' + id + ')" onkeypress="tool_all_family_del(' + id + ')">削除する</a></dd>',
'</dl>',
'<div id="addFamily' + (id + 1) + '"><a href="javascript:void(0);" onclick="tool_all_family(' + (id + 1) + ')" onkeypress="tool_all_family(' + (id + 1) + ')" class="ya">扶養親族を追加する</a></div>'
].join("\n");
	AddFamilyJd = 1;
}
function tool_all_family_del(id) {
	$('addFamilyKz' + id).innerHTML = '';
	if(id==0) {
		AddFamilyJd = '';
	}
}
function tool_all_family_(id) {
	if($("addFamily_0")) {
		$("addFamily_0").style.display = 'block';
	}
	if($("kyouiku_jd")) {
		$("kyouiku_jd").style.display = 'block';
	}
	if(id==0 && AddFamilyJd_==1) {
		return;
	}
	$('addFamily_' + id).innerHTML = [
'<dl class="tables" id="addFamilyKz_' + id + '">',
'<dt>出産計画年</dt>',
'<dd><select name="family_[' + id + ']">' + tool_all_years() + '</select> <a href="javascript:void(0);" onclick="tool_all_family_del_(' + id + ')" onkeypress="tool_all_family_del_(' + id + ')">削除する</a></dd>',
'</dl>',
'<div id="addFamily_' + (id + 1) + '"><a href="javascript:void(0);" onclick="tool_all_family_(' + (id + 1) + ')" onkeypress="tool_all_family_(' + (id + 1) + ')" class="ya">出産計画を追加する</a></div>'
].join("\n");
	AddFamilyJd_ = 1;
}
function tool_all_family_del_(id) {
	$('addFamilyKz_' + id).innerHTML = '';
	if(id==0) {
		AddFamilyJd_ = '';
	}
}
/*******************************************************************
経営計画ソフト http://ma-bank.net/tool/business/
********************************************************************/
function tool_business_input(ib, is) {
	chkCode(ib);
	var vs = 0;
	var val = Math.ceil($("price").value);
	var id = (val>0) ? is : 99;
	for(var i=2; i<=6; i++) {
		if($("per_" + i) && $("v_per_" + i)) {
			vs += Math.ceil($("per_" + i).value);
			$("v_per_" + i).innerHTML = '（' + checkSum(val * $("per_" + i).value / 100) + '万円）';
			$("per_" + i).disabled = (id!=99) ? false : true;
			if(id==99) {
				$("v_per_" + i).innerHTML = '';
			}
		}
	}
	$("p_id").innerHTML = (id!=99) ? '（' + checkSum(vs * val / 100) + '万円）' : '';
	$("p_per").innerHTML = (id!=99) ? vs : 0;
	$("v_per_1").innerHTML = (id!=99) ? '（' + checkSum(val * $("per_1").value / 100) + '万円）' : '';
	$("v_pers").innerHTML = (id!=99) ? $("per_1").value : 0;
	$("s_per_1").innerHTML = (id!=99) ? '（' + checkSum(val) + '万円）' : '';
}
/*******************************************************************
ＤＣＦ法の計算式 http://ma-bank.net/tool/dcf/
********************************************************************/
function tool_dcf_check(txt, n, jd) {
	if(jd==1) {
		$(txt).value = $('dcf_2').value*n/100;
	}else if(jd==2) {
		$(txt).value = $('dcf_0').value*n;
	}else {
		$(txt).value = (n) ? n : '';
	}
	$(txt).background = '#fee';
}
function tool_dcf_reset() {
	for(var i=0; i<7; i++) {
		$('dcf_' + i).value = "";
		if(i<4) {
			$('dcf_a' + i).checked = true;
		}
	}
	$('yen1').checked = true;
	tool_dcf_check(1);
}
function tool_dcf_input(ib, is) {
	chkCode(ib);
	var val = Math.ceil($("dcf_0").value);
	var id = (val>0) ? is : 99;
	for(var i=1; i<=6; i++) {
		$("dcf_" + i).disabled = (id!=99) ? false : true;
	}
	var ary = ['dcf_a0', 'co21', 'co22', 'co23', 'dcf_a3', 've280', 've2100', 'dcf_a2', 'n205', 'n210', 'n220', 'dcf_a1', 'r25', 'r210', 'r215' ,'dcf_a4', 'gv10', 'gv20'];
	for(var i=0; i<ary.length; i++) {
		$(ary[i]).disabled = (id!=99) ? false : true;
	}
	$("tool_r").style.color = (id!=99) ? '#191919' : '#777';
}
/*******************************************************************
ＦＸ投資ソフト http://ma-bank.net/tool/fx/
********************************************************************/
function tool_fx_input() {
	var rev = '';
	var sum = $('rate1').value*$('tan').value*$('kazu').value;
	var val = $('val').value;
	if(sum && val) {
		rev = Math.round((sum/val)*10)/10;
		var s = ($('fx_1').value>rev) ? ['', ''] : ['<strong class="red">', '<strong>'];
		rev = s[0] + '　（*レバレッジ: ' + Math.round(rev) + '倍）' + s[1];
	}
	$('v_tori').innerHTML = '＝ ' + checkSum(sum) + '円';
	$('v_val').innerHTML = checkSum(val) + '円' + rev;
}
function tool_fx_rate(r) {
	$('rate1').value = r;
	$('rate2').value = r;
	tool_fx_input();
}
function tool_fx_rates(id, pm) {
	var val = $('rate' + id).value - 0;
	$('rate' + id).value = (pm==1) ? val - 1 : val - (-1);
	if(id==1) {
		tool_fx_input();
	}
}
/*******************************************************************
投資不動産（収益物件）ソフト http://ma-bank.net/tool/realestate/
********************************************************************/
function tool_realestate_input(ib, is) {
	chkCode(ib);
	var val = Math.ceil($("price").value);
	var id = (val>0) ? is : 99;
	if(!id || id==5) {
		$("v_per5").innerHTML = '（' + checkSum(val * $("per_5").value / 100) + '万円）';
	}
	if(!id || id==1) {
		$("v_per1").innerHTML = '（' + checkSum(val * $("per_1").value / 100) + '万円）';
	}
	if(!id || id==4) {
		$("v_per4").innerHTML = '（*借入金' + checkSum(val * $("per_4").value / 100) + '万円）';
	}
	if(!id || id==5) {
		$("v_per5").innerHTML = '（' + checkSum(val * $("per_5").value / 100) + '万円）';
	}
	if(!id || id==10) {
		$("v_per0").innerHTML = '（*年間想定賃料' + checkSum(val * $("per_0").value / 100 * $("per_6").value / 100) + '万円）';
	}
	for(var i=0; i<10; i++) {
		if($("per_" + i)) {
			$("per_" + i).disabled = (id!=99) ? false : true;
			if(id==99) {
				$("v_per" + i).innerHTML = '';
			}
		}
	}
	$("tool_r").style.color = (id!=99) ? '#191919' : '#777';
}
/*******************************************************************
決算書の読み方 http://ma-bank.net/bsplcf/
a1: ["circle", "ltitle", "title", "list"],
********************************************************************/
var ia = {
	a1: ["title", "list"],
	a2: ["140", "201", "301"],
	a3: ["はじめに", "貸借対照表", "損益計算書", "キャッシュフロー計算書", "結論"]
};
var c1c=getCode(), kid1="kessann", kid2="kessann2";
var n1c = "<p class=\"s12s\">※財務諸表の数値等は実際のものと違う場合があるので必ず原本を確認して下さい。Ｕチャート分析は決算書の概略をつかむためのものです。より詳細な財務分析は有価証券報告書等を元に行なって下さい。</p>";
/*******************************************************************
決算書の読み方: 会社コード取得
********************************************************************/
function getCode() {
	var murl = document.URL.split("/");
	return murl[murl.length-2];
}
/*******************************************************************
決算書の読み方: データファイルの選択
********************************************************************/
function loadFirst3(n) {
	for(var i=0; i<ia["a2"].length; i++) {
		$("div" + ia["a2"][i]).style.display = "block";
	}
	mDisp(n);
	if(!n) {
		$(kid2).innerHTML = pNext(1);
		return mDispTop(0);
	}
	switch(n) {
	case 4 :
		for(i=0; i<ia["a2"].length; i++) {
			if($("list" + ia["a2"][i] + c1c)) {
				$("list" + ia["a2"][i] + c1c).style.display = "none";
			}
		}
		break;
	default :
		for(i=0; i<ia["a2"].length; i++) {
			$("div" + ia["a2"][i]).style.display = "none";
		}
		$("div" + ia["a2"][n-1]).style.display = "block";
	}
	mDispTop(n);
	loadFile("./bsplcfs/xml/?id=text&cx=" + c1c, n);
	return '';
}
/*******************************************************************
決算書の読み方: 次へ進む
********************************************************************/
function pNext(n) {
	return "<a href=\"" + document.URL + "#a_bodys\" onclick=\"return loadFirst3(" + n + ");\" onkeypress=\"return loadFirst3(" + n + ");\" class=\"ya\"><strong>次へ進む</strong></a>\n";
}
/*******************************************************************
決算書の読み方: 表示
********************************************************************/
function pDisp(data, n) {
	var p = (n>0 && n<4) ? "\n　" + pNext(n+1) : "";
	return decodeURIComponent(data["item"]["a" + n]) + p;
}
/*******************************************************************
決算書の読み方: トップ表示
********************************************************************/
function mDispTop(n) {
	var u = "「Ｕチャート」";
	var l = "５期分の決算書（貸借対照表・損益計算書・キャッシュフロー計算書）です。全体像をつかみやすくするために、簡略化して表示しています。<br />\n　" + pNext(1) + "\n";
	var m = u + "を使って、" + ia["a3"][n] + "の概略を分析したところです。";
	var x = [l, m, m, m, u + "を使って、決算書の概略を分析した結論です。"];
	$(kid1).innerHTML = (n>=0 && n<5) ? "\n※" + x[n] : "";
}
/*******************************************************************
決算書の読み方: ナビ表示
********************************************************************/
function mDisp(n) {
	var t="<ul class=\"enter3\">\n";
	for(var i=0; i<ia["a3"].length; i++) {
		var oh = (i) ? " class=\"ya\"" : "";
		if(n==i || (!n && !i)) {
			t += "<li class=\"flag\">" + (i+1) + ". " + ia["a3"][i] + "</li>\n";
		}else {
			t += "<li><a href=\"" + document.URL + "#a_bodys\" onclick=\"return loadFirst3(" + i + ");\" onkeypress=\"return loadFirst3(" + i + ");\"" + oh + ">" + (i+1) + ". " + ia["a3"][i] + "</a></li>\n";
		}
	}
	$("kmenu").innerHTML = t + "</ul>\n";
	$("kmenu2").innerHTML = t + "</ul>\n" + n1c;
}
/*******************************************************************
ajax: データファイルの読み込み
********************************************************************/
function loadFile(fName, n) {
	var hObj = createXMLHttpRequest();
	if(hObj) {
		hObj.open("GET", fName, true);
		hObj.onreadystatechange = function() { 
			setTimeout(function() {
				if(hObj.readyState==0 || hObj.readyState==4) {
					return;
				}
				hObj.abort();
				NotFiles(kid1);
				return;
			}, 15000);
			switch(hObj.readyState) {
			case 4 :
				var t = hObj.responseText;
				if(!t) {
					NotFiles(kid1);
					return;
				}
				var data = eval("(" + t + ")");
				if(!data) {
					NotFiles(kid1);
					return;
				}
				if(n=="teiki") {
					alert(data);
				}else {
					$(kid2).innerHTML = pDisp(data, n);
				}
				break;
			default :
				$(kid2).innerHTML = "<p><img src=\"./img/load.gif\" alt=\"[load]\" /> Now Loading...</p>";
			}
		}
		hObj.send(null);
	}
}
/*******************************************************************
ajax: データなし
********************************************************************/
function NotFiles(id) {
	$(id).innerHTML = "<p class=\"f10\">（データを取得できませんでした）</p>";
}
/*******************************************************************
ajax: XMLHttpRequestオブジェクト
http://allabout.co.jp/internet/javascript/closeup/CU20050515A/
********************************************************************/
function createXMLHttpRequest(){
	if(window.ActiveXObject){
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e2) {
				return null;
			}
		}
	}else if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}else {
		return null;
	}
}
/*******************************************************************
$
********************************************************************/
function $(tagId) {
	return document.getElementById(tagId);
}
/*******************************************************************
Smooth Scroll
http://www.kryogenix.org/ 
********************************************************************/
var ss = {
	fixAllLinks: function() {
		var allLinks = document.getElementsByTagName('a');
		for(var i=0; i<allLinks.length; i++) {
			var lnk = allLinks[i];
			if((lnk.href && lnk.href.indexOf('#') != -1) && ((lnk.pathname == location.pathname) || ('/' + lnk.pathname == location.pathname)) && (lnk.search == location.search)) {
				ss.addEvent(lnk, 'click', ss.smoothScroll);
			}
		}
		ss.resize();
	},
	smoothScroll: function(e) {
		if(window.event) {
			target = window.event.srcElement;
		}else if(e) {
			target = e.target;
		}else {
			return;
		}
		if(target.nodeName.toLowerCase() != 'a') {
			target = target.parentNode;
		}
		if(target.nodeName.toLowerCase() != 'a') {
			return;
		}
		anchor = target.hash.substr(1);
		var allLinks = document.getElementsByTagName('a');
		var destinationLink = null;
		for(var i=0; i<allLinks.length; i++) {
			var lnk = allLinks[i];
			if(lnk.name && (lnk.name == anchor)) {
				destinationLink = lnk;
				break;
			}
		}
		if(!destinationLink) {
			destinationLink = $(anchor);
		}
		if(!destinationLink) {
			return;
		}
		var destx = destinationLink.offsetLeft; 
		var desty = destinationLink.offsetTop;
		var thisNode = destinationLink;
		while(thisNode.offsetParent && (thisNode.offsetParent != document.body)) {
			thisNode = thisNode.offsetParent;
			destx += thisNode.offsetLeft;
			desty += thisNode.offsetTop;
		}
		clearInterval(ss.INTERVAL);
		cypos = ss.getCurrentYPos();
		ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
		ss.INTERVAL = setInterval('ss.scrollWindow(' + ss_stepsize + ', ' + desty + ', "' + anchor + '")', 10);
		if(window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if(e && e.preventDefault && e.stopPropagation) {
			e.preventDefault();
			e.stopPropagation();
		}
		return;
	},
	scrollWindow: function(scramount, dest, anchor) {
		wascypos = ss.getCurrentYPos();
		isAbove = (wascypos < dest);
		window.scrollTo(0, wascypos + scramount);
		iscypos = ss.getCurrentYPos();
		isAboveNow = (iscypos < dest);
		if((isAbove != isAboveNow) || (wascypos == iscypos)) {
			window.scrollTo(0, dest);
			clearInterval(ss.INTERVAL);
			location.hash = anchor;
		}
	},
	getCurrentYPos: function() {
		if(document.body && document.body.scrollTop) {
			return document.body.scrollTop;
		}
		if(document.documentElement && document.documentElement.scrollTop){
			return document.documentElement.scrollTop;
		}
		return (window.pageYOffset) ? window.pageYOffset : 0;
	},
	addEvent: function(elm, evType, fn) {
		if(elm.addEventListener) {
			elm.addEventListener(evType, fn, false);
			return true;
		}else if(elm.attachEvent) {
			return elm.attachEvent("on" + evType, fn);
		}else {
			return false;
		}
	},
// http://bluedb.org/ajax/archives/23
	resize: function(event) {
		if($("topnew")) {
			$("topnew").style.width = (ss.getWidth()<999) ? '220px' : 'auto';
		}
	},
	getWidth: function() {
		if(window.innerWidth) {
			return window.innerWidth;
		}else if(document.documentElement && document.documentElement.clientWidth) {
			return document.documentElement.clientWidth;
		}else if(document.body && document.body.clientWidth) {
			return document.body.clientWidth;
		}
		return false;
	}
}
ss.STEPS = 25;
ss.addEvent(window, "load", ss.fixAllLinks);
ss.addEvent(window, "resize", ss.resize);

