//<meta http-equiv=Content-Type content="text/html; charset=big5">
// JavaScript Document，本文件需要common.js內的findObj函數
//副程式，計算信用評分的結果
function caculate(){
	//debug
	//alert('ok');
	//建立迴圈用及暫存input物件reference的變數
	var i,j,resultObj,tempObj;
	//先清除評分結果欄位內的值
	var resultObj = findObj('result');
	resultObj.value = 0;
	//建立一個儲存各input物件名稱的陣列
	var inputArray = new Array('age','occupation','seniority','revenue','insurance','salary','loan','economy','creditCard');
	//建立一個儲存各input物件value的陣列
	//var valueArray = new Array();
	for(i=0; i< inputArray.length; i++){
		//求得各input物件reference
		tempObj = findObj(inputArray[i]);
		//分析每個radio物件陣列內元素哪個是被選取的
		for(j=0; j< tempObj.length; j++){
			//如果是被選取的
			if(tempObj[j].checked == true){
				//把值儲存在valueArray陣列內
				//valueArray[i] = tempObj[j].value;
				//加總所有使用者選取的數值
				resultObj.value = parseInt(resultObj.value) + parseInt(tempObj[j].value);
			}
		}
	}
	//debug
	//alert(valueArray[0]);
	//呼叫popUpWindow副程式，將評分結果顯示在result.php網頁內
	popUpWindow('program/result.php?score='+resultObj.value);
}
//-----------------------------------------------------------------------------	