﻿function textchanged()
{
    var text1 = document.getElementById('LinkButton1');
    alert(text1.value);
}

function trim(stringToTrim) 
    {
	    return stringToTrim.replace(/^\s+|\s+$/g,"");
    }


    function textchanged(controlID, labelID)
    {         
        label = document.getElementById(labelID);                
        
        label.innerHTML = '';
        txtArray = document.getElementById(controlID).value.split(',');        
        
        if(trim(document.getElementById(txtArray[0]).value).length > 0)
        {
            var valuesArray = trim(document.getElementById(txtArray[0]).value).split(' ');
            for(i=0; i< valuesArray.length; i++)
            {
                if(i != (valuesArray.length - 1))
                {
                    label.innerHTML += valuesArray[i] + ' <b>AND</b> ';
                }
                else
                {
                    label.innerHTML += valuesArray[i] + ' ';
                }
            }                        
        }
        
        if(trim(document.getElementById(txtArray[1]).value).length > 0)
        {            
            label.innerHTML += '<b>AND</b> "' + document.getElementById(txtArray[1]).value + '" ';
        }
        
        if(trim(document.getElementById(txtArray[2]).value).length > 0)
        {
            if(label.innerHTML.length > 0)
            {
                label.innerHTML += '<b>OR</b> ';
            }
            label.innerHTML += document.getElementById(txtArray[2]).value + ' ';          
        }
        
        if(trim(document.getElementById(txtArray[3]).value).length > 0)
        {
            if(label.innerHTML.length > 0)
            {
                label.innerHTML += '<b>OR</b> ';
            }
            label.innerHTML += document.getElementById(txtArray[3]).value + ' ';            
        }
        
        if(trim(document.getElementById(txtArray[4]).value).length > 0)
        {
            if(label.innerHTML.length > 0)
            {
                label.innerHTML += '<b>OR</b> ';
            }
            label.innerHTML += document.getElementById(txtArray[4]).value + ' ';
        }
        
        if(trim(document.getElementById(txtArray[5]).value).length > 0)
        {
            if(label.innerHTML.length > 0)
            {
                label.innerHTML += '<b>OR</b> ';
            }
            label.innerHTML += document.getElementById(txtArray[5]).value + ' ';
        }
        
        if(trim(document.getElementById(txtArray[6]).value).length > 0)
        {            
            var notWordsArray = document.getElementById(txtArray[6]).value.split(' ');
            
            for(i = 0;i < notWordsArray.length ; i++)
            {               
                if(trim(notWordsArray[i]).length > 0)
                {
                    label.innerHTML += '<b>NOT</b> ' + notWordsArray[i] + ' ';
                }
            }
        }
    }
