//Javascript function to convert RGB to Hex asks user to input the values in the form of R, G, B.
//This comma separated combination of RGB can be used to convert the RGB to hex by generating hex code for each color.
//User can input value between 0-255 for Red, Green and Blue. E.g.: 192,192, 192 will convert this RGB value to C0C0C0.
  function toRGBHex(num)
  {
        var decToHex="";
        var arr = new Array();
        var numStr = new String();
        numStr = num;

        arr = numStr.split(",");

        for(var i=0;i<3;i++)
        {
              var hexArray = new Array( "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" );
              var code1 = Math.floor(arr[i] / 16);var code2 = arr[i] - code1 * 16;
              decToHex += hexArray[code1];
              decToHex += hexArray[code2];
        }
        return (decToHex);
  }

      function DoSaveAndRunSchedRepNow(AUrl){
        var theform = document.forms[0];
        var theEmailFlag = null;
        if (theform.EMailAfterGenerate != null){
          if (theform.EMailAfterGenerate.checked)
            theEmailFlag = "true";
        }
        if (theEmailFlag == null){
          var EPos = AUrl.indexOf('EMailAfterGenerateFlag');
          //alert(AUrl);
          if (EPos != -1){

             //Code to create a check box
            //var cb = document.createElement("input"); // create input node
            //cb.type = "checkbox"; // set type
            //cb.name = "EMailAfterGenerate"; // set name if necessary
            //cb.checked = cb.defaultChecked = true; // make it checked now and by default
            //cb.visible = false;

            var AVal = "EMailAfterGenerateFlag=";
            EPos = EPos + AVal.length;
            AVal = AUrl.substring(EPos, EPos+1);
            //alert(AVal);
            if (AVal == "0"){
              //cb.checked = false; // make it checked now and by default
              theEmailFlag="false";
            }
            else
              theEmailFlag="true";
          }
          if (theEmailFlag == null)
            return(1);
        }

        //alert(theEmailFlag);        
        if (theEmailFlag=="true"){
          var UserResult = confirm('Warning : Report output may also be sent to the Client as per settings.\n' +
                                 '\nIf you are simply test running reports then please un-check the "E-Mail/Fax to Client as per Client record specs" option to avoid sending.\n' +
                                 '\nAre you sure you want to continue and send the report output to the Client?');
          //alert(UserResult);
          if(UserResult=="0")
            return(0);
          else
            return(1);
        }
        else
            return(1);
      }

      function SetThisDate(StartYear,StartMonth,StartDay,StartDateWanted){
        // alert(StartYear.value+" X "+StartMonth.value+" X "+StartDay.value+" X "+StartDateWanted);  
        var StartYearWanted = StartDateWanted.getFullYear();
        var StartMonthWanted = StartDateWanted.getMonth();
        var StartDayWanted = StartDateWanted.getDate();
       //  alert(StartYearWanted+" X "+StartMonthWanted+" X "+StartDayWanted);
        for (var i = 0; i < StartYear.length; i++){
        if (StartYear.options[i].value==StartYearWanted)
          StartYear.options[i].selected = true;
        }
        for (var i = 0; i < StartMonth.length; i++){
        if (i==StartMonthWanted)
          StartMonth.options[i].selected = true;
        }
        for (var i = 0; i < StartDay.length; i++){
        if (i==(StartDayWanted-1))
          StartDay.options[i].selected = true;
        }
      }

    function daysInMonth(year, month) {
        var d = new Date(year, month+1, 0);
        return d.getDate();
        }

    function IsEndOfMonth(aDate){
       var result = false;
       var curyear = aDate.getYear();
       var curmonth = aDate.getMonth();
       var curday =  aDate.getDate();
       result = curday == daysInMonth(curyear, curmonth);
       return result;
    }

    function AdjustDate(DateType, DateValue){
       var theform = document.forms[0];
       var CurrentValue = DateValue;

       if((DateType=="Months") || (DateType==3)){
         var dateStart = new Date(theform.StartDateCalEditor.value);
         var dateEnd = new Date(theform.EndDateCalEditor.value);
         dateStart = dateEnd;
         var IsEOM = IsEndOfMonth(dateStart);
         var startyear = dateStart.getYear() + 1900;
         var startmonth = dateStart.getMonth() - CurrentValue;
         var startday = dateStart.getDay();
         var deltayr = 0; //CurrentValue / 12;
        
          var startmon = startmonth;
	  while (startmon < 0) {
	     startmon = startmon + 12;
      	     startyear = startyear -1;
	  }
	         
        if (IsEOM || (startday > daysInMonth(startyear,startmon))) 
                startday = daysInMonth(startyear,startmon) 
		
 	       
	 var dateStartWanted = dateStart.setFullYear(startyear,startmon,startday);
	  //  alert(dateStartWanted );
       }

       if((DateType=="Weeks") || (DateType==2)){
         CurrentValue=CurrentValue*7;
         var dateStart = new Date(theform.StartDateCalEditor.value);
         var dateEnd = new Date(theform.EndDateCalEditor.value);
         dateStart = dateEnd;
         var CurrDate=dateEnd.getDate()
         var dateStartWanted = dateStart.setDate(CurrDate - CurrentValue);
       }

       if((DateType=="Days") || (DateType==1)){
         var dateStart = new Date(theform.StartDateCalEditor.value);
         var dateEnd = new Date(theform.EndDateCalEditor.value);
         dateStart = dateEnd;
         var CurrDate=dateEnd.getDate()
         var dateStartWanted = dateStart.setDate(CurrDate - CurrentValue);
       }
       //alert(dateStart);
       //theform.StartDateCal.CalendarSelectDate=dateStart;
       //var ACal=document.getElementById("StartDateCal");
       //ACal.SelectedDate = dateStart;
       //ACal.Date = dateStart;
       //ACal.CalendarSelectDate(dateStart);
       theform.StartDateCalEditor.value=(dateStart.getMonth()+1)+"/"+dateStart.getDate()+"/"+dateStart.getFullYear();
  }

  
  function EnableAndAdjustDate(rdDateType,txtDateEnValue,txtDateDis1Value,txtDateDis2Value){
    //alert(theform.txtDateEnValue.value)
    txtDateEnValue.disabled=false;
    txtDateDis1Value.disabled=true;
    txtDateDis2Value.disabled=true;
    if (txtDateEnValue.value!="")
      AdjustDate(rdDateType.value, txtDateEnValue.value)
  }

  function ValidateDate() {
    var theform = document.forms[0];
    var dateStart = new Date(theform.StartDateCalEditor.value);
    var dateEnd = new Date(theform.EndDateCalEditor.value);
    dateToday = new Date();
    var dateDifference = dateToday - dateStart;
    // alert(dateDifference + ' ' + dateToday + ' ' + dateStart + ' ' + dateEnd); 
    if (dateDifference < 0){
     alert("Start Date(" + dateStart + ") should be less than Today's Date.");
     return 0;}
    dateDifference = dateToday - dateEnd;
    if (dateDifference < 0){
     alert("End Date(" + dateStart + ") should be less than Today's Date.");
     return 0;}
    dateDifference = dateEnd - dateStart;
    if (dateDifference < 0){
     alert("Start Date(" + dateStart + ") should be less than the End Date(" + dateEnd + ").");
     return 0;}
    return 1;
  }

  function DoSaveSavedFNamePSTypeCBoxChange(){
   //alert("1");
    var theform = document.forms[0];
    if ((theform.SavedFNamePSTypeCBox!=null) && (theform.PreOrSufFixFldNameOrString!=null)){
      //alert(theform.SavedFNamePSTypeCBox.value);
      if ((theform.SavedFNamePSTypeCBox.value=="None") || (theform.SavedFNamePSTypeCBox.value=="0"))
        theform.PreOrSufFixFldNameOrString.disabled=true;
      else
        theform.PreOrSufFixFldNameOrString.disabled=false;
    }
  }

      function DoEmailPDFAfterGenCBoxClick(){
      //alert("1");
        var theform = document.forms[0];
        AEMailLabel = document.getElementById('EmailStatusLbl');
        if ((theform.EMailAfterGenerate!=null) && (AEMailLabel!=null)){
                //if (theform.EMailAfterGenerate.checked==true)
                //alert("2");
                if (theform.EMailAfterGenerate.checked==true)
                    AEMailLabel.style.visibility = 'visible';
                else
                    AEMailLabel.style.visibility = 'hidden';
        }
      }

      function DoSavePDFAfterGenCBoxClick1(){
        var theform = document.forms[0];
        if ((theform.SavePDFAfterGenerateCBox!=null) && (theform.RepSetFolderName!=null)
           && (theform.SaveUnderMergeFoldersCBox!=null) && (theform.SavedFNamePSTypeCBox!=null)
           && (theform.FilePathFldNameOrString!=null)){
                //if (theform.SavePDFAfterGenerateCBox.checked==true)
                  //alert("1");
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.RepSetFolderName.readOnly=false;
                else
                  theform.RepSetFolderName.readOnly=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.FilePathFldNameOrString.readOnly=false;
                else
                  theform.FilePathFldNameOrString.readOnly=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.SaveUnderMergeFoldersCBox.readOnly=false;
                else
                  theform.SaveUnderMergeFoldersCBox.readOnly=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.SavedFNamePSTypeCBox.readOnly=false;
                else
                  theform.SavedFNamePSTypeCBox.readOnly=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  DoSaveSavedFNamePSTypeCBoxChange();
                else{
                    if (theform.PreOrSufFixFldNameOrString!=null){
                      //alert(theform.PreOrSufFixFldNameOrString.value);
                        theform.PreOrSufFixFldNameOrString.readOnly=true;
                    }
                }
        }
      }

      function DoSavePDFAfterGenCBoxClick(){
        var theform = document.forms[0];
        if ((theform.SavePDFAfterGenerateCBox!=null) && (theform.RepSetFolderName!=null)
           && (theform.SaveUnderMergeFoldersCBox!=null) && (theform.SavedFNamePSTypeCBox!=null)
            && (theform.FilePathFldNameOrString!=null)){
                //if (theform.SavePDFAfterGenerateCBox.checked==true)
                  //alert("1");
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.RepSetFolderName.disabled=false;
                else
                  theform.RepSetFolderName.disabled=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.FilePathFldNameOrString.disabled=false;
                else
                  theform.FilePathFldNameOrString.disabled=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.SaveUnderMergeFoldersCBox.disabled=false;
                else
                  theform.SaveUnderMergeFoldersCBox.disabled=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  theform.SavedFNamePSTypeCBox.disabled=false;
                else
                  theform.SavedFNamePSTypeCBox.disabled=true;
                if (theform.SavePDFAfterGenerateCBox.checked==true)
                  DoSaveSavedFNamePSTypeCBoxChange();
                else{
                    if (theform.PreOrSufFixFldNameOrString!=null){
                      //alert(theform.PreOrSufFixFldNameOrString.value);
                        theform.PreOrSufFixFldNameOrString.disabled=true;
                    }
                }
        }
      }

  function SendRepToSupport(TheURL){
    //var TheURL="SendRepToSupport";
    var theform = document.forms[0];
    //TheURL=TheURL + "?RepRTMFname=" + theform.RepRTMFName.value;
    //if (theform.UserDirName!=null)
    //  TheURL=TheURL + "&UserDirName=" + theform.UserDirName.value;
    //TheURL=TheURL + "&CustomRep=" + theform.CustomRep.value;
    //TheURL=TheURL + "&ReportGroup=" + theform.ReportGroup.value;
    var FeatureStr = "scrollbars=yes ,resizable=yes ,toolbar=no ,menubar=no ,statusbar=yes, ";
    FeatureStr = FeatureStr + "width=1100, height=825, top=120, left=150";
    //alert(TheURL);
    window.open(TheURL, "", FeatureStr);
  }

  function OpenEditReportWindow(AUrl){
    //alert(AUrl);
    //window.location=AUrl;
    var FeatureStr = "scrollbars=yes, resizable=yes, toolbar=no, menubar=no, statusbar=yes, ";
    FeatureStr = FeatureStr + " width=1100, height=810, top=100, left=60";
    window.open(AUrl, "", FeatureStr);
  }

  function OpenCloneReportWindow(AUrl, AAction, IsARepGroup, ARepName, ARepMsg){
    //alert(AUrl);
    //window.location=AUrl;
    if(AAction=="true"){
      if(IsARepGroup=="true")
        var UserResult = 1;
         /*var UserResult = confirm('Are you sure you want to create a new clone for the Report Group "' +
                              ARepName + '"?.\nPress Ok to continue or Cancel to Edit the Report Group instead.'+
                            '\nCloning a Report Group will not clone its constituent reports. They have to be cloned individually.'); 
		*/	    
      else
         var UserResult = 1;
        /*var UserResult = confirm('Are you sure you want to create a new clone for the Report "' +
                              ARepName + '"?.\nPress Ok to continue or Cancel to Edit the report instead.');
	*/		      
      if(UserResult=="0")
        AUrl=AUrl+'&ReportAction=Edit';
      else
        AUrl=AUrl+'&ReportAction=Clone';
    }
    else{
      if(IsARepGroup=="true")
      	var UserResult = 1;
        /*var UserResult = confirm('Are you sure you want to create a new clone for the Report Group "' + ARepName + '"?.' +
                               '\nCloning a Report Group will not clone its constituent reports. They have to be cloned individually.');
			       */
      else{
        if ((ARepMsg!=null) && (ARepMsg!=""))
	 var UserResult = 1;
         /* var UserResult = confirm('Are you sure you want to create a new clone for the Report "' +
                                ARepName + '"?.\nThe cloned report will replace this report in the group. Press Ok to continue.');
		*/		
        else
          /*var UserResult = confirm('Are you sure you want to create a new clone for the Report "' + ARepName + '"?.');
	  */
	  var UserResult = 1;
	  }
      if(UserResult=="0")
        return;
      else 
        AUrl=AUrl+'&ReportAction=Clone';
    }
    var FeatureStr = "scrollbars=yes, resizable=yes, toolbar=no, menubar=no, statusbar=yes, ";
    FeatureStr = FeatureStr + " width=1100, height=810, top=100, left=60";
    window.open(AUrl, "", FeatureStr);
  }

  function DoProductPage(){
    var aURL="/CTWebScripts/CTWebControl.dll/GenLoginPage";
    window.open(aURL, "AWindowName", "");
  }

   function SetCheckAllFields(val) {
    var theform = document.forms[0];
    var len=theform.elements.length;
    var elename;
    var i=0;
    for( i=0 ; i<len ; i++){
      elename=theform.elements[i].name;
      elename=elename.substring(0, 3);
      if (elename=="row")
        theform.elements[i].checked=theform.checkuncheckall.checked;
    }
   }

   function ClearManualBtnClick(){
        var theform = document.forms[0];
        theform.__TARGETNAME.value = "";
        theform.__ACTIONNAME.value = "";
        alert(theform.__TARGETNAME.value);
   }
   
    function RemoveBlanks(iStr){
      var temp="";
      for(var i=0;i<iStr.length;++i){
        var c=iStr.charAt(i);
            if (c!=" ") temp += c;
      }
      return temp;
    }

   function __doCustomPostBack(eventTarget, eventArgument)
   {
     var theform = document.forms[0];
     theform.__TARGETNAME.value = eventTarget;
     theform.__ACTIONNAME.value = eventArgument;
     theform.__LEFTPOS.value = dxModule.Pos.GetWindowScroll().x;
     theform.__TOPPOS.value = dxModule.Pos.GetWindowScroll().y;
     theform.submit();
   }

   function GetLastChars(ASourceStr, AResultStr, ACharCount){
     AResultStr = "";
     for(var i=ASourceStr.length;i>ACharCount;--i){
       AResultStr += ASourceStr.charAt(i);
     }

   }

   function GetNameValue(ANameValObj, ADelim){
      ANameValObj.AValue="";
      ANameValObj.AName="";
      var FoundEq=false;
      for(var i=0;i<ANameValObj.NameValstr.length;++i){
        var c=ANameValObj.NameValstr.charAt(i);
        if (FoundEq)
          ANameValObj.AValue+=c;
        else{
          if (c==ADelim)
            FoundEq=true;
          else
            ANameValObj.AName+=c;
        }
      }
   }

      var CurrentFontColorCallerDivName;
      var CurrentPenShapeName;
      var FontColorWinHandle;

      function DoSetCurrentFontColorCallBack(){
        FontColorCallerDiv=document.getElementById(CurrentFontColorCallerDivName);
        FontColorWinHandle.SetCurrentFontColor(FontColorCallerDiv);
        var BorderShape=document.getElementById(CurrentPenShapeName);
        FontColorWinHandle.SetCurrentParams(BorderShape.value)
        //alert("DoSetCurrentFontColorCallBack-" + BorderShape.value);
      }

      function DowindowCheckAndClose(){
        //alert("B4");
        if(FontColorWinHandle == null || FontColorWinHandle.closed){
            //alert('null');
        }
        else{
            //alert(FontColorWinHandle.location);
            FontColorWinHandle.close();
        }
      }

      function EditFontColorBorder(AnyFontColorDisplayDivName, AnyCurrentPenShapeName){
        //alert(AnyFontColorDisplayDivName);
        var TheURL = "CTFontColorEditor";
        var ActualHieght="600";
        TheURL = TheURL + "?ShowFont=true&ShowColor=true&ShowPen=true";
        var FeatureStr = "scrollbars=no, resizable=no, toolbar=no, menubar=no, statusbar=yes, ";
        FeatureStr = FeatureStr + "width=500, height=" + ActualHieght + ", top=100, left=300";
        //alert(theurl+featurestr);
        CurrentFontColorCallerDivName = AnyFontColorDisplayDivName;
        CurrentPenShapeName = AnyCurrentPenShapeName;
        //alert("EditFontColorBorder - "+CurrentPenShapeName);
        //alert(FontColorWinHandle.name);
        DowindowCheckAndClose();
        FontColorWinHandle = window.open(TheURL, "SelectFontandColor", FeatureStr);
      }

      function EditFontOnly(AnyFontColorDisplayDivName){
        //alert(AnyFontColorDisplayDivName);
        var TheURL = "CTFontColorEditor";
        var ActualHieght="400";
        TheURL = TheURL + "?ShowFont=true";
        var FeatureStr = "scrollbars=no, resizable=no, toolbar=no, menubar=no, statusbar=yes, ";
        FeatureStr = FeatureStr + "width=500, height=" + ActualHieght + ", top=300, left=300";
        //alert(theurl+featurestr);
        CurrentFontColorCallerDivName = AnyFontColorDisplayDivName;
        DowindowCheckAndClose();
        FontColorWinHandle = window.open(TheURL, "SelectFontandColor", FeatureStr);
        //if (window.showModalDialog) {
        //  window.showModalDialog(TheURL,"SelectFontandColor", FeatureStr);}
        //else {
        //  window.open(TheURL,'SelectFontandColor', FeatureStr+',modal=yes');}
      }

      function EditColorOnly(AnyFontColorDisplayDivName){
        //alert(AnyFontColorDisplayDivName);
        var TheURL = "CTFontColorEditor";
        var ActualHieght="400";
        TheURL = TheURL + "?ShowColor=true";
        var FeatureStr = "scrollbars=no, resizable=no, toolbar=no, menubar=no, statusbar=yes, ";
        FeatureStr = FeatureStr + "width=500, height=" + ActualHieght + ", top=300, left=300";
        //alert(theurl+featurestr);
        CurrentFontColorCallerDivName = AnyFontColorDisplayDivName;
        DowindowCheckAndClose();
        FontColorWinHandle = window.open(TheURL, "SelectFontandColor", FeatureStr);
      }

      function EditFontColor(AnyFontColorDisplayDivName){
        //alert(AnyFontColorDisplayDivName);
        var TheURL = "CTFontColorEditor";
        var ActualHieght="500";
        TheURL = TheURL + "?ShowColor=true&ShowFont=true";
        var FeatureStr = "scrollbars=no, resizable=no, toolbar=no, menubar=no, statusbar=yes, ";
        FeatureStr = FeatureStr + "width=500, height=" + ActualHieght + ", top=300, left=300";
        //alert(theurl+featurestr);
        CurrentFontColorCallerDivName = AnyFontColorDisplayDivName;
        DowindowCheckAndClose();
        FontColorWinHandle = window.open(TheURL, "SelectFontandColor", FeatureStr);
      }

      function EditColorBorder(AnyFontColorDisplayDivName, AnyCurrentPenShapeName){
        //alert(AnyFontColorDisplayDivName);
        var TheURL = "CTFontColorEditor";
        var ActualHieght="450";
        TheURL = TheURL + "?ShowColor=true&ShowPen=true";
        var FeatureStr = "scrollbars=no, resizable=no, toolbar=no, menubar=no, statusbar=yes, ";
        FeatureStr = FeatureStr + "width=500, height=" + ActualHieght + ", top=300, left=300";
        //alert(theurl+featurestr);
        CurrentFontColorCallerDivName = AnyFontColorDisplayDivName;
        CurrentPenShapeName = AnyCurrentPenShapeName;
        //alert("EditColorBorder - " + CurrentPenShapeName);
        DowindowCheckAndClose();
        FontColorWinHandle = window.open(TheURL, "SelectFontandColor", FeatureStr);
      }

      function MakeFontColorInCaller(aFontColorPreviewDiv){
        FontColorCallerDiv = document.getElementById(CurrentFontColorCallerDivName);
        FontColorCallerDiv.style.fontSize=aFontColorPreviewDiv.style.fontSize;
        FontColorCallerDiv.style.color=aFontColorPreviewDiv.style.color;        
        FontColorCallerDiv.style.backgroundColor=aFontColorPreviewDiv.style.backgroundColor;
        FontColorCallerDiv.style.fontFamily=aFontColorPreviewDiv.style.fontFamily;
        FontColorCallerDiv.style.fontStyle=aFontColorPreviewDiv.style.fontStyle;
        FontColorCallerDiv.style.fontWeight=aFontColorPreviewDiv.style.fontWeight;
        FontColorCallerDiv.style.textDecoration=aFontColorPreviewDiv.style.textDecoration;
        FontColorCallerDiv.innerText=aFontColorPreviewDiv.innerText;
        FontColorCallerDiv.style.borderWidth=aFontColorPreviewDiv.style.borderWidth;
        FontColorCallerDiv.style.borderColor=aFontColorPreviewDiv.style.borderColor;
        FontColorCallerDiv.style.borderStyle=aFontColorPreviewDiv.style.borderStyle;
        //alert("Font Color test");
      }

     function MakeParamsInCaller(aCurrentPenShape){
        var BorderShape=document.getElementById(CurrentPenShapeName);
        BorderShape.value=aCurrentPenShape;
        //alert("MakeParam - " + BorderShape.value);       
     }

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function GetRadioValue(AObj){
	if(!AObj)
		return "";
	var radioLength = AObj.length;
	if(radioLength == undefined)
		if(AObjv.checked)
			return AObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(AObj[i].checked) {
			return AObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function SetRadioValue(AObj, newValue){
        //alert("hi26" + newValue);
	if(!AObj)
		return;
	var radioLength = AObj.length;
	if(radioLength == undefined) {
		AObj.checked = (AObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		AObj[i].checked = false;
		if(AObj[i].value == newValue.toString()) {
			AObj[i].checked = true;
		}
	}
}

function setCheckedValue(radioObj, newValue) {
        //alert("hi25");
	if(!radioObj){
              //alert("hi21");
		return;}
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}


//function CTconfirm(Msg) {  confirm(Msg);
  //       }

