var arrObj;



//functions for marketing begin


function callContactUs()
{
        pathTerms="/epcj/webtier/html/1.62ContactUs.html";
        window.open(pathTerms,"Terms",'alwaysRaised=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=645,height=350');
}

function goToHome()
{
        location.href="/epcj/home.jsp"
}
function callHome()
{
        location.href="/epcj/home.jsp"
}
// fun of client begin

//functions for marketing end


/***************************************************************************
* Function to check the given input is of the length required or not       *
* @parameter    value                                                      *
* @return value boolean                                                    *
***************************************************************************/
function lengthCheck(value, maxlength) {
        var l_value = ""+value;

        /* check the given input is blankspace or digits */

        if(l_value.length <= maxlength) {
                 return true;
        }

        return false;
}

/***************************************************************************
* Function to check the given input is of the length required or not       *
* @parameter    value                                                      *
* @return value boolean                                                    *
***************************************************************************/
function lengthMaxMinCheck(value,minlength,maxlength) {
        var l_value = ""+value;

        /* check the given input is blankspace or digits */

        if((l_value.length >= minlength) &&(l_value.length <= maxlength)) {
                 return true;
        }

        return false;
}

/**************************************************************************/
/* Function to check the given input is proper alphanumCheck format or not*/
/* checking for a-z,A-Z,0-9*/
/* @parameter   value*/
/* @return value        0 : false, not OK*/
/*                              1 : true, OK*/
/*  Textbox: Keyword ,Answer your identifying question,Mailing Postcode/Zipcode*/
/*  Textbox  Company Name*/
/**************************************************************************/
function alphanumCheck(value)
{
        var ch;
        var index = 0;
        var len=value.length;

        if(len <=1)
        {

                return -1;
        }

        if(value != "")
        {
                while(index < value.length)
                {
                        ch = value.charAt(index);

                        if((ch < 'a' || ch > 'z')
                                        && (ch < 'A' || ch > 'Z')
                                        && (ch < '0' || ch > '9')&&(ch != ' '))



                                {
                                        return 0;

                                }
                        index++;
                }
                return 1;
        }
        return 0;
}//end alphanumCheck()



/**************************************************************************
* Function to check name
* checking for a-z,A-Z,0-9,-,_
* @parameter    value
* @return value 0 : false, not OK
* 1 : true, OK
* By the specs 0-9,a-z,-,_ allowed
* Textbox: username,CreateUserName,Company Username
**************************************************************************/

function usernameCheck(value)
{
        var ch;
        var index = 0;
        var len=value.length;


        if(value != "")
        {
                while(index < value.length)
                {
                        ch = value.charAt(index);

                        if((ch < 'a' || ch > 'z')
                                        && (ch < 'A' || ch > 'Z')
                                        && (ch < '0' || ch > '9')
                                        && (ch != '-')
                                        && (ch != '_')
                                        && (ch != ''))

                                {
                                        return 0;

                                }
                        index++;
                }
                return 1;
        }
        return 0;
}//end usernameCheck()

/**************************************************************************
* Function to check name password
* checking for a-z,A-Z,0-9,-,_
* @parameter    value
* @return value 0 : false, not OK
* 1 : true, OK
* By the specs 0-9,a-z,-,_ allowed
* Textbox: password,CreatePassword,ConfirmPAssword,Company Password
**************************************************************************/

function passwdCheck(value)
{
        var ch;
        var index = 0;
        var len=value.length;
        if(len <5 || len>10)
        {
                //alert("password length cannot be less than than 5 or greater than 10");
                return -1;
        }
        if(value != "")
        {
                while(index < value.length)
                {
                        ch = value.charAt(index);

                        if((ch < 'a' || ch > 'z')
                                        && (ch < 'A' || ch > 'Z')
                                        && (ch < '0' || ch > '9')
                                        && (ch != '-')
                                        && (ch != '_'))

                                {
                                        return 0;

                                }
                        index++;
                }
                return 1;
        }
        return 0;
}//end passwdCheck()


/**************************************************************************
* Function to check alphabet
* checking a-z,A-Z
* @parameter    value
* @return value 0 : false, not OK
*                               1 : true, OK
* By the specs A-Z,a-z allowed
* Textbox FirstName,LastName,Mailing City,Mailing County State,Permanent City
**************************************************************************/

function alphabetCheck(value)
{


        var ch;
        var index = 0;

        var len=value.length;

        if(len<=1 || len>50)
        {
                //alert("invalid length");
                return -1;
        }
        if(value != "")
        {
                while(index < value.length)
                {
                        ch = value.charAt(index);

                        if((ch < 'a' || ch > 'z')
                                        && (ch < 'A' || ch > 'Z')&&(ch != ' '))

                                {
                                        return 0;

                                }
                        index++;
                }
                return 1;
        }
        return 0;
}//end alphabetCheck()



/**************************************************************************
* Function to check mailingaddress
* @parameter    value
* @return value 0 : false, not OK
*                               1 : true, OK
* By the specs 0-9,a-z,A-Z,_,#,,  allowed
*  TextBox : Permanent Address1,Permanent Address1
**************************************************************************/

function mailingaddressCheck(value)
{

        var ch;
        var index = 0;
        var len=value.length;
        if(len<=3 || len>50)
        {
                return -1;
        }

        for (var i=0; i < value.length; i++)
          {

                   var ch = value.charAt(i);
                   if(ch=='(')
                   {

                   }
          }

        if(value != "")
        {
                while(index < value.length)
                {
                        ch = value.charAt(index);

                        if((ch < 'a' || ch > 'z')
                                        && (ch < 'A' || ch > 'Z')
                                        && (ch < '0' || ch > '9')
                                        && (ch != '.')
                                        && (ch != '-')
                                        && (ch != '#')
                                        && (ch != ',')
                                        && (ch != ' ')
                                )

                                {
                                        return 0;

                                }

                        index++;
                }
                return 1;
        }
        return 0;
}//end mailingaddressCheck()






/*******************************************************************************************
*Function to validate the entered email address.
*@param value
*@return 0: NOT OK
*               1 : OK
*By the specs 0-9,a-z,A-Z,_,-,.,@  allowed
* TextBox : Contact Email,Email Address,Reply-to-Email-Address
********************************************************************************************/


function isValidEmailId(email)
{
    email = trim(email)
    if (email.match(/^[a-zA-Z0-9][a-zA-Z0-9\'\w\.-]*@[a-zA-Z0-9][a-zA-Z0-9\w\.-]*\.[a-zA-Z0-9\w\.-]*[a-zA-Z0-9]$/)) {
        return 1;
    } else {
        return 0;
    }
}

function isValidEmailIdOLD(email)
{
        email = trim(email)
        var index=0;
        var strprefix;
        var strpostfix;
        var lastIndex=0;
        var length = email.length;
        for(var j=0;j<length;j++)
        {
                if(email.charAt(j)==' ')
                return 0;

        }
        if(length==0)
        {
                return 0;
        }
        index = email.indexOf('@');
        if( (email.indexOf('.')==0) || (index==0) )
        {
                return 0;
        }

        lastIndex = email.lastIndexOf('@');
        if((lastIndex-index)!=0)
        {
                return 0;
        }
        
        strprefix = email.substring(0,index);
        strpostfix = email.substring(index);
        index = strpostfix.indexOf('.');
        lastIndex = strpostfix.lastIndexOf('.');
        if( index==-1)
        {
                return 0;
        }
        
        if(lastIndex==(strpostfix.length-1))
        {
                return 0;
        }
        
        lastIndex=email.indexOf('@');
        if ((email.charAt(lastIndex-1)=='.')||(email.charAt(lastIndex+1)=='.'))
                return 0;
        index = strpostfix.indexOf('@');
        if( index == -1)
        {
                return 0;
        }
        
        var iChars = "*|,\":<>[]{}`\';()&$#%";
        for (var i = 0; i < length; i++) {
                if (iChars.indexOf(email.charAt(i)) != -1)
                        return 0;
        }
        

        index =strpostfix.indexOf('.');
        lastindex=strpostfix.lastIndexOf('.');

        if( index == -1) {
                return 0;
        }
        else {
                // ** added by harpreet - 13/jan/02 - BEGIN
                // Domain is symbolic name.  Check if it's valid.
                var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
                
                var domArr=strpostfix.split(".");
                var len=domArr.length;
                
                /* domain name seems valid, but now make sure that it ends in a
                known top-level domain (like com, edu, gov) or a two-letter word,
                representing country (uk, nl). */
                
                if (domArr[domArr.length-1].length!=2 && 
                                ((domArr[domArr.length-1]).toLowerCase()).search(knownDomsPat)==-1) {
                        //alert("The address must end in a well-known domain or two letter country.");
                        return 0;
                } else {
                        return 1;
                }
                // ** added by harpreet - 13/jan/02 - END       
        }

        /*      for (var i = index; i < lastindex; i++) {
                if (strpostfix.charAt(i)== '.')
                {
                        return 0;
                }
        }*/

        //return 1;



}//isValidEmail



/**************************************************************************
  * Function to trim out the whitespace
  * @parameter  value
  * @return value       null
**************************************************************************/
function trim(value)
{
    value = ""+value;
    if(isBlank(value) || value.length == 0)
        return value;
    for (var leftIndex = 0; leftIndex < value.length; leftIndex++) {
        if ((value.charCodeAt(leftIndex) != 12288) && (value.charAt(leftIndex) != " ") && (value.charCodeAt(leftIndex) != 160)) {
            for (var rightIndex = value.length - 1; rightIndex >= leftIndex; rightIndex--) {
                if ((value.charAt(rightIndex) != " ") && (value.charCodeAt(leftIndex) != 160)) {
                    return value.substring(leftIndex, rightIndex+1);
                }
            }
        } else {
            if(leftIndex == value.length - 1){
                return "";
            }
        }
    }
}

/**************************************************************************
* Function  to check the given input is blankspace or a number with decimal
* @parameter    value
* @return value 0 : false, not OK
*                               1 : true, OK
**************************************************************************/
function numCheckWithDecimal(value)
{
        var l_ch;
        var l_value = ""+value;
        var l_index = 0;
        var dec_index = 0;

        /* check the given input is blankspace or digits */

        if(l_value != "")
        {
                while(l_index < l_value.length)
                {
                        l_ch = l_value.charAt(l_index);

                        if((l_ch < '0' || l_ch > '9')&& (l_ch != '.'))
                        {
                                return 0;
                        }
            l_index++;
                        if (l_ch == '.')
                        {
                                dec_index++;
                                if (dec_index > 1)
                                        return 0;
                        }
                }
        return 1;
        }
    return 0;
}//end numCheckWithDecimal








/**************************************************************************
* This function check whether a field on the screen is blank or not
* @parameter      value
* @return value       boolean
************************************************************************/
function isBlank(value)
{


    if(value == null || value == "" || value.length == 0) {
            return true;
    }
    return false;
}


/**************************************************************************
* Function  to check the vaid phone,fax number
* @parameter    value
* @return value 0 : false, not OK
*                               1 : true, OK
**************************************************************************/

function phonefaxCheck(value)
{

        var len=value.length;
        
        

        var l_ch;
        var l_value = ""+value;
        var l_index = 0;

        if(l_value != "")
        {
                while(l_index < l_value.length)
                {
                        l_ch = l_value.charAt(l_index);
                        
                        if((l_ch  < 'a' || l_ch  > 'z')
                            && (l_ch  < 'A' || l_ch  > 'Z')
                            &&(l_ch < '0' || l_ch > '9')
                            && (l_ch != ' ')
                            &&(l_ch != '-')
                            && (l_ch != '(')
                            &&(l_ch != ')')
                            &&(l_ch != ',')
                            &&(l_ch != '.')
                            )
                        {
                                return 0;
                        }
                  l_index++;
                }
                
                if(len <10 || len>20)
                {
                        return -1;
                }
                
        return 1;
        }
        
    return 0;
}//end phoneCheck

/**************************************************************************/
/* Function to check other key skills*/
/* checking for a-z,A-Z,0-9,,,;,-*/
/* @parameter   value*/
/* @return value        0 : false, not OK*/
/*                              1 : true, OK*/
/*  Textbox: otherskillcheck*/
/**************************************************************************/
function skillCheck(value)
{
        var ch;
        var index = 0;


        if(value != "")
        {
                while(index < value.length)
                {
                        ch = value.charAt(index);

                        if((ch < 'a' || ch > 'z')
                                        && (ch < 'A' || ch > 'Z')
                                        && (ch < '0' || ch > '9')&&(ch != ';')
                                        &&(ch != ',')&&(ch != '-'))



                                {
                                        return 0;

                                }
                        index++;
                }
                return 1;
        }
        return 0;
}//end skillCheck()

/**************************************************************************
* Function to check profile summary
* checking a-z,A-Z,0-9
* @parameter    value
* @return value 0 : false, not OK
*                               1 : true, OK
* By the specs A-Z,a-z,0-9 allowed
**************************************************************************/

function ProfileSummaryCheck(value)
{


        var ch;
        var index = 0;


        if(value != "")
        {
                while(index < value.length)
                {
                        ch = value.charAt(index);

                        if((ch < 'a' || ch > 'z')
                                        && (ch < 'A' || ch > 'Z')&&(ch != ' ')
                                        &&(ch < '0' || ch > '9'))

                                {
                                        return 0;

                                }
                        index++;
                }
                return 1;
        }
        return 0;
}//end ProfileSummaryCheck()

function getAction()
{
        return "/epcj/EPCController";
}

function populateParentSkill(){
        var ParentSkill = new Array();
}
/** selecting a combo box item **/
function doSelect(selectName,selectedItem)
{
var selectIt = trim(selectedItem);
        for(i=0;i<selectName.length;i++)
        {
                //alert("selectName.options[i].value:"+selectName.options[i].value);
                //alert("selectedItem:"+selectedItem);
                if(trim(selectName.options[i].value) == selectIt)
                selectName.selectedIndex=i;
                //alert("SELECTED .."+selectName.selectedIndex);
        }
        //alert(selectName.selectedIndex);
        //alert(selectName.value);
}

//Manisha........... added on 25th Sept.....
function getChildValue(value)
{
        var childId = '';
        if (value.indexOf('~') > 0)
                childId = value.substring(0,value.indexOf('~'));
        return childId;
}

function doSelectChild(selectName,selectedItem)
{
        var selectIt = trim(selectedItem);
        if (selectIt != "" && selectIt > 0 ){
                for(i=0;i<selectName.length;i++)
                {
                        if(getChildValue(selectName.options[i].value) == selectIt){
                        selectName.selectedIndex=i;
                        }
                }
        }
}
var flag = false;
function checkParentDiscipline()
{
  var disId = 0;
  var val = document.forms[0].cmbDiscipline[document.forms[0].cmbDiscipline.selectedIndex].value;
  if (val == ""){
      alert(getMessage('EPCJOBS','104', new Array()));
      document.forms[0].cmbDiscipline.focus();
      document.forms[0].cmbDiscipline.selectedIndex = 0;
      return false;
   }  
   else
   {
   disId = getChildValue(val)
   if (disId == 0 ){
    alert(getMessage('EPCJOBS','105', new Array()));
    document.forms[0].cmbDiscipline.focus();
    document.forms[0].cmbDiscipline.selectedIndex = 0;
    return false;
  }
 }
 return true;
 }

//Added by MANISHA on 17th September
function checkIndustry(theSelect)
{
  if (theSelect == null) theSelect = document.forms[0].cmbIndustry;
  var sel =0;
  var enable=false;
  var alertNoSelectParent = false;
  for (i=0; i < theSelect.options.length; i++) {
    var parId = 0;
    //To check if max of 2 are selected..
    if(theSelect.options[i].selected == true) {
      var val = theSelect.options[i].value;
      if (val.lastIndexOf('~') > 0)
      parId = val.substring(val.lastIndexOf("~")+1,val.length);

      if (parId == 0 ){
        alertNoSelectParent = true;
        theSelect.focus();
        theSelect.options[i].selected = false;
        //return false;
      }
      sel++;
    } // end if
  } // end for
  if (alertNoSelectParent) {
    alert(getMessage('EPCJOBS','141', new Array()));
    return false;
  }
}


function checkParentDisciplineJobRole(field, fieldName)
{
 var disId = 0;
 if (field.selectedIndex > 0)
 {
 
  var val = field[field.selectedIndex].value;
  if (val == ""){
           if (fieldName == 'DISCIPLINE')
                  alert(getMessage('JOBS','221', new Array()));
          else
                  alert(getMessage('JOBS','224', new Array()));
      field.focus();
      field.selectedIndex = 0;
      return false;
   }  
   else
   {
   disId = getChildValue(val)
    if (disId == 0 ){
    if (fieldName == 'DISCIPLINE')
                alert(getMessage('EPCJOBS','140', new Array()));
        else
        alert(getMessage('EPCJOBS','105', new Array()));
    field.focus();
    field.selectedIndex = 0;
    return false;
  }
 }
 }
 return true;
 }
//Devi-- added on 30th September -- for industry changes

//to make the field null
function makeNull(field)
{
  lengthOfField = field.length;
    for (p=0;p<=lengthOfField;p++)
    {
      field.options[p] = null;
    }
   field.options.length = 0;
}

function JSSelObject(ObjId,ObjDesc,ObjType)
{
      this.ObjId=ObjId;
      this.ObjDesc=ObjDesc;
      this.ObjType=ObjType;

}

// to get the parent description for a child value
function getParentDesc(value)
{
        var parentDesc = 0;
        if (value.lastIndexOf('~') > 0)
                parentDesc = value.substring(value.lastIndexOf('~')+1,value.length);
        return parentDesc;
}

// to get the child description
function getChildDesc(value)
{
        var childDesc = "";
        if(value.indexOf('~') > 0) {
          var clval = value.substring(value.indexOf('~')+1,value.length);
          if(clval.indexOf('~') > 0) {
            childDesc = clval.substring(0,clval.indexOf('~'));
          }
        }
        
        return childDesc;

}

// to deselect combo values
function deSelectCombo(comboObject1)
{
        for (i=0;i<comboObject1.options.length;i++)
                if (comboObject1.options[i].selected == true)
                        comboObject1.options[i].selected = false;
}

// to get the selected values from the upper box
function getSelectedValues(comboObject1,isParentReqd)
{
        var arrSelItemsValue = new Array();
        var arrSelItemsDisp = new Array();
        var arrSelItems = new Array();
        var selcount=0;
        
        for (i=0;i<comboObject1.options.length;i++){
                if (comboObject1.options[i].selected==true){
                        var valOpt = comboObject1.options[i].value;
                        if (comboObject1.options[i].value.indexOf('~') > 0){
                        var  resVal = comboObject1.options[i].value.substring(0,comboObject1.options[i].value.indexOf('~'));
                        arrSelItemsValue[selcount] = resVal;
                }
                        else 
                                arrSelItemsValue[selcount] = comboObject1.options[i].value;
                if(isParentReqd){
                        var parDesc = getParentDesc(valOpt);
                        var childdesc = getChildDesc(valOpt);
                        arrSelItemsDisp[selcount] = parDesc+ " - " +childdesc;
                }
                else
                        arrSelItemsDisp[selcount] =comboObject1.options[i].text;
                selcount++;
                }
        }
        
        arrSelItems[0] = arrSelItemsValue;
        arrSelItems[1] = arrSelItemsDisp;
        return arrSelItems;
}

//to validate the values before 
function validateVal(comboObject1,noallowed,type)
{
        var icount = 0;
        for (i=0;i<comboObject1.options.length;i++){
                if (comboObject1.options[i].selected == true)
                        icount++;
        }
        if(noallowed > 0){
        if(icount > noallowed){
                        msg = validateFieldsValues(type,'CHECK-MAX',noallowed);
                alert(msg);
                comboObject1.focus();
                return false;
        }
}
}

//to confirm the selected values 
function confirmVal(comboObject1,type)
{
        var selected_value = "";
        if (type == 'WORKAUTHORIZATION')
        {

                for (i=0;i<comboObject1.options.length;i++){
                        if (comboObject1.options[i].selected == true)
                        {
                                selected_value = comboObject1.options[i].value;
                                break ;
                        }
                }


                if (selected_value.length > 0 )
                {
                        var msg = eval("WorkAuthorization_getMessage("+selected_value+")");     
                        if (!(confirm(msg)))
                        {
                                comboObject1.focus();
                                return false;
                        }
                }
        }
        
        return true ;
}

var arrResult = new Array();

//
function AddFields(comboObject1,comboObject2,noallowed,isParentReqd,type)
{
        arrExistIndId=new Array();
        arrExistIndDesc=new Array();
        var arrNewIndId = new Array();
        var arrNewIndDesc = new Array();
        var arrNewInd=new Array();
        var count = 0;
        var existlength = comboObject2.options.length;
        var flag = false;
        var tempObject = null;
        var msg = null;
        
        if(comboObject1.options.length == 0)
        {
                msg = validateFieldsValues(type,'ADD-NOVALUE',noallowed);
                alert(msg);
                comboObject1.focus();
                return;
        }
        if (comboObject1.selectedIndex < 0){
                        msg = validateFieldsValues(type,'ADD-DELETE',noallowed);
                        alert(msg);
                        comboObject1.focus();
                        return;
        }//if

        var retFlag = checkForNone(comboObject1,comboObject2,type);
        if(retFlag){
                retFlag = false;
                return;
        }

                if(confirmVal(comboObject1, type) == false) return ;

        if(validateVal(comboObject1,noallowed,type) == false) return;
        
        arrNewInd=getSelectedValues(comboObject1,isParentReqd);
        arrNewIndId = arrNewInd[0];
        arrNewIndDesc = arrNewInd[1];
        
        tempObject =  getObject(type);
        
        
        if(tempObject == null){
        addObject(arrNewIndId,arrNewIndDesc,type,comboObject2); 
        }
        else
        {
                        arrExistIndId = tempObject.ObjId;
                        arrExistIndDesc=tempObject.ObjDesc;     
                        for(k=0;k<arrExistIndId.length;k++){
                                if(arrExistIndDesc[k] == "None"){
                                arrExistIndId.length = 0;
                                arrExistIndDesc.length = 0;
                                }
                        }
                        count = arrExistIndId.length;
                        var selcount = arrNewIndId.length;
                        var scount = 0;
                                                
                        for (i=0;i<arrNewIndId.length;i++){
                                for(j=0;j<existlength;j++){
                                                if(arrNewIndId[i] == arrExistIndId[j]){
                                                         flag = true;
                                                         break;
                                                }//if
                                        }//for
                                        
                                        if(!flag){
                                        arrExistIndId[count] = arrNewIndId[i];
                                        arrExistIndDesc[count] = arrNewIndDesc[i];
                                        count = count + 1;
                                        } //if
                                        flag= false;    
                        }//for
                        if(noallowed > 0){
                        if(arrExistIndId.length > noallowed)
                        {
                                msg = validateFieldsValues(type,'ADD-MAX',noallowed);
                                alert(msg);
                                arrExistIndId.length = existlength;
                                arrExistIndDesc.length=existlength;
                                arrExistIndId = tempObject.ObjId;
                                arrExistIndDesc=tempObject.ObjDesc;
                                                                comboObject1.focus();
                                                                return;
                        }       
                        }
                        addObject(arrExistIndId,arrExistIndDesc,type,comboObject2);
                        
                }//else
                        deSelectCombo(comboObject1);
        
 }// function ends
 

function DeleteFields(comboObject,type,noallowed)
{
        var arrSelItemsValue = new Array();
        var arrSelItemsDisp = new Array();
        var scount=0;
        var count = 0;
        var selcount = 0;
        var flag = false;
        var msg = null;

        if(comboObject.options.length <= 0 || comboObject.options[0].value == constValue)
        {
                msg = validateFieldsValues(type,'DELETE',noallowed);
                alert(msg);
                comboObject.focus();
                return;
        }//if

        if (comboObject.selectedIndex < 0 ){
                        msg = validateFieldsValues(type,'ADD-DELETE',noallowed);
                        alert(msg);
                        comboObject.focus();
                        return;
        }//if

        for (i=0;i<comboObject.options.length;i++){
                if (comboObject.options[i].selected==false)
                {
                        arrSelItemsValue[count] = comboObject.options[i].value;
                        arrSelItemsDisp[count] = comboObject.options[i].text;
                        count++;
                }
        }//for
        
        if(type == "GENERALSKILLS" || type == "DISCSPECSKILLS")
                deleteFromParent(arrSelItemsValue,arrSelItemsDisp,type);
    addObject(arrSelItemsValue,arrSelItemsDisp,type,comboObject);
        
                
}

var objCount = 0;
//creating JSObject
function addObject(arrExistIndId,arrExistIndDesc,type,comboObject2)
{
        var     isObjectExists = false;
        if(arrObj == null)
        {
                arrObj = new Array();
        }//if
                objCount = arrObj.length;       
        if(objCount > 0){
                for(var i=0;i<objCount;i++)
                        if(arrObj[i].ObjType == type){
                            arrObj[i].ObjId = arrExistIndId;
                                arrObj[i].ObjDesc = arrExistIndDesc;
                                isObjectExists = true;
                                break;
                        }//if
                
        }//if
        if(!isObjectExists)
                arrObj[objCount++] = new JSSelObject(arrExistIndId,arrExistIndDesc,type);
        
        prepareOption(arrExistIndId,arrExistIndDesc,comboObject2);
}
        
// validate values before creating the objects
function validateFieldsValues(type,val,noallowed)
{
        var msg = "";
        
        if(val == 'ADD-DELETE'){
                if(type == 'INDUSTRY')
                msg = getMessage('EPCJOBS','103', new Array());
                else if(type == 'PROFQUAL')
                        msg = getMessage('EPCJOBS','110', new Array());
                else if(type == 'ACADQUAL')
                        msg = getMessage('EPCJOBS','111', new Array());
                else if(type == 'CITIZENSHIP')
                        msg = getMessage('EPCJOBS','112', new Array());
                else if(type == 'CITIZENSHIP_REQ')
                        msg = getMessage('EPCJOBS','112', new Array());
                else if(type == 'WORKAUTHORIZATION')
                        msg = getMessage('EPCJOBS','113', new Array());
                else if(type == 'DISCSPECSKILLS')
                        msg = getMessage('EPCJOBS','114', new Array());
                else if(type == 'GENERALSKILLS')
                        msg = getMessage('EPCJOBS','115', new Array());
        }
        else if(val == 'DELETE'){
                if(type == 'INDUSTRY')
                msg = getMessage('EPCJOBS','116', new Array());
                else if(type == 'PROFQUAL')
                        msg = getMessage('EPCJOBS','117', new Array());
                else if(type == 'ACADQUAL')
                        msg = getMessage('EPCJOBS','118', new Array());
                else if(type == 'CITIZENSHIP')
                        msg = getMessage('EPCJOBS','119', new Array());
                else if(type == 'CITIZENSHIP_REQ')
                        msg = getMessage('EPCJOBS','119', new Array());
                else if(type == 'WORKAUTHORIZATION')
                        msg = getMessage('EPCJOBS','120', new Array());
                else if(type == 'DISCSPECSKILLS')
                        msg = getMessage('EPCJOBS','121', new Array());
                else if(type == 'GENERALSKILLS')
                        msg = getMessage('EPCJOBS','122', new Array());
        }
        else if(val == 'CHECK-MAX'){
                if(type == 'INDUSTRY'){
                        if(noallowed == 2)
                msg = getMessage('EPCJOBS','123', new Array());
                        else
                                msg = getMessage('EPCJOBS','132', new Array());
                }
                else if(type == 'PROFQUAL')
                        msg = getMessage('EPCJOBS','124', new Array());
                else if(type == 'ACADQUAL')
                        msg = getMessage('EPCJOBS','125', new Array());
                else if(type == 'CITIZENSHIP')
                        msg = getMessage('EPCJOBS','126', new Array());
                else if(type == 'CITIZENSHIP_REQ')
                        msg = getMessage('EPCJOBS','142', new Array());
                else if(type == 'WORKAUTHORIZATION')
                        msg = getMessage('EPCJOBS','127', new Array());
                else if(type == 'DISCSPECSKILLS')
                        msg = getMessage('EPCJOBS','121', new Array());
                else if(type == 'GENERALSKILLS')
                        msg = getMessage('EPCJOBS','122', new Array());
        }
        else if(val == 'ADD-NOVALUE'){
                if(type == 'PROFQUAL')
                        msg = getMessage('EPCJOBS','133', new Array());
                else if(type == 'ACADQUAL')
                        msg = getMessage('EPCJOBS','134', new Array());
        }
        else if(val == 'ADD-MAX'){
                if(type == 'INDUSTRY'){
                        if(noallowed == 2)
                msg = getMessage('EPCJOBS','102', new Array());
                        else
                                msg = getMessage('EPCJOBS','135', new Array());
                }
                else if(type == 'PROFQUAL')
                        msg = getMessage('EPCJOBS','136', new Array());
                else if(type == 'ACADQUAL')
                        msg = getMessage('EPCJOBS','137', new Array());
                else if(type == 'CITIZENSHIP')
                        msg = getMessage('EPCJOBS','109', new Array());
                else if(type == 'CITIZENSHIP_REQ')
                        msg = getMessage('EPCJOBS','142', new Array());                 
                else if(type == 'WORKAUTHORIZATION')
                        msg = getMessage('EPCJOBS','108', new Array());
        }
        return msg;

}
                                        
// preparing the options for display
function prepareOption(arrExistIndId,arrExistIndDesc,comboObject2)
{
        makeNull(comboObject2);
        if(arrExistIndId != null) {
                for (var j = 0; j < arrExistIndId.length; j++)
                {
                        x = new Option(arrExistIndDesc[j],arrExistIndId[j]);
                        comboObject2.options[comboObject2.options.length]  = x;
                }
        }
 }

 var arrFloodObject = null;
 function onBack(type,comboObject2)
 {
        if(arrObj == null)
                arrFloodObject = getObject(type); 
        if(arrFloodObject != null)
                prepareOption(arrFloodObject.ObjId,arrFloodObject.ObjDesc,comboObject2);
        
 }


 // get the object of a particular type from the object array
 function getObject(type)
 {
        var arrFloodInd = null;
                
        if(arrObj != null){
                for(var i=0;i<arrObj.length;i++){
                        if(arrObj[i].ObjType == type){
                                arrFloodInd = arrObj[i];
                        }
                } 
        }//if
        return arrFloodInd;
 }

var lowerListBoxType    = new Array();
var lowerListBoxhdnVarName = new Array();

// to get the mapping between the lower box type and 
//hidden variable name associated with it.
function prepareTypeHiddeNameArray(tempType,tempVarName)
{
   var len1 = lowerListBoxType.length;
     
  if(len1==0)
          {
          lowerListBoxType[0] = tempType;
         lowerListBoxhdnVarName[0]     =  tempVarName;
          }

  else  {
          lowerListBoxType[len1] = tempType;
          lowerListBoxhdnVarName[len1++] = tempVarName;
  }
     
}// prepareTypeHiddeNameArray


// for deselecting the checkboxes when a particular item is deleted
// applicable only for Discipline-Specific Skills and General Skills
function deleteFromParent(arrSelItemsValue,arrSelItemsDisp,type)
{
        var skilldesc;

    if(type == "GENERALSKILLS")
                    ParentSkill = new Array();
        else if(type == "DISCSPECSKILLS")
                        ParentDesciSkill = new Array();
        
                for(var i=0;i<arrSelItemsValue.length;i++)
           {
                if(type == "GENERALSKILLS"){
                        ParentSkill[i] = arrSelItemsValue[i]+"~"+arrSelItemsDisp[i];
        }
                else if(type == "DISCSPECSKILLS"){
                        ParentDesciSkill[i] = arrSelItemsValue[i]+"~"+arrSelItemsDisp[i];
        }
        }//for
}//deleteFromParent


//fucntion to check if None is selected. If yes then all 
//other values selected previously will be removed
function checkForNone(comboObject1,comboObject2,type)
{
        var arrNoneId = new Array();
        var arrNoneDesc = new Array();
        var chkFlag = false;
        var result = false;

        for(var i=0;i<comboObject1.options.length;i++){
                if (comboObject1.options[i].selected == true)
                {
                        if(comboObject1.options[i].text == "None"){
                                if(comboObject2.options.length > 0 && comboObject2.options[0].value != constValue && comboObject2.options[0].text !="None")
                                        result = confirm("All your earlier selections will be erased if you are trying to move 'None', do you really want to proceed?");
                                else
                                {
                                        arrNoneId[i] = comboObject1[i].value;
                                        arrNoneDesc[i] = comboObject1[i].text;
                                        chkFlag = true;
                                        break;
                                }
                                
                                if(result){
                                arrNoneId[i] = comboObject1[i].value;
                                arrNoneDesc[i] = comboObject1[i].text;
                                chkFlag = true;
                                break;
                        }
                                else{
                                        chkFlag = true;
                                        return chkFlag;
                                }
                        }
                        
                }
        }
        if(chkFlag){
                addObject(arrNoneId,arrNoneDesc,type,comboObject2);
                deSelectCombo(comboObject1);
        }
        return chkFlag;
}


