var selectedList;
var availableList;
var value;


function createListObjects(){
   
    availableList = document.getElementById("availableOptions");
    selectedList = document.getElementById("selectedOptions");
}
function delAttribute(){
    var selIndex = selectedList.selectedIndex;
    if(selIndex < 0)
        return;
    availableList.appendChild(selectedList.options.item(selIndex))
    selectNone(selectedList,availableList);
    setSize(availableList,selectedList);
}


function addAttribute(){
 var addIndex = availableList.selectedIndex;

    if(addIndex < 0)
        return;
    selectedList.appendChild(availableList.options.item(addIndex));
    selectNone(selectedList,availableList);
    setSize(selectedList,availableList);

    }

function delAll(){
    var len = selectedList.length -1;
    for(i=len; i>=0; i--){
        availableList.appendChild(selectedList.item(i));
    }
    selectNone(selectedList,availableList);
    setSize(selectedList,availableList);

}
function addAll(){
    var len = availableList.length -1;
    for(i=len; i>=0; i--){
        selectedList.appendChild(availableList.item(i));
    }
    selectNone(selectedList,availableList);
    setSize(selectedList,availableList);

}
function selectNone(list1,list2){
    list2.selectedIndex = -1;

    selIndex = -1;

}


function setSize(list1,list2){
    list1.size = getSize(list1);
    list2.size = getSize(list2);
}
function getSize(list){

    var len = list.childNodes.length;
    var nsLen = 0;

    for(i=0; i<len; i++){
        if(list.childNodes.item(i).nodeType==1)
            nsLen++;
    }
    if(nsLen<2)
        return 2;
    else
        return nsLen;
}



function copyToList(from, to) {
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
 if (toList.options.length > 0 && toList.options[0].value == 'temp') {
 toList.options.length = 0; 
} 
var sel = false;
var secili = false;

for (i=0;i<fromList.options.length;i++) { 
		var current = fromList.options[i];
                sel = current.selected;
		if (sel) { 
		    if(!control(current, toList))
                    {
                        
                                txt = current.text; 
				val = current.value;
                                toList.options[toList.length] = new Option(txt,val); 
                                current.selected=false;
                        	  
                    }
                    else{
                        current.selected=false;
                    }
                    
		}
                
               
                                        
}
		}

function copyToListMadde(from, to) {
fromList = eval('document.forms[1].' + from);
toList = eval('document.forms[1].' + to);

for (i=0;i<fromList.options.length;i++) { 
		var current = fromList.options[i];
                sel = current.selected;
		if (sel) { 
		    if(!control(current, toList))
                    {
                        
                                txt = current.text; 
				val = current.value;
                                toList.options[toList.length] = new Option(txt,val); 
                                current.selected=false;
                        	  
                    }
                    else{
                        current.selected=false;
                    }
                    
		}
                
               
                                        
		
		}
}

function control(current, toList){
    var mevcut = false;
   // alert("length: "+toList.options.length);
  for (i=0;i<toList.options.length;i++) {
		var to = toList.options[i];
                if(to.value == current.value){
                    mevcut=true;
                }
                
}
    return mevcut;
    
}
function copyToListAndDelMadde(from, to) {
fromList = eval('document.forms[1].' + from);

toList = eval('document.forms[1].' + to);

 if (toList.options.length > 0 && toList.options[0].value == 'temp') {
 toList.options.length = 0; 
}
var sel = false; 
for (i=0;i<fromList.options.length;i++) { 
		var current = fromList.options[i]; 
		if (current.selected) {
                    

					sel = true; 
					if (current.value == 'temp') { 
						alert ('You cannot move this text!'); 
							return;
					 } 
					txt = current.text; 
					val = current.value;
    
					toList.options[toList.length] = new Option(txt,val); 
					fromList.options[i] = null; 
					i--; 
					} 
					} 
					if (!sel) 
					alert ('You haven\'t selected any options!');
 
		}
                function copyToListAndDel(from, to) {
fromList = eval('document.forms[0].' + from);

toList = eval('document.forms[0].' + to);

 if (toList.options.length > 0 && toList.options[0].value == 'temp') {
 toList.options.length = 0; 
}
var sel = false; 
for (i=0;i<fromList.options.length;i++) { 
		var current = fromList.options[i]; 
		if (current.selected) {
                    

					sel = true; 
					if (current.value == 'temp') { 
						alert ('You cannot move this text!'); 
							return;
					 } 
					txt = current.text; 
					val = current.value;
    
					toList.options[toList.length] = new Option(txt,val); 
					fromList.options[i] = null; 
					i--; 
					} 
					} 
					if (!sel) 
					alert ('You haven\'t selected any options!');
 
		}

function toggle1() {document.forms[0].maddeOncelik.value = "1";}
function controlOncelik(){
var count=0;
myCheckboxArray = document.forms[0].elements["oncelik[]"];
for(i=0;i<myCheckboxArray.length;i++)
        if(myCheckboxArray[i].checked)
	{
	   count = count+1;
	}
	if(count>2){
	 alert("2 den fazla secenek isaretlenemez!");
	 document.forms[0].Submit.disabled = true;
	}
	else
	 document.forms[0].Submit.disabled = false;
	  
}

		
function allSelect()
{
  List = document.forms[0].selectedOptions;
  if (List.length && List.options[0].value == 'temp') return;
  for (i=0;i<List.length;i++)
  {
     List.options[i].selected = true;
  }
}
function allSelectMadde()
{
  List = document.forms[1].selectedOptions;
  if (List.length && List.options[0].value == 'temp') return;
  for (i=0;i<List.length;i++)
  {
     List.options[i].selected = true;
  }
}


function showSelected(){
    var optionList = document.getElementById("selectedOptions").options;
    var data = '';
    var len = optionList.length;
    for(i=0; i<len; i++){
        if(i>0)
            data += ',';
        data += optionList.item(i).value;

    }
    document.write(data);
}


function toggle( x ){
 if ( x.style ) { 
 x.style.backgroundColor = ('red' == x.style.backgroundColor)? 'white' : 'red'; 
 diger.digerUid.value = x.id;
 }
}

function getValue(x){
	diger.digerUid.value = x.id;
}
 
var preEl ;
var orgBColor;
var orgTColor;
function HighLightTR(backColor,textColor){  
if(typeof(preEl)!='undefined') {
preEl.bgColor=orgBColor; 
try{ChangeTextColor(preEl,orgTColor);}catch(e){;}
} 
var el = event.srcElement;
el = el.parentElement;
orgBColor = el.bgColor;
orgTColor = el.style.color;
el.bgColor=backColor;

try{ChangeTextColor(el,textColor);}catch(e){;}
 
preEl = el; 
}

function ChangeTextColor(a_obj,a_color){  ;
for (i=0;i<a_obj.cells.length;i++){
a_obj.cells(i).style.color=a_color; 
}
}



