function isNumeric(sText)
{
   if ( sText == null ) return false;
   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 handleJumpBranch(el) {
        var value = el.options[el.selectedIndex].value;
		//alert("xxx"+value);
        if (value != '*') {
		    location.href ='branchCondition.jspa?surveyId=' +
									document.branchConditionForm.surveyId.value +
									'&questionNo=' + document.branchConditionForm.questionNo.value + 
									'&action=' + value;
            //targ.href='editSurveyCategory.jspa?action=View&surveyCategoryId='+value;
            }
        el.selectedIndex = 0;
      }
   function handleJumpLocale(el) {
        var value = el.options[el.selectedIndex].value;
        if (value != '*') {
            location.href='setLocale.jspa?locale='+value;
            }
        el.selectedIndex = 0;
      }
   
  function handleJumpCat(el) {
        var value = el.options[el.selectedIndex].value;
        if (value != '*') {
            location.href='editSurveyCategory.jspa?action=View&surveyCategoryId='+value;
            }
        el.selectedIndex = 0;
      }

function handleJumpLibCat(el) {
        var value = el.options[el.selectedIndex].value;
        if (value != '*') {
            document.questionLibraryForm.categoryId.value=value;
	        document.questionLibraryForm.submit();
             }
      }	  

  function handleJumpSurvey(el) {
        var value = el.options[el.selectedIndex].value;
        if (value != '*') {
            location.href='editSurvey.jspa?action=SurveyAdmin&surveyId='+value;
            }
        el.selectedIndex = 0;
      }
	  
function handleJumpRange(el) {
        var value = el.options[el.selectedIndex].value;
//		alert ("value="+value+"oo");
//		alert ("document.questionListForm.range.value="+document.questionListForm.range.value);
        if (value != '*') {
            document.questionListForm.action.value = "view";
			document.questionListForm.range.value = value;			
//			alert ("document.questionListForm.range.value="+document.questionListForm.range.value);
	        document.questionListForm.submit();
			
             }
      }	  

    function onRow(el) {
       el.style.backgroundColor = '#eeeeee';
    }

    function offRow(el) {
       el.style.backgroundColor = '#ffffff';
    }


 function helpWindow(url, _height, _width) {
	var name = "ats_help_w";
//	var features ="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=1,resizable=1,width="+_width+",height="+_height
//	helpw = window.open(url, name, features);
    helpw = window.open(url, name);
	helpw.focus();
 }

 function forumWindow(url, _height, _width) {
	var name = "ats_forum_w";
//	var features ="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=1,resizable=1,width="+_width+",height="+_height
//	helpw = window.open(url, name, features);
    forumw = window.open(url, name);
	forumw.focus();
 }

 function freeonlineWindow(url, _height, _width) {
	var name = "ats_online_w";
//	var features ="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=1,resizable=1,width="+_width+",height="+_height
//	helpw = window.open(url, name, features);
    onlinew = window.open(url, name);
	onlinew.focus();
 }

  function freesamplesWindow(url, _height, _width) {
	var name = "ats_sample_w" 
//	var features ="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=1,resizable=1,width="+_width+",height="+_height
//	helpw = window.open(url, name, features);
    samplew = window.open(url, name);
	samplew.focus();
 }


 
 function newWindow(url, _height, _width) { //, _name
	
	var name = "new_window";
//	if(isdefined(_name))
//	  name = _name;
//	var features ="toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,copyhistory=1,resizable=1,width="+_width+",height="+_height
	var features ="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=1,resizable=1,width="+_width+",height="+_height

	neww = window.open(url, name, features);
	neww.focus();
 }


var showIt = "inline";

function showHideSection(objectId) {
    if (document.getElementById(objectId) != null) {
        if (document.getElementById(objectId).style.display == "none") {
            document.getElementById(objectId).style.display = showIt;
            if (document.getElementById(objectId+"Img")) {
                document.getElementById(objectId+"Img").src = "../images/arrow_expanded.gif";
            }
            state = "inline";
        } else {
            document.getElementById(objectId).style.display = "none";
            if (document.getElementById(objectId+"Img")) {
                document.getElementById(objectId+"Img").src = "../images/arrow_collapsed.gif";
            }
            state = "none";
        }
    }
}




// Will need to include the following for Mozilla
//document.all = document.getElementsByTagName("*");
function showHideNavigation(item) {
    taskSet = document.getElementById("child_"+item);
    taskImg = document.getElementById("img_"+item);
    if (taskSet.style.display == "block") {
        taskSet.style.display = "none";
        taskImg.src = "../images/arrow_collapsed.gif";
    } else {
        taskSet.style.display = "block";
        taskImg.src = "../images/arrow_expanded.gif";
    }
}

function showHidePortlet(objectId) {
    if (document.getElementById(objectId) != null) {

        if (document.getElementById(objectId).style.display == "none") {
            if (document.getElementById(objectId+"Img")) {
                document.getElementById(objectId+"Img").src = "../images/title_minimize.gif";
            }
            //inspect(document.getElementById(objectId));
            //document.getElementById(objectId).setAttribute("style","width:100%");
            document.getElementById(objectId).style.display = showIt;
            state = showIt;

        } else {
            if (document.getElementById(objectId+"Img")) {
                document.getElementById(objectId+"Img").src = "../images/title_restore.gif";
            }
            document.getElementById(objectId).style.display = "none";
            state = "none";
        }

    }
}

function findParentRow(el,st) {
    par = el.parentNode;
    if (par.tagName == "TR") {
        par.className = st;
    } else {
        findParentRow(par,st);
    }

}
function checkChecks(chk) {
    if (chk.checked == true) {
        findParentRow(chk,"table-row-selected");
    } else {
        findParentRow(chk,"table-row");
    }
}

function mouseOverOut(par,selected) {
   //alert(par.tagName);
    if(selected == true){
   
	    par.className = "table-row-selected";
    } else {
        par.className = "table-row" ;
    }
}


function checkSelected(theForm,chkname)
{
   var checkednum = 0;
   var uncheckednum = 0;
   var formlen = theForm.length;


   for (var i=0;i<formlen;i++){
        var theitem = theForm.elements[i].name;
        var ischeck = theitem.indexOf("sel_",0) + 1;
        if (ischeck > 0) {
                if (theForm.elements[i].checked == true) {
                          checkednum += 1;                        
                }
                else {
                        uncheckednum += 1;
                }
        } //end of ifcheck>0
               
        }
  if(checkednum==0) return false;
  return true;		
//onclick()= if(!checkSelected(this.form)) alert("please select at one ..."); return false;
}   

//select1, select2
//onclick=selector(this.form.multise1, this.form.multise2,'msssg')
function selector(l1, l2, msg)
{
	var res=false;
	for (var i = 0; i < l1.options.length; i++)
	{
    	if (l1.options[i].selected)
	   	{
			o=new Option(l1.options[i].text,l1.options[i].value);
			l2.options[l2.options.length]=o;
			l1.options[i]=null;
			i=i-1;
			res=true;
		}
	}
	 if(res==false){
	   if (msg != null) {
	    window.alert(msg) ;	
	  }
	  }
}

function isdefined(varx){
  return (typeof(varx)=="undefined") ? false : true ;
}	

function selectOptions(l2)
{
	for (var j = 0; j < l2.options.length; j++)
	{
		l2.options[j].selected=true;
	}
  return true;	
} 