function getPageObject(sObjID) {
	if (document.all)
		return document.all[sObjID] 
	else 
		return document.getElementById(sObjID)
}


// Main submition check
function SbmtFrm(frm) {
	if (frm == "") {
		frm = getPageObject("fb-form")
	}
	
	if (typeof (Common_Scripts_survey_LimitMsg) == "undefined")
		Common_Scripts_survey_LimitMsg = "Please limit your message to 200 characters. You have used " + frm.q_10.value.length + " characters."
		
	if (invalLength(frm.q_10, "", 200, Common_Scripts_survey_LimitMsg)) { return
		frm.q_10.focus()
		return
	}
	
	if ((!notChecked(frm.q_3)) && (frm.q_3[Checked(frm.q_3)].value == "0") && (frm.other.value == "")) {
		if (typeof (Common_Scripts_survey_SecondQue) == "undefined")
			Common_Scripts_survey_SecondQue = "Please answer the Second Question!"
			
		alert(Common_Scripts_survey_SecondQue);
		frm.other.focus()
		return
	}
	
	frm.submit()

}

// Submit Affiliate Survey
function SbmtFrmAff(frm) {

	// question 1
	if (((notChecked(frm.q_18)) || 
		 (notChecked(frm.q_19)) ||
		 (notChecked(frm.q_20)) ||
		 (notChecked(frm.q_21)) ||
		 (notChecked(frm.q_23)) ||
		 (notChecked(frm.q_24)) ||
		 (notChecked(frm.q_25)) ||
		 (notChecked(frm.q_39))) ||
		(notChecked(frm.q_26)) ||
		(notChecked(frm.q_27)) ||
		(notChecked(frm.q_28)) ||
		((notChecked(frm.q_29)) || 
		 (notChecked(frm.q_30)) ||
		 (notChecked(frm.q_31)) ||
		 (notChecked(frm.q_31))))
	{
		if (typeof (Common_Scripts_survey_RadioButtonQue) == "undefined")
			Common_Scripts_survey_RadioButtonQue = "Please answer at least all radio button questions."
			
		alert(Common_Scripts_survey_RadioButtonQue);
		return
	}
	
	frm.submit()

}

//check whether any value of radio button control is checked
function notChecked(ctl) {
	for (var i = 0; i < ctl.length; i++) {
		if (ctl[i].checked) return false
	}

	ctl[0].focus()
	return true
}

//defines which control is checked
function Checked(ctl) {
	for (var i = 0; i < ctl.length; i++) {
		if (ctl[i].checked) return i
	}
}

//makes control with value '0' checked
function SelectOther(group) {
	for (var i=0; i<group.length; i++) {
		if (group[i].value == "0") {
			group[i].checked = true
			break
		}
	}
}