// JavaScript Document
//////////////////////////////////////////////////////////
    //Role javascript functions
    
    function RemoveFromRoleLeft()
    {
        var RoleLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxRoleLeft');
        var RoleRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxRoleRight');
        var RoleLeftLength = RoleLeftListObject.options.length;
        var RoleRightLength = RoleRightListObject.options.length;
        for(var i=RoleLeftListObject.options.length-1;i>=0;i--)
        {
            if( RoleLeftListObject.options[i].selected){
                RoleRightLength = RoleRightListObject.options.length;
                RoleRightListObject.options[RoleRightLength] = new Option(RoleLeftListObject.options[i].text, RoleLeftListObject.options[i].value);
                RoleLeftListObject.remove(i);
            }
        }
        
        //Ordering RoleRight list
        var tempText;
        var tempValue;
        RoleRightLength = RoleRightListObject.options.length;
        for (var i=0; i<RoleRightLength-1; i++)
        {
            for(var j=i+1; j<RoleRightLength; j++){
                //if(RoleRightListObject.options[i].value > RoleRightListObject.options[j].value){
                if(RoleRightListObject.options[i].text > RoleRightListObject.options[j].text){ //sort by text
                    tempText = RoleRightListObject.options[i].text;
                    tempValue = RoleRightListObject.options[i].value;
                    RoleRightListObject.options[i].text = RoleRightListObject.options[j].text;
                    RoleRightListObject.options[i].value = RoleRightListObject.options[j].value;
                    RoleRightListObject.options[j].text = tempText;
                    RoleRightListObject.options[j].value = tempValue;   
                }
            }
        }

        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtRoleList');
        RoleRightLength = RoleRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<RoleRightLength; i++)
            TextObject.value +=RoleRightListObject.options[i].value+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
        
        

    }
    function RemoveFromRoleRight(){
        var RoleLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxRoleLeft');
        var RoleRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxRoleRight');
        var RoleLeftLength = RoleLeftListObject.options.length;
        var RoleRightLength = RoleRightListObject.options.length;
        for(var i=RoleRightListObject.options.length-1;i>=0;i--)
        {
            if(RoleRightListObject.options[i].selected){
                RoleLeftLength = RoleLeftListObject.options.length;
                RoleLeftListObject.options[RoleLeftLength] = new Option(RoleRightListObject.options[i].text, RoleRightListObject.options[i].value);
                RoleRightListObject.remove(i);
            }
        }

        //Ordering Left list
        var tempText;
        var tempValue;
        RoleLeftLength = RoleLeftListObject.options.length;
        for (var i=0; i<RoleLeftLength-1; i++)
        {
            for(var j=i+1; j<RoleLeftLength; j++){
                //if(RoleLeftListObject.options[i].value > RoleLeftListObject.options[j].value){
                if(RoleLeftListObject.options[i].text > RoleLeftListObject.options[j].text){  //sort by text
                    tempText = RoleLeftListObject.options[i].text;
                    tempValue = RoleLeftListObject.options[i].value;
                    RoleLeftListObject.options[i].text = RoleLeftListObject.options[j].text;
                    RoleLeftListObject.options[i].value = RoleLeftListObject.options[j].value;
                    RoleLeftListObject.options[j].text = tempText;
                    RoleLeftListObject.options[j].value = tempValue;   
                }
            }
        }
        
        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtRoleList');
        RoleRightLength = RoleRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<RoleRightLength; i++)
            TextObject.value +=RoleRightListObject.options[i].value+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
    }
    
    
    //////////////////////////////////////////////////////////
    //Associate javascript functions
        
    function RemoveFromAssociateLeft()
    {
        var AssociateLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxAssociateLeft');
        var AssociateRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxAssociateRight');
        var AssociateLeftLength = AssociateLeftListObject.options.length;
        var AssociateRightLength = AssociateRightListObject.options.length;
        var temp="";
        for(var i=AssociateLeftListObject.options.length-1;i>=0;i--)
        {
            if( AssociateLeftListObject.options[i].selected){
                //if( AssociateLeftListObject.options[i].text.substring(0,1) != '>' ){  //if its not a title move it, titles have got '>' in front of them
                temp = AssociateLeftListObject.options[i].value.substring(AssociateLeftListObject.options[i].value.length-1,AssociateLeftListObject.options[i].value.length);
                if( temp == '0' || temp == '5'){ //if its not a title you can move it, because titles havent got 0 or 5 at right hand side digit in their Order column in database
                    AssociateRightLength = AssociateRightListObject.options.length;
                    AssociateRightListObject.options[AssociateRightLength] = new Option(AssociateLeftListObject.options[i].text, AssociateLeftListObject.options[i].value);
                    AssociateLeftListObject.remove(i);
                }
            }
        }
        
        //Ordering AssociateRight list
        var tempText;
        var tempValue;
        AssociateRightLength = AssociateRightListObject.options.length;
        for (var i=0; i<AssociateRightLength-1; i++)
        {
            for(var j=i+1; j<AssociateRightLength; j++){
                if(parseInt(AssociateRightListObject.options[i].value) > parseInt(AssociateRightListObject.options[j].value)){
                    tempText = AssociateRightListObject.options[i].text;
                    tempValue = AssociateRightListObject.options[i].value;
                    AssociateRightListObject.options[i].text = AssociateRightListObject.options[j].text;
                    AssociateRightListObject.options[i].value = AssociateRightListObject.options[j].value;
                    AssociateRightListObject.options[j].text = tempText;
                    AssociateRightListObject.options[j].value = tempValue;   
                }
            }
        }

        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtAssociateList');
        AssociateRightLength = AssociateRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<AssociateRightLength; i++)
            TextObject.value +=AssociateRightListObject.options[i].text+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
        
    }
    function RemoveFromAssociateRight(){
        var AssociateLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxAssociateLeft');
        var AssociateRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxAssociateRight');
        var AssociateLeftLength = AssociateLeftListObject.options.length;
        var AssociateRightLength = AssociateRightListObject.options.length;
        for(var i=AssociateRightListObject.options.length-1;i>=0;i--)
        {
            if(AssociateRightListObject.options[i].selected){
               AssociateLeftLength = AssociateLeftListObject.options.length;
               AssociateLeftListObject.options[AssociateLeftLength] = new Option(AssociateRightListObject.options[i].text, AssociateRightListObject.options[i].value);
               AssociateRightListObject.remove(i);
            }
        }


        //Ordering Left list
        var tempText;
        var tempValue;
        var tempColor;
        var tempBackground;
        AssociateLeftLength = AssociateLeftListObject.options.length;
        for(var i=0; i<AssociateLeftLength-1; i++){
            for(var j=i+1; j<AssociateLeftLength; j++){
                //if(AssociateLeftListObject.options[i].text.substring(0,1) != '>' &&   AssociateLeftListObject.options[j].text.substring(0,1) != '>'){ //dont order title values
                    if(parseInt(AssociateLeftListObject.options[i].value) > parseInt(AssociateLeftListObject.options[j].value)){
                        tempText = AssociateLeftListObject.options[i].text;
                        tempValue = AssociateLeftListObject.options[i].value;
                        tempColor = AssociateLeftListObject.options[i].style.color;
                        tempBackground = AssociateLeftListObject.options[i].style.backgroundColor;
                        AssociateLeftListObject.options[i].text = AssociateLeftListObject.options[j].text;
                        AssociateLeftListObject.options[i].value = AssociateLeftListObject.options[j].value;
                        AssociateLeftListObject.options[i].style.color = AssociateLeftListObject.options[j].style.color;
                        AssociateLeftListObject.options[i].style.backgroundColor = AssociateLeftListObject.options[j].style.backgroundColor;
                        AssociateLeftListObject.options[j].text = tempText;
                        AssociateLeftListObject.options[j].value = tempValue;   
                        AssociateLeftListObject.options[j].style.color = tempColor;
                        AssociateLeftListObject.options[j].style.backgroundColor = tempBackground;
                        
                     
                    }
                //}
            }
        }
        
        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtAssociateList');
        AssociateRightLength = AssociateRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<AssociateRightLength; i++)
            TextObject.value +=AssociateRightListObject.options[i].text+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
        
        
    }
        
        
    //////////////////////////////////////////////////////////
    //Industry Organisation javascript functions
    
    function RemoveFromIndustryOrganisationLeft()
    {
        var IndustryOrganisationLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxIndustryOrganisationLeft');
        var IndustryOrganisationRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxIndustryOrganisationRight');
        var IndustryOrganisationLeftLength = IndustryOrganisationLeftListObject.options.length;
        var IndustryOrganisationRightLength = IndustryOrganisationRightListObject.options.length;
        var temp="";
        for(var i=IndustryOrganisationLeftListObject.options.length-1;i>=0;i--)
        {
            if( IndustryOrganisationLeftListObject.options[i].selected){
            
                //alert(IndustryOrganisationLeftListObject.options[i].value);
            
                //if( CompanyLeftListObject.options[i].text.substring(0,1) != '>' ){  //if its not a title move it, titles have got '>' in front of them
                temp = IndustryOrganisationLeftListObject.options[i].value.substring(IndustryOrganisationLeftListObject.options[i].value.length-1,IndustryOrganisationLeftListObject.options[i].value.length);
                if( temp == '0' || temp == '5'){ //if its not a title you can move it, titles havent got 0 or 5 at right hand side digit in their Order column
                    IndustryOrganisationRightLength = IndustryOrganisationRightListObject.options.length;
                    IndustryOrganisationRightListObject.options[IndustryOrganisationRightLength] = new Option(IndustryOrganisationLeftListObject.options[i].text, IndustryOrganisationLeftListObject.options[i].value);
                    IndustryOrganisationLeftListObject.remove(i);
                }
            }
        }
        
        //Ordering IndustryOrganisationRight list
        var tempText;
        var tempValue;
        IndustryOrganisationRightLength = IndustryOrganisationRightListObject.options.length;
        for (var i=0; i<IndustryOrganisationRightLength-1; i++)
        {
            for(var j=i+1; j<IndustryOrganisationRightLength; j++){
                if(parseInt(IndustryOrganisationRightListObject.options[i].value) > parseInt(IndustryOrganisationRightListObject.options[j].value)){
                    tempText = IndustryOrganisationRightListObject.options[i].text;
                    tempValue = IndustryOrganisationRightListObject.options[i].value;
                    IndustryOrganisationRightListObject.options[i].text = IndustryOrganisationRightListObject.options[j].text;
                    IndustryOrganisationRightListObject.options[i].value = IndustryOrganisationRightListObject.options[j].value;
                    IndustryOrganisationRightListObject.options[j].text = tempText;
                    IndustryOrganisationRightListObject.options[j].value = tempValue;   
                }
            }
        }

        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtIndustryOrganisationList');
        IndustryOrganisationRightLength = IndustryOrganisationRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<IndustryOrganisationRightLength; i++)
            TextObject.value +=IndustryOrganisationRightListObject.options[i].text+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
        
    }
    function RemoveFromIndustryOrganisationRight(){
        var IndustryOrganisationLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxIndustryOrganisationLeft');
        var IndustryOrganisationRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxIndustryOrganisationRight');
        var IndustryOrganisationLeftLength = IndustryOrganisationLeftListObject.options.length;
        var IndustryOrganisationRightLength = IndustryOrganisationRightListObject.options.length;
        for(var i=IndustryOrganisationRightListObject.options.length-1;i>=0;i--)
        {
            if(IndustryOrganisationRightListObject.options[i].selected){
               IndustryOrganisationLeftLength = IndustryOrganisationLeftListObject.options.length;
               IndustryOrganisationLeftListObject.options[IndustryOrganisationLeftLength] = new Option(IndustryOrganisationRightListObject.options[i].text, IndustryOrganisationRightListObject.options[i].value);
               IndustryOrganisationRightListObject.remove(i);
            }
        }


        //Ordering Left list
        var tempText;
        var tempValue;
        var tempColor;
        var tempBackground;
        IndustryOrganisationLeftLength = IndustryOrganisationLeftListObject.options.length;
        for(var i=0; i<IndustryOrganisationLeftLength-1; i++){
            for(var j=i+1; j<IndustryOrganisationLeftLength; j++){
                //if(CompanyLeftListObject.options[i].text.substring(0,1) != '>' &&   CompanyLeftListObject.options[j].text.substring(0,1) != '>'){ //dont order title values
                    if(parseInt(IndustryOrganisationLeftListObject.options[i].value) > parseInt(IndustryOrganisationLeftListObject.options[j].value)){
                        tempText = IndustryOrganisationLeftListObject.options[i].text;
                        tempValue = IndustryOrganisationLeftListObject.options[i].value;
                        tempColor = IndustryOrganisationLeftListObject.options[i].style.color;
                        tempBackground = IndustryOrganisationLeftListObject.options[i].style.backgroundColor;
                        IndustryOrganisationLeftListObject.options[i].text = IndustryOrganisationLeftListObject.options[j].text;
                        IndustryOrganisationLeftListObject.options[i].value = IndustryOrganisationLeftListObject.options[j].value;
                        IndustryOrganisationLeftListObject.options[i].style.color = IndustryOrganisationLeftListObject.options[j].style.color;
                        IndustryOrganisationLeftListObject.options[i].style.backgroundColor = IndustryOrganisationLeftListObject.options[j].style.backgroundColor;
                        IndustryOrganisationLeftListObject.options[j].text = tempText;
                        IndustryOrganisationLeftListObject.options[j].value = tempValue; 
                        IndustryOrganisationLeftListObject.options[j].style.color = tempColor;
                        IndustryOrganisationLeftListObject.options[j].style.backgroundColor = tempBackground;
                    }
                //}
            }
        }
        
        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtIndustryOrganisationList');
        IndustryOrganisationRightLength = IndustryOrganisationRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<IndustryOrganisationRightLength; i++)
            TextObject.value +=IndustryOrganisationRightListObject.options[i].text+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
    }   
    
    
    
    
    
     
     
    //////////////////////////////////////////////////////////
    //Company javascript functions
        
    function RemoveFromCompanyLeft()
    {
        var CompanyLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxCompanyLeft');
        var CompanyRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxCompanyRight');
        var CompanyLeftLength = CompanyLeftListObject.options.length;
        var CompanyRightLength = CompanyRightListObject.options.length;
        var temp="";
        for(var i=CompanyLeftListObject.options.length-1;i>=0;i--)
        {
            if( CompanyLeftListObject.options[i].selected){
                //if( CompanyLeftListObject.options[i].text.substring(0,1) != '>' ){  //if its not a title move it, titles have got '>' in front of them
                temp = CompanyLeftListObject.options[i].value.substring(CompanyLeftListObject.options[i].value.length-1,CompanyLeftListObject.options[i].value.length);
                if( temp == '0' || temp == '5'){ //if its not a title you can move it, titles havent got 0 or 5 at right hand side digit in their Order column
                    CompanyRightLength = CompanyRightListObject.options.length;
                    CompanyRightListObject.options[CompanyRightLength] = new Option(CompanyLeftListObject.options[i].text, CompanyLeftListObject.options[i].value);
                    CompanyLeftListObject.remove(i);
                }
            }
        }
        
        //Ordering CompanyRight list
        var tempText;
        var tempValue;
        CompanyRightLength = CompanyRightListObject.options.length;
        for (var i=0; i<CompanyRightLength-1; i++)
        {
            for(var j=i+1; j<CompanyRightLength; j++){
                if(parseInt(CompanyRightListObject.options[i].value) > parseInt(CompanyRightListObject.options[j].value)){
                    tempText = CompanyRightListObject.options[i].text;
                    tempValue = CompanyRightListObject.options[i].value;
                    CompanyRightListObject.options[i].text = CompanyRightListObject.options[j].text;
                    CompanyRightListObject.options[i].value = CompanyRightListObject.options[j].value;
                    CompanyRightListObject.options[j].text = tempText;
                    CompanyRightListObject.options[j].value = tempValue;   
                }
            }
        }

        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtCompanyList');
        CompanyRightLength = CompanyRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<CompanyRightLength; i++)
            TextObject.value +=CompanyRightListObject.options[i].text+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
        
    }
    function RemoveFromCompanyRight(){
        var CompanyLeftListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxCompanyLeft');
        var CompanyRightListObject = document.getElementById('ctl00_MasterContentPlaceHolder_lboxCompanyRight');
        var CompanyLeftLength = CompanyLeftListObject.options.length;
        var CompanyRightLength = CompanyRightListObject.options.length;
        for(var i=CompanyRightListObject.options.length-1;i>=0;i--)
        {
            if(CompanyRightListObject.options[i].selected){
               CompanyLeftLength = CompanyLeftListObject.options.length;
               CompanyLeftListObject.options[CompanyLeftLength] = new Option(CompanyRightListObject.options[i].text, CompanyRightListObject.options[i].value);
               CompanyRightListObject.remove(i);
            }
        }


        //Ordering Left list
        var tempText;
        var tempValue;
        var tempColor;
        var tempBackground;
        CompanyLeftLength = CompanyLeftListObject.options.length;
        for(var i=0; i<CompanyLeftLength-1; i++){
            for(var j=i+1; j<CompanyLeftLength; j++){
                //if(CompanyLeftListObject.options[i].text.substring(0,1) != '>' &&   CompanyLeftListObject.options[j].text.substring(0,1) != '>'){ //dont order title values
                    if(parseInt(CompanyLeftListObject.options[i].value) > parseInt(CompanyLeftListObject.options[j].value)){
                        tempText = CompanyLeftListObject.options[i].text;
                        tempValue = CompanyLeftListObject.options[i].value;
                        tempColor = CompanyLeftListObject.options[i].style.color;
                        tempBackground = CompanyLeftListObject.options[i].style.backgroundColor;
                        CompanyLeftListObject.options[i].text = CompanyLeftListObject.options[j].text;
                        CompanyLeftListObject.options[i].value = CompanyLeftListObject.options[j].value;
                        CompanyLeftListObject.options[i].style.color = CompanyLeftListObject.options[j].style.color;
                        CompanyLeftListObject.options[i].style.backgroundColor = CompanyLeftListObject.options[j].style.backgroundColor;
                        CompanyLeftListObject.options[j].text = tempText;
                        CompanyLeftListObject.options[j].value = tempValue; 
                        CompanyLeftListObject.options[j].style.color = tempColor;
                        CompanyLeftListObject.options[j].style.backgroundColor = tempBackground;
                    }
                //}
            }
        }
        
        //Populating hidden text field
        var TextObject = document.getElementById('ctl00_MasterContentPlaceHolder_txtCompanyList');
        CompanyRightLength = CompanyRightListObject.options.length;
        TextObject.value ='';
        for (var i=0; i<CompanyRightLength; i++)
            TextObject.value +=CompanyRightListObject.options[i].text+'|';
        TextObject.value = TextObject.value.substring(0,TextObject.value.length-1);
    }   
    

