
var blnNewArray = false;

// variables for slide viewer
var first = false;
var cnt = 0;
var aSlides = new Array();	

function remove(rightselect){

	    var n;
	    var x;
		var arraycounter = 0;
		var delete_array = new Array();
		
		
        for (n=0;n<rightselect.length;n++){
        	
        	if(rightselect.options[n].selected){	
        	
        		delete_array[arraycounter] = rightselect[n].value;
        		arraycounter++;
        	}
	
        }
        
          for (n=0;n<rightselect.length;n++){
          	
          	for(x=0;x<arraycounter;x++){
          		
          		if(rightselect[n].value == delete_array[x]){

          			rightselect.remove(n);	
          		}	
          	}
          	
          }	
		
}


function move_right(leftselect,rightselect){
	
		var n;
		var arraycounter = 0;
		var opt_text_arr = new Array();
		var opt_value_arr = new Array();

        for (n=0;n<leftselect.length;n++){
        	
        	if(leftselect.options[n].selected){	
        	
				opt_text_arr[arraycounter] = leftselect[n].text;
				opt_value_arr[arraycounter] = leftselect[n].value;
				arraycounter++;
        	}
	
        }
	
		if(opt_text_arr == null){
			
			
			
		} else {
		
		      	var a;
		      	for (a=0;a<arraycounter;a++){
		    	
				//create new option
				var newOpt = document.createElement("OPTION");
				
				newOpt.text = opt_text_arr[a];
				newOpt.value = opt_value_arr[a];
				
				//add to right form
				rightselect.add(newOpt);
				
		      	}
	
	}
	
	
}

function validate_select(dropdown,dropdown2){
	
		if(dropdown.length == 0){
			
			return false	
		} 
	
		if(dropdown2 != 0){
	
		
			if(dropdown2.length == 0){
			
			return false	
			} 
		
		}
	
	
	
}


function selectmultiple(dropdown,dropdown2){

	
		if(dropdown.length != 0){	
			
			for (n=0;n<dropdown.length;n++){
		
			dropdown.options[n].selected = true;
			}
		
			dropdown.name = dropdown.name + "[]";	
		}
	
		
	if(dropdown2 != 0){
		if(dropdown2.length != 0){		
		for (n=0;n<dropdown2.length;n++){
	
		dropdown2.options[n].selected = true;
		}
	
		dropdown2.name = dropdown2.name + "[]";
		}
	}
}

function getSelected(opt) {
            var selected = new Array();
            var index = 0;
            var chk = 0;
            for (var intLoop = 0; intLoop < opt.length; intLoop++) {
               if ((opt[intLoop].selected) ||
                   (opt[intLoop].checked)) {
                  index = selected.length;
                  selected[index] = new Object;
                  selected[index].value = opt[intLoop].value;
                  selected[index].index = intLoop;
                  chk = 1;
               }
            }
           		
			if (chk == 1){
				self.viewuser.ViewUserForm.hiddenpersonid.value = selected[0].value;
	            self.viewuser.ViewUserForm.submit();
			}
 }
 
 function filter(form,txt,list,rightlist){

    //generate backup if not already done
    var same = false;
    
    if (blnNewArray == false){
    	
    	blnNewArray = true;
    	list.bakid = null;
        list.baktext = null;
    
        list.bakid = new Array();
        list.baktext = new Array();
			
        var n;
		
        for (n=0;n<list.length;n++){
               	
               	list.bakid[n] = list[n].value;
	        	list.baktext[n] = list[n].text;
      }
    }
    //Remove everything from list
    var d;
    //original list length
    var listlength = list.bakid.length;

    for(d=0;d<listlength;d++){
        //remove options
        list.remove(0);
    }


    //Find matches and populate list box
    //get length of searchstring
    var txtlen = txt.length;
    var e;
    var c=0;
	var x;
	
        for(e=0;e<listlength;e++){

        	
        	var check = list.baktext[e].substr(0,txtlen);
            if(check.toLowerCase() == txt.toLowerCase()){
                //Create new options
               
                if(rightlist){
	        	for	(x=0;x<rightlist.length;x++){
	        			if(list.bakid[e] == rightlist[x].value){
	        			same = true;	
	        		}
	        	}
        	}
                
	             if(same == false){
		                var newOpt = document.createElement("OPTION");
		                newOpt.text=list.baktext[e];
		                newOpt.value=list.bakid[e];
		                list.add(newOpt);
                }
                
				same = false;
            }
    }
    


}

function new_array(){
	
var blnNewArray = false;
	
}

function go_onClick(dropdown){
	
	window.location.href=dropdown.options[dropdown.options.selectedIndex].value;
	
}

/*

function add_array(a){
	
// todo
		aSlides[cnt] = a.style;
		
		for(i=0;i<cnt;i++){
			aSlides[cnt].color='red';
			alert(aSlides[cnt]);
		}
		
	    cnt++;
}
*/

function highlight(a){
		
	//add_array(a);
	a.style.color='#0000CC';
	
}