function to_first(){
	document.form.referer.value = "0";
	document.form.submit();
}

function to_yearly(){
	document.form.mode.value = "yearly";
	document.form.referer.value = "1";
	document.form.submit();
}

function to_monthly(){
	document.form.mode.value = "monthly";
	document.form.referer.value = "1";
	document.form.submit();
}

function to_check(){
	document.form.referer.value = "2";
	document.form.submit();
}

function to_prev(){
	document.form.referer.value = "1";
	document.form.submit();
}

function to_method(){
	document.form.referer.value = "3";
	document.form.submit();
}

function getElement(id){

	myN6 = document.getElementById;
	myIE = document.all;
	myN4 = document.layers;

	if(myIE){
		return document.all[id];
	}else if(myN6){
		return document.getElementById(id);
	}else if(myN4){
		return document[id];
	}
}


function refreshTotal(){
	for(var i=0;i<13;i++){	getTotal(i);	}
}

function getTotal(num){
	var total = 0;
	for(var i=0;i<12;i++){
		var obj_name = "document.form.elements['em_value["+num+"]["+i+"]']";
		total += eval(obj_name).value*1;
	}
	getElement('em_total'+num).innerHTML = addFigure(total);
}

function addFigure(str) {
	var num = new String(str).replace(/,/g, "");
	while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
	return num;
}

function open_graph(num){
	window.open("graph.php?num="+num,"graph","width=800,height=480,toolbar=no,location=no,status=no,menubar=no,scrollbar=no");	
}