// Array used for Confirmation Dialog			  
var confirmationProperties = new Array();                                       // 800WA_WEBCONSOLE261

/**
 * This method is used for validating the alert no field 
 *  @since 08-00
 */
function validateSetUpForm()
{ 
    if(document.forms[0].submit != null) {                                      // 800WA_WEBCONSOLE451
    if(document.forms[0].submit.disabled == true){                              // 800WA_WEBCONSOLE451
        return false;                                                           // 800WA_WEBCONSOLE451
    }                                                                           // 800WA_WEBCONSOLE451
    }                                                                           // 800WA_WEBCONSOLE451
	var l_varFlag = false;
	var l_objSetup = trim(document.forms[0].alertno.value);                     // 800WA_WEBCONSOLE213
	var l_iMinValue = WEB_ALERT_MIN_VALUE;                                      // 800WA_WEBCONSOLE424
	var l_iMaxValue = WEB_ALERT_MAX_VALUE;                                      // 800WA_WEBCONSOLE424
	parent.webconSetupValue = true;                                             // 800WA_WEBCONSOLE391
	// if  no value is put inside AlertCount Text field
	if(l_objSetup.length == 0 || l_objSetup == " " ) 
	{
		alertMsg(MSG_ALERTNUM_CHECK);
		document.forms[0].alertno.value = "";                                   // 800WA_WEBCONSOLE371
		document.forms[0].alertno.focus();
		return false;
	}
// if  value is put inside AlertCount Text field not a number
   else if(isNaN(l_objSetup) || l_objSetup < 0 || isDecimal(l_objSetup) 
                                      || (l_objSetup.indexOf('+') == 0))        // 800WA_WEBCONSOLE251 // 800WA_WEBCONSOLE366 //800WA_WEBCONSOLE419
   {                                                                            // 800WA_WEBCONSOLE251
	   alertMsg(MSG_COMMON_POSITIVE_INTEGER_CHECK                               // 800WA_WEBCONSOLE251
		                                  ,WEB_ALERT_TEXT_NAME  );              // 800WA_WEBCONSOLE251
	   document.forms[0].alertno.select();                                      // 800WA_WEBCONSOLE341
	   document.forms[0].alertno.focus();			                            // 800WA_WEBCONSOLE251
	   return false;                                                            // 800WA_WEBCONSOLE251
   }                                                                            // 800WA_WEBCONSOLE251
// if  value is put inside AlertCount Text field is more than 100 or less than 5
    //else  if((document.forms[0].alertno.value < 5)                            // 800WA_WEBCONSOLE424  
    //           || (document.forms[0].alertno.value >100))                     // 800WA_WEBCONSOLE424  
    else if((parseInt(document.forms[0].alertno.value,10) < l_iMinValue)        // 800WA_WEBCONSOLE424 
               || (parseInt(document.forms[0].alertno.value,10) > l_iMaxValue)) // 800WA_WEBCONSOLE424     
   {
	   alertMsg(MSG_COMMON_RANGE_CHECK,WEB_ALERT_TEXT_NAME 
		                   ,WEB_ALERT_MIN_VALUE ,WEB_ALERT_MAX_VALUE );
	   document.forms[0].alertno.select();                                      // 800WA_WEBCONSOLE341
	   document.forms[0].alertno.focus();
	   return false;
   } 	  	
   // if valid value set the setup flag to false.
   else 
   {
	  parent.webconSetupValue=false;
   }
   document.forms[0].alertno.readOnly = true;                                   // 800WA_WEBCONSOLE451
   document.forms[0].submit.disabled = true;                                    // 800WA_WEBCONSOLE451
}

/**
 * Check for decimal value
 * @param r_Num is a numeric value
 * @return true or false
 * @since 08-00
 */
function isDecimal(r_Num){                                                      // 800WA_WEBCONSOLE366
  for (var l_iIdx = 0; l_iIdx < r_Num.length; l_iIdx++) {                       // 800WA_WEBCONSOLE366
  	if(r_Num.charAt(l_iIdx) == "." )                                            // 800WA_WEBCONSOLE366
  	{                                                                           // 800WA_WEBCONSOLE366
  	 return true;                                                               // 800WA_WEBCONSOLE366
  	}                                                                           // 800WA_WEBCONSOLE366
  }                                                                             // 800WA_WEBCONSOLE366
  return false;                                                                 // 800WA_WEBCONSOLE366
}                                                                               // 800WA_WEBCONSOLE366

/**
 * This method is used for formatting the message and displaying the validation
 * message if clientside validation fails
 * @since 08-00
 */
function alertMsg(r_varKey,r_varArg0,r_varArg1,r_varArg2)
{
    l_stAlertMessages = new String(l_starrErrorMsg[r_varKey]);
	var l_varExpression0 = /\{0\}/gi;
	var l_varExpression1 = /\{1\}/gi;
	var l_varExpression2 = /\{2\}/gi;
    // Replace the parameter with the arguments 
    l_stAlertMessages = l_stAlertMessages.replace(l_varExpression0, r_varArg0);
	l_stAlertMessages = l_stAlertMessages.replace(l_varExpression1, r_varArg1);
	l_stAlertMessages = l_stAlertMessages.replace(l_varExpression2, r_varArg2);

	alert(r_varKey + "\n" + l_stAlertMessages);                                 // 800WA_WEBCONSOLE191
}

 /**
 * This method is to checked  whether any changes made in AlertCount TextBox or
 * not.If any changes made it sets the flag to true .
 *  @since 08-00
 */
function setupFlag()
{
	parent.webconSetupValue=true;
}

var m_varGlobal ;                                                               // 800WA_WEBCONSOLE371

/**
 * This method gets the object argument and stores in member variable
 * @param r_obj is the component object name
 * @since 08-00
 */
function setObject(r_obj)                                                       // 800WA_WEBCONSOLE371
{                                                                               // 800WA_WEBCONSOLE371
 m_varGlobal = r_obj;                                                           // 800WA_WEBCONSOLE371
}                                                                               // 800WA_WEBCONSOLE371

 /**
 * This method is to check whether after making any changes  in Alertno 
 * text field  without clicking setup button  we want to do any other operation.
 *  In this case it will display confirmation message.
 *  @since 08-00
 */
function confirmSetupCheck(r_stStyleId)
{
  document.getElementById('page_title').innerHTML = m_headingArray[r_stStyleId];//800WA_WEBCONSOLE454
// This will make the background colour of the Hyperlink to gray after selection
	activeLink('other',m_webconMenuArray);                                      // 800WA_WEBCONSOLE335
   //document.getElementById(r_stStyleId).style.background="gray";              // 800WA_WEBCONSOLE335
// If webconSetup flag is TRUE display Confirmation  Dialog
	if(parent.webconSetupValue)
	{
		var l_varConfirmDialogProp = new confirmationDialog(                    // 800WA_WEBCONSOLE261
				 					confirmationProperties[0],
				 					confirmationProperties[1],
				 					MSG_COMMON_CONFIRM_CHANGED,
				 					l_arrConfirmMsg[MSG_COMMON_CONFIRM_CHANGED],
				 					confirmationProperties[2],
				 					confirmationProperties[3],
				 					confirmationProperties[4],
				 					confirmationProperties[5]);                 // 800WA_WEBCONSOLE261                          
  	 var confirmMessage = confirmDialog(l_varConfirmDialogProp);                // 800WA_WEBCONSOLE261
		if(confirmMessage)                                                      // 800WA_WEBCONSOLE261 
		{                                                                       // 800WA_WEBCONSOLE261
			parent.webconSetupValue = false;                                    // 800WA_WEBCONSOLE261
		}                                                                       // 800WA_WEBCONSOLE261
		else                                                                    // 800WA_WEBCONSOLE371
		{                                                                       // 800WA_WEBCONSOLE371
		    parent.main.m_varGlobal.focus();                                    // 800WA_WEBCONSOLE371
		}                                                                       // 800WA_WEBCONSOLE371
		return confirmMessage;                                                  // 800WA_WEBCONSOLE261
	}	
}
// Array vaiable that will hold the "Id" of Menus in header screen
var m_webconMenuArray = [                                                       // 800WA_WEBCONSOLE335
				 	      "other",                                              // 800WA_WEBCONSOLE335
					       "help"                                               // 800WA_WEBCONSOLE335
				         ];                                                     // 800WA_WEBCONSOLE335