var isDHTML = 0;var isLayers = 0;var isAll = 0;var isID = 0;if (document.getElementById) {isID = 1; isDHTML = 1;}else {if (document.all) {isAll = 1; isDHTML = 1;}else { browserVersion = parseInt(navigator.appVersion);if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)){isLayers = 1; isDHTML = 1;}}}
function findDOM(objectID,withStyle) {if (withStyle == 1) {if (isID) {return (document.getElementById(objectID).style); } else {if (isAll) {return (document.all[objectID].style); } else {if (isLayers) {return (document.layers[objectID]); }};}} else {if (isID) {return (document.getElementById(objectID)); } else {if (isAll) {return (document.all[objectID]); } else {if (isLayers) {return (document.layers[objectID]); }};}}}
function findLivePageHeight() {return window.innerHeight != null? window.innerHeight: document.body.clientHeight != null? document.body.clientHeight:null;}
function findLivePageWidth() {return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;}

		function findObjHeight(s) 
		{
		  return s.offsetHeight? s.offsetHeight:s.document.height? s.document.height:null;
		}
function findObjWidth(s) 
    {
       return s.offsetWidth? s.offsetWidth:s.document.width? s.document.width:null;
    }
function posX() 
    {
      return window.pageXOffset != null? window.pageXOffset:document.body.scrollRight != null? document.body.scrollRight:null;
    }
function posY() 
    {
       return window.pageYOffset != null? window.pageYOffset:document.body.scrollTop != null? document.body.scrollTop:null;
    }

function initStat()
    {
       stobj=findDOM("st",0);if (!stobj) return;stobjs=findDOM("st",1);stw=findObjWidth(stobj) + 30;sth=findObjHeight(stobj) + 30;setInterval("posStat()",50);
    }

function posStat()
   {
    stobjs.right=posX()+findLivePageWidth()-stw;
    stobjs.top=posY()+findLivePageHeight()-sth;
    stobjs.visibility="visible";
   }




function isHasSubOption()
 {
   
   
  if(typeof(document.frmSurveyQuestion.rdhasSubOption_Y)!="undefined")
   {
	if(document.frmSurveyQuestion.rdhasSubOption_Y.checked==true)
		{
		document.frmSurveyQuestion.ddParentOption.selectedIndex=0;
		//document.frmSurveyQuestion.txtSubOptionText.value="";
		document.frmSurveyQuestion.ddParentOption.disabled=true;
		document.frmSurveyQuestion.txtSubOptionText.disabled=false;
		}
		else
		{
		//document.frmSurveyQuestion.ddParentOption.selectedIndex=0;
		 document.frmSurveyQuestion.txtSubOptionText.value="";
		 document.frmSurveyQuestion.ddParentOption.disabled=false;
		 document.frmSurveyQuestion.txtSubOptionText.disabled=true;
		}
    }
 }
 
   
   
   function valQuestionOption(objSource, objArgs) 
   {
   
    if(document.frmDSParams.rdCalcFunction_SUM.checked==true ||
       document.frmDSParams.rdCalcFunction_COUNT.checked==true ||
       document.frmDSParams.rdCalcFunction_VAL.checked==true)
     {
		if(document.frmDSParams.ddQuestionOption.selectedIndex > 0 )
		{
		   return objArgs.IsValid = true
		}
		else
		{   
			return objArgs.IsValid = false
		} 
     }
    else
     {
          return objArgs.IsValid = true
     } 
   }
   
   //HH add on 18/3/2005
    function showFile(path)
	  {
	   window.open(path,'ReportFile','left=200,top=200,width=300,height=300,resizable=1,location=1,menubar=1,scrollbars=1,status=1,toolbar=1');
	  }	
 ///E=HH


function extractNumber(obj, decimalPlaces, allowNegative)
{
	var temp = obj.value;
	
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) {
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) {
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;

	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) {
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	
	obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}






 