<!--

//========================================================================

//function to copy selected option fields from one select box to other
//also checks if the one to be assigned exists in the destination object
function copySelected( fromObject, toObject )
    {
    var t = toObject.options.length;
    var l = fromObject.options.length;
    var found;
    //loop through each selected options list and create the same option in the destination
    for ( var i = 0; i < l; i++ )
        {
        if ( fromObject.options[i].selected )
            {
            found = false;
            //loop to validate destination object for existent of export item
            for ( var j = 0; j < t; j++ )
                {
                if ( fromObject.options[i].text == toObject.options[j].text )
                    {
                    found = true;
                    }
                }
            //calls addOption to create the option on the destination based on the current selection
            if ( found != true )
                {
                addOption( toObject, fromObject.options[i].text, fromObject.options[i].value );
                }
            }
        }
    }

//========================================================================

//function to remove selected option item from target option object
function removeSelected ( targetObject )
    {
    for ( var i = targetObject.options.length-1; i > -1; i-- )
        {
        if ( targetObject.options[i].selected )
            {
            targetObject.options[i] = null;
            }
        }
    }

//========================================================================

//function to create an option object on the list. Object must be of select list object.
function addOption( object, text, value)
    {
    var defaultSelected = false;
    var selected = false;
    var optionName = new Option(text, value, defaultSelected, selected);
    object.options[object.length] = optionName;    
    }

//========================================================================

//function to remove all options from the target select box object.
function removeAll ( object )
    {
    //set null to each option object from the list object once all is exported
    for ( var i = object.options.length-1; i > -1; i-- )
        {
        object.options[i] = null;
        }
    }

//========================================================================

//tailored function to check if countries have access to certain items
function validate_items ( list1, list2 )
    {
    var l = list1.options.length;
	var k = list2.options.length;
    var strMessage = "";

    var nonIT = Array ( "AUT - AUSTRIA", "ESP - SPAIN", "FRA - FRANCE", "GRC - GREECE",
                        "ISL - ICELAND", "ITA - ITALY", "JPN - JAPAN", "KOR - KOREA, REPUBLIC OF",
                        "NLD - NETHERLANDS", "NOR - NORWAY", "POL - POLAND", "PRT - PORTUGAL" );

    var nonCC = Array ( "CAN - CANADA", "ESP - SPAIN", "FRA - FRANCE", "GRC - GREECE",
                        "JPN - JAPAN", "POL - POLAND" );

    //checks if the exceptional variables have been selected
    for ( var i = 0; i < l; i++ )
        {
        var code = list1.options[i].value;
        var newCode = code.substr(0,2);
        if ( newCode == "IT" )
            var foundIT = true;
        if ( newCode == "CC" )
            var foundCC = true;
        }

    if ( foundIT == true )
        {
        for ( i = 0; i < k; i++ )
            {
            for ( j = 0; j < nonIT.length; j++ )
                {
                if ( list2.options[i].text == nonIT[j] )
                    strMessage += list2.options[i].text + " did not participate in IT questionnaire\n";
                }
            }
        }

    if ( foundCC == true )
        {
        for ( i = 0; i < k; i++ )
            {
            for ( j = 0; j < nonCC.length; j++ )
                {
                if ( list2.options[i].text == nonCC[j] )
                    strMessage += list2.options[i].text + " did not participate in CC questionnaire\n";
                }
            }
        }

     if ( strMessage != "" )
        {
        strMessage += "Please remove the above countrie(s) or Variable(s) from your selection.\n";
        alert ( strMessage );
        return false;
        }

     return true;
     }

//========================================================================

//function to populate a hidden variable from the imported select options
function createHidden( fromObject1, toObject1, fromObject2, toObject2 )
    {
    var output1 = '';
	var output2 = '';
    var l = fromObject1.options.length;
	var k = fromObject2.options.length;

    
    if ( l > 4 )
        {
        alert ("No more than 4 Variables can be selected");
        return false;
        }
    else if ( l == 0 )
        {
        alert ("You have not selected any Variables");
        return false;
        }
    else if ( k == 0 )
        {
        alert ("You have not selected any Countries");
        return false;
        }
    else
        {
        if ( validate_items( fromObject1, fromObject2 ) )
            {
            for ( var i = 0; i < l; i++ )
            {
                //constructs one post variable as a whole string of select options
                //to be manipulated by server-side scripting in the calling page.
                if (i != 0) {
                	output1 += ',';
                }
                output1 += escape( fromObject1.options[i].value );
            }
            for ( var i = 0; i < k; i++ )
            {
                //constructs one post variable as a whole string of select options
                //to be manipulated by server-side scripting in the calling page.
                if (i != 0) {
                	output2 += ',';
                }
                output2 += escape( fromObject2.options[i].value );
            }
            toObject1.value = output1;
            toObject2.value = output2;
            return true;
            }
		else
		return false;
        }
    }

//========================================================================

//function to remove dummy first select option index to trick
//netscape to force the initial width of an empty select box.
function checkOptions( formObj1, formObj2 )
    {
    formObj1.options[0] = null;
    formObj2.options[0] = null;
    }

//-->