   /*
copyright (c) 2003 RDC Engineering, Inc.
all rights reserved
 */
var mvcDirtyFlag = false;
var mvcTreeTargetUrl = 'nothing';  // used by 'tree' navigators - it is modified by 'detail' pages as they load so that the tree will reload the correct detail page when the user selects another value from the tree

function mvcSetDirty() {
   mvcDirtyFlag = true;
}

defaultStatus = "MSDS On File";

function getStyleClass (className) {
  if (document.all) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].rules.length; r++)
        if (document.styleSheets[s].rules[r].selectorText == '.' + className)
          return document.styleSheets[s].rules[r];
  }
  else if (document.getElementById) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
        if (document.styleSheets[s].cssRules[r].selectorText == '.' + className)
          return document.styleSheets[s].cssRules[r];
  }
  return null;
}
function mvcDoTableColumns(formDataID) {
   var win = window.open(mvcContextPath+'/config/jsp/columns.jsp?did='+formDataID,'popup','width=800,height=400,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
   win.focus();
}

function mvcDoTableSpreadsheet(formDataID,formParamVals) {
   if(formParamVals=='null'||formParamVals=='') {
      var win = window.open(mvcContextPath+'/spreadsheet.jsp?did='+formDataID,'popup','width=800,height=400,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      win.focus();
   } else {
      var win = window.open(mvcContextPath+'/spreadsheet.jsp?did='+formDataID+'&p='+formParamVals,'popup','width=800,height=400,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      win.focus();
   }
}
function doDVNewRecord(targetURL,baseTarget) {
 //var baseTarget ='blank';
  if(baseTarget=='blank') {
 	var win = window.open(mvcContextPath+targetURL,'','width=600,height=450,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
 	win.focus();
   } else {
       if(!parent.tabFrame) {
	var wlTemp = window.location.href;
      window.location = mvcContextPath+"/detailFrame.jsp?TF="+wlTemp.replace("?","|").replace("=","~") +'&BF='+mvcContextPath+targetURL.replace("&",",").replace("?","|").replace(/=/g,"~");
       } else {
          parent.frames[1].window.location = mvcContextPath+targetURL;
       }
   }
}
function mvcShowPopMenu(elementID,e) {
   var formObj = document.getElementById(elementID);
   formObj.style.left = e.clientX-10;
   formObj.style.top = e.clientY-10;
   formObj.style.visibility = 'visible';
}

function mvcPopMenu(formObj) {
//   var formObj = document.getElementById(elementID);
   formObj.style.visibility = 'visible';
}

function mvcHidePopMenu(formObj) {
//   var formObj = document.getElementById(elementID);
   formObj.style.visibility = 'hidden';
}

// used by input elements in dataview filter row
function doDVFilterRollover(formObj) {
   var theClass = "";
   theClass = formObj.className;
   // note that if the input element has fired onChange
   // theClass will = "dvFilterDataNew" and will
   // not change on roll over
   if(theClass=="dvFilter") {
     formObj.className = "dvFilterOver";
   } else if (theClass=="dvFilterOver") {
     formObj.className = "dvFilter";
   } else if (theClass=="dvFilterSize") {
     formObj.className = "dvFilterSizeOver";
   } else if (theClass=="dvFilterSizeOver") {
     formObj.className = "dvFilterSize";
   } else if (theClass=="dvFilterData") {
     formObj.className = "dvFilterDataOver";
   } else if (theClass=="dvFilterDataOver") {
     formObj.className = "dvFilterData";
   }
}

// used by input elements in dataview filter row
function doDVFilterChange(formObj) {
   formObj.className = "dvFilterDataNew";
   mvcSetDirty();
}

function mvcAction(formObj,actionValue)
{
   if (actionValue=='frmwkSpoolDocument')
   {
        var location_path = document.location;
        var id_select = document.FORM_1.id_menu_item_selected.value;
        if (id_select==0)
        {
             alert('Please select a Location to view the document corresponding to it.');
             return;
        }
       	var win = window.open(mvcContextPath+'/frmwkSpoolDocument.jsp?path='+location_path+'&i='+id_select,'spool_document','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      // wait for window to paint
      var idSel=0;
      while(win.document.forms.length<1)
      {
         idSel = idSel*3;
       }
        win.document.forms[0].submit();
 	win.focus();
   }
   else if(mvcValidateForm(formObj)) {
   	formObj.mvcActionID.value=actionValue;
   	formObj.submit();
   } else {
      return false;
   }
	return true;
}

function mvcActionNavigate(formObj,actionValue) {


 // alert("Anthuv");
   var theURL = actionValue;
         //alert(theURL);
   if(formObj.id_select) {
      var idSel = mvcGetSelectedRadioValue(formObj.id_select);
      if (idSel==null) {
         alert('nothing selected');
         return false;
      } else {
        if(theURL.indexOf('?')>0) {
         theURL += '&id_select='+idSel;
        } else {
         theURL += '?id_select='+idSel;
        }
      }
   }
   var win = window.open(theURL,'actionPop','width=800,height=400,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   win.focus();
	return true;
}

/* function mvcDoTableNavigate(formObj,formDataID,actionValue){
  var theURL = actionValue;
//Checkbox type checking condition added by Ramesh.k on 01/05/2005 to fix the error in TRI chemical page done by Mr.Srither
var idLen=null;
if((formObj.id_select == '[object]') && (formObj.id_select.length)){
  idLen="Yes";
}
else{
  idLen="No";
}

   if((idLen=='No') && (formObj.id_select!='undefined') && (formObj.id_select) && (formObj.id_select.type=='radio')){
      if(formObj.id_select == '[object]') id_type=formObj.id_select.type;
         else id_type=formObj.id_select.type;
           var idSel = mvcGetSelectedRadioValue(formObj.id_select);
         if (idSel==null) {
           if(id_type=='radio') {
            alert('nothing selected');
             return false;
              }
            }
          else { if(theURL.indexOf('?')>0) { theURL += '&id_select='+idSel;  }      else { theURL += '?id_select='+idSel; } }
    }
   else {
       if((idLen=='Yes') && (formObj.id_select!='undefined') && (formObj.id_select) && (formObj.id_select[0].type=='radio')){
        if(formObj.id_select[0] == '[object]') id_type=formObj.id_select[0].type;
         else id_type=formObj.id_select[0].type;
           var idSel = mvcGetSelectedRadioValue(formObj.id_select);
         if (idSel==null) {
           if(id_type=='radio') {
            alert('nothing selected');
             return false;
              }
            }
          else { if(theURL.indexOf('?')>0) { theURL += '&id_select='+idSel;  }      else { theURL += '?id_select='+idSel; } }
    }
   }
     var win = window.open(theURL,'actionPop','width=800,height=400,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
     win.focus();
     return true;
   }*/
function mvcDoTableNavigate(formObj,formDataID,actionValue) {
   var theURL = actionValue;
   if(formObj.id_select) {
      var idSel = mvcGetSelectedRadioValue(formObj.id_select);
      if (idSel==null) {
         alert('nothing selected');
         return false;
      } else {
        if(theURL.indexOf('?')>0) {
         theURL += '&id_selected='+idSel;
        } else {
         theURL += '?id_selected='+idSel;
        }
      }
   }
   var win = window.open(theURL,'actionPop','width=800,height=400,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   win.focus();
	return true;
}

// For New Popup Window
// Added by Anthuvan.
function mvcActionNavigate(formObj,actionValue) {

    //   alert("Anthuv");
   var theURL = actionValue;
         //alert(theURL);
   if(formObj.id_select) {
      var idSel =    (formObj.id_select);
      if (idSel==null) {
         alert('nothing selected');
         return false;
      } else {
        if(theURL.indexOf('?')>0) {
         theURL += '&id_select='+idSel;
        } else {
         theURL += '?id_select='+idSel;
        }
      }
   }
   var win = window.open(theURL,'actionPop','width=800,height=400,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   win.focus();
	return true;
}
// used by data view pages for roll-over
var dvRowSelected = 0;
var dvRowOver = 0;

function doDVRowOver(row,frmID) {

	var theClass = "";
 if(dvRowSelected!=0) {
		// we have a selected row, so if this is that row do nothing
		if(dvRowSelected==row) {
       return;
		}
	}
	dvRowOver = row;

	theClass = document.getElementById(frmID.name+'_dvRow'+dvRowOver).className;
//alert(theClass);
 if(theClass=="dvRowEven") {
  document.getElementById(frmID.name+'_dvRow'+row).className = "dvRowOverEven";
	} else {
		document.getElementById(frmID.name+'_dvRow'+row).className = "dvRowOverOdd";
 }
}


function doDVRowOut(row,frmID) {
 var theClass = "";
 if(dvRowSelected!=0) {
  // we have a selected row, so if this is that row do nothing
		if(dvRowSelected==row) {
			return;
 	}
	}
	if(dvRowOver!=0) {
 	theClass = document.getElementById(frmID.name+'_dvRow'+row).className;
  if(theClass=="dvRowOverEven") {
			document.getElementById(frmID.name+'_dvRow'+row).className = "dvRowEven";
		} else {
 		document.getElementById(frmID.name+'_dvRow'+row).className = "dvRowOdd";
  }
		dvRowOver = 0;
	}
}


function doDVRowEdit(row,targetURL,baseTarget,formObj) {
 if(!formObj.id_select.length) {
    formObj.id_select.checked=true;
 } else {
    formObj.id_select[row-1].checked=true;
 }
 var theClass = "";
 if(dvRowSelected!=0) {
   theClass = document.getElementById(formObj.name+'_dvRow'+dvRowSelected).className;
	if(theClass=="dvRowSelectedEven") {
		document.getElementById(formObj.name+'_dvRow'+dvRowSelected).className = "dvRowEven";
 	} else {
      document.getElementById(formObj.name+'_dvRow'+dvRowSelected).className = "dvRowOdd";
	}
 }
 dvRowSelected = row;
 theClass = document.getElementById(formObj.name+'_dvRow'+dvRowSelected).className;
 if(theClass=="dvRowOverEven") {
   document.getElementById(formObj.name+'_dvRow'+dvRowSelected).className = "dvRowSelectedEven";
 } else {
   document.getElementById(formObj.name+'_dvRow'+dvRowSelected).className = "dvRowSelectedOdd";
 }
 if(baseTarget=='blank') {
 var win = window.open(mvcContextPath+targetURL,'','width=600,height=450,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
 win.focus();
 } else {
    if(!parent.tabFrame) {
	var wlTemp = window.location.href;
      window.location = mvcContextPath+"/detailFrame.jsp?TF="+wlTemp.replace("?","|").replace("=","~") +'&BF='+mvcContextPath+targetURL.replace("&",",").replace("?","|").replace(/=/g,"~");
    } else {
      parent.frames[1].window.location = mvcContextPath+targetURL;
    }
 }
}
function doDVRadioSelect(row,formObj) {
   if(!formObj.id_select.length) {
      formObj.id_select.checked=true;
   } else {
      formObj.id_select[row-1].checked=true;
   }
}

function doDVCheckboxSelect(row,formObj) {
   if(!formObj.id_select.length) {
      var curVal = formObj.id_select.checked;
      if(curVal==true) {
         formObj.id_select.checked=false;
      } else {
         formObj.id_select.checked=true;
      }
   } else {
      var curVal = formObj[row-1].checked;
      if(curVal==true) {
         formObj[row-1].checked=false;
      } else {
         formObj[row-1].checked=true;
      }
   }
}


function doTabPage(targetURL) {
   if(mvcDirtyFlag==true) {
      if(confirm('            *** The page was modified. ***\r\rPress Cancel to return to the page to save your changes.\rPress Ok, to continue, you will loose your changes.')) {
         window.location.replace(mvcContextPath+targetURL);
      } else {
         return false;
      }
   } else {
      window.location.replace(mvcContextPath+targetURL);
   }
}

function mvcDoPrintReports(formObj,queryParams) {
   if(!formObj.id_select) {
      alert('There is no table with id_select as the selection item');
      return false;
   }
   var idSel = mvcGetSelectedRadioValue(formObj.id_select);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }
   var strPath = document.location.pathname;
   var ReportPath = '/frmwkReports.jsp';

   if(queryParams!=null&&queryParams!='') {
      var win = window.open(mvcContextPath+ReportPath + '?id_select='+idSel+'&jsp='+strPath.substring(strPath.indexOf('/',1))+'&'+queryParams,'print_report','width=640,height=480,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
      win.focus();
   } else {
      var win = window.open(mvcContextPath+ReportPath + '?id_select='+idSel+'&jsp='+strPath.substring(strPath.indexOf('/',1)),'print_report','width=640,height=480,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
      win.focus();
   }
   return false;
}

/*function mvcDoReportParameters(formObj,queryParams) {
   if(!formObj.id_report) {
      alert('There is no table with id_report as the selection item');
      return false;
   }
   var idSel = mvcGetSelectedRadioValue(formObj.id_report);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }
   var strURL = mvcContextPath+'/frmwkReportParam.jsp?id_report='+idSel;
   if(queryParams!=null&&queryParams!='') {
      strURL = strURL + '&' + queryParams;
   }
   var win = window.open(strURL,'print_report','width=600,height=350,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
  win.focus();
   return false;
}*/
/* Vijy2, to directly call the report without prompting for parameters page */
function mvcDoRunReport(formObj,queryParams) {
   if(!formObj.id_report) {
      alert('There is no table with id_report as the selection item');
      return false;
   }

   var idSel = formObj.id_report.value;
   //var idSel = mvcGetSelectedRadioValue(formObj.id_report);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }
   var strURL = mvcContextPath+'/frmwkReportParam.jsp?id_report='+idSel;
   if(queryParams!=null&&queryParams!='') {
      strURL = strURL + '&' + queryParams;
   }
   //var win = window.replace(strURL,'print_report','width=600,height=350,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
    formObj.Submit.value='Submit';
Validation(formObj);
doSubmitForm();
//    formObj.submit();
   return false;
}

function mvcDoReportParameters(formObj,queryParams) {
   if(!formObj.id_report) {
      alert('There is no table with id_report as the selection item');
      return false;
   }
   var idSel = mvcGetSelectedRadioValue(formObj.id_report);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }

   var strURL = mvcContextPath+'/frmwkReportParam.jsp?id_report='+idSel;

   if(queryParams!=null&&queryParams!=''&&queryParams!='null') {
      strURL = strURL + queryParams;
   }
   var win = window.open(strURL,'print_report','width=600,height=350,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
  win.focus();
   return false;
}

function viewMSDSDocument(id_msds)
{
   var location_path = new String(document.location);
   var win = window.open(mvcContextPath+'/frmwkSpoolDocument.jsp?path='+location_path+'&i='+id_msds,'spool_document','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   // wait for window to paint
   while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   win.document.forms[0].submit();
 	win.focus();


}


function frmwkSpoolDocument(formObj)
{
   if(!formObj.id_select) {
      alert('There is no table with id_select as the selection item');
      return false;
   }
   var idSel = mvcGetSelectedRadioValue(formObj.id_select);
   //alert('idSel ='+idSel);
   var location_path = new String(document.location);
   //alert(location_path);
   var idx = location_path.indexOf("?");
   /*String strSp added to check the get document page is having id_document value
    or other value. If formObj.sp object is not in that page then the page does
    not have id_document. This checking added by Ramesh.k on 01/18/2005.
   */
   var strSp=null;
   if(formObj.sp=='[object]')
      strSp = formObj.sp.value

   if (idx > 0)
      location_path =location_path.substring(0,idx);
   //alert(location_path);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }
   if (idSel==null)
   {
      alert('The Document corresponding to the entity selected cannot be found.');
      return false;
   }
   var win = window.open(mvcContextPath+'/frmwkSpoolDocument.jsp?i='+idSel+'&sp='+strSp,'spool_document','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   // wait for window to paint
   while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   win.document.forms[0].submit();
 	win.focus();
   return false;
}

 /*
    Function commented by V. Ramkumar on 31st Dec 2004 as the stream is done,
    thro a single interface frmWkSpoolDocument.*/

function frmwkMsdsDocument(formObj) {
   if(!formObj.id_select) {
      alert('There is no table with id_select as the selection item');
      return false;
   }
   var idSel = mvcGetSelectedRadioValue(formObj.id_select);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }
 	var win = window.open(mvcContextPath+'/frmwkMsdsDocument.jsp?i='+idSel,'spool_document','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   // wait for window to paint
  while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   win.document.forms[0].submit();
 	win.focus();
   return false;
}


/* Function commented by V. Ramkumar on 31st Dec 2004 as the stream is done,
   thro a single interface frmWkSpoolDocument.*/

function frmwkSafeUseGuide(formObj) {
   if(!formObj.id_select) {
      alert('There is no table with id_select as the selection item');
      return false;
   }
   var idSel = mvcGetSelectedRadioValue(formObj.id_select);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }
 	var win = window.open(mvcContextPath+'/frmwkSafeUseGuide.jsp?i='+idSel,'spool_document','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   // wait for window to paint
  while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   win.document.forms[0].submit();
 	win.focus();
   return false;
}



function frmwkSpoolReport(formObj) {
   if(!formObj.id_select) {
      alert('There is no table with id_select as the selection item');
      return false;
   }
   var idSel = mvcGetSelectedRadioValue(formObj.id_select);
   if (idSel==null) {
      alert('nothing selected');
      return false;
   }
 	var win = window.open(mvcContextPath+'/frmwkSpoolReport.jsp?r='+idSel+'&i='+formObj.i.value,'spool_report','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   // wait for window to paint
   while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   win.document.forms[0].submit();
 	win.focus();
   this.close();
   return false;
}
function mvcDoTableAction(formObj,formDataID,actionValue)
{
 if(actionValue=='Cancel') {
     mvcClosePopWindow();
     return false;
   }
   if(formObj.id_select && actionValue!='SetFilter') {
      var idSel = mvcGetSelectedRadioValue(formObj.id_select);
      if (idSel==null) {

         alert('nothing selected');
         return false;
      }
   }
	if(actionValue=='Delete') {

		if(!confirm('Delete selected record(s)?')) {
			mvcClearRefresh();
			return false;
		}
      if(!parent.tabFrame) {
         null;
      } else {
         parent.tabFrame.window.location = mvcContextPath+"/blank.html";
      }
	}
   if(actionValue=='frmwkSpoolDocument')
   {
      frmwkSpoolDocument(formObj);
   }
   else {
	formObj.mvcFormDataID.value=formDataID;
   	formObj.mvcActionID.value=actionValue;
   	formObj.submit();
   }
	return true;
}

function mvcDoTableRowUp(tableID,rowNum) {
	var oRow = document.all[tableID].rows(tableID+'_'+rowNum);
	var thisCellUp = document.all[tableID].rows(oRow.rowIndex).cells(0).innerHTML;
	var destCellUp = document.all[tableID].rows(oRow.rowIndex-1).cells(0).innerHTML;
	document.all[tableID].rows(oRow.rowIndex).cells(0).innerHTML = destCellUp;
	document.all[tableID].rows(oRow.rowIndex).id = tableID+'_'+(rowNum-1);
	document.all[tableID].rows(oRow.rowIndex-1).cells(0).innerHTML = thisCellUp;
	document.all[tableID].rows(oRow.rowIndex-1).id = tableID+'_'+rowNum;
	document.all[tableID].moveRow(oRow.rowIndex-1,oRow.rowIndex);
}

function mvcDoTableRowDown(tableID,rowNum) {
	var oRow = document.all[tableID].rows(tableID+'_'+rowNum);
	var thisCellDown = document.all[tableID].rows(oRow.rowIndex).cells(0).innerHTML;
	var destCellDown = document.all[tableID].rows(oRow.rowIndex+1).cells(0).innerHTML;
	document.all[tableID].rows(oRow.rowIndex).cells(0).innerHTML = destCellDown;
	document.all[tableID].rows(oRow.rowIndex).id = tableID+'_'+(rowNum+1);
	document.all[tableID].rows(oRow.rowIndex+1).cells(0).innerHTML = thisCellDown;
	document.all[tableID].rows(oRow.rowIndex+1).id = tableID+'_'+rowNum;
	document.all[tableID].moveRow(oRow.rowIndex,oRow.rowIndex+1);
}

// when user clicks on object access button, we need to set the form variable that the framework
// ActionRouterListner looks to to ascertain what action to take, done with JavaScript rather
// than input buttons to simplify the framework logic
function mvcDoObjectAccess(formObj,actionSelected) {
	if(actionSelected=='Listing') {
		if(top.navFrame.navTree.getSelected()!=null) {
			top.dataFrame.location.replace(top.navFrame.navTree.getSelected().action);
			return true;
		} else {
			alert('There is nothing selected in the navigation tree.  Please select something from the tree to navigate');
			return false;
		}
	}
	if(actionSelected=='Delete') {
		if(!confirm('Delete selected record?')) {
			mvcClearRefresh();
			return false;
		}
	}
   if(mvcDirtyFlag==true) {
      if(actionSelected=='0') {
      	formObj.mvcActionID.value=actionSelected;
      	if(mvcValidateForm(formObj)==true) {
      		// we set the closing flag so we don't
      		// validate the form a second time with
      		// the submit
      		formObj.mvcIsClosing.value = 'T';
      		formObj.submit();
      		return true;
      	} else {
      		return false;
      	}
      }
      if(confirm('            *** The page was modified. ***\r\rPress Cancel to return to the page to save your changes.\rPress Ok, to continue, you will loose your changes.')) {
      	formObj.mvcActionID.value=actionSelected;
      	if(mvcValidateForm(formObj)==true) {
      		// we set the closing flag so we don't
      		// validate the form a second time with
      		// the submit
      		formObj.mvcIsClosing.value = 'T';
      		formObj.submit();
      		return true;
      	} else {
      		return false;
      	}
      } else {
         return false;
      }
   } else {

   	formObj.mvcActionID.value=actionSelected;
   	if(mvcValidateForm(formObj)==true) {
   		// we set the closing flag so we don't
   		// validate the form a second time with
   		// the submit
   		formObj.mvcIsClosing.value = 'T';
                formObj.submit();
   		return true;
   	} else {
   		return false;
   	}

   }
}

function mvcDoTableSort(formObj,formDataID,columnNum) {
	if(formObj.mvcSortID) {
		formObj.mvcFormDataID.value=formDataID;
		formObj.mvcSortID.value=columnNum;
		formObj.submit();
	}
}

function mvcDoTablePage(formObj,formDataID,pageNum,maxPage) {
	if(formObj.mvcPageID) {
                if(isNaN(pageNum)) {
                   alert("Pae Number is not valid");
                   return false;
                }
                if(pageNum < 1 || pageNum > maxPage) {
                   alert("Page Number is out of range");
                   formObj.mvcPageID.value=pageNum;
                   return false;
                }
		formObj.mvcFormDataID.value=formDataID;
		formObj.mvcPageID.value=pageNum;
		formObj.submit();
	}
}

function mvcDoTableToggleOption(formObj,formDataID) {
	formObj.mvcFormDataID.value=formDataID;
	formObj.mvcActionID.value='ToggleOptions';
	formObj.submit();
	return true;
}

function mvcDoClearFilters(formObj,formDataID) {
	formObj.mvcFormDataID.value=formDataID;
	formObj.mvcActionID.value='ClearFilters';
	formObj.submit();
	return true;
}

function mvcDoTableRecordsPerPage(formObj,formDataID,selectObj) {
	formObj.mvcFormDataID.value=formDataID;
	formObj.mvcItemsPerPage.value=selectObj.options[selectObj.selectedIndex].value;
	formObj.submit();
}

function mvcSetTopFrameTitle(titleText) {
   if(top.headFrame) {
      if(top.headFrame.document.getElementById('titletext')) {
         top.headFrame.document.getElementById('titletext').innerHTML = titleText;
      }
   }
}

function changeGeneratorSelected(newGeneratorName) {
	var txt = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"blacktext\" nowrap>";
	txt = txt + newGeneratorName
	txt = txt + "</td><td width=\"100%\"><img src=\"/ttimages/page/header_select.gif\"></td></tr></table>";
	top.headFrame.document.all['page_message'].innerHTML = txt;
}

function mvcGetSelectedRadioValue(formObj) {
	if(formObj.length) {

		for(var i=0; i<formObj.length; i++) {
			if(formObj[i].checked==true) {
                             // alert('value1 = '+formObj[i].value);
				return formObj[i].value;
			}
		}
	} else {

               //Added by Rekha.. on 1/13/05.-to give alert as "nothing selected" while deleting  single record
                if(formObj.checked==true){

		    return formObj.value;
		 }
	}
}

function mvcCloseWindow() {
	// this function will set the ttIsClosing flag in all
	// forms on the page, the the validateForm function will
	// allow exit without validation
	for(var f=0;f<document.forms.length;f++) {
		for(var i=0;i<document.forms[f].elements.length;i++) {
			if(document.forms[f].elements[i].name=='mvcIsClosing') {
				document.forms[f].elements[i].value='T';
				break;
			}
		}
	}
}

// This function is called by the framework FormTag when
// an action event has mapped close/reload parent, the
// hintID is to pass back to parent which record in its
// dataView should be selected
function mvcCloseAndReloadParent(hintID) {
   var win = this.window.top;
   var winOpener = win.opener;
   if(winOpener) {
      var wURL = winOpener.location;
      if(hintID&&hintID!='T') {
         winOpener.location = wURL+'&frmwkRefreshID='+hintID;
      } else {
         winOpener.location = wURL;
      }
   } else {
      var wURL = parent.frames[0].window.location;
      if(hintID&&hintID!='T') {
         parent.frames[0].window.location = wURL+'&frmwkRefreshID='+hintID;
      } else {
         parent.frames[0].window.location = wURL;
      }
   }
   win.close();
   return true;
}

// This function is called by the framework FormTag when
// an action event has mapped close/reload parent, the
// hintID is to pass back to parent which record in its
// dataView should be selected
function mvcReloadParent(hintID) {
   var win = this.window.top;
   var winOpener = win.opener;
   if(winOpener) {
      var wURL = winOpener.location;
      if(hintID&&hintID!='T') {
         winOpener.location = wURL+'&frmwkRefreshID='+hintID;
      } else {
         winOpener.location = wURL;
      }
   } else {
      var wURL = parent.frames[0].window.location;
      if(hintID&&hintID!='T') {
         parent.frames[0].window.location = wURL+'&frmwkRefreshID='+hintID;
      } else {
         parent.frames[0].window.location = wURL;
      }
   }
   return true;
}

function doSubmitForm() {
   if(mvcValidateForm(document.FORM_1)) {
      document.FORM_1.submit();
   } else {
      return false;
   }
}

function doFormAction(action) {
   if(mvcValidateForm(document.FORM_1)) {
      document.FORM_1.submit();
   } else {
      return false;
   }
}


function mvcClosePopWindow() {
   if(mvcDirtyFlag==true) {
      if(confirm('            *** The page was modified. ***\r\rPress Cancel to return to the page to save your changes.\rPress Ok, to continue, you will loose your changes.')) {
         var win = this.window.top;
         win.close();
      } else {
         return false;
      }
   } else {
      var win = this.window.top;
      win.close();
   }
   return true;
}

function mvcCloseNewRecord() {
   if(mvcDirtyFlag==true) {
      if(confirm('            *** The page was modified. ***\r\rPress Cancel to return to the page to save your changes.\rPress Ok, to continue, you will loose your changes.')) {
         window.location = mvcContextPath+"/blank.html";
      } else {
         return false;
      }
   } else {
      window.location = mvcContextPath+"/blank.html";
   }
   return true;
}

function mvcSetRefresh() {
	// this function sets the refresh flag for all forms on the page
	for(var f=0;f<document.forms.length;f++) {
		for(var i=0;i<document.forms[f].elements.length;i++) {
			if(document.forms[f].elements[i].name=='mvcIsRefreshing') {
				document.forms[f].elements[i].value='T';
				break;
			}
		}
	}
}

function mvcClearRefresh() {
	// this function sets the refresh flag for all forms on the page
	for(var f=0;f<document.forms.length;f++) {
		for(var i=0;i<document.forms[f].elements.length;i++) {
			if(document.forms[f].elements[i].name=='mvcIsRefreshing') {
				document.forms[f].elements[i].value='F';
				break;
			}
		}
	}
}

function mvcShowMessage(msg_txt) {
	status = msg_txt;
}

function mvcClearStatus() {
	status = defaultStatus;
}

function isEmpty(formObj) {
	if(formObj.value.length == 0) {
		return true;
	}
	return false;
}

function isValidEmail(formObj) {
	var matchArray = formObj.value.match(/^(.+)@(.+)\.(.+)$/);
	if(matchArray == null) {
		return false;
	}
	return true;
}

function isValidNumber(formObj) {
	var matchArray = formObj.value.match(/^[0-9]+$/);
	if(matchArray == null) {
		return false;
	}
	return true;
}

function isValidDecimalNumber(formObj) {
	var matchArray = formObj.value.match(/^[0-9,\.]+$/);
	if(matchArray == null) {
		return false;
	}
	return true;
}

function isValidDate(formObj) {
	if(formObj.value.length==0) {
		return false;
	}
	var d = formObj.value;
	d = new Date(d);
	if (isNaN(d)) {
		d = null;
		return false;
	}
	return true;
}

// this function is called to reformat date strings based on users local settings
function mvcFormLoaded(formObj) {
	mvcSetFormElementProperties(formObj);
	for(var i=0;i<formObj.length;i++) {
		var formElement = formObj.elements[i];
      // we need to paint the data from calendar tags into their visible input element
      if(formElement.isDate) { // input element may have been painted by calendar tag
         var iVal = formElement.name.indexOf('calPopFld'); // all pop calendar fields end in calPopFld
         if(iVal>0) {
         var lVal = formElement.name.lastIndexOf('d');
         var eVal = formElement.name.substring(iVal+9,formElement.name.length);
         var objID1 = formElement.name.substring(0,iVal);
         var objID = formElement.name.substring(0,iVal);
            if(eVal.match(/^[0-9]+$/)){
             objID = objID1 +"[" + eVal + "]";
              formElement.id = objID;
            }
            //dateObj = document.getElementById(objID);
            dateObj=eval("document.FORM_1."+objID);
            dateObj2=eval("document.FORM_1."+objID1);
            if(dateObj) {
               if(dateObj.value) {
                  formElement.value = mvcGetShortDateFormat(dateObj.value);
               }
            } // if we find date object
            else {
               if(dateObj2.value) {
                  formElement.value = mvcGetShortDateFormat(dateObj2.value);
               }
            } // if we find date object
         } // if painted by calendar tag
      } // if(formElement.isDate)
      else if(formElement.isDateText) { // hidden element painted by text tag to allow localization of date output
         if(formElement.value) {
            if(formElement.value.length) {
               // we know text tag painted date into a <div> tag
               dateObj = document.getElementById(formElement.name+'Txt');
               if(dateObj) {
                 dateObj.innerHTML = mvcGetShortDateFormat(formElement.value);
               }
            } // if(formElement.value.length
         } // if(formElement.value)
      } // else if(formElement.isDateText)
   } // for(var i=0;i<formObj.length;i++)
   if(formObj.frmwkRefreshID) {
      if(formObj.frmwkRefreshID!='T') {
         if(formObj.id_select) {
          	if(formObj.id_select.length) {
         		for(var i=0; i<formObj.id_select.length; i++) {
         			if(formObj.id_select[i].value==formObj.frmwkRefreshID.value) {
               		doDVRadioReselectEditRow(i+1);
         				return;
         			}
         		}
         	} else {
           		doDVRadioReselectEditRow(1);
         	} // formObj.length
         } // if(formObj.id_select)
      } //formObj.frmwkRefreshID!='T'
   } // if(formElement.frmwkRefreshID)
}

function mvcValidateForm(formObj) {
	// check to see if the user clicked the 'close' button, if so exit without validation
	if(formObj.mvcIsClosing.value=='T') {
		return true;
	}
	// first we check to see if the form is being resubmitted
	if(formObj.mvcIsRefreshing.value=='T') {
		if(!confirm('This page has already been submitted.\n\nCancel to return to page,\nOk to continue.')) {
			return false;

		}
	}
	// set the refresh flag so if the user clicks a submit button it will be intercepted
	// this function makes sure the refresh flag is set for all forms on the page rather
	// than just the form that submitted the action
	mvcSetRefresh();
	// we need to set the JavaScript properties of all the controls in this form
	// in order to validate the form
	mvcSetFormElementProperties(formObj);
	// now we process all the elements on the form
	for(var i=0;i<formObj.length;i++) {
		var formElement = formObj.elements[i];
		// first we check to see if the element is empty, but is not optional
		// we focus on text fields first
		if(formElement.type=="text"){
			// as a default all fields are 'required' so if the optional property is not defined, or
			// if the optional property is set to false then we need to make sure the text field has
			// a value in it.  This is only a check for a value, not a 'valid' value which will occur
			// in the next block of code.
			if(!formElement.optional) {
				if(isEmpty(formElement)) {
					formElement.focus();
					alert('You must enter a value for '+formElement.name);
					mvcClearRefresh();
					return false;
				}
			}
			// Ok, we now know that all the required fields are not empty, so we can validate their value.
			// Remember that we need to validate the data in all non-Empty fields, not just the required fields.
			// We utilize the isDate, isNumeric and isEmail properties to perform basic client side data validation.
			if(!isEmpty(formElement)) {
				if(formElement.isDate) {
					if(!isValidDate(formElement)) {
						formElement.focus();
						alert('The date value for '+formElement.name+' is not valid.');
						mvcClearRefresh();
						return false;
					} else {
						// all date fields need to be formated for input into the database
						replaceDateString(formElement);
					}
				} else if(formElement.isNumeric) {
					// we stip any dollar signs or commas from the field
					var vNum = formElement.value.replace(/[\,,\\$]/g,"");
					var v = parseFloat(vNum);
					if(isNaN(v)){
						formElement.focus();
						alert('The numeric value for  '+formElement.name+' is not valid.');
						mvcClearRefresh();
						return false;
					} else {
						if(formElement.min) {
							var vMinVal = formElement.min.replace(/[\,,\\$]/g,"");
							var vMin1 = parseFloat(vMinVal);
							if(v<vMin1) {
								formElement.focus();
								alert('The numeric value for  '+formElement.name+' is below the minimum value of '+formElement.min);
								mvcClearRefresh();
								return false;
							}
						}  // min
						if(formElement.max) {
							var vMaxVal = formElement.max.replace(/[\,,\\$]/g,"");
							var vMax1 = parseFloat(vMaxVal);
							if(v>vMax1) {
								formElement.focus();
								alert('The numeric value for  '+formElement.name+' is above the maximum value of '+formElement.max);
								mvcClearRefresh();
								return false;
							}
						} // max
					} // isNaN
					// repacle the existing value for submittal to server
					formElement.value = vNum;
				} else if(formElement.isEmail) {
					if(!isValidEmail(formElement)) {
						formElement.focus();
						alert('The email address for '+formElement.name+' is not valid.');
						mvcClearRefresh();
						return false;
					}
				} else if(formElement.isInteger) {
					if(!isValidNumber(formElement)) {
						formElement.focus();
						alert('The integer number for '+formElement.name+' is not valid.');
						mvcClearRefresh();
						return false;
					} else {
						var iVal = parseInt(formElement.value);
						if(formElement.min) {
							if(!isValidNumber(formElement.min)) {
								formElement.focus();
								alert('The integer value specified as the minimum value for '+formElement.name+' is not a valid integer.');
								mvcClearRefresh();
								return false;
							}
							var vMin2 = parseInt(formElement.min);
							if(v<vMin2) {
								formElement.focus();
								alert('The numeric value for  '+formElement.name+' is below the minimum value of '+formElement.min);
								mvcClearRefresh();
								return false;
							}
						} // min
						if(formElement.max) {
							if(!isValidNumber(formElement.max)) {
								formElement.focus();
								alert('The integer value specified as the maximum value for '+formElement.name+' is not a valid integer.');
								mvcClearRefresh();
								return false;
							}
							var vMax2 = parseInt(formElement.max);
							if(v>vMax2) {
								formElement.focus();
								alert('The numeric value for  '+formElement.name+' is above the maximum value of '+formElement.max);
								mvcClearRefresh();
								return false;
							}
						} // max
					} // valid number
				} // integer/date/numeric
			} // !isEmpty()
		} else if(formElement.type=="textarea") {
			if(!formElement.optional) {
				if(isEmpty(formElement)) {
					formElement.focus();
					alert('You must enter a value for '+formElement.name);
					mvcClearRefresh();
					return false;
				}
			}
			if(!isEmpty(formElement)) {
				if(formElement.value.length>formElement.maxchars) {
					alert('The value you entered for '+formElement.name+' was to long.  This\rfield only supports up to '+formElement.maxchars+' characters and your value\rwas ' + formElement.value.length + ' characters long.\r\rCAUTION: Your value was truncated to fit this field.');
					formElement.value = formElement.value.substring(0,formElement.maxchars);
				}
			}

		} // formElement.type == text/textarea
//--------------------------------------- Script added by S.Anantha Narayanan for validate the Date field isEmpty
                  if(isEmpty(formElement)){
                     if(formElement.isDate){
                       if(formElement.type=='hidden'){
                            if(!formElement.optional){
                               alert('You must enter a value for '+formElement.name);
                               mvcClearRefresh();
                               return false;
                               }
                            }
                          }
                        }
//--------------------------------------
	} // for each element
	return true;
}

function rewriteURL(strObj) {
	// replace all occurances of whitespace with '%20' character for URL
	var retVal = strObj.replace(/\s/g,"%20");
	return retVal;
}

function getDateString(d) {
	var yy = d.getFullYear();
	var mm = d.getMonth() + 1;
	var dd = d.getDate();
	var dCoded = 'none';
   if(yy<1970)
      yy += 100;
	if(mm<10) {
		dCoded = '0' + mm + '/';
	} else {
		dCoded = mm + '/';
	}
	if(dd<10) {
		dCoded += '0' + dd;
	} else {
		dCoded += dd;
	}
	dCoded += '/' + yy
	return dCoded;
}

function replaceDateString(formObj) {
	var dstr = formObj.value;
	dval = new Date(dstr);
	var yy_val = dval.getFullYear();
	var mm_val = dval.getMonth() + 1;
	var dd_val = dval.getDate();
	var codedStr = 'none';
   if(yy_val<1970)
      yy_val += 100;
	if(mm_val<10) {
		codedStr = '0' + mm_val + '/';
	} else {
		codedStr = mm_val + '/';
	}
	if(dd_val<10) {
		codedStr += '0' + dd_val;
	} else {
		codedStr += dd_val;
	}
	codedStr += '/' + yy_val
	formObj.value = codedStr;
}

function mvcGetShortDateFormat(strFrmwkFormat) {
   if(!strFrmwkFormat.length) {
      return "";
   }
   var dArray = strFrmwkFormat.split('/'); // always MM/DD/YYYY
   locDate = new Date(dArray[2],dArray[0]-1,dArray[1]);
   var fmtString = locDate.toLocaleDateString();
   if(fmtString!=NaN){
   if(fmtString.indexOf(', ')>0) {
      // US Format
      fmtString = strFrmwkFormat;
   } else {
      // the month is spelled out and will therefore be NaN.
      var strArray = fmtString.split(' ');
      if(isNaN(strArray[0])) {
         // month is first
         fmtString  = dArray[0];
         fmtString += '/';
         if(strArray[1].length>2) {
            // year is second - MM/YYYY/DD
            fmtString += dArray[2];
            fmtString += '/';
            fmtString += dArray[1];
         } else {
            // day is second -- MM/DD/YYYY
            fmtString += dArray[1];
            fmtString += '/';
            fmtString += dArray[2];
         }
      } else if(isNaN(strArray[1])) {
         // month is second
         if(strArray[0].length>2) {
            // year is first -- YYYY/MM/DD
            fmtString  = dArray[2];
            fmtString += '/';
            fmtString += dArray[0];
            fmtString += '/';
            fmtString += dArray[1];

         } else {
            // day is first -- DD/MM/YYYY
            fmtString  = dArray[1];
            fmtString += '/';
            fmtString += dArray[0];
            fmtString += '/';
            fmtString += dArray[2];
         }
      } else {
         // month is last?
         if(strArray[0].length>2) {
            // year is first -- YYYY/DD/MM
            fmtString  = dArray[2];
            fmtString += '/';
            fmtString += dArray[1];
            fmtString += '/';
            fmtString += dArray[0];
         } else {
            // day is first -- DD/YYYY/MM
            fmtString  = dArray[1];
            fmtString += '/';
            fmtString += dArray[2];
            fmtString += '/';
            fmtString += dArray[0];
         }
      }
   }
   }
   return fmtString;
}

function mvcPopCalendar(frmObj,inputID,popTitle,e) {
   var winProp = 'width=185,height=165,location=no,menu=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes';
   winProp += ',left=';
   winProp += e.clientX-60;
   winProp += ',top=';
   winProp += e.clientY-10;
   var win = window.open(mvcContextPath+'/frmwkCalendar.html','mvcCalendarPop',winProp);
   // wait for window to paint
   var idSel = 1;
   while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   var obj=eval("document."+frmObj+"." + inputID);
   obj.id=inputID;
   win.mvcCalPopShow(frmObj,obj.id,popTitle,e);
   win.moveTo(e.clientX-60,e.clientY-10);
   win.focus();
}


// Check Browser for Css
// Added By Dominic, 11/12/2003
var mvcContextPath;

if(document.all) {
  document.write("<link type='text/css' rel='stylesheet' href='");
  document.write(mvcContextPath);
  document.write("/css/ie.css'>");

}
else if(document.getElementById) {
  document.write("<link type='text/css' rel='stylesheet' href='");
  document.write(mvcContextPath);
  document.write("/css/netscape.css'>");
}
else if(document.layers) {
  document.write("<link type='text/css' rel='stylesheet' href='");
  document.write(mvcContextPath);
  document.write("/css/netscape.css'>");
}
/****** For Populating and Validating MM/DD/YYYY Date select boxes
*       Coded by Mr.Sagayaraj, dated 09/16/2004
*/

function populateDate()
{
  var nowDate = new Date();
  var theForm = document.FORM_1;
	var d = theForm.day.options[theForm.day.selectedIndex].value;

	var m = theForm.month.options[theForm.month.selectedIndex].value;
	  //d = (dd < 10) ? '0' + dd : dd;

	var y = theForm.year.options[theForm.year.selectedIndex].value;
	var val = (m +'/'+ d +'/'+ y);
	theForm.accum_date.value =  val;
}
function MWJ_findSelect( oName, oDoc ) { //get a reference to the select box using its name
	if( !oDoc ) { oDoc = window.document; }
	for( var x = 0; x < oDoc.forms.length; x++ ) { if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }
	for( var x = 0; document.layers && x < oDoc.layers.length; x++ ) { //scan layers ...
		var theOb = MWJ_findObj( oName, oDoc.layers[x].document ); if( theOb ) { return theOb; } }
	return null;
}
function dateChange( d, m, y ) {
	d = MWJ_findSelect( d ), m = MWJ_findSelect( m ), y = MWJ_findSelect( y );
	//work out if it is a leap year
	var IsLeap = parseInt( y.options[y.selectedIndex].value );
	IsLeap = !( IsLeap % 4 ) && ( ( IsLeap % 100 ) || !( IsLeap % 400 ) );
	//find the number of days in that month
	IsLeap = [31,(IsLeap?29:28),31,30,31,30,31,31,30,31,30,31][m.selectedIndex];
	//store the current day - reduce it if the new month does not have enough days
	var storedDate = ( d.selectedIndex > IsLeap - 1 ) ? ( IsLeap - 1 ) : d.selectedIndex;
	while( d.options.length ) { d.options[0] = null; } //empty days box then refill with correct number of days
	for( var x = 0; x < IsLeap; x++ ) {
		temp = x + 1;
		xx = (temp < 10) ? '0' + temp : temp;
		d.options[x] = new Option( xx, xx);
	}
	d.options[storedDate].selected = true; //select the number that was selected before
	if( window.opera && document.importNode ) { window.setTimeout('MWJ_findSelect( \''+d.name+'\' ).options['+storedDate+'].selected = true;',0); }
}
function setToday( d, m, y ) {
	d = MWJ_findSelect( d ), m = MWJ_findSelect( m ), y = MWJ_findSelect( y );
	var now = new Date(); var nowY = ( now.getYear() % 100 ) + ( ( ( now.getYear() % 100 ) < 39 ) ? 2000 : 1900 );
	//if the relevant year exists in the box, select it
	for( var x = 0; x < y.options.length; x++ ) { if( y.options[x].value == '' + nowY + '' ) { y.options[x].selected = true; if( window.opera && document.importNode ) { window.setTimeout('MWJ_findSelect( \''+y.name+'\' ).options['+x+'].selected = true;',0); } } }
	//select the correct month, redo the days list to get the correct number, then select the relevant day
	m.options[now.getMonth()].selected = true; dateChange( d.name, m.name, y.name ); d.options[now.getDate()-1].selected = true;
	if( window.opera && document.importNode ) { window.setTimeout('MWJ_findSelect( \''+d.name+'\' ).options['+(now.getDate()-1)+'].selected = true;',0); }
}
function checkMore( y, curBot, curTop, min, max ) {
	var range = curTop - curBot;
	if( typeof( y.nowBot ) == 'undefined' ) { y.nowBot = curBot; y.nowTop = curTop; }
	if( y.options[y.selectedIndex].value == 'MWJ_DOWN' ) { //they have selected 'lower'
		while( y.options.length ) { y.options[0] = null; } //empty the select box
		y.nowBot -= range + 1; y.nowTop = range + y.nowBot; //make note of the start and end values
		//adjust the values as necessary if we will overstep the min value. If not, refill with the
		//new option for 'lower'
		if( min < y.nowBot ) { y.options[0] = new Option('Lower ...','MWJ_DOWN'); } else { y.nowBot = min; }
		for( var x = y.nowBot; x <= y.nowTop; x++ ) { y.options[y.options.length] = new Option(x,x); }
		y.options[y.options.length] = new Option('Higher ...','MWJ_UP');
		y.options[y.options.length - 2].selected = true; //select the nearest number
		if( window.opera && document.importNode ) { window.setTimeout('MWJ_findSelect( \''+y.name+'\' ).options['+(y.options.length - 2)+'].selected = true;',0); }
	} else if( y.options[y.selectedIndex].value == 'MWJ_UP' ) { //A/A except upwards
		while( y.options.length ) { y.options[0] = null; }
		y.nowTop += range + 1; y.nowBot = y.nowTop - range;
		y.options[0] = new Option('Lower ...','MWJ_DOWN');
		if( y.nowTop > max ) { y.nowTop = max; }
		for( var x = y.nowBot; x <= y.nowTop; x++ ) { y.options[y.options.length] = new Option(x,x); }
		if( max > y.nowTop ) { y.options[y.options.length] = new Option('Higher ...','MWJ_UP'); }
		y.options[1].selected = true;
		if( window.opera && document.importNode ) { window.setTimeout('MWJ_findSelect( \''+y.name+'\' ).options[1].selected = true;',0); }
	}
}
function reFill( y, oBot, oTop, oDown, oUp ) {
	y = MWJ_findSelect( y ); y.nowBot = oBot; y.nowTop = oTop;
	//empty and refill the select box using the range of numbers specified
	while( y.options.length ) { y.options[0] = null; }

	for( var x = oBot; x <= oTop; x++ ) { y.options[y.options.length] = new Option(x,x); }
	}

/**** End of Populating Date
*
*/
function mvcDoFilterOnEnter(formObj,formDataID,actionValue)
{
  if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)){
      mvcDoTableAction(formObj,formDataID,actionValue);
  }
}
function mvcDoPageOnEnter(formObj,formDataID,pageNum,maxPage)
{
  if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)){
      mvcDoTablePage(formObj,formDataID,formObj.gotopage.value,maxPage);
  }
}
function mvcActionNavigate(formObj,actionValue) {

    //  alert("Anthuv");
   var theURL = actionValue;
         //alert(theURL);
   if(formObj.id_select) {
      var idSel = mvcGetSelectedRadioValue(formObj.id_select);
      if (idSel==null) {
         alert('nothing selected');
         return false;
      } else {
        if(theURL.indexOf('?')>0) {
         theURL += '&id_selected='+idSel;
        } else {
         theURL += '?id_selected='+idSel;
        }
      }
   }
   var win = window.open(theURL,'actionPop','width=800,height=400,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   win.focus();
	return true;
}
function doDVViewRecord(targetURL,frmObj) {
 //var baseTarget ='blank';
if(frmObj.id_select!='[object]'){
   alert('nothing selected');
   return false;
}
var idSel=mvcGetSelectedRadioValue(frmObj.id_select);
      if (idSel==null) {
         alert('nothing selected');
         return false;
      } else {
          targetURL=targetURL+idSel;
 	  var win = window.open(mvcContextPath+targetURL,'','width=600,height=450,left=30,top=30,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
 	  win.focus();
      }
}

 function viewSafeUserGuide(id_value)
 {
       var win = window.open(mvcContextPath+'/frmwkSpoolDocument.jsp?i='+id_value+'&sp=N','spool_document','width=600,height=450,left=210,top=150,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
       if (id_value==null)
       {
           win.close();
           alert('Sorry there was no Corresponding SafeUseGuide ');
           return;
       }

        // // wait for window to paint
       var idSel=0;
        while(win.document.forms.length<1)
        {
             idSel = idSel*3;
        }
        win.document.forms[0].submit();
        //win.focus();
 }


function viewMSDSDocument(id_msds)
{
   var location_path = new String(document.location);
   var win = window.open(mvcContextPath+'/frmwkSpoolDocument.jsp?path='+location_path+'&i='+id_msds,'spool_document','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   // wait for window to paint
   var idSel=0;
   while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   win.document.forms[0].submit();
   win.focus();
}



function viewSpanishSafeUserGuide(id_value)
{
       var win =window.open(mvcContextPath+'/frmwkSpoolDocument.jsp?i='+id_value+'&path=spanishsafeuseguide','popup','width=600,height=450,left=210,top=150,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
       if (id_value==null)
       {
           win.close();
           alert('Sorry there was no Corresponding Spanish SafeUseGuide ');
           return;
       }

        // // wait for window to paint
       var idSel=0;
        while(win.document.forms.length<1)
        {
             idSel = idSel*3;
        }
        win.document.forms[0].submit();
       win.focus();
 }
function doCONTACTView(){
      var win = window.open(mvcContextPath + '/msds/hazcom/contact_us.jsp','spool_document','width=600,height=520,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      return false;

}
function doPDFView(documentID) {
      var location_path = new String(document.location);
      var idx = location_path.indexOf("?");
      if(idx>0)
        location_path = location_path.substring(0,idx);
      var win = window.open(mvcContextPath+'/frmwkSpoolDocument.jsp?sp='+document.FORM_1.sp.value+'&i='+documentID,'spool_document','width=600,height-500,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      // wait for window to paint
      while(win.document.forms.length<1) {
        idx = idx * 3;
      }
      win.document.forms[0].submit();
      win.focus();
      return false;
}
function doMSDSinfo(msdsid) {
      var win = window.open(mvcContextPath+'/msds/admin/msds_info_frm.jsp?i='+msdsid,'msds_info','width=600,height-500,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      var idx = 0;
      win.focus();
      return false;
}
/*function dofrmwkspoolmsds(idVal) {
var idSel=0;
   var win = window.open(mvcContextPath+'/frmwkSpoolMsds.jsp?i='+idVal,'spool_msds','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
   // wait for window to paint
   while(win.document.forms.length<1) {
      idSel = idSel*3;
   }
   win.document.forms[0].submit();
   win.focus();

   return false;
}*/


 function dofrmwkspoolmsds(rowId) {

 if(eval(document.FORM_1.id_select[rowId-1])== '[object]')
{
    var strIdMsds=eval(document.FORM_1.id_select[rowId-1].value);
}
 else
 {
var strIdMsds=document.FORM_1.id_select.value;
//var strIdMsds=rowId;
 }

   var strPath = document.location.pathname;
   var ReportPath = '/frmwkReports.jsp';
   var ParentPath = strPath.substring(strPath.indexOf('/',1));
//   if (ParentPath == '/msds/hazcom/manage_lists.jsp'){
        ReportPath = '/msds/master/manage_lists_reports.jsp';
//   }
var win = window.open(mvcContextPath+ReportPath+'?id_msds='+strIdMsds+'&jsp='+ReportPath,'spool_msds','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      win.focus();

   return false;
}
function dofrmwkspoolLocmsds(idVal,idLoc) {

   var strPath = document.location.pathname;
   var ReportPath = '/frmwkReports.jsp';
   var ParentPath = strPath.substring(strPath.indexOf('/',1));
//   if (ParentPath == '/msds/hazcom/manage_lists.jsp'){
        ReportPath = '/msds/master/manage_lists_reports.jsp';
//   }
var win = window.open(mvcContextPath+ReportPath+'?id_msds='+idVal+'&jsp='+ReportPath+'&id_location='+idLoc,'spool_msds','width=600,height=450,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
      win.focus();

   return false;
}

function selectAll(obj,Obj1){
    if(Obj1.checked){
        if(obj.length){
          for(cnt = 0; cnt < obj.length; cnt++)
                  obj[cnt].checked=true;
        }
        else
            obj.checked=true;
    }
    else{
         if(obj.length){
           for(cnt = 0; cnt < obj.length; cnt++)
               obj[cnt].checked=false;
         }
         else
             obj.checked=false;
    }
   return true;
}
function ChkselectAll(obj,Obj2){

var IsChecked = true;
if(obj.length){
          for(cnt = 0; cnt < obj.length; cnt++){
           if(!obj[cnt].checked)
              IsChecked=false;
          }
        }
      else{
         if(!obj.checked)
              IsChecked=false;
      }
if(IsChecked)
   Obj2.checked=true;
else
    Obj2.checked=false;
   return true;
}

function showstatusrecords(status,bid){
  window.open(mvcContextPath+'/msds/batch/mct_batch_item_status.jsp?status='+status+'&bid='+bid,'spool_document','width=600,height-500,left=30,top=30,location=no,menubar=yes,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}

