		function checkMaxSelected (select, maxSelected) {
			if (!select.storeSelections) {
				select.storeSelections = new Array(select.options.length);
				select.selectedOptions = 0;
			}
			for (var i = 0; i < select.options.length; i++) {
				if (select.options[i].selected && 
						!select.storeSelections[i]) {
					if (select.selectedOptions < maxSelected) {
						select.storeSelections[i] = true;
						select.selectedOptions++;
					}
					else {
						alert('Selection will be discarded as limit of ' + maxSelected 
		+ ' is reached.');
						select.options[i].selected = false;
					}
				}
				else if (!select.options[i].selected &&
								 select.storeSelections[i]) {
					select.storeSelections[i] = false;
					select.selectedOptions--;
				}
			}
		}
		
		var init = new Array();
		var chkArr = new Array(2);
		var mxCntArr = new Array();
		function maxSelectedList(qId,elemId,ttlBox,chkElem, mxCnt,specify,answerId){
			var checkOn = true;
			init_len = init.length;
			//chkArr[qId] = Array();
			for(x=0;x<init.length;x++){
				if(init[x] == null){//initialize array values to false
					//alert("init-"+init[x]);
					for(var a=0; a<ttlBox;a++){
						chkArr[qId][a] = false;
						//alert(chkArr[qId][a]);
					}	
					break;		
				}//end if
				//alert("init-"+init[x]);
			}//end for
			
			for(z=0;z<init_len+1;z++){
				if(init[z]==qId) break;
				if(init[z]==null) init[z] = qId;
			}	
			
			var cnt=0;
			for(var b=0;b<chkArr[qId].length;b++){
				//alert(chkArr[qId].length);
				cnt += chkArr[qId][b]?1:0; 		
			}//end for
			//alert("count = "+cnt);
			if(cnt>=mxCnt && !chkArr[qId][elemId]){
				checkOn = false;
				document.getElementById(chkElem).checked=false;		
			}else{
				chkArr[qId][elemId] = chkArr[qId][elemId]? false: true;
				document.getElementById(chkElem).checked=chkArr[qId][elemId];		
			}
			if(specify==1){
				//alert(document.getElementById(chkElem).checked);
					specsOn(qId,answerId,chkElem);
			}//end if(specify==1){	
			return checkOn;
		} 
		
		function specsOn(question_id,answerId,chkId){
			specId = 'specifics['+question_id+']['+answerId+']';
			//alert(document.getElementById(chkId).checked);
			if(!document.getElementById(chkId).checked){
				document.getElementById(specId).value="";
				document.getElementById(specId).disabled=true;
			}else{
				//alert(document.getElementById(chkId).checked);
				//alert("checked");
				document.getElementById(specId).disabled=false;
				document.getElementById(specId).focus();
			}
		}
		function intOnly(i) {
			if(i.value.length>0) {
				i.value = i.value.replace(/[^\d]+/g, ''); 
			}
		}
		function maxchar(i,limit) {
			if(i.value.length>limit) {
				i.value = i.value.substring(0,limit);
			}
		}
		function toggle(i) {
			if(document.getElementById(i) != null){
				if(document.getElementById(i).style.display=='block') {
					document.getElementById(i).style.display='none';
				}else{
					document.getElementById(i).style.display='block'
				}
			}
		}
		function checkDisplay(question,ansId,type,count,ansCount) {
			var eshow = 'specifics_'+question+'['+ansCount+']';
			for(i=0;i<count;i++){
				var ehide = 'specifics_'+question+'['+i+']';
				//alert(ehide);
				if(document.getElementById(ehide) != null){
					document.getElementById(ehide).style.display = "none";
					document.getElementById(ehide).value = "";
				}
			}	
			if(document.getElementById(eshow) != null){
				document.getElementById(eshow).style.display = "block";
			}
		}