/*
Text Link/Image Map Tooltip Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, and 100's more DHTML scripts
Visit http://www.dynamicdrive.com
*/

/*if (!document.layers&&!document.all&&!document.getElementById)
event="test"*/
function showtip(current,e,text)
{
	if (document.all||document.getElementById)
	{	
		thetitle=text.split('<br>')
		if (thetitle.length>1)
		{
			thetitles=''
			for (i=0;i<thetitle.length;i++)
			thetitles+=thetitle[i]
			current.title=thetitles
		}
		else
			current.title=text
		}

	else if (document.layers)
	{
		document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>')
		document.tooltip.document.close()
		document.tooltip.left=e.pageX+5
		document.tooltip.top=e.pageY+5
		document.tooltip.visibility="show"
	}
}

function hidetip()
{
	if (document.layers)
	document.tooltip.visibility="hidden"	
}

/*Testing for finding Texts in drop Down lists*/
/* 
- Give Credit Where Its Due - 
Please acknowledge this article and its author, at 
least in code comments, when using this code. 

Author: 
Justin Whitford 
Source: www.evolt.org 

Thank you. 
*/ 

/* 
filtery(pattern, list) 
pattern: a string of zero or more characters by 
which to filter the list 
list: reference to a form object of type, select 

Example: 
<form name="yourForm"> 
<input type="text" name="yourTextField" onchange="filtery(this.value,this.form.yourSelect)"> 
<select name="yourSelect"> 
<option></option> 
<option value="Australia">Australia</option> 
*/ 

function filtery(pattern, list){ 
/* 
if the dropdown list passed in hasn't 
already been backed up, we'll do that now 
*/ 
if (!list.bak){ 
/* 
We're going to attach an array to the select object 
where we'll keep a backup of the original dropdown list 
*/ 
list.bak = new Array(); 

for (n=0;n<list.length;n++){ 
list.bak[list.bak.length] = new Array(list[n].value, list[n].text); 
} 
} 

/* 
We're going to iterate through the backed up dropdown 
list. If an item matches, it is added to the list of 
matches. If not, then it is added to the list of non matches. 
*/ 
match = new Array(); 
nomatch = new Array(); 

for (n=0;n<list.bak.length;n++){ 
if(list.bak[n][1].toLowerCase().indexOf(pattern.toLowerCase())!=-1){ 
match[match.length] = new Array(list.bak[n][0], list.bak[n][1]); 
} 
else{ 
nomatch[nomatch.length] = new Array(list.bak[n][0], list.bak[n][1]); 
} 
} 

/* 
Now we completely rewrite the dropdown list. 
First we write in the matches, then we write 
in the non matches 
*/ 
for (n=0;n<match.length;n++){ 
list[n].value = match[n][0]; 
list[n].text = match[n][1]; 
} 

for (n=0;n<nomatch.length;n++){ 
list[n+match.length].value = nomatch[n][0]; 
list[n+match.length].text = nomatch[n][1]; 
} 

/* 
Finally, we make the 1st item selected - this 
makes sure that the matching options are 
immediately apparent 
*/ 
list.selectedIndex=0; 
} 

function MoveItem(ctrlSource, ctrlTarget) 
{
	var Source = document.getElementById(ctrlSource);
	var Target = document.getElementById(ctrlTarget);

	if ((Source != null) && (Target != null)) {
		var intIndex = Source.options.selectedIndex
		while ( Source.options.selectedIndex >= 0 ) {
			var newOption = new Option(); // Create a new instance of ListItem
			newOption.text = Source.options[Source.options.selectedIndex].text;
			newOption.value = Source.options[Source.options.selectedIndex].value;

			Target.options[Target.length] = newOption; //Append the item in Target
			Source.remove(Source.options.selectedIndex);  //Remove the item from Source
		}
		Source.options.selectedIndex = intIndex
	}
}

function MoveAll(ctrlSource, ctrlTarget) 
{
	var Source = document.getElementById(ctrlSource);
	var Target = document.getElementById(ctrlTarget);

	if ((Source != null) && (Target != null)) {
		Source.options.selectedIndex = 0
		while ( Source.options.selectedIndex >= 0 ) {
			var newOption = new Option(); // Create a new instance of ListItem
			newOption.text = Source.options[Source.options.selectedIndex].text;
			newOption.value = Source.options[Source.options.selectedIndex].value;
		    
			Target.options[Target.length] = newOption; //Append the item in Target
			Source.remove(Source.options.selectedIndex);  //Remove the item from Source
			Source.options.selectedIndex = 0
		}
	}
}

