function IsNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
		}
	}
   return IsNumber;
}

function popInfo(url) {
	openSimpleWindow("IFA_Info",url,400,600,200,200);
}

function openSimpleWindow(name,url,height,width,top,left) {
	newWindow=window.open(url,name,"height="+height+",width="+width+",screenX="+left+",screenY="+top+",resizable=yes,scrollbars=yes,status=no");
	newWindow.focus();
	return newWindow;
}

function content_popup(content_ref,content_title_ref,window_name) {
	if (window_name==undefined) {
		window_name = "sd_popup";
	}
	newWindow = openSimpleWindow(window_name,"content_popup.php?ref="+content_ref+"&title_ref="+content_title_ref,400,600,200,200);
	newWindow.focus();
	return;
}

function updateGroupSum(qu_id, questionsArray) {
	
	//alert(questionsArray);
	var sum = 0;
	for (j=0;j<questionsArray.length;j++) {
		//alert(eval("aGroupQuestions_"+qu_id+"[j]"));
		//alert(document.surveyForm["aAnswers[" + eval("aGroupQuestions_"+qu_id+"[j]") + "]"].value);
		value = document.surveyForm["aAnswers[" + eval("aGroupQuestions_"+qu_id+"[j]") + "]"].value;
		var valid = IsNumeric(value);
		if (valid==true) {
			sum = sum + (value-0);
		} else {
			alert("Please enter a numeric value");
		}
	}
	eval("document.surveyForm['aQuestions[" + qu_id + "][total]'].value = sum;")
}

function updateSliders(group_qu_id, qu_id, slider, questionsArray) {
	var otherSlidersTotal = 0;
	var currentSlidersTotal = 0;
	var maxAllowed = 0;
	eval("maxAllowed = document.surveyForm['aQuestions[" + qu_id + "][qu_max_selected]'].value");
	eval("currentSlidersTotal = s"+qu_id+".getValue()");
	for (j=0;j<questionsArray.length;j++) {
		if (questionsArray[j]!=qu_id) {
			eval("temp = s"+questionsArray[j]+".getValue()");
			otherSlidersTotal = otherSlidersTotal + temp;
		}
	}
	if ((currentSlidersTotal+otherSlidersTotal)>maxAllowed) {
		eval("s"+qu_id+".setValue((maxAllowed-otherSlidersTotal))");
		eval("document.surveyForm['aQuestions[" + group_qu_id + "][total]'].value = "+maxAllowed);
	} else {
		eval("document.surveyForm['aQuestions[" + group_qu_id + "][total]'].value = "+(currentSlidersTotal+otherSlidersTotal));
	}
}

//var aGroupQuestions = new Array();
//var questionLength = 0;
