
var AppStatus = 'Prod'; 
var isVewSource = true; 
var AuthorAppVersion = '3.0';
var PPMAppVersion = '3.0';
var IIPCAppVersion = '3.0';
var IIRESAppVersion='0.9'
var CalendarWin = null ;
var FlowPainterWin ;
var WaitModalWin = null ;
//Call other JS menus
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/j_scripts/calendar.js' type='text/javascript'></SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/j_scripts/ComboList.js' type='text/javascript'></SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/j_scripts/JSRichEditor.js' type='text/javascript'></SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/j_scripts/JSMenu.js' type='text/javascript'></SCRIPT>");
//document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/j_scripts/WaitlayerMessage.js'><\/SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/j_scripts/jspell/jspell.js' type='text/javascript'></SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/j_scripts/CamilionValidate.js' type='text/javascript'></SCRIPT>");
var WaitConsoleWin = null;
var errorwin = null; 
  
var isShowWait = true; 
var waitwin=null;
//var IE = (document.all) ? 1 : 0;
//var NS = (document.layers) ? 1 : 0;
var NS4 = (document.layers)? true:false
var IE4 = (document.all)? true:false 
var IE5 = false;
var IE6 = false;
var NS6 = false;
var isSubmitted = false;
var ScreenHiddenControl = null;
var ScreenLabelControl = null;
var ColorPickerWindow = null;


function disableDependencyQuestions(controlids, hideForValue, value ){
	if ( controlids == null || controlids == '' ) return;
	var controls = controlids.split(',');
	for ( var i=0; i<controls.length; i++ ){
		if ( controls[i] != null && controls[i] != '' ){
			var tr = getTRForDependencyQuestions ( controls[i] ) ;
			if ( tr != null ){
				tr.disabled = ( hideForValue == value );
//				alert( 'TagName : ' + tr.tagName + ' id : ' + tr.id );
			}
			var control = document.getElementsByName( controls[i] );
			for ( var j=0; j<control.length; j++ ){
				if ( control[j].HAS_DEPENDENCY_QUESTIONS == '1' && value == '0' && control[j].value == '0' ){
					control[j].click();
//					control[j].checked = true;
//					alert( control[j].onclick );
//					eval ( control[j].onclick );
				}
				control[j].disabled = ( hideForValue == value );
			}
		}
	}
}

function hideDependencyQuestions( controlids, hideForValue, value ){
	if ( controlids == null || controlids == '' ) return;
	var controls = controlids.split(',');
	for ( var i=0; i<controls.length; i++ ){
		if ( controls[i] != null && controls[i] != '' ){
			var tr = getTRForDependencyQuestions ( controls[i] ) ;
			if ( tr != null ){
				tr.style.display = ( hideForValue == value ? 'none' : '' );
			}
			var control = document.getElementsByName( controls[i] );
			for ( var j=0; j<control.length; j++ ){
				if ( control[j].HAS_DEPENDENCY_QUESTIONS == '1' && value == '0' && control[j].value == '0' ){
					control[j].click();
				}
			}
		}
	}
}

function getTRForDependencyQuestions( controlid ){
	var trObj = null;
	var control = document.getElementsByName( controlid );
	if ( control != null && control[0] != null ){
		control = control[0];
		var parent = control.parentNode;
		while ( parent != null ){ 
			parent = parent.parentNode;
			if ( parent.tagName == 'TR' && parent.id == 'DATA_SEC_ROW_X' ) break;
		}
		if ( parent != null && parent.tagName == 'TR'  && parent.id == 'DATA_SEC_ROW_X' ){
			trObj = parent;
		}
	}
	return trObj;
}



function getAllWindows(joWin)
{
	var loArr = new Array();
	getParentWindows(joWin,loArr);
	return loArr;
}

function getParentWindows(joWin, joArr)
{
	try{
	if (typeof (joWin) != 'undefined' && joWin != null && joWin.top != null ) 
 	{ 
		var topWin = joWin.top;
		if(topWin != null)
		{
			joArr[joArr.length] = topWin;
			var oWin = topWin.dialogArguments;
			if(oWin == null) oWin = topWin.opener;
			if(oWin == null)
			{
				return joArr;
			}
			else
			{
				return getParentWindows(oWin, joArr);
			}
		}	
	} 
	}catch(e){} 	
}

function doClose()
{
 window.close();
}

function onContextOption()
{
	if(isVewSource )
	{
		return true;
	}
	else
	{
		return false;
	}		
}



var windowWidth = window.screen.availWidth ;
var windowHeight = window.screen.availHeight ;
//alert(navigator.userAgent);
// Microsoft Stupidity Check.
if (IE4) 
{
	if (navigator.userAgent.indexOf('MSIE 5')>0) 
	{
		IE5 = true;
	}
	else if( navigator.userAgent.indexOf('MSIE 6')>0)
	{
		IE6 = true;
	}
}
// NetScape Stupidity Check for Version 6
if(((!NS4)) && (!(IE4))) 
{
	if (navigator.userAgent.indexOf('Netscape6')>0) 
	{
		NS6 = true;
	} 
}

function showHide( obj, image ){
	if ( obj != null && obj.style != null){
		if ( obj.style.display == 'none' ){
			obj.style.display = '';
			if (image != null ) image.src='/images/formeditor/tools/Hide.jpg';
		}else{
			obj.style.display = 'none';
			if (image != null ) image.src='/images/formeditor/tools/Show.jpg';
		}
	}
	_afterShowHideSection(obj,image);	
}
function _afterShowHideSection(oObj,oImage)
{


}
var whitespace = " \t\n\r";    // whitespace characters
// WINDOW STATUS FUNCTIONS
window.defaultStatus = "";
//for NS 6.0
//top.document.getElementById('fs2').cols = '40%, *';



function setCheckBoxValue(fromValueObject, toValueObject)
{
  	if(fromValueObject.checked)
  	{
		var jsCheckValue =  fromValueObject.value;


		if(jsCheckValue != null && jsCheckValue != '')
		{
			toValueObject.value = jsCheckValue;
		}
	}
	else
	{
		toValueObject.value = '';
	}

}

function setCheckRadioValue(fromValueObject, toValueObject)
{
  	if(fromValueObject != null )
  	{
		var jsCheckValue =  fromValueObject.value;
		if(jsCheckValue != null && jsCheckValue != '')
		{
			toValueObject.value = jsCheckValue;
		}
	}
	else
	{
		toValueObject.value = '';
	}

}



function popUpWindowCenter(Location, WinName, WinWidth, WinHeight)
{
	var windowX = Math.ceil( (window.screen.width  - WinWidth) / 2 );
	var windowY = Math.ceil( (window.screen.height - WinHeight) / 2 );
    var WinName2 = null;

   		WinName2 = window.open(Location, WinName, "toolbar=no,titebar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight+",top="+windowX+",left="+windowY);
		WinName2.focus();


}

function openReadOnlyPopUp(whatUrl) 
{
					theurl=whatUrl;
					wname ="FieldHelpWIN";
					W=592;
					H=610;
					windowCERRARa 		= "/default_skin/images/skin/close_a.gif";
					windowCERRARd 		= "/default_skin/images/skin/close_d.gif";
					windowCERRARo 		= "/default_skin/images/skin/close_o.gif";
					windowTIT 	    	= "<font face=verdana size=1 color=blue>&nbsp;? Emppower Process Field Help</font>";
					windowBORDERCOLOR   	= "#000000";
					windowBORDERCOLORsel	= "#000000";
					windowTITBGCOLOR    	= "#9EBEDE";
					windowTITBGCOLORsel 	= "#FFFFFF";
					openchromeless(theurl, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel)
}



function ShowWaitFrame()
{
  //make sure this page is in the frame
  // Comment out this part if you need the wait screen
  /* 
	 if(self != top)
 	{
			//parent.parent.document.all("SignOn").rows="*,100%";
		if(isShowWait)
		{
				if(IE4 || IE5)
				{
					if(top.document.all.SignOn != null)
					top.document.all.SignOn.cols = '*,100%'
				}	
				else if (NS6)
				{
					if(top.document.getElementById('SignOn') != null)
					top.document.getElementById('SignOn').cols = '*,100%';
				}	
				else if(NS4)
				{
					OpenWait();
				}	
		}	
	 }
	 */
}

function KillWaitFrame()
{
 // make sure this page is in the frame
 // Comment out this code for wit screen to work
 /*
	if(self != top)
 	{
			if(isShowWait)
			{
				if(top.document.all.SignOn != null )
				{
					if(IE4 || IE5)
					{
						CloseWait()
						top.document.all.SignOn.cols = '100%,*'
					}
					else if (NS6)
					{
						top.document.getElementById('SignOn').cols = '100%,*';
					}	
					else if(NS4)	
						CloseWait();
				}		
					
			}	
	 }
	 */
 }


function winStatus( msg )
{
	if( msg != null && trim(msg) != "" ) 
	{
		window.status = msg;
	}	
}



//WINDOW FUNCTIONS
function goThere( node,loc ) {
	//Only perform folder opening, don't close anything
	if( parent.nav.indexOfEntries[node].isOpen == false )
		parent.nav.clickOnNode(node);
	window.location = loc;
}

function popUp( loc, w, h, menubar,winName ) {
	if( w == null ) { w = 500; }
	if( h == null ) { h = 350; }
	if( menubar == null || menubar == false ) {
		menubar = "";
	} else {
		menubar = "menubar,";
	}

	if( NS4 ) { w += 50; }
	// Need the var or else IE4 blows up not recognizing editorWin
	var editorWin = window.open(loc,winName, menubar + 'resizable,scrollbars,width=' + w + ',height=' + h);
	//if( !newWin.opener )
		//newWin.opener = window;
	editorWin.focus(); //causing intermittent errors
}

function popUpLarge( loc, winName ) {
	var menubar = null;
	if( menubar == null ) { menubar = false; }
	popUp( loc, 800, 400, menubar,winName );
}

function popUpError( loc ) {

	if (errorwin == null)
	{
		errorwin = window.open(loc, "errorWindow", "toolbar,menubar,scrollbars,resizable,width=500,height=280");
    }
	else
	{
		if (errorwin.closed == true)
		{
			errorwin = window.open(loc, "errorWindow", "toolbar,menubar,scrollbars,resizable,width=500,height=280");			
			errorwin.focus();
		}
		else 
			errorwin.focus();
	}
}

function previewConsole(WinName, Location ,WinWidth,WinHeight) 
{

var ConsoleWin = null;

var WinWidth = windowWidth * 0.90 ;
var WinHeight = windowHeight * 0.80; 

var windowX = Math.ceil( (window.screen.width  - WinWidth) / 2 );
var windowY = Math.ceil( (window.screen.height - WinHeight) / 2 );
	if (ConsoleWin == null)
	{
		ConsoleWin = window.open(Location, WinName, "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,width="+WinWidth+",height="+WinHeight);
		ConsoleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) )
		ConsoleWin.focus();
    }
	else
	{
		if (ConsoleWin.closed == true)
		{
			ConsoleWin = window.open(Location, WinName, "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,width="+WinWidth+",height="+WinHeight);			
			ConsoleWin.focus();
			ConsoleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) )
		}
		else
		{ 
			ConsoleWin.focus();
		}	
	}
}



function popUpConsole(WinName, Location ,WinWidth,WinHeight) 
{
var ConsoleWin = null;

var WinWidth = windowWidth * 0.90 ;
var WinHeight = windowHeight * 0.80; 

var windowX = Math.ceil( (window.screen.width  - WinWidth) / 2 );
var windowY = Math.ceil( (window.screen.height - WinHeight) / 2 );
	if (ConsoleWin == null)
	{
		//ConsoleWin = window.showModalDialog(Location, WinName, "dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;edge:sunken" );
		ConsoleWin = window.open(Location, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=yes,width="+WinWidth+",height="+WinHeight);
		ConsoleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) )
		ConsoleWin.focus();
    }
	else
	{
		if (ConsoleWin.closed == true)
		{
			//ConsoleWin = window.showModalDialog(Location, WinName, "dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;edge:sunken" );
			ConsoleWin = window.open(Location, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=yes,width="+WinWidth+",height="+WinHeight);			
			ConsoleWin.focus();
			ConsoleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) )
		}
		else
		{ 
			ConsoleWin.focus();
		}	
	}
}

function popUpSubConsole(WinName, Location ,WinWidth,WinHeight) 
{

var SubConsoleWin = null;

var WinWidth = windowWidth 
var WinHeight = windowHeight * 0.50; 

var windowX = Math.ceil( (window.screen.width  - WinWidth) / 2 );
var windowY = Math.ceil( (window.screen.height - WinHeight) / 2 );
	if (SubConsoleWin  == null)
	{
		//SubConsoleWin = window.showModalDialog(Location, WinName, "dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;edge:sunken" );
		SubConsoleWin  = window.open(Location, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=yes,width="+WinWidth+",height="+WinHeight);
		//SubConsoleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
		//SubConsoleWin.focus();
    }
	else
	{
		if (SubConsoleWin .closed == true)
		{
			SubConsoleWin = window.showModalDialog(Location, WinName, "dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;edge:sunken" );
			//SubConsoleWin  = window.open(Location, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=yes,width="+WinWidth+",height="+WinHeight);			
			SubConsoleWin.focus();
			SubConsoleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) )
		}
		else 
			SubConsoleWin.focus();
	}
}

function currentTimeMillis()
{
	var oTime = new Date();
	var oHours = oTime.getHours();
	var oMinutes = oTime.getMinutes();
	var oSeconds = oTime.getSeconds();
	var oMilseconds = oTime.getMilliseconds();
	var oFinalString =  oHours+''+oMinutes+''+oSeconds+''+oMilseconds ;
	return oFinalString;
}

function closeMe() {
	self.close();
	//parent.close();
}

function closeConsole() {
	self.parent.close() ;
	//if (parent.opener.parent.parent.name != null || parent.opener.parent.parent.name != 'undefined'){
 		//parent.opener.parent.parent.focus ;
	//}
}


function openerReload() {
	if( parent.opener.name != null )
		parent.opener.location.reload();
		//alert( parent.opener.name );
		//parent.opener.r();
}

function r() {
	self.setTimeout("rl()", 2000);
}
function rl(){
	self.location.reload();
}

// NAV TREE FUNCTIONS
function navRefresh() {
	top.nav.location.reload();
}
//FORM FUNCTIONS
//FORM GET FUNCTIONS
function checkRadio(vField) 
{
	noRadio = true
	if(radioObject == null)return noRadio;
	for (i=0;i<vField.length;i++) {
		if (vField[i].checked) {
			noRadio = false
			i = vField.length
		}
	}
	return(noRadio)
}


function getRadioValue(radioObject)
{
	var value = null
	if(radioObject == null )return value;
	var value = null
	for (var i=0; i<radioObject.length; i++) 
	{
		if (radioObject[i].checked) 
		{
			value = radioObject[i].value
			break
		}
	}
	return value
}

function getSelectVal(vField)
{
  if(vField != null && vField.options != null && vField.options.length != null )
  {
	if(vField.options.length > 0 )
	{
		var ret = vField.options[vField.selectedIndex].value
		return(ret)
	}	
  }	
}

function getMultiSelectVal(vField,jsSeparator)
{
  var lsValue = "";	
  if(vField != null &&  vField.options != null && vField.options.length != null )
  {
	for (var i = 0; i < vField.options.length; i++) 
	{   
		if (vField.options[i].selected)
		{
	      lsValue=lsValue+jsSeparator+vField.options[i].value;
		}
	}
	return lsValue;
  }
}

function isIntegerValue(obj) {
		var s = obj.value;
if(obj != null)
{
	    if (isInteger(s) )
		{ 	
				return true;
		}
		else
		{
			alert("Please enter a numeric value");
			obj.value="";
			obj.focus();
			return false;	
			
	    }
}		
}

function checkLength(obj,jsMaxLength)
{
	
	if(jsMaxLength == '' || jsMaxLength == null || jsMaxLength == 'undefined')
	{
		return true;
	}
		var s = obj.value;
		var sLength = s.length
	    if (sLength == 0 || sLength == null )
		{ 	
				return true;
		}
		else if(sLength > jsMaxLength)
		{
			alert("The maximum length of the field is "+jsMaxLength+" characters");
			obj.value=s.substring(0,jsMaxLength)
			return false;	
	    }
		else
		{
			return true;
		}
}

function isCurrencyValue(obj) {
		var s = obj.value;
	 
	    if (isInteger(s) )
		{ 	
				return true;
		}
		else
		{
			alert("Please enter a numeric value of the format ####.##");
			obj.value="";
			return false;	
	    }
}


//FORM SET FUNCTIONS
function setSelectedValue(selectobj, val)
{
	//alert("val="+val);
	if( selectobj != null && selectobj.tagName == 'SELECT')
	{
	      for (var i = 0; i < selectobj.length; i++)
	      {
	          if (val == selectobj.options[i].value)
	          {
	             selectobj.options[i].selected = true;
	             //break;
				 return true;
	           }
	      }
	 } 
	   return false;
	 
}
function setSelectedValueNull(selectobj)
{
	 if( selectobj != null && selectobj.tagName == 'SELECT')
	{
    	selectobj.options[0].selected = true;
	}	
}
function setSelectedValueMulty(selectobj, val)
{
	if(val =="")
	{
		return;
	}
	var pos=0;
	var j=-1;  
	while(pos != -1)
	{
		pos = val.indexOf(",",j+1)
		if(pos == -1)
		{
			var val_1 = val.substring((val.lastIndexOf(",")+1),val.length);
		}
		else
		{
			var val_1 = val.substring(j+1,pos);
		}
		j=pos;
    	  for (var i = 0; i < selectobj.length; i++)
      		{
	      		if (val_1 == selectobj.options[i].value)
          		{
            		 selectobj.options[i].selected = true;
             		break;
           		}
			}   
     }
}
function setRadioValue(radioobj, val)
{
	if( radioobj != null && radioobj.length != null )
	{
      	for (var i = 0; i < radioobj.length; i++)
      	{
			val_1 = radioobj[i].value;
			if(val == val_1)
			{
             	radioobj[i].checked = true;
             	break;
           	}
     	}
	} 
}

var _oDateErrorObjName = 'DAY';
function ValidateDate(MonthObj,DayObj,YearObj,FormatObj){

	MonthObj = document.getElementById( MonthObj );
	DayObj = document.getElementById( DayObj );
	YearObj = document.getElementById( YearObj );

	if (FormatObj == null) return;
	if (MonthObj == null) return;
	if (DayObj == null) return;
	if (YearObj == null) return;
	var joObj =  window.event.srcElement;
	var joName = joObj.name;
   	var FirstArg=FormatObj.substring(0,2);
	var SecondArg=FormatObj.substring(2,4);
	var ThirdArg=FormatObj.substring(4,6);
	var formMonth="";
	var formDay="";
	var formYear="";
	var nameArr = joName.split('_');
	var today =  new Date() ;
	if(nameArr.length > 0 && joObj.tagName == 'INPUT' && joObj.type == 'text' ) 
	{
		var DatePortion = nameArr[nameArr.length - 1];
		if(DatePortion=='MONTHPARTDATE'||DatePortion=='DAYPARTDATE')
		{
			if(joObj.value!=null && joObj.value.length==1)
				joObj.value = '0'+joObj.value;
		}
	}
	if (FirstArg=="DD")
	{
		 formMonth=getSelectVal(MonthObj);
	}	
	else
	{
		 formMonth=MonthObj.value;
		 if(formMonth!=null&&formMonth.length == 1) // If value is single digit, concat a 0 in the front.
		 	formMonth = '0'+formMonth;
	}		
	
	if (SecondArg=="DD")
	{
			 formDay=getSelectVal(DayObj);
	}
	else
	{
		formDay=DayObj.value;
		if(formDay!=null&&formDay.length == 1)// If value is single digit, concat a 0 in the front.
			formDay = '0'+formDay;
	}			
	if (ThirdArg=="DD")
	{
	 	formYear=getSelectVal(YearObj);
	}
	else
	{
		formYear=YearObj.value;
		if(formYear!=null)
		{
			if(formYear.length == 1)// If value is single digit, concat a 200 in the front.
			{
				formYear = today.getYear().toString().substring(0,3)+formYear;
				YearObj.value = formYear;
			}	
			else if(formYear.length == 2)// If value is single digit, concat a 20 in the front.
			{
				if(parseInt(formYear)> 50 )
					formYear = (parseInt(today.getYear().toString().substring(0,2) ) -1).toString()+formYear;
				else
					formYear = today.getYear().toString().substring(0,2)+formYear;
				YearObj.value = formYear;
			}
			else if(formYear.length == 3)// If value is single digit, concat a 2 in the front.
			{
				formYear = today.getYear().toString().substring(0,1)+formYear;
				YearObj.value = formYear;
			}
		}	
	}
	var formDate=formMonth+"/"+formDay+"/"+formYear;
	if(formMonth != "" && formDay !="" && formYear !="" && formMonth != null 
		&& formDay != null && formYear != null)
	{
		if(!(isDateString(formDate)))
		{
			alert("Please Enter a valid date");
			if(_oDateErrorObjName == 'MONTH')
			{
				if (FirstArg=="DD")
					setSelectedValueNull(MonthObj);
				else
				 MonthObj.value="";
				 
				MonthObj.focus(); 
			}
			
			if(_oDateErrorObjName == 'DAY')
			{
				if (SecondArg=="DD")
				setSelectedValueNull(DayObj);
				else
					DayObj.value="";
				DayObj.focus();
			}
			if(_oDateErrorObjName == 'YEAR')
			{
				if (ThirdArg=="DD")
					setSelectedValueNull(YearObj);
				else
					YearObj.value="";
				YearObj.focus();	
			}
			return false;	
		}
	
	}
	return true;
}

//FORM DATE FUNCTION
function ValidateDateFormatMDText(MonthObj,DayObj,YearObj)
{
	var formMonth=getSelectVal(MonthObj);
	var formDay=getSelectVal(DayObj);
	var formYear=YearObj.value;
	
	var formDate=formMonth+"/"+formDay+"/"+formYear;
	
	if(formMonth != "" && formDay !="" && formYear !="")
	{
		if(!(isDateString(formDate)))
		{
			alert("Please Enter a valid data");
			setSelectedValueNull(MonthObj);
			setSelectedValueNull(DayObj);
			YearObj.value="";
			return false;	
		}
	
	}
	return true;
}
function ValidateDateFormatMDY(MonthObj,DayObj,YearObj)
{
	var formMonth=getSelectVal(MonthObj);
	var formDay=getSelectVal(DayObj);
	var formYear=getSelectVal(YearObj);
	
	var formDate=formMonth+"/"+formDay+"/"+formYear;
	
	if(formMonth != "" && formDay !="" && formYear !="")
	{
		if(!(isDateString(formDate)))
		{
			alert("Please Enter a valid date");
			setSelectedValueNull(MonthObj);
			setSelectedValueNull(DayObj);
			setSelectedValueNull(YearObj);
			return false;	
		}
	
	}
	return true;
}


/***********************************************************************************************************************************
*	The following function are for the Date object text format
*	This function will move the cursor to the next object on the line and
*	also check for the valid value based on the mask provided
*/
function CheckAndAdvance(oObject,oAdvanceObject,oLength,oFormat)
{

	var oSourceObject = oObject;
	var oNextobject = null ;
	CheckDateValueFormat(oObject,oFormat);
	if(oAdvanceObject != '' )
	{
		oNextobject = document.getElementById(oAdvanceObject);
		if(oSourceObject.value.length == oLength )
		{
			oNextobject.focus();
		}
	}	
}
function CheckDateValueFormat(oCheckObject,oCheckFormat)
{
	if(oCheckObject == null || oCheckObject.value == '' )
	return ;
	
	var s = oCheckObject.value;
	for ( i = 0; i < s.length; i++ )
	{   
	  	var c = s.charAt(i);
		if ( ! isDigit(c)  )
		{ 	
			alert("Please enter a valid number");
			oCheckObject.value ='';
			return;
		}	
	}
	
	if(oCheckFormat == 'DD')
	{
		if(s.length == 2 )
		{
			if(s < 0 || s > 31 )
			{
			
				alert("Invalid Day, Please enter a value between 01 and 31 ");	
				oCheckObject.value ='';
				return;		
			}
		}
	}
	if(oCheckFormat == 'MM')
	{
		if(s.length == 2 )
		{
			if(s < 0 || s > 12 )
			{
			
				alert("Invalid Month, Please enter a value between 01 and 12 ");			
				oCheckObject.value ='';
				return;
			}
		}
	}
	
}
/***********************************************************************************************************************************
*	End of Text Date control functions
*/

/***********************************************************************************************************************************
*	FormatDate()-  AUTOINSERTS the /'s IN A DATE for 
*	CheckDate()- Validates Date Entered is a Valid Date
*
*	COPY AND PASTE THE FOLLOWING INTO YOUR INPUT FIELD AND CHANGE TO APPROPRIATE FRAME LOCATION (ie: parent. or self.) :
*	onchange="CheckDateDMY(this)" OR onchange="CheckDateMDY(this)
 onkeydown="FormatDate(this, window.event.keyCode,'down','DMY' or 'MDY')" onkeyup="FormatDate(this, window.event.keyCode,'up')"
***********************************************************************************************************************************/
function FormatDate(i, delKey,direction,dateFormatType,sepChar) 
{
	if(sepChar == null)sepChar="/"	
  if (i.value.length < 10) 
  {
  	if (delKey!=9) 
	{ //tab
	  	if(delKey!=8 && delKey!=46 && delKey!=16 &&  !(delKey>36 && delKey<41)){ //if the delete, backspace, shift, are not the keys that caused the keyup event.
  			var fieldLen = i.value.length
   			if ((delKey >= 48 && delKey <= 57) || (delKey >= 96 && delKey <=105)) 
			{
				if(dateFormatType == "MDY" || dateFormatType == "DMY")
				{
   					if (fieldLen == 2 || fieldLen == 5) 
					{
      					i.value = i.value + sepChar;
		     		}
				}	
				else if(dateFormatType == "YMD")
				{
   					if (fieldLen == 4 || fieldLen == 7) 
					{
      					i.value = i.value + sepChar;
		     		}
				}	
   			}
			else
			{
   				if (direction == "up") {
     				if (i.value.length == 0) {
      					i.value = ""
	     			} else {
		      			i.value = i.value.substring(0,i.value.length-1)
	   				}
    			}
	 		}
  			i.focus()
	  	}
 	} else {
 		if (direction == "down") {
			if(dateFormatType == "MDY")
			{
		 		CheckDateMDY(i);
			}
			else if(dateFormatType == "DMY")
			{
		 		CheckDateDMY(i);
			}
			else if(dateFormatType == "YMD")
			{
		 		CheckDateYMD(i);
			}
  		}
  	}
 }
}
function CheckDateMDY(THISDATE) {
	var err=0
	a=THISDATE.value
	if (a.length != 10) err=1
	b = a.substring(0, 2)// month
	c = a.substring(2, 3)// '/'
	d = a.substring(3, 5)// day
	e = a.substring(5, 6)// '/'
	f = a.substring(6, 10)// year
	if (b<1 || b>12) err = 1
	if (d<1 || d>31) err = 1
	if (f<1900) err = 1
	if (b==4 || b==6 || b==9 || b==11){
		if (d==31) err=1
	}
	if (b==2){
		var g=parseInt(f/4)
		if (isNaN(g)) {
			err=1
		}
		if (d>29) err=1
		if (d==29 && ((f/4)!=parseInt(f/4))) err=1
	}
	if (err==1) {
		alert(THISDATE.value + ' is not a valid date. Please re-enter.');
		THISDATE.value = ""
	}
}

function CheckDateDMY(THISDATE) {
	var err=0
	a=THISDATE.value
	if (a.length != 10) err=1
	d = a.substring(0, 2)// month
	c = a.substring(2, 3)// '/'
	b = a.substring(3, 5)// day
	e = a.substring(5, 6)// '/'
	f = a.substring(6, 10)// year
	if (b<1 || b>12) err = 1
	if (d<1 || d>31) err = 1
	if (f<1900) err = 1
	if (b==4 || b==6 || b==9 || b==11){
		if (d==31) err=1
	}
	if (b==2){
		var g=parseInt(f/4)
		if (isNaN(g)) {
			err=1
		}
		if (d>29) err=1
		if (d==29 && ((f/4)!=parseInt(f/4))) err=1
	}
	if (err==1) {
		alert(THISDATE.value + ' is not a valid date. Please re-enter.');
		THISDATE.value = ""
	}
}
function CheckDateYMD(THISDATE) {
	var err=0
	a=THISDATE.value
	if(a == '')return;
	if (a.length != 10) err=1
	d = a.substring(5, 7)// month
	c = a.substring(4, 5)// '-'
	b = a.substring(8, 10)// day
	e = a.substring(7, 8)// '-'
	f = a.substring(0, 4)// year
	
	//alert("Month="+d+" Day="+b+" Year="+f+" First Sep="+c+" Second Sep ="+e);
	if(c != '-')err=1;
	if(e != '-')err=1;
	if (d<1 || d>12) err = 1
	if (b<1 || b>31) err = 1
	if (f<1900) err = 1
	if (d==4 || d==6 || d==9 || d==11){
		if (b==31) err=1
	}
	if (d==2){
		var g=parseInt(f/4)
		if (isNaN(g)) {
			err=1
		}
		if (b>29) err=1
		if (b==29 && ((f/4)!=parseInt(f/4))) err=1
	}
	if (err==1) {
		alert(THISDATE.value + ' is not a valid date. Please enter a valid data in YYYY-MM-DD format.');
		THISDATE.value = ""
		if(THISDATE != null)
		THISDATE.focus();
		
	}
}
/******************************************************************
*DATE STRING FUNCTIONS
*
*
******************************************************************/
function isDateString(stringValue) 
{
		// create a String object
		var theString = new String(stringValue);
		
		// determine the delimiter character (must be "/" "-" or space)
		var delimiterCharacter
		if ( theString.indexOf('/') > 0 )
			delimiterCharacter = '/';
		else
			if ( theString.indexOf('-') > 0 )
				delimiterCharacter = '-';
			else
				if ( theString.indexOf(' ') > 0 )
					delimiterCharacter = ' ';
				else
					return false;
					
		// split the string into an array of tokens
		var theTokens = theString.split(delimiterCharacter);
		
		// there must be either two or three tokens
		if ( theTokens.length < 2 || theTokens.length > 3 )
			return false;
		
		// convert the tokens to String objects, which will be needed later,
		// stripping a single leading 0
		var tokenIndex;
		for ( tokenIndex = 0; tokenIndex < theTokens.length; tokenIndex++ ) {
			theTokens[tokenIndex] = new String(theTokens[tokenIndex])			
			if ( theTokens[tokenIndex].charAt(0) == '0' )
				theTokens[tokenIndex] = theTokens[tokenIndex].substring(1, theTokens[tokenIndex].length);
		}

		// all of the tokens must be positive integers
		for ( tokenIndex = 0; tokenIndex < theTokens.length; tokenIndex++ ) {
			if ( ! isNonnegativeInteger(theTokens[tokenIndex]) )
				return false;
		}
		
		// we need to identify the year, month, and day tokens
		var numericValue;
		var yearTokenIndex = -1;
		var monthTokenIndex = -1;
		var dayTokenIndex = -1;
		for ( tokenIndex = 0; tokenIndex < theTokens.length; tokenIndex++ ) {
					
			// convert the value
			numericValue = parseInt(theTokens[tokenIndex], 10);
					
			// could this token be a month?
			if ( numericValue <= 12 ) {
					
				// yes; do we already have a month?
				if ( monthTokenIndex == -1 ) {
						
					// no; assign this token to the month and continue
					monthTokenIndex = tokenIndex;
					continue;
				}
				else {
							
					// we already have a month; this token could
					// also be the day; do we already have a day?
					if ( dayTokenIndex == -1 ) {
						
						// no; assign this token to the day and continue
						dayTokenIndex = tokenIndex;
						continue;
					}
					else {
							
						// we already have a day; this token could
						// also be the year; do we alreay have a year?
						if ( yearTokenIndex == -1 ) {
						
							// no; assign this token to the year and continue
							dayTokenIndex = tokenIndex;
							continue;
						}
					}
				}
			}
			else {
						
				// the value is too large for a month;
				// could this token be a day?
				if ( numericValue <= 31 ) {
						
					// yes; do we already have a day?
					if ( dayTokenIndex == -1 ) {
						
						// no; assign this token to the day and continue
						dayTokenIndex = tokenIndex;
						continue;
					}
					else {
							
						// we already have a day; this token could
						// also be the year; do we alreay have a year?
						if ( yearTokenIndex == -1 ) {
						
							// no; assign this token to the year and continue
							dayTokenIndex = tokenIndex;
							continue;
						}
					}
				}
				else {
						
					// the value is too large for a day;
					// could this token be a year?
					if ( numericValue <= 9999 ) {
					
						// yes; do we already have a year?
						if ( yearTokenIndex == -1 ) {
							// no; assign this token to the year
							yearTokenIndex = tokenIndex;
						}
					}
				}
			}
		}	// end of for loop
		
		// evaluate, based on the number of tokens
		if ( theTokens.length == 2 ) {
			
			// two tokens can be either a month/year combination or a month/day
			// combination with the current year assumed; either way, we must have
			// a month
			if ( monthTokenIndex == -1 )
			{	
				// no month
				_oDateErrorObjName='MONTH';
				return false;
			}	
			// do we have a year?
			if ( ! (yearTokenIndex == -1) ) {
			
				// yes; month/year combination; must be okay
				return true;
			}
			else
				
				// no year; do we have a day?
				if ( ! (dayTokenIndex == -1) ) {
				
					// yes; month/day combination; get the current year
					var today = new Date();
					var currentYear = today.getYear();

					// make sure it's a valid date (we were testing days using
					// 31, and that might be too many for the month)
					//return isDate(currentYear, theTokens[monthTokenIndex], theTokens[dayTokenIndex]);
					if(isDate(currentYear, theTokens[monthTokenIndex], theTokens[dayTokenIndex]))
						return true;
					else{
							return false;
						}	
				}
				else
				{
					// we have neither a year nor a day
					_oDateErrorObjName='YEAR';	
					return false;
				}	
		}
		else {
			
			// three tokens; we should have found tokens for year, month, and day
			//alert('yearTokenIndex :'+yearTokenIndex+' monthTokenIndex :'+monthTokenIndex+' dayTokenIndex :'+dayTokenIndex)
			if ( yearTokenIndex == -1 || monthTokenIndex == -1 || dayTokenIndex == -1 )
			{
				if(yearTokenIndex == -1)_oDateErrorObjName='YEAR';
				if(monthTokenIndex == -1)_oDateErrorObjName='MONTH';
				if(dayTokenIndex == -1)_oDateErrorObjName='DAY';
				// missing one or more
				return false;
			}	
			else
			{
				// found all; however, VBScript can only handle the following sequences
				if ( monthTokenIndex == 0 ) {
				
					// must be m/d/y
					if ( dayTokenIndex != 1 || yearTokenIndex != 2)
					{
						if(yearTokenIndex != 2)_oDateErrorObjName='YEAR';
						if(dayTokenIndex != 1)_oDateErrorObjName='DAY';
						return false;
					}	
				}
				else
					if ( dayTokenIndex == 0 ) {
				
						// must be d/m/y
						if ( monthTokenIndex != 1 || yearTokenIndex != 2)
						{
							if(monthTokenIndex != 1)_oDateErrorObjName='MONTH';
							if(dayTokenIndex != 2)_oDateErrorObjName='DAY';
							return false;
						}	
					}
					else
						if ( yearTokenIndex == 0 ) {
				
							// must be y/m/d
							if ( monthTokenIndex != 1 || dayTokenIndex != 2)
							{
								if(monthTokenIndex != 1)_oDateErrorObjName='MONTH';
								if(dayTokenIndex != 2)_oDateErrorObjName='DAY';
								return false;
							}	
						}
						else
						
							// something is wrong
							return false;
				
				// make sure it's a valid date (we were testing days using a value
				// of 31, and that might be too many for the actual month)
				return isDate(theTokens[yearTokenIndex], theTokens[monthTokenIndex], theTokens[dayTokenIndex]);
			}	
		}
	}

var daysInMonth = makeArray(12);
	daysInMonth[1] = 31;
	daysInMonth[2] = 29;
	daysInMonth[3] = 31;
	daysInMonth[4] = 30;
	daysInMonth[5] = 31;
	daysInMonth[6] = 30;
	daysInMonth[7] = 31;
	daysInMonth[8] = 31;
	daysInMonth[9] = 30;
	daysInMonth[10] = 31;
	daysInMonth[11] = 30;
	daysInMonth[12] = 31;



function daysInFebruary(year) {
	    return ( ((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function isDate(year, month, day) {
	    if ( ! ( isYear(year) && isMonth(month) && isDay(day) ) ) return false;
	    var intYear = parseInt(year);
	    var intMonth = parseInt(month);
	    var intDay = parseInt(day);
	    if ( intDay > daysInMonth[intMonth] ){ return false;_oDateErrorObjName='DAY';}
		
	    if ( ( intMonth == 2 ) && ( intDay > daysInFebruary(intYear) ) ) return false;
	    return true;
}

function isDay(s) {
_oDateErrorObjName='DAY';	
	    return isIntegerInRange(s, 1, 31);
}


function isMonth(s) {
_oDateErrorObjName='MONTH';	
	    return isIntegerInRange (s, 1, 12);
}


function isYear(s) {
_oDateErrorObjName='YEAR';	
		if ( ! isNonnegativeInteger(s) ) return false;
	    //return ( (s.length == 2) || (s.length == 4) || );
	    return ( (s.length == 4) && s > 1800 );
}





//These functions are used to populate the day according to the month and year -by Suresh


function populate(Year_obj,Month_Obj,Date_Obj) 
{
	 
	timeA = new Date(Year_obj.options[Year_obj.selectedIndex].text, Month_Obj.options[Month_Obj.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < Date_Obj.length; i++) 
	{
		Date_Obj.options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++) 
	{
		Date_Obj.options[i] = new Option(i+1);
	}
		Date_Obj.options[0].selected = true;
}
function getYears() 
{

// You can easily customize what years can be used
	var years = new Array(1997,1998,1999,2000,2001,2005)

	for (var i = 0; i < Year_obj.length; i++) 
	{
		Year_obj.options[0] = null;
	}
	timeC = new Date();
	currYear = timeC.getFullYear();
	for (var i = 0; i < years.length; i++) 
	{
		Year_obj.options[i] = new Option(years[i]);
	}
		Year_obj.options[3].selected=true;
}
//window.onLoad = getYears;



/******************************************************************
*INTEGER FUNCTIONS
*
*
******************************************************************/

function validateDecimals(oObject,oLength,oPrecision,oAllowNegative)
{
	if(oObject == null || oLength == null)
		return;

	if(checkBlankObject(oObject) ){
		oObject.value = '' ;
		return ;
	}
	if ( isNaN(oObject.value) ){
		oObject.value = '' ;
		alert('Please enter a numeric value.' ); 
		return;
		//oObject.focus() ;
	}
	if(oAllowNegative == null)oAllowNegative = true ;
	var numberValue = oObject.value ;
	oLength=(oLength == '*')? 16 : parseInt(oLength);
	oPrecision=(oPrecision == '*')? 16 :parseInt(oPrecision);
	var decReg = "";
	var oMessage = "";
	if(!oAllowNegative)oMessage = " Negative value is not allowed.";
	if (oPrecision == 0 ||  numberValue.indexOf('.') == -1 )
	{
		if ( oPrecision == 0 )
			numberValue = Math.round(numberValue);
		else
			oLength = oLength - oPrecision;
		if(oAllowNegative)
			decReg = "^[+|-]?\\d{0," + oLength + "}$";
		else
			decReg = "^[+]?\\d{0," + oLength + "}$";
		var regex = new RegExp(decReg);
		if (regex.test(numberValue)) 
		{
			oObject.value = numberValue ;
		}else{
			alert(' Invalid value. The maximum length allowed for the field '+oObject.name+' is '+oLength+'.'+oMessage );
			oObject.value = '';
		}
	}else if(oPrecision > 0)
	{
		var lval = oLength - oPrecision;
		if(oAllowNegative)
			decReg ="^[+|-]?\\d{0," + lval + "}.\\d{0," + oPrecision + "}$";
		else
			decReg ="^[+]?\\d{0," + lval + "}.\\d{0," + oPrecision + "}$";
		var regex = new RegExp(decReg);
		if (!regex.test(numberValue)) 
		{
			oObject.value = custRound(numberValue,oPrecision);
			if(!regex.test(oObject.value))
			{
			   alert('Invalid value. The maximum number of digits allowed before the decimal point for this field is '+lval+'.'+oMessage );
			   oObject.value = '';
			}
		}
	}	
}



function custRound(x,places) 
{
	return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}


function checkBlankObject(formObj) 
{
	if(formObj == null) return;

	var oVal = formObj.value ;
	return( checkBlankValue(oVal) );	
}
function checkBlankValue(oValue) 
{
	if (oValue == "")
		return true;
	var regex = new RegExp(/^\s+$/);
	if (regex.test(oValue))
		return true;			
	return false;
}
function isDigit(c) {
		return ( ( c >= "0" ) && ( c <= "9" ) )
}

function isInteger(s) 
{
	s =''+s; 	
	if(s.indexOf('-')==0){
			s = s.substring(1);
	}
	var x = s.indexOf('.');
	s = s.substring(0,x) + s.substring(x+1);
	for ( i = 0; i < s.length; i++ )
	{   
	        var c = s.charAt(i);
			if ( ! isDigit(c)   )
			{ 	
				return false;
				//alert( "Please enter a valid Number");
				//break;
			}	
	}
	return true;
}


function isIntegerInRange(s, a, b) {
	    if ( ! isInteger(s) ) return false;
	    var num = parseInt (s);
	    return ( ( num >= a ) && ( num <= b ) );
}

function isNonnegativeInteger(s) {
	if( s.charAt(0) == "-" ){
		 return false;
	 }else if(s.indexOf(".") > -1)
	 {
	 	return false;
	 }else
  	 {
	   return ( isSignedInteger(s));
	 }
}

function isSignedInteger(s) {
 	    var startPos = 0;
	    if ( ( s.charAt(0) == "-" ) || ( s.charAt(0) == "+" ) )
	       startPos = 1;    
	    return ( isInteger(s.substring(startPos, s.length)) )
}
function handleNumberInput( object ){
	if( /[^0-9]/.test( object.value ) ){
		object.value=object.value.replace( /([^0-9])/g, "" );
	}
}

/******************************************************************
*STRING FUNCTIONS
*
*
******************************************************************/
function lTrim(s) {
		var i = 0;
	    while ( (i < s.length) && charInString(s.charAt(i), whitespace) )
	       i++;
	    return s.substring(i, s.length);
}


function rTrim(s) {
		var i = s.length ;
	    while ( i > 0 && (i <= s.length) && charInString(s.charAt(i - 1), whitespace) )
	       i--;
		if( i >= 0 )	return  s.substring(0, i );
		else			return s;
}

function trim(s) {
		if( s == null || s == '' ) return s;
		return lTrim(rTrim(s));
}

function charInString(c, s) {
		for (i = 0; i < s.length; i++) {
			if (s.charAt(i) == c)
				return true;
	    }
	    return false;
}



function strReplace( asString, asForString, asWithString) 
{
	var liStartPos;
	var liFirstPos = 0;
	var asTempStaring = '' ;
	if (asString == null || asString == '' )
		return asTempStaring;

	if (asForString==null || asString == '')
		return asString;

	if (asWithString==null)
		return asString;
	
	while ( (liStartPos = asString.indexOf ( asForString, liFirstPos )) != -1 )
	{
		liFirstPos = liStartPos+asWithString.length;
		if ( liStartPos > 0 )
		{
			asString =asString.substring ( 0, liStartPos )+ asWithString+ asString.substring ( liStartPos + asForString.length  );
		}
		else
		{
			asString = asWithString + asString.substring ( liStartPos + asForString.length  );
		}
	}
	return  asString ;
}
function strReplaceHidden( entry) 
{
	return strReplace(entry,'_',' ');
}
function isWhitespace( s )
{

    if(s == null || s.length == 0 )
	{
	 	return true;
	}
	else
	{	
        for (var i = 0; i < s.length; i++)
		{
            // Check that current character isn't whitespace.
            var c = s.charAt(i);
            if (whitespace.indexOf(c) == -1)
			return false;
        }

        return true;
    }
}
/******************************************************************
*MISC FUNCTIONS
*
*
******************************************************************/
function makeArray(n) {
	   for ( var i = 1; i <= n; i++ ) {
	      this[i] = 0
	   } 
	   return this
}

			



function openIT(whatUrl) 
{
	theurl=whatUrl;
	wname ="imgWIN";
	W=650;
	H=500;
	windowCERRARa 		= "/default_skin/images/skin/close_a.gif";
	windowCERRARd 		= "/default_skin/images/skin/close_d.gif";
	windowCERRARo 		= "/default_skin/images/skin/close_o.gif";
	windowTIT 	    	= "<font face=verdana size=1 color=blue>&nbsp;? Emppower Process Flow chart</font>";
	windowBORDERCOLOR   	= "lime";
	windowBORDERCOLORsel	= "lime";
	windowTITBGCOLOR    	= "#9EBEDE";
	windowTITBGCOLORsel 	= "#FFFFFF";
	openchromeless(theurl, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel)
}




/******************************************************************
*MISC FUNCTIONS
*For IE 5.0 Window Open
*
******************************************************************/


// Chromeless window v1.0 (OPEN)
// www.microbians.com / Gabriel Suchowolski power[z]one - powerz@microbians.com
//
// Distributed under the terms of the GNU Library General Public License
//
// - This routins are modifications based on Steinman DynAPI, so please... better use the original one. http://www.dansteinman.com/dynduo/
// - Chromeless trick by webFX. http://www.eae.net/webfx/
// - Chromeless mouse control to handled like a normal window by Gabriel Suchowolski power[z]one

function openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel) {

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) isie=true
	else											     isie=false

	if (isie) { H=H+20+2; W=W+2; }

	s = ",width="+W+",height="+H;

	if (isie) {
		var parameters = escape( theURL+"|"+windowCERRARa+"|"+windowCERRARd+"|"+windowCERRARo+"|"+windowTIT+"|"+windowBORDERCOLOR+"|"+windowBORDERCOLORsel+"|"+windowTITBGCOLOR+"|"+windowTITBGCOLORsel)

		splashWin = window.open( "" , wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0"+s)

		splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
		splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )
		
		splashWin.document.open("text/html", "replace");
		splashWin.document.write("<html><style type='text/css'>\n");
		splashWin.document.write("body                  { border: 1px solid #000000; overflow: hidden; margin: 0pt;}");
		splashWin.document.write("#stillloadingDiv 	{ position: absolute; left: 0px; top: 0px; width: 100%px; height: 19px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,100%,19,0);}");
		splashWin.document.write("</style>\n");
		splashWin.document.write("<body onload=\"top.document.location.replace('/default_skin/jsp/chromeless.html?"+parameters+"')\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no'>");
		splashWin.document.write("<div id=stillloadingDiv><table width=100% height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;c o n t a c t i n g . . .</font></td></tr></table></div>");
		splashWin.document.write("</body></html>");
		splashWin.document.close();

	}
	else    var splashWin = window.open(theURL, wname, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0"+s, true)

	splashWin.focus();
}




//////////////////////////////////////////////////////////////// CHROMELESS OPEN WINDOW //////
// Se genera una variable global con el nombre del wname... el nuevo objeto creado es eval(wname)
function openwinnowin(theurl, wname, W, H) {
	if (is.ie) r = ",resizable=0"
	else       r = ",resizable=1"
	s = ",width="+W+",height="+H;

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	var splashWin = window.open("", wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0"+r+s)

	splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
	splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )

	splashWin.document.open("text/html", "replace");
	splashWin.document.write("<html><style type='text/css'>\n");
	splashWin.document.write("#lineLDiv 		{ position: absolute; left:         0px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineRDiv		{ position: absolute; left: "+(W-1)+"px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineBDiv 		{ position: absolute; left:         0px; top: "+         (H-1)+"px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#lineTDiv 		{ position: absolute; left:         0px; top:                  0px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#stillloadingDiv 	{ position: absolute; left:         0px; top: "+Math.ceil(H/2)+"px; width: "+W+"px; height: "+H+"px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,"+W+",19,0);}");
	splashWin.document.write("</style>\n");
	splashWin.document.write("<body onload=\"self.document.location.href='"+theurl+"'\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no' style='border: 0px; overflow: hidden; margin: 0pt;'>");
	splashWin.document.write("<div id='lineLDiv'></div>");
	splashWin.document.write("<div id='lineRDiv'></div>");
	splashWin.document.write("<div id='lineBDiv'></div>");
	splashWin.document.write("<div id='lineTDiv'></div>");
	splashWin.document.write("<div id=stillloadingDiv><table width=100% height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;c o n t a c t i n g . . .</font></td></tr></table></div>");
	splashWin.document.write("</body></html>");
	splashWin.document.close();

	splashWin.focus();

	eval(wname+"=splashWin")
}

//functions to validate fields

function checkNum(str)
{
	if( str == ""||str == null)
	{
		str = 0.0;
	return false;
	}
	var j = 0;
	
	for(var i=0;i<str.length; i++)
	{
		if(str.substring (i,i+1) !='')
		{
			j=i;
			break;
		}
	}

	for(var i=j;i<str.length;i++)
	{
		var ch = str.substring(i,i+1)
		if((ch<""||"9"<ch)&&ch !='.'&&ch!='$'&&ch!='<')
		{
			alert( "Not a valid number");
			return false;
		}
	}
return true;
}


function exat( val , len , decimal)
{
	if(decimal == null)decimal=1;
	scale = Math.pow(10,decimal+1);
	tStr = "" + Math.round(parseFloat(val)*scale);
	if (tStr.length == 0 || tStr =="0")
	{
		tStr = "0";
		for (var i=0;i<=decimal; i++)
		tStr +="0";
	}
	
	str = "."+tStr.substring(tStr.length-decimal-1,tStr.length);
	for(i=tStr.length-decimal-2,j=0;i>=0;i--)
	{
		if(++j>3)
		{
			str= ","+str;
			j=0;
		}
	str = tStr.substring(i,i+1)+str;
	}
	str = "$"+ str;
	i=len-str.length;
	if (scale !=1)
	i--;
	while(0<i--)
	str = " "  +str;
return str;
}


function displayCurrency( val , len , decimal){

if(!checkNum(val .value)){
val .focus();
val .select();
val .value="";
return false;
}

if(decimal == null)decimal=1;
scale = Math.pow(10,decimal+1);
tStr = "" + Math.round(parseFloat(val.value)*scale);
if (!(tStr.length == 0 && tStr =="0")){
str = tStr.substring(0,tStr.length-decimal-1) + "."+tStr.substring(tStr.length-decimal-1,tStr.length);
}
if (tStr.length-decimal-1>len){
alert("The number is too large");
val .focus();
val .select();
val .value="";
return false;
}
val.value=str;
return true;
}

function formatPhoneNumber(element,format)
{
	if(checkBlankObject(element) )return true ;
	var val = element.value ;
	if(val.length < format.length){
		if(val.length == 1 && format.charAt(0) != '#' )element.value =  format.charAt(0) + val;
		var formatChar = format.charAt(val.length) ;
		if(formatChar != '#')element.value = val + formatChar;
		return true ;
	}else if(val.length == format.length){
	 	return true ;
	}else if(val.length > format.length){
		element.value = val.substring(0,format.length) ;
	}	
	
}


function validatePhoneNumber(element,format)
{
	if(checkBlankObject(element))return true ;
	var phoneReg='^';
	var chr ;
	for(var i=0 ;i<format.length ;i++){
		chr = format.charAt(i) ;
		phoneReg += (chr=='#')? "[0-9]" :"[\\"+chr+"]" ;
	}
	phoneReg += "$" ;
	var regex = new RegExp(phoneReg);
	if (!regex.test(element.value)) {
		alert("Phone number must be of the format "+format);
		element.value = '';
		element.focus();
		return false;
	}
	return true;
}


function validateZipCode(element, sep)
{
	if(checkBlankObject(element))return true ;
	if (typeof sep == 'undefined')sep = "-";
	var	zipReg = "^[0-9]{5}(|[\\"+sep+"]?[0-9]{4})$"
	var regex = new RegExp(zipReg);
	if (!regex.test(element.value)) {
		alert("US Zip Code must be of the format ##### or #####"+sep+"####.");
		//element.value = '';
		element.focus();
		return false;
	}
	return true;
}
	


function validatePostalCode(element, sep)
{
	if(checkBlankObject(element))return true ;
	if (typeof sep == 'undefined')sep = " ";
	var zipReg = "^[a-zA-Z][0-9][a-zA-Z]\\"+sep+"[0-9][a-zA-Z][0-9]$";
	var regex = new RegExp(zipReg);
	if (!regex.test(element.value)) {
		alert("Canadian Postal Code must be of the format A#A"+sep+"#A#.");
		//element.value = '';
		element.focus();
		return false;
	}
	return true;
}


function emailValidate(element)
{
var newValue = element.value
var newLength = newValue.length
	if ((( newValue.indexOf("@")== -1 )||( newValue.indexOf(".")== -1 ))&&(newLength != 0))
	{
	alert("Invalid e-mail address");
	return false;
	}
}
function ValidateDeleteMember()
		{	
			return confirm("Are you sure you want to delete this user ?")
		}	



  
  
function checkAlphaNumeric(obj) 
{
   
	if( obj == null || obj == 'undefined' )
	{
   		return true;
	}
		
	var s = trim(obj.value);
	if(s.length == 0)
	{
		return true;
	}
	else if(isWhitespace(s))
	{
		return true;
	}	
	else
	{

    // check for all alpha
    	 for (var i=0; i < s.length; i++)
     	{
         	 var ch = s.substring(i, i+1);
          	if ((ch >= "A" && ch <= "Z") || 
               (ch >= "a" && ch <= "z") ||
               (ch == " ") ||
			   (ch >= "0" && ch <= "9") ||
			   (ch == "@") ||
			   (ch == "_") ||
			   (ch == "-") ||
			   (ch == "/") ||
			   (ch == "[") ||
			   (ch == "]") ||
			   (ch == "{") ||
			   (ch == "}") 
			   )
          	{
              	 continue;
          	}
          	else
          	{
               	alert("Invalid Charaters.  Please re-enter");
               // You can use the following line to blank the entered value if you want
               // form.fullname.value="";
               	var newString = s.substring(0,i)
			   	obj.value= newString ;
               	return;
          	}
     	}
	}
}		


function checkDBAlphaNumeric(obj) 
{
   
	if( obj == null || obj == 'undefined' )
	{
   		return true;
	}
		
	var s = trim(obj.value);
	if(s.length == 0)
	{
		return true;
	}
	else if(isWhitespace(s))
	{
		return true;
	}
	else
	{

    // check for all alpha
    	 for (var i=0; i < s.length; i++)
     	{
         	 var ch = s.substring(i, i+1);
          	if ((ch >= "A" && ch <= "Z") || 
               (ch >= "a" && ch <= "z") ||
               (ch == " ") ||
			   (ch >= "0" && ch <= "9") ||
			   (ch == "_") || (ch == "$")
			   )
          	{
				// If the first Letter is Digit or _ then error
				if(i == 0)
				{	
					if ( 	(ch == " ") ||
			   				(ch >= "0" && ch <= "9") ||
			  			 	(ch == "_") 
			   			)
						{
               				alert("Invalid First Character.  Please re-enter");
               				//var newFirstString = s.substring(1,s.length)
			   				obj.value= "" ;
               				return false;
						}
				
				}
				else
				{
              	 	continue;
				}	
          	}
          	else
          	{
               	alert("Invalid Characters.  Please re-enter");
               // You can use the following line to blank the entered value if you want
               	var newString = s.substring(0,i) 
			   	obj.value= newString ;
               	return false;
          	}
     	}
	}
	return true;
}



// Function to Support TD MouseOver, TD Click
var btnLastClass = null;
var btnLastFontColor = null;


function TDUp(oFrom,OnClassName,UpClassName, OffClassName)
{

	if(OnClassName == null || OnClassName == '')
	{
		OnClassName ='TDOn';
	}
	
	if(UpClassName == null || UpClassName == '')
	{
		UpClassName ='TDUp';
	}

	if(OffClassName == null || OffClassName == '')
	{
		OffClassName ='TDOff';
	}

	if (document.readyState != "complete") return;
	//movement between A and DIV
	if (window.event.fromElement == null || window.event.toElement == null) return;

	if ((!oFrom.children(0).className) && ((oFrom.children(0).className == UpClassName )  && (window.event.fromElement.contains(window.event.toElement) || window.event.toElement.contains(window.event.fromElement)))) 
	{
		if ( oFrom.children(0).className != OnClassName )
		{
			window.event.cancelBubble=true;
			btnLastClass = oFrom.children(0).className;
			btnLastFontColor = oFrom.children(0).style.color;
			oFrom.children(0).className = UpClassName;	
			oFrom.children(0).style.color = "Black";
			oFrom.children(0).children(0).style.color = "Blue";
		}	
	}
	if (gbc.ie4) 
	{	
		if (window.event.fromElement.contains(window.event.toElement) || window.event.toElement.contains(window.event.fromElement)) return;
	}
	if (oFrom.children(0).className != OnClassName)
	{
		window.event.cancelBubble=true;
		btnLastClass = oFrom.children(0).className;
		btnLastFontColor = oFrom.children(0).style.color;
		oFrom.children(0).className = UpClassName;	
		oFrom.children(0).style.color = "blue";
		oFrom.children(0).children(0).style.color = "blue";
	}

}
function TDHide(oFrom,OnClassName,UpClassName, OffClassName,LinkColor){
	
	if(LinkColor == null || LinkColor == '')
	{
		LinkColor ='Blue';
	}
	
	if(OnClassName == null || OnClassName == '')
	{
		OnClassName ='TDOn';
	}
	
	if(UpClassName == null || UpClassName == '')
	{
		UpClassName ='TDUp';
	}

	if(OffClassName == null || OffClassName == '')
	{
		OffClassName ='TDOff';
	}
	
	if (document.readyState != "complete") return;
	//moving out of the button space
	if (window.event.toElement == null || window.event.toElement.tagName == "BODY" || window.event.toElement.tagName == "IMG" || window.event.toElement.tagName == "TD") 
	{
		//alert ("Class: " + btnLastClass + " Color: " + btnLastFontColor);
		window.event.cancelBubble=true;
		if (oFrom.children(0).className != OnClassName )
		{
			if (btnLastClass == null) btnLastClass = OffClassName;
			oFrom.children(0).className = btnLastClass;
			//oFrom.children(0).style.color = btnLastFontColor;
			//oFrom.children(0).children(0).style.color = btnLastFontColor;

			oFrom.children(0).style.color = LinkColor;
			oFrom.children(0).children(0).style.color = LinkColor;
			return;
		}	
	}

	//movement between A and DIV
	if (gbc.ie4) 
	{
		if (window.event.fromElement.contains(window.event.toElement) || window.event.toElement.contains(window.event.fromElement)) return;
	}
	//moving between buttons
	window.event.cancelBubble=true;
	if (oFrom.children(0).className != OnClassName )
	{
		if (btnLastClass == null) btnLastClass = OffClassName
		oFrom.children(0).className = btnLastClass;
		//oFrom.children(0).children(0).style.color = btnLastFontColor;
		//oFrom.children(0).style.color = btnLastFontColor;
		oFrom.children(0).style.color = LinkColor;
		oFrom.children(0).children(0).style.color = LinkColor;
	}
}

function TDDown(oFrom,DownClassName){
	if(DownClassName == null || DownClassName == '')
	{
		DownClassName ='TDOn';
	}
	
	if (document.readyState != "complete") return;
	window.event.cancelBubble=true;
	oFrom.children(0).className = 'TDOn';
	// new
	//alert(oFrom.children(0).children(0).style.color);
	oFrom.children(0).children(0).style.color = "Blue";
}
function TDClick(oFrom){
	if (document.readyState != "complete") return;
	window.event.cancelBubble=true;
	oFrom.children(0).className = "TDOn";
}
function TDMouseClick(element,element_id,OnClassName, OffClassName)
{

	if(OnClassName == null || OnClassName == '')
	{
		OnClassName ='TDOn';
	}
	
	if(OffClassName == null || OffClassName == '')
	{
		OffClassName ='TDOff';
	}

	if (document.readyState != "complete") return;

	window.event.cancelBubble=true;
	
	if(document.all('Nav_Default') != null && document.all('Nav_Default') != 'undefined')
	{
		document.all('Nav_Default').className = OffClassName;
	}	

	if ((oldHnav != null))
	{
	
		oldHnav.children(0).className =OffClassName;
	} 
	oldHnav=element; 
	element.children(0).className =OnClassName;
	element.children(0).children(0).style.color = 'Blue';
		
}

var isClicked = false;
//*****************************************	 
//Global caps function.  Use g_bc in all pages
//to access the browser info
//*****************************************	 
function globalCaps(){
	var A=navigator.userAgent, t=true, p="", v="";
	p=A.indexOf("MSIE");
	if (p!=-1){
    	this.ie=true;
		v=A.charAt(p+5);
		(v=="2")?this.ie2=true:this.ie2=false;
		(v=="3")?this.ie3=true:this.ie3=false;
		(v=="4")?this.ie4=true:this.ie4=false;
		(v=="5")?this.ie5=true:this.ie5=false;
	} else {
		this.ie=false;
		this.ie2=false;
		this.ie3=false;
		this.ie4=false;
		this.ie5=false;	
	}
	(this.ie4||this.ie5)?this.IE4RelOrNewer=true:this.IE4RelOrNewer=false;
	(A.indexOf("Mozilla") != -1 && A.indexOf("compatible")==-1)?this.nav=true:this.nav=false;
	(A.indexOf("Windows 95")>0||A.indexOf("Win95")!=-1||A.indexOf("Win98")!=-1||A.indexOf("Windows 98")!=-1||A.indexOf("Windows NT")!=-1)?this.win32=true:this.win32=false;
	(A.indexOf("Windows 3.1")!=-1||A.indexOf("Win16")!=-1)?this.win16=true:this.win16=false;
	(A.indexOf("Mac")!=-1)?this.anymac=true:this.anymac=false;
	(A.indexOf("SunOS")!=-1||A.indexOf("HP-UX")!=-1||A.indexOf("X11")!=-1)?this.unix=true:this.unix=false;
	(A.indexOf("Windows CE")!=-1)?this.wince=true:this.wince=false;
}

//*****************************************
//Global browser info object
//*****************************************
var gbc=new globalCaps();		


function OpenCalenderWindow()
{
		var WinName = 'camilionCal';
		var WinWidth = '210' ;
		var WinHeight = '230'; 

		var windowX =  event.clientX + 10;
		if( (windowX + 210) > windowWidth)
		{
			windowX = event.clientX - 430
		}
		var windowY =  event.clientY  + 100;
		
		if (CalendarWin == null)		
		{
			CalendarWin = window.open('/calendar.html', WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,width="+WinWidth+",height="+WinHeight+",top="+windowX+",left="+windowY);
			CalendarWin.focus();
			CalendarWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) )
		}
		else
		{	
			if (CalendarWin.closed == true)
			{
				CalendarWin.close();
				CalendarWin = window.open('/calendar.html', WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,width="+WinWidth+",height="+WinHeight+",top="+windowX+",left="+windowY);
				CalendarWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
				CalendarWin.focus();
			}
			else
			{ 
				CalendarWin.close();
				CalendarWin = window.open('/calendar.html', WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,width="+WinWidth+",height="+WinHeight+",top="+windowX+",left="+windowY);
				CalendarWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
				CalendarWin.focus();
			}	
		}
return CalendarWin;
}

function checkInvalidCharcters(objname,obj)
{
	var s = trim(obj.value);
for (var i=0; i < s.length; i++)
{
         	 var ch = s.substring(i, i+1);
				if (   (ch == "@") ||
					   (ch == "_") ||
					   (ch == " ") ||
					   (ch == "-") ||
					   (ch == "/") ||
				       (ch == "[") ||
					   (ch == "]") ||
					   (ch == "{") ||
					   (ch == "}") ||
					   (ch == "#") ||
					   (ch == "$") ||
					   (ch == "%") ||
					   (ch == "^") ||
					   (ch == "&") ||
					   (ch == "*") ||
					   (ch == "(") ||
					   (ch == ")"))  
     		 	  
			   {
			   		msg  = "Invalid Charcter in the " + objname;	
					alert(msg);
			   		return true;
			   }
			   else
			   {
				continue;			   
			   }
}
	
}	

function disableBackSpace(){
	if(window.event && window.event.keyCode == 8) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
		return false;
	}
}

function disableForms() 
{
	var oAll = document.forms[0].elements;
	var oLinks = document.links
	if (oAll != null)
	{
    	for (var i = 0; i < oAll.length; i++) 
		{
			if(oAll[i].tagName != 'LINK')
			{
				if( oAll[i].disabled != null || typeof (oAll[i].disabled) != 'undefined') 
				{
					oAll[i].disabled = true ;
				}
			}	
		}	
    	for (var j = 0; j < oLinks.length; j++) 
		{
			if( oLinks[j].onclick != null || typeof (oLinks[j].onclick) != 'undefined') 
			{
				oLinks[j].href = 'javascript:void(0);' ;
				oLinks[j].onclick = 'javascript:void(0);' ;
			}
	  }
	} 	  
}


function doReadOnlyForm() 
{
	var oAll = document.all
	var oLinks = document.links
	if (oAll != null)
	{
    	for (var i = 0; i < oAll.length; i++) 
		{
			if(oAll[i].tagName != 'LINK' && oAll[i].type != 'button')
			{
				if( oAll[i].disabled != null || typeof (oAll[i].disabled) != 'undefined') 
				{
					oAll[i].disabled = true ;
				}
			}	
		}	
    	for (var j = 0; j < oLinks.length; j++) 
		{
			if( oLinks[j].onclick != null || typeof (oLinks[j].onclick) != 'undefined') 
			{
				oLinks[j].href = 'javascript:void(0);' ;
				oLinks[j].onclick = 'javascript:void(0);' ;
			}
	  }
	} 	  
}



//*************************** Start of Debug messages *****************************
var raampje, xtra, ytra;
function sleepen()
{
	if (event.button!=1)return;	
	raampje = eval("CMDebugContainer");temp1=raampje.style.posLeft;
	temp2=raampje.style.posTop;xpos=event.clientX;
	ypos=event.clientY;xtra = temp1-xpos;
	ytra = temp2-ypos;document.onmousemove=plaats;
}

function plaats()
{
	if (event.button==1)
	{
		raampje.style.pixelLeft=event.clientX+xtra;
		raampje.style.pixelTop=event.clientY+ytra;
		return false;
	}
}

function DoDebugMessage()
{
	var oKey = window.event.keyCode;
	if( event.ctrlKey && oKey == 123)
	{
		ShowDebugMessage();
	}
	else if( event.ctrlKey && oKey == 122)
	{
		ShowRunTimeDebugMessage();
	}
}
var oDebugPopUp;
var RunTimeDebug = null;
function ShowRunTimeDebugMessage()
{
		var WinName = 'CamilionRunTimeDebug'
		var WinWidth = windowWidth * 0.90 ;
		var WinHeight = windowHeight * 0.90 ; 
		var path = '/util/RunTimeDebugMessage.jsp';
		var windowX = Math.ceil( (window.screen.width  - WinWidth) / 2 );
		var windowY = Math.ceil( (window.screen.height - WinHeight) / 2);
		var isDialogWin = false ;
		if(window.dialogHeight != undefined )isDialogWin = true ;
		if (RunTimeDebug == null)		
		{
			if(isDialogWin){
				RunTimeDebug = window.showModalDialog(path,window , "toolbar:no;menubar:no;scrollbars:no;resizable:yes;help:no;status:no;dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;dialogLeft:"+windowX+"px;dialogTop:"+windowY+"px;");				
			}
			else{
				RunTimeDebug = window.open(path, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight);
				RunTimeDebug.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );			
				RunTimeDebug.focus();
			}			
		}
		else
		{	
			if (RunTimeDebug.closed == true)
			{
				if(isDialogWin){
					RunTimeDebug = window.showModalDialog(path,window , "toolbar:no;menubar:no;scrollbars:no;resizable:yes;help:no;status:no;dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;dialogLeft:"+windowX+"px;dialogTop:"+windowY+"px;");
				}
				else{
					RunTimeDebug = window.open(path, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight);
					RunTimeDebug.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
					RunTimeDebug.focus();
				}				
			}
			else
			{ 
				RunTimeDebug.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
				RunTimeDebug.focus();
			}	
		}	
}

function ShowDebugMessage()
{		
	var otext = document.getElementById('CamilionDebugInfo').innerHTML;
		
	titlecolor = "black"; 						
	opacitytitle = 45;   						

	color = "White";							
	var thisspan = eval("CMDebugContainer.style") 
	thisspan.pixelLeft = document.body.scrollLeft + 100;		
	thisspan.pixelTop =  document.body.scrollTop + 100;
	thisspan.width =  "760px";
	thisspan.height =  "350px";
	//thisspan.visibility="visible";
	
	output = "<table cellpadding=0 cellspacing=0 width=760 height=340 border=1 ><tr>";
	output += "<td onmousedown='' style='cursor:hand' onmouseup='JavaScript:document.onmousemove=\"\" ' bgcolor='"+titlecolor+"' style='filter:alpha(opacity="+opacitytitle+");' width =300 height=20><FONT colour='black'>Debug Information</FONT></td><td bgcolor='silver'>";
	output += "<SPAN TITLE=\"Close\" onclick='parent.hideDebugPopup()' style='cursor:hand'>X</SPAN></td></tr>";
	output += "<tr><td width=100% colspan=2><table ";   
	output += " width=760 height=300 bgcolor='"+color+"'><tr><td height=760 width=300 align='left' valign='top' >"+ otext+"</td></tr></table></td></tr>";

	CMDebugContainer.innerHTML = output;
	srcElem = event.srcElement;
	
	oDebugPopUp = window.createPopup();
	var oPopBody = oDebugPopUp.document.body
	oPopBody.scroll="yes"
	oPopBody.style.overflow ="auto"
	oPopBody.style.backgroundColor =color;
	oPopBody.innerHTML = output ;
	
	ix = 0;
    iy = 10;
	oDebugPopUp.show( ix , iy , 770,360 , srcElem);
	
}
function hideDebugPopup(){
	if(oDebugPopUp)
		if(oDebugPopUp.isOpen)
			oDebugPopUp.hide();
	
}

function closeraam()
{
	CMDebugContainer.style.visibility="hidden";
}
//****************************** End of Debug Functions*********************/

if (document.images) 
{	
	// Image for folder
	NoNote = new Image;
    NoNote.src = '/images/icons/NoNote.gif';
    EmptyNote = new Image;
    EmptyNote.src = '/images/cm_fill.gif';

	SpellcheckImg = new Image;
    SpellcheckImg.src = '/images/icons/spellcheck.gif';
    EmptySpellcheckImg = new Image;
    EmptySpellcheckImg.src = '/images/cm_fill.gif';
}

function ShowHideNoteImage (oObject,oColumnName)
{
	//alert("document.all = "+document.all);
	//alert("oObject = "+oObject);
	//alert("oColumnName = "+oColumnName);
	HideAllNoNotesImages();
	oSpanObject = document.all['NOTE_'+oColumnName];
	//oSpanObject = document.getElementById['NOTE_'+oColumnName];
	//oSpanObject = document.getElementById['NOTE_'+oColumnName];
	//alert("oSpanObject = "+oSpanObject);
	//alert(oColumnName.tagName);
	//alert(oImages[i].src.indexOf("cm_fill.gif"));
	if(oSpanObject != null && oSpanObject.tagName == 'IMG' && (oSpanObject.src.indexOf("cm_fill.gif")) > -1  )
	{
		oSpanObject.src = NoNote.src;
		//alert("oSpanObject.src = "+oSpanObject.src);
		oSpanObject.parentElement.disabled = false ;
	}
}
function HideAllNoNotesImages()
{
	//alert("entered+HideAllNoNotesImages()");
	var oImages = document.images;
	//alert(oImages.length);
	if (oImages != null)
	{
    	for (var i = 0; i < oImages.length; i++) 
		{
		//alert((oImages[i].tagName == 'IMG' && (oImages[i].src.indexOf("NoNote")) > -1 ));
			//alert(oImages[i].tagName);
			//alert(oImages[i].src.indexOf("NoNote"));
			if(oImages[i].tagName == 'IMG' && (oImages[i].src.indexOf("NoNote")) > -1 )
			{
				//alert(oImages[i].tagName + oImages[i].tagName);
				//alert("oImages["+i+"] = "+oImages[i]);
				//alert(oImages[i].parentElement.parentElement.tagName);
				//alert(oImages[i].parentElement);
				//alert(oImages[i].parentElement.parentElement);
				//alert(oImages[i].parentElement.parentElement.tagName);
				if(oImages[i].parentElement!= null && oImages[i].parentElement.parentElement != null &&  oImages[i].parentElement.parentElement.tagName == 'SPAN')
				//if(oImages[i].parentElement!= null && oImages[i].parentElement.parentElement != null)
				{
					//alert("entered");
					oImages[i].src = EmptyNote.src;
					//alert("oImages["+i+"].src = "+EmptyNote.src);
					oImages[i].style.width = 24;
					oImages[i].style.height = 16;
					oImages[i].parentElement.disabled = true ;
					
				} 
			}	
		}
	}		
}


function ShowHideSpellcheckImage (oObject,oColumnName)
{
	HideAllSpellcheckImages();
	oSpanObject = document.all['SPELLCHECK_'+oColumnName];
	if(oSpanObject != null && oSpanObject.tagName == 'IMG' && (oSpanObject.src.indexOf("cm_fill.gif")) > -1  )
	{
		oSpanObject.style.width = 16;
		oSpanObject.style.height = 16;
		oSpanObject.src = SpellcheckImg.src;
		oSpanObject.parentElement.disabled = false ;
	} 
}
function HideAllSpellcheckImages()
{
	var oImages = document.images;
	if (oImages != null)
	{
    	for (var i = 0; i < oImages.length; i++) 
		{
			if(oImages[i].tagName == 'IMG' && oImages[i].id.indexOf("SPELLCHECK_") == 0 )
			{
				if(oImages[i].parentElement!= null && oImages[i].parentElement.parentElement != null &&  oImages[i].parentElement.parentElement.tagName == 'SPAN')
				{
					oImages[i].src = EmptySpellcheckImg.src;
					oImages[i].style.width = 16;
					oImages[i].style.height = 16;
					oImages[i].parentElement.disabled = true ;
					
				} 
			}	
		}
	}		
}


// Functions nede by Rich text Editor

function _updateRichHTML(asId) {
	var loDataElement = document.getElementById("__spellcheck_" + asId);
	var loRichEditFrame = document.getElementById("richedit_" + asId);
	if (loDataElement && loRichEditFrame && loRichEditFrame.tagName == "IFRAME") {
		loRichEditFrame.contentWindow._setHTML(loDataElement.value);
	}
}

function expand_onclick_handler(oID){
		// the state is collapase so force environment to be expanded.
		var oObj_1 =document.getElementById('oCollapso'+oID);
		var oObj_2 =document.getElementById('oMTData'+oID);
		if(oObj_1.state == "collapsed")
		{
			oObj_2.style.overflow = "visible";
			oObj_1.title = "Collapse";
			oObj_1.src = "/images/icons/UI_OM_collapse.gif";
			oObj_1.state = "expanded";
		}
		else
		{
			oObj_2.style.overflow = "auto";
			oObj_1.title = "Expand";
			oObj_1.src = "/images/icons/UI_OM_expand.gif";
			oObj_1.state = "collapsed";
		}
			
}

function contentEdit_onclick_handler(oID)
{
	var oObjTable1 = document.getElementById('DisplayContentTABLE_A_'+oID);
	var oObjTable2 = document.getElementById('DisplayContentTABLE_B_'+oID);
	

	if(oObjTable1 != null)
		oObjTable1.style.display='none';

	if(oObjTable2 != null)
		oObjTable2.style.display='';
	
	var oIFrame = oObjTable2.children(0).children(0).children(0).children(0).children(0); 	
	if( oIFrame != null && oIFrame.tagName=='IFRAME')	
		oIFrame.scrollIntoView();
}
function contentEdit_ondeactivate_handler(oObj,oID)
{
	if(oObj != null && oObj.contentWindow != null)
	{
		if(oObj.contentWindow._updateThisContent)
			oObj.contentWindow._updateThisContent();
	}	
}
function LoadRichText(oID,oValueObject)
{
	var _oDataContainer = document.getElementById('oMTData'+oID);
	_oDataContainer.innerHTML = document.getElementById(oValueObject).value;
}
function ResizeRichText(oID)
{

	var _oDataContainer = document.getElementById('oMTData'+oID);
	
	_oDataContainer.contentEditable=false
	
	if(_oDataContainer.clientHeight > _oDataContainer.scrollHeight )
		_oDataContainer.style.height = _oDataContainer.scrollHeight +"px"
	else if(_oDataContainer.scrollHeight < 255)
		_oDataContainer.style.height = _oDataContainer.scrollHeight+"px";	
	else
		_oDataContainer.style.height = "255px";	
	
	// If there is no Scroll then hide the Expand bsr	
	var _oCpllaspImg = document.getElementById('oCollapso'+oID);
	if(_oDataContainer.scrollHeight < 255 )
	{
		_oCpllaspImg.style.display='none';
	}
	else
	{
		_oCpllaspImg.style.display='';
	}
	document.body.focus();	
}

	function ShowHintPage()
	{
		var HintWin = null;
		var WinName = 'CamilionHint'
		var WinWidth = windowWidth * 0.50 ;
		var WinHeight = windowHeight * 0.30 ; 
		var result ='';
		var path = '/util/password_util/ForgotPassword.jsp';
		var windowX = Math.ceil(  WinWidth / 2 );
		var windowY = Math.ceil(  WinHeight / 2 );
		
		if (HintWin == null)		
		{
			window.close();
			HintWin = window.open(path, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight);
			HintWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
			HintWin.focus();
		}
		else
		{	
			if (HintWin.closed == true)
			{
				window.close();
				HintWin = window.open(path, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight);
				HintWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
				HintWin.focus();
			}
			else
			{ 
				HintWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
				HintWin.focus();
			}	
		}
	
	}
function OpenResetPasswordScreen(jsUserId)
{
	
	var WinWidth = windowWidth * 0.50 ;
	var WinHeight = windowHeight * 0.40 ; 
	var windowX = Math.ceil(  WinWidth / 2 );
	var windowY = Math.ceil(  WinHeight / 2 );

	var path = '/util/password_util/ChangePassword.jsp?Dialog=BuildFrame&Action=GetUserInfo&Msg=ReSetPassword&UserId='+jsUserId+'&Time='+currentTimeMillis();
	window.showModelessDialog(path,window,'dialogHeight:'+WinHeight+'px;dialogWidth:'+WinWidth+'px;scroll:off; center: yes; status:no; resizable:yes ; help:no');

}
function ShowChangePasswordPage()
{
	var WinWidth = windowWidth * 0.50 ;
	var WinHeight = windowHeight * 0.40 ; 
	var windowX = Math.ceil(  WinWidth / 2 );
	var windowY = Math.ceil(  WinHeight / 2 );

	var path = '/util/password_util/ChangePassword.jsp?Dialog=BuildFrame&Action=ValidateUser&Msg=ChangePassword&Time='+currentTimeMillis();
	window.showModelessDialog(path,window,'dialogHeight:'+WinHeight+'px;dialogWidth:'+WinWidth+'px;scroll:off; center: yes; status:no; resizable:yes ; help:no');


}
function ResizeApp(oLength)
{
		var jsHeight = document.body.clientHeight - oLength  ;
		if(document.getElementById('ContentDiv') != null )
		{
			if(document.getElementById('ContentDiv').style.height != null && jsHeight > 0 )
			{
				document.getElementById('ContentDiv').style.height = jsHeight
			}
		}		
}
	
 function ShowConfirmDialog(oMessage,oWidth,oHeight)
 {
 
	if(oWidth == null )
		oWidth=300;
	if(oHeight == null )
		oHeight=175;
		
	 var oCheck = showModalDialog('/util/dialog_util/ConfirmDialog.jsp',oMessage,'dialogHeight:'+oHeight+'px;dialogWidth:'+oWidth+'px;scroll:off; center: yes; status:no; resizable:no ; help:no');
	 
	 return oCheck;
 }

function ShowMessageDialog(oMessage,oWidth,oHeight)
{
	HandleMessageDialog(oMessage,oWidth,oHeight,1);
}

function ShowMessage(oMessage,oWidth,oHeight)
{
	HandleMessageDialog(oMessage,oWidth,oHeight,1);
}

function ShowWarnMessage(oMessage,oWidth,oHeight)
{
	HandleMessageDialog(oMessage,oWidth,oHeight,2);

}
function ShowErrorMessage(oMessage,oWidth,oHeight)
{
	HandleMessageDialog(oMessage,oWidth,oHeight,3);
}
function HandleMessageDialog(oMessage,oWidth,oHeight,oType)
{

	if(oWidth == null )
		oWidth=267;
	if(oHeight == null )
		oHeight=150;
	window.showModalDialog('/util/dialog_util/AlertDialog.jsp?Type='+oType,oMessage,'dialogHeight:'+oHeight+'px;dialogWidth:'+oWidth+'px;scroll:off; center: yes; status:no; resizable:yes ; help:no ');

}
function ShowLoginHelp()
{

		var TroubleWin = null;
		var WinName = 'CamilionTrouble'
		var WinWidth = windowWidth * 0.50 ;
		var WinHeight = windowHeight * 0.50 ; 
		var path = 'LoginTrouble.jsp';
		var windowX = Math.ceil(  WinWidth / 2 );
		var windowY = Math.ceil(  WinHeight / 2 );
		
		window.showModelessDialog(path,window,'dialogHeight:'+WinHeight+'px;dialogWidth:'+WinWidth+'px;scroll:off; center: yes; status:no; resizable:no ; help:no');
		/*
		if (TroubleWin == null)		
		{
			window.close();
			TroubleWin = window.open(path, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight);
			TroubleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
			TroubleWin.focus();
		}
		else
		{	
			if (TroubleWin.closed == true)
			{
				window.close();
				TroubleWin = window.open(path, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight);
				TroubleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
				TroubleWin.focus();
			}
			else
			{ 
				TroubleWin.moveTo( Math.ceil( windowX ) , Math.ceil( windowY ) );
				TroubleWin.focus();
			}	
		}
	TroubleWin.focus();
	*/
	}
function showPrintPreview(oWidth,oHeight,oType,oModel)
{
		var WinWidth = windowWidth * 0.50 ;
		var WinHeight = windowHeight * 0.50 ; 
		if(oType != null && oType == '%')
		{
			if(oWidth != null)WinWidth= windowWidth * oWidth;
			if(oHeight != null)WinHeight=windowHeight * oWidth;
		
		}else if(oType != null && oType == 'px'){
			if(oWidth != null)WinWidth=oWidth;
			if(oHeight != null)WinHeight=oWidth;
		}
		var windowX = Math.ceil(  WinWidth / 2 );
		var windowY = Math.ceil(  WinHeight / 2 );
		
	if(oModel== null || oModel)
	{	
		window.showModelessDialog("/util/PrintPreview.htm",window,'dialogHeight:'+WinHeight+'px;dialogWidth:'+WinWidth+'px;center:yes;status:no;resizable:no;help:no');
	}else
	{
		window.open("/util/PrintPreview.htm", 'oPrintPreview', "toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,width="+WinWidth+",height="+WinHeight+",top="+windowX+",left="+windowY);
	}
}	

/*******************************************************************************************************
*  functions for handling text to currency format
********************************************************************************************************/

function formatCurrency(num,obIsDecimal,obIsRound,obShowSign) 
{
	if(checkBlankValue(num))return "";
	if(obShowSign == null)obShowSign=true;
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	if(obIsRound)
	{
		var oTemp = Math.round( num + '.' + cents)
		num =oTemp.toString();
	}	
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	if(obIsDecimal && !obIsRound)
	{
		return (((sign)?'':'-(') + ((obShowSign)?'$':'') + num + '.' + cents + ((sign)?'':')'));
	}	
	else if(obIsDecimal && obIsRound)
	{
		return (((sign)?'':'-(') + ((obShowSign)?'$':'') + num + ((sign)?'':')'));
	}	
	else if(!obIsDecimal)
	{
		return (((sign)?'':'-(') + ((obShowSign)?'$':'') + num + ((sign)?'':')'));
	}	
}


function jsTextToMoney()
{
	this.isRestricted = true;
	this.isDecimal = true;
	this.isRound = true;
	this.isAlert = true;
	this.isFactor = false;
	this.scale = 2;
	this.maxLength ='*';
	this.srcElement = null;
	this.ValueObject = null;
	this.originalValue= "0";
	this.ShowSign = true;
	var me=this;
	var decReg = "";
	this.invoke=function () 
	{
	if( me.isRestricted )
			me.srcElement.detachEvent("onpropertychange",me.restrictInput)
		
		if (checkBlankObject(me.srcElement)){ 
				if(me.ValueObject != null){
					me.ValueObject.value = '';	 
					me.srcElement.detachEvent("onblur",me.invoke)
					return; 
				}	
		}
		var oval = me.srcElement.value.toUpperCase();
		var splitBy="";
		if(me.isFactor)	
			splitBy="K";
			
		if(oval.indexOf("M") > -1 )
			splitBy ="M"
		else if(oval.indexOf("K") > -1 )
			splitBy ="K"
		else if(oval.indexOf("B") > -1 )
			splitBy ="B"
		
		if(! splitBy == "") 
		{
			var oSplit = oval.split(splitBy);
			
			if(! checkBlankValue(oSplit[0]) && oSplit.length==2 && isInteger(oSplit[0]) && oSplit[1]=='' )
			{
				if(splitBy == 'M')
				{
					me.srcElement.value = formatCurrency(oSplit[0] * 1000000,me.isDecimal,me.isRound,me.ShowSign)
					//window.status= 'A'+formatCurrency(oSplit[0] * 1000000,me.isDecimal,me.isRound)+' B :'+me.srcElement.value;
				}	
				else if(splitBy == 'B')
				{
					me.srcElement.value = formatCurrency(oSplit[0] * 1000000000,me.isDecimal,me.isRound,me.ShowSign)
				}	
				else if(splitBy == 'K')
				{
					me.srcElement.value = formatCurrency(oSplit[0] * 1000,me.isDecimal,me.isRound,me.ShowSign)
				}	
	
			}else{
				alert("Please enter a valid value");
				me.ValueObject.value = '0';
				me.srcElement.value='';
				me.srcElement.detachEvent("onblur",me.invoke);
				me.ValueObject.fireEvent("onchange");
				me.ValueObject.fireEvent("onblur");
				return;
			}	

 		 }
		 else
		 {	
		 	if(isInteger(oval) )
			{
			 	me.srcElement.value = formatCurrency(oval,me.isDecimal,me.isRound,me.ShowSign)
			}else{
					alert("Please enter a valid value");
					me.ValueObject.value = '0';
					me.srcElement.value='';
					me.srcElement.detachEvent("onblur",me.invoke);
					me.ValueObject.fireEvent("onchange");
					me.ValueObject.fireEvent("onblur");
					return;
			}	
		 }
		
		if(me.ValueObject != null)
		{
			var oTempValue = me.srcElement.value.toString().replace(/\$|\,|\(|\)/g,'');
			if( isInteger(oTempValue))
			{
				if(oTempValue.length > me.ValueObject.getAttribute("DataLength"))
				{
					alert("The value you have entered is larger than the acceptable length which is :"+me.ValueObject.getAttribute("DataLength"));
					me.ValueObject.value = '0';
					me.srcElement.value ='';	
					me.srcElement.detachEvent("onblur",me.invoke)
					me.ValueObject.fireEvent("onchange");
					me.ValueObject.fireEvent("onblur");
					return;
				}else
				{
					me.ValueObject.value = oTempValue;
					validateDecimals(me.ValueObject,me.ValueObject.getAttribute("DataLength"),me.ValueObject.getAttribute("Scale"));
				}	
			}	
			else
				me.ValueObject.value = '0';	
		}
		me.ValueObject.fireEvent("onchange");
		me.ValueObject.fireEvent("onblur");
		handleCurrencyColor(me.srcElement,me.ValueObject);
		
		me.srcElement.detachEvent("onblur",me.invoke)
		
	}	 

	this.restrictInput=function () 
	{
		if(/[^-0-9.Mm|Kk|Bb]/.test( me.srcElement.value ) ){
		me.srcElement.value=me.srcElement.value.replace( /([^0-9.Mm|Kk|Bb])/g, "" );
		}
 	}
	
}
function handleCurrencyColor(oMask,oSource)
{

	if(oSource != null)
			if(parseFloat (oSource.value	) < 0 )
				oMask.style.color='Red';
			else
				oMask.style.color='Black';
}
function clearInvalidInput(oControl)
{
	var  isValid = false;
	var oValue = oControl.value;
	if (oValue < 0 || oValue.indexOf('-') > -1 ){
		isValid = true;	
		alert(' Value for this field must be positive ')
		var id = oControl.id;
		var pos = id.indexOf('_OPMASK');
		if (pos > -1 ){
			var oCont = document.getElementById(id.substring(0,pos))
			oControl.style.color='Black';
			oControl.value ='$0';			
			oCont.value ='0';
		}else{
			oControl.value ='0';
		}
	}	
	return isValid;
}
/***************************************************************************************************
*
*-- Convert currency format to text format, Copyright (c) 2001-2002
*
*	Example: if the Display is like $10,000,000 when you click the text box this will be converted to 1M
*	Usage : onfocus="convertMoneyToText(this)"
*	Params : jsSumObject (String)- The Object that need to sum the values and display as MoneyToText format
*	Params : jbIsFactor (Boolean)- Do we fefault the factor to "K" if the user does not enter. If false the the number will be taken as is. default :false
*	Params : jbRestricted (Boolean)- if you want to restrict the user of what they can type in to the Box default :true
*	Params : jbIsDecimal (Boolean)- if you want to display the decimals default :true
*	Params : jbIsRound (Boolean)- if you want to round the result default :true
*	Params : jbIsAlert (Boolean)- if you want to alert the user of the input is in the wrong format default :true (Not Implemented)
*	Params : jiScale (Number)- What is the maximum length of the decimal points default :2 (Not implemented)
*	Params : jimaxLength (Number)- What is the maximum length before the decimal a user can enter default :* (Not Implemented)
*******************************************************************************************************/

function convertMoneyToText(oObj,jbIsDecimal,jbIsRound,jsValueObject,jsShowSign,jbIsFactor,jbRestricted,jbIsAlert,jiScale,jiMaxLength)
{
	var joTextToMoney =new jsTextToMoney( );
	var oConvert = false;
	if(oObj == null) return ;
	else	joTextToMoney.srcElement = oObj
	
	// Set the Original value so that the Sum function can be re calculated
	joTextToMoney.originalValue=oObj.value;
	if(jsValueObject != null ){	joTextToMoney.ValueObject=jsValueObject;}
	if(jbIsFactor != null )joTextToMoney.isFactor=jbIsFactor;
	
	if(jbRestricted == null )jbRestricted = true; 
	
	 joTextToMoney.isRestricted=jbRestricted;
	
	if(jbIsDecimal != null )joTextToMoney.isDecimal=jbIsDecimal;
	if(jbIsRound != null )joTextToMoney.isRound=jbIsRound;
	if(jbIsAlert != null )joTextToMoney.isAlert=jbIsAlert;
	if(jiScale != null )joTextToMoney.scale=jiScale;
	if(jiMaxLength != null )joTextToMoney.maxLength=jiMaxLength;
	if(jsShowSign != null )joTextToMoney.ShowSign=jsShowSign;
	
	//alert('joTextToMoney.ShowSign :'+joTextToMoney.ShowSign)
	if(oObj.value.indexOf(',') > 0 )
		oConvert = true;
	var otmp1 = oObj.value.replace(/\$|\,|\(|\)/g,'');
	if (isInteger(otmp1)) 
	{
		var otemp2 = otmp1 / 1000000 ;
		var otemp3 = otmp1 / 1000 ;
		var otemp4 = otmp1 / 1000000000 ;
		if(otemp4 < 1 )
		{
			if(otemp2 < 1 )
				if(oConvert || jbIsFactor)
					oObj.value =  otemp3  +'K'
				else
					oObj.value =  otmp1 	
			else
				oObj.value = (otemp2 )+'M'
		}
		else
		{
			oObj.value = (otemp4 )+'B'
		}	
		//window.status=oObj.value;
		oObj.attachEvent("onblur",joTextToMoney.invoke);
		//if(jsSumObject != null)
			//oObj.attachEvent("onchange",joTextToMoney.doSumCalculation);
		//window.status=jbRestricted;
		
		if( jbRestricted )
			oObj.attachEvent("onpropertychange",joTextToMoney.restrictInput)
		
		oObj.select()	
	}
	else
	{	// if the value is not a number then clear the value
		oObj.value ='';
	}
}
function doControlSum(oSumObject, oSumColumns,oSumFormat)
{
	var oSplit = oSumColumns.split("|")
	var obj = null
	var oFinal = 0
	var	num1 = "0";
	var num2 =  "0";
	for(var i = 0 ; i < oSplit.length ; i++)
	{	 
		obj = document.getElementById(oSplit[i]);
		if(obj != null)
		{
			num2 =  trim( obj.value.toString()).replace(/\$|\,|\(|\)/g,'');
			if(num2 == '' || isNaN(num2))
				num2 = "0";
				
			num1 =  parseFloat(num1) + parseFloat(num2) 
		}
	
	}
	if(oSumFormat == 'TEXT')
		document.getElementById(oSumObject).value = formatCurrency(num1,false,false)
	else if(oSumFormat == 'NUMBERMASK')
	{
		setMaskValue(oSumObject,num1)
	}else
		document.getElementById(oSumObject).value = num1;
}
/*******************************************************************************************************
*  End of functions for handling text to currency format
********************************************************************************************************/

/*******************************************************************************************************
*  Start of functions for handling Output Mask
********************************************************************************************************/
function MaskControl()
{
	//convertMoneyToText(oObj,jbIsDecimal,jbIsRound,jsValueObject,jsShowSign,jbIsFactor,jbRestricted,jbIsAlert,jiScale,jiMaxLength)
	this.SourceColumn = null;
	this.TargetColumn = null;
	this.isDecimal = true;
	this.isRound = true;
	this.Length = 16;
	this.Scale = 0;
	this.ShowSign = true;
	var me=this;
	this.invoke=function () 
	{
		convertMoneyToText(me.TargetColumn,me.isDecimal,me.isRound,me.SourceColumn,me.ShowSign,false,false,true,me.Scale,me.Length);	
	}	 


}

function _displayOutputMask(oKey,oColumn,oDisplayColumn)
{
	var oCol = document.getElementById(oColumn);
	var oDispCol = document.getElementById(oDisplayColumn);
	if(oCol == null || oDispCol == null) return;
	validateDecimals(oCol,oCol.getAttribute("DataLength"),oCol.getAttribute("Scale"));
	_handleOutputMask(oKey,oCol,oDispCol,(oDispCol.readOnly)?false:true);
}
function _handleOutputMask(oKey,oColumnControl,oDisplayColumnControl,oAttachEvent)
{
	switch(oKey)
	{
        case "1":
            handleMask1(oColumnControl,oDisplayColumnControl,oAttachEvent); 
            break;
        case "2":
            handleMask2(oColumnControl,oDisplayColumnControl,oAttachEvent); 
            break;
        case "3":
            handleMask3(oColumnControl,oDisplayColumnControl,oAttachEvent); 
            break;
        case "4":
            handleMask4(oColumnControl,oDisplayColumnControl,oAttachEvent); 
            break;
        case "5":
            handleMask5(oColumnControl,oDisplayColumnControl,oAttachEvent); 
            break;
 		default:
            handleMask1(oColumnControl,oDisplayColumnControl,oAttachEvent);
            break; 
    }
}
function handleMask1(oColumn,oDisplayColumn,oAttachEvent)
{
	var _oControl = new MaskControl()
	_oControl.TargetColumn=oDisplayColumn;
	_oControl.SourceColumn=oColumn;
	_oControl.Length=oColumn.getAttribute("DataLength");
	_oControl.Scale=oColumn.getAttribute("Scale");
	//_oControl.invoke
	if(oAttachEvent == null || oAttachEvent)
	oDisplayColumn.attachEvent("onfocus",_oControl.invoke)
	

	if(isNaN(oColumn.value))return;
	oDisplayColumn.value = formatCurrency( oColumn.value , true,false,true);
	handleCurrencyColor(oDisplayColumn,oColumn);
}

function handleMask2( oColumn,oDisplayColumn,oAttachEvent)
{

	var _oControl = new MaskControl()
	_oControl.TargetColumn=oDisplayColumn;
	_oControl.SourceColumn=oColumn;
	_oControl.isDecimal=false;
	_oControl.isRound=false;
	_oControl.Length=oColumn.getAttribute("DataLength");
	_oControl.Scale=oColumn.getAttribute("Scale");

	//_oControl.invoke
	if(oAttachEvent == null || oAttachEvent)
	oDisplayColumn.attachEvent("onfocus",_oControl.invoke)

	if(isNaN(oColumn.value))return;
	oDisplayColumn.value = formatCurrency( oColumn.value , false,false,true)
	handleCurrencyColor(oDisplayColumn,oColumn);

}
function handleMask3( oColumn,oDisplayColumn,oAttachEvent)
{
	var _oControl = new MaskControl()
	_oControl.TargetColumn=oDisplayColumn;
	_oControl.SourceColumn=oColumn;
	_oControl.isDecimal=false;
	_oControl.isRound=true;
	_oControl.Length=oColumn.getAttribute("DataLength");
	_oControl.Scale=oColumn.getAttribute("Scale");

	//_oControl.invoke
	if(oAttachEvent == null || oAttachEvent)
	oDisplayColumn.attachEvent("onfocus",_oControl.invoke)

	
	if(isNaN(oColumn.value))return;
	oDisplayColumn.value = formatCurrency( oColumn.value , false,true,true)
	handleCurrencyColor(oDisplayColumn,oColumn);

}
function handleMask4( oColumn,oDisplayColumn,oAttachEvent)
{
	var _oControl = new MaskControl()
	_oControl.TargetColumn=oDisplayColumn;
	_oControl.SourceColumn=oColumn;
	_oControl.isDecimal=true;
	_oControl.isRound=false;
	_oControl.Length=oColumn.getAttribute("DataLength");
	_oControl.Scale=oColumn.getAttribute("Scale");

	//_oControl.invoke
	if(oAttachEvent == null || oAttachEvent)
	oDisplayColumn.attachEvent("onfocus",_oControl.invoke)
	

	if(isNaN(oColumn.value))return;
	oDisplayColumn.value = formatCurrency( oColumn.value , true,true,true)
	handleCurrencyColor(oDisplayColumn,oColumn);

}
function handleMask5( oColumn,oDisplayColumn,oAttachEvent)
{
	var _oControl = new MaskControl()
	_oControl.TargetColumn=oDisplayColumn;
	_oControl.SourceColumn=oColumn;
	_oControl.isDecimal=false;
	_oControl.isRound=true;
	_oControl.ShowSign=false;
	_oControl.Length=oColumn.getAttribute("DataLength");
	_oControl.Scale=oColumn.getAttribute("Scale");

	//_oControl.invoke();
	if(oAttachEvent == null || oAttachEvent)
	oDisplayColumn.attachEvent("onfocus",_oControl.invoke)

	
	if(isNaN(oColumn.value))return;
	
	oDisplayColumn.value = formatCurrency( oColumn.value , false,true,false)
	handleCurrencyColor(oDisplayColumn,oColumn);

}

function setMaskValue(oControlName,oValue)
{
	var oControl = document.getElementById(oControlName);
	var oMaskControl = document.getElementById(oControlName+"_OPMASK");
	
	if(oControl.getAttribute("ValueType") == 'Number')
	{
		if(isNaN(oValue.toString()))return;
        if( !isInteger(oValue.toString()) )
        {        
          alert("The value :"+oValue+" is not a valid value for the input field :"+oControlName);
          return;
        }

		oControl.value=oValue;
		validateDecimals(oControl,oControl.getAttribute("DataLength"),oControl.getAttribute("Scale"));
		_handleOutputMask(oControl.getAttribute("OutPutMaskId"),oControl,oMaskControl,false);
	}	
}

/*******************************************************************************************************
*  End of functions for handling Output Mask
********************************************************************************************************/

/*******************************************************************************************************
*  Start of functions for handling Questionnaire
********************************************************************************************************/
function ResizeQuestionnaire(oDiveObject,oHeight)
{

	this.oDiv = oDiveObject;
	this.oDesiredHeight = oHeight
	var me=this;
	this._DoResize=function () 
	{
		me.oDiv.style.height = Math.round( me.oDiv.clientHeight * (oHeight / 100))+"px";	
	}

}



/*******************************************************************************************************
*  End of functions for handling Questionnaire
********************************************************************************************************/


function OpenGlossary(Language_Code,Term) 
{
		if(Term == null)
		Term ="";
		theurl="/help/glossary/"+Language_Code+"/GlossaryFrame.jsp?LangCode="+Language_Code+"&Term="+Term;
		var GlossaryWin = null;
		var WinName = 'CamilionGlossary'
		var WinWidth = windowWidth * 0.60 ;
		var WinHeight = windowHeight * 0.75 ; 
		var result ='';
		var windowX = Math.ceil( (windowWidth - WinWidth) / 2 );
		var windowY = Math.ceil( (windowHeight -  WinHeight ) / 2 );
		

		if (GlossaryWin == null)		
		{
			window.close();
			GlossaryWin = window.open(theurl, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight+",top="+windowX+",left="+windowY);
			GlossaryWin.focus();
		}
		else
		{	
			if (GlossaryWin.closed == true)
			{
				window.close();
				GlossaryWin = window.open(theurl, WinName, "toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+WinWidth+",height="+WinHeight+",top="+windowX+",left="+windowY);
				GlossaryWin.focus();
			}
			else
			{ 
				GlossaryWin.focus();
			}	
		}
}
  function openDiary(jsPkColumn,jsDisColumn,jsSubject)
  {
       var WinWidth         = windowWidth * .45  ;
       var WinHeight         = windowHeight * .40; 
       var windowX         = Math.ceil( (window.screen.width  - WinWidth) / 2 );
       var windowY         = Math.ceil( (window.screen.height - WinHeight) / 2 );
       var jsDialog = 'RETRIEVE';
       var jsPkId =  document.getElementById(jsPkColumn).value;
       var jsPdefId = document.getElementById("_PDEFID").value;
       var jsPiThreadId = document.getElementById("_PITHREADID").value;
       var jsPdefActId = document.getElementById("_PDEFACTID").value;
       var jsPiHistId = document.getElementById("_PITHREADHISTID").value;                                                
       var jsPolicyNumber = document.getElementById("POLICY_NUMBER").value;
       if(jsPkId == null || jsPkId ==''||jsPkId=='undefined') jsDialog = 'NEW';
       var path                 = '/client/jsp/enu/diaryFrame.jsp?Dialog='+jsDialog+'&DiaryId='+jsPkId+'&PK_COLUMN='+jsPkColumn+'&DIS_COLUMN='+jsDisColumn+'&POLICYNUMBER='+jsPolicyNumber+'&SUBJECT='
                                       +jsSubject+'&_PDEFID='+jsPdefId+'&_PITHREADID='+jsPiThreadId+'&_PDEFACTID='+jsPdefActId+'&_PITHREADHISTID='+jsPiHistId+'&Time='+currentTimeMillis();
//        var jsReturn = window.open(path, "", "toolbar=no,menubar=no,scrollbars=auto,resizable=yes,status=no,titlebar=no,width="+WinWidth+",height="+WinHeight);
	   disableRuneTimeForms()
       showModalDialog(path, window, "dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;edge:sunken; center: Yes; status: no;help:no" );
       submitFlowForm('SAVEFORM');
}

function openSubjectTo(jsPkId)
{
    var WinWidth         = windowWidth * .50  ;
    var WinHeight         = windowHeight * .40; 
    var windowX         = Math.ceil( (window.screen.width  - WinWidth) / 2 );
    var windowY         = Math.ceil( (window.screen.height - WinHeight) / 2 );
    var jsDialog = 'RETRIEVE';
    if(jsPkId == null || jsPkId ==''||jsPkId=='undefined') jsDialog = 'NEW';	
    var jsSubmissionNumber = document.getElementById("SUBMISSION_NUMBER").value;	
    var path  = '/client/jsp/enu/subjectToFrame.jsp?Dialog='+jsDialog+'&DiaryId='+jsPkId+'&SUBMISSIONNO='+jsSubmissionNumber;
  //  var jsReturn = window.open(path, "", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,titlebar=no,width="+WinWidth+",height="+WinHeight);
    showModalDialog(path, window, "dialogWidth:"+WinWidth+"px;dialogHeight:"+WinHeight+"px;edge:sunken; center: Yes; status: no;help:no" );
    submitFlowForm('SAVEFORM');
}

// End Of RichText Functions
/*******************************************************************************************************
*  Start of functions for handling auto Tab
********************************************************************************************************/

var _oCurrentTabOrder = null;
var _oTabArray =  new Array();
var _oTabTotal = 0;
function _handleTabOrder()
{
/*
	if(document.forms[0] == null ) return;
	var oCollection = document.forms[0].elements
	
	for(var i = 0; i < oCollection.length ; i++)
	{
		if(oCollection[i].type != 'hidden')
		{
			if(! oCollection[i].disabled)
			{
				_oTabArray[_oTabTotal] =oCollection[i] ;
				_oTabTotal++;
			}	
		}	
	}
	//alert(_oTabTotal)
	document.body.attachEvent("onkeyup",_CheckAndMoveTab)	
	*/
}
function _CheckAndMoveTab()
{
/*
	var oKey = window.event.keyCode;
	var oSource = document.activeElement;
	try
	{
		if(oKey == 9)
		{
			//alert("oSource.id:"+oSource.id +"  oTabArray[_oTabTotal].id:"+ _oTabArray[_oTabTotal-1].id);
			if(oSource.id == _oTabArray[_oTabTotal-1].id)
			{
				if(_oTabArray[0].focus)
                 _oTabArray[0].focus();
                if(_oTabArray[0].select)
                _oTabArray[0].select();
			}	
		}
	}catch(e){}		
*/	
}
function _fixUSZipCode(asFormVariable,isHyphen)
{
	var oField = document.getElementById(asFormVariable);
	if(oField == null )return;
	if(checkBlankValue(oField.value)){oField.value='';return;}
	var oFieldValue = oField.value;
	var oFieldLength = oFieldValue.length;
	if(oFieldLength <= 5)
	{
		var oPadLength = 5 - oFieldLength
		for(var i = 0; i < oPadLength; i++)
		{
			oFieldValue = '0'+oFieldValue;
		}
		oField.value = oFieldValue ;
	}
	else
	{
		var oPadLength = 9 - oFieldLength
		for(var i = 0; i < oPadLength; i++)
		{
			oFieldValue = '0'+oFieldValue;
		}
		if(isHyphen)
		oField.value = oFieldValue.substring(0,5)+'-'+oFieldValue.substring(5,9) ;
		else
		oField.value = oFieldValue ;
	}
	if(oField.value.length > 9)oField.value = oField.value.substring(0,9) ;
}

/*******************************************************************************************************
*  End of functions for handling auto Tab
********************************************************************************************************/

/*******************************************************************************************************
*  Start of functions for handling cookie 
********************************************************************************************************/
function getCookie(NameOfCookie)
{

// First we check to see if there is a cookie stored.
// Otherwise the length of document.cookie would be zero.

if (document.cookie.length > 0) 
{ 

// Second we check to see if the cookie's name is stored in the
// "document.cookie" object for the page.

// Since more than one cookie can be set on a
// single page it is possible that our cookie
// is not present, even though the "document.cookie" object
// is not just an empty text.
// If our cookie name is not present the value -1 is stored
// in the variable called "begin".

begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1) // Note: != means "is not equal to"
{ 

// Our cookie was set. 
// The value stored in the cookie is returned from the function.

begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 

// Our cookie was not set. 
// The value "null" is returned from the function.

}
function fixDate(date) 
{
	var base = new Date(0)
	var skew = base.getTime()
	if (skew > 0)
	date.setTime(date.getTime() - skew)
}

var now = new Date()
	fixDate(now)
	now.setTime(now.getTime() + 31 * 12 * 24 * 60 * 60 * 1000)
	var caution = false;

function setCookie(name, value, expires, path, domain, secure) 
{
expires = now;
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : now.toGMTString() ) +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000)
{
	//alert("curCookie ="+curCookie);
	document.cookie = curCookie
}
else
if (confirm("Cookie exceeds 4KB and will be cut!"))
document.cookie = curCookie
}


function delCookie (NameOfCookie) 
{

	if (getCookie(NameOfCookie)) 
	{
		document.cookie = NameOfCookie + "=" +"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
} 
 



/*******************************************************************************************************
*  End of functions for handling cookie 
********************************************************************************************************/

/** 
 * $Id: JS_functions.js,v 1.208.32.2 2007/02/12 23:34:08 siva.sivanantha Exp $ 
*/