function color_option_titles(){
	if(document.getElementById("ConnectedPages1_LB_All_Channels")){		
		fromListBox=document.getElementById("ConnectedPages1_LB_All_Channels");
		for(var i=0; i<fromListBox.length;i++){
			if(fromListBox.options[i].value=="title"){
				fromListBox.options[i].id="option_title";		
			}
		}
	}
}
function listMe(fromListBox,toListBox,userControlName){
	fromListBox=document.getElementById(userControlName+":"+fromListBox);
	toListBox =document.getElementById(userControlName+":"+toListBox);
	
	//multiple selection - get all selected options
	for(var i=0; i<fromListBox.length;i++){
		if(fromListBox.options[i].selected){//get selected option to copy
			if(fromListBox.options[i].value!="title"){
				//not a title			
				if(!OptionExists(toListBox,fromListBox.options[i].value)){//if this option doesn't already exists
					toListBox.options[toListBox.length]= new Option(fromListBox.options[i].text,fromListBox.options[i].value);
				}
				else{
					alert("פריט זה כבר קיים ברשימה");
				}
			}
		}
	}
 
	//delItem(fromListBox);           
}

function OptionExists(inList,optionValue){//checks if option value exists in given list box
	for(var i=0; i<inList.length;i++){
	if(inList.options[i].value==optionValue){
			return true;
		}
	}
	return false;
}

function delItem(theList,userControlName){//delete item from list 
	theList = document.getElementById(userControlName+":"+theList);
	if (! OptionExists(document.getElementById(userControlName+':LB_All_Channels'),theList.options[theList.options.selectedIndex].value)){
		if (document.getElementById('ChkBoxConnectedPages1:chbConnecteds') != null){
			document.getElementById('ChkBoxConnectedPages1:chbConnecteds').checked=false;
		}
	}
	if (theList.options.selectedIndex >-1){
		theList.options[theList.options.selectedIndex] = null;	
	}
} 

function CopyList(fromListBox,toListBox){//copy list items from one list to another
	fromListBox=document.getElementById(fromListBox);
	toListBox =document.getElementById(toListBox);
	//alert("fromListBox: " + fromListBox);
	//alert("toListBox: " + toListBox);
	for(var i=0; i<fromListBox.length;i++){
		toListBox.options[toListBox.length]= new Option(fromListBox.options[i].text,fromListBox.options[i].value);
	}       
}//end CopyList

function ListToString(fromListBox,toInput){//copy list items from list to a string
	fromListBox=document.getElementById(fromListBox);
	toInput =document.getElementById(toInput);
	toInput.value="";
	for(var i=0; i<fromListBox.length;i++){
		toInput.value+=fromListBox.options[i].text+"#"+fromListBox.options[i].value+"#";
	}
	//alert("input value: \n" + toInput.value);
}//end ListToString

function func(ctrlId,userControlName){
//alert(userControlName);
	if(confirm("הנך עומד לבצע שינויים במערכת.האם ברצונך להמשיך ?")){
			//LB_All_Channels>>client_side_LB_All_Channels
			ListToString(userControlName+':LB_All_Channels',userControlName+':LB_All_Channels_CS');
			//LB_To_Connect>>client_side_LB_To_Connect
			ListToString(userControlName+':LB_To_Connect',userControlName+':LB_To_Connect_CS');
			__doPostBack(ctrlId,'');
	}
}
function NewsCheckBoxClicked(chanText,chanValue){
	//var newsChBox = document.getElementById("OneChannelConnectedPage1_CheckBox1");
	var newsChBox = document.getElementById("ChkBoxConnectedPages1_chbConnecteds");
	var toListBox = document.getElementById("ConnectedPages1:LB_To_Connect");
	if (newsChBox != null && toListBox != null){
		if (newsChBox.checked){
			if(!OptionExists(toListBox,chanValue)){
				toListBox.options[toListBox.length] = new Option(chanText,chanValue);
			}
		}
			
		if (! newsChBox.checked){
			for (var i=0; i<toListBox.length; i++) { 
				if (toListBox.options[i].value == chanValue ){ 
					toListBox.options[i] = null; 
					i=i-1; //this index option deleted, check what takes it's place 
				} 
			} 
		} 
	}
}