
function ShowHideMultipleSelection(ControlClientID, evt)
{
	var textBoxMain = window.document.getElementById(ControlClientID + '_' + 'tbMain');
	var divisionMain = window.document.getElementById(ControlClientID + '_' + 'divMain');
	
	//removes the 'Select' string tbMain
	switch(textBoxMain.value)
	{
		case 'Select':
			textBoxMain.value = '';
	        break;
		case '':
			textBoxMain.value = '';//Select
			break;
		default:
			break;
	}	
	
	var displayStatus = divisionMain.style.display;
	if(displayStatus == 'block')
	{
		divisionMain.style.display = 'none';
		if(window.document.getElementById(ControlClientID + '_' + 'hfAutoPostBack').value == 'True')
		{
			document.getElementById(ControlClientID + '_' + '__EVENTTARGET1').value = 'MultiSelectDropDown';
			document.getElementById(ControlClientID + '_' + '__EVENTARGUMENT1').value = textBoxMain.value;
			__doPostBack('MultiSelectDropDown',window.document.getElementById(ControlClientID + '_' + 'tbMain').value);
		}
	}
	else 
	{
	
		divisionMain.style.display = 'block';
	}
	//event.cancelBubble = true;
	var e = (window.event) ? window.event : evt;
	e.cancelBubble = true;
}

function ChangeColor(color, evt)
{
	var e = (window.event) ? window.event : evt;
	var ele = (e.srcElement) ? e.srcElement : e.target;	
	if (ele.className == 'MultiselectListItemLabel')
	{
		ele = ele.parentElement;
	}
	if(ele.className == 'MultiselectListItem')
		ele.style.backgroundColor = color; 
}

function HideOnFocusLost()
{
    var divCollection = window.document.getElementsByTagName('div');
    
    
    for (index = 0; index < divCollection.length; index++)
	{
		var divisionMain = divCollection[index];
		if (divisionMain.id.indexOf('divMain') >= 0 && divisionMain.style.display == 'block')
			divisionMain.style.display = 'none';
			
	}
 
}

function GetOrSetCheckBoxItemText(chkbox, ControlClientID)
{
	var labelCollection = window.document.getElementsByTagName('label');
	var hSelectedItemsValueList = document.getElementById(ControlClientID + '_' + 'hfSelectedItemsVlaues');
	var textBoxCurrentValue = new String();
	
	var selectedLabelValue;		
	
	
	textBoxMain = window.document.getElementById(ControlClientID + '_' + 'tbMain');
		
	textBoxCurrentValue = textBoxMain.value;
	for(index = 0; index < labelCollection.length; index++)
	{
		if(chkbox.id == labelCollection[index].getAttribute("htmlFor") || chkbox.id == labelCollection[index].getAttribute("for"))
			labelValue = labelCollection[index].innerText == null ? labelCollection[index].textContent : labelCollection[index].innerText; 		
	}
	
	if(chkbox.checked)
	{
		textBoxCurrentValue = labelValue + ', ';
		window.document.getElementById(ControlClientID + '_' + 'tbMain').value += textBoxCurrentValue;
		
		hSelectedItemsValueList.value = hSelectedItemsValueList.value + chkbox.value + ', ';
	}
	else
	{
		textBoxCurrentValue = textBoxCurrentValue.replace(labelValue+', ', "");
		window.document.getElementById(ControlClientID + '_' + 'tbMain').value = textBoxCurrentValue;
		
		hSelectedItemsValueList.value = hSelectedItemsValueList.value.replace(chkbox.value+', ',"");
	}		
}


function CheckValues(ControlClientID)
{	
	var control = ControlClientID + '_' + 'hfSelectedItemsVlaues';
	var parentControl = window.document.getElementById(control);	
}

function ChangeItemColor(spMain, position, ControlClientID)
{
	textBoxMain = window.document.getElementById(ControlClientID + '_' + 'tbMain');
	if (position == 'over')
	{
		spMain.style.backgroundColor = '#ffcc66'; //'#808080';
	}
	else
	{ 
		spMain.style.backgroundColor = 'whitesmoke';	
	}		
}

function HideSelectionList(ControlClientID)
{
	var displayStatus = window.document.getElementById(ControlClientID + '_' + 'divMain').style.display;
	if(displayStatus == 'block')
	{
		window.document.getElementById(ControlClientID + '_' + 'divMain').style.display = 'none';
	}
	else 
	{
		window.document.getElementById(ControlClientID + '_' + 'divMain').style.display = 'block';
	}
}

function CancelBubbleEvent(evt)
{
	var e = (window.event) ? window.event : evt;
	e.cancelBubble = true;	
}