﻿// JScript File

function CheckAndMove(lst,a)
{
    if (a==1)
    {
        if(lst.selectedIndex == -1)
        {
            alert('Please select an Item to move up.');
        }
        else 
        {
            if(lst.selectedIndex == 0)
            {
                alert('First element cannot be moved up');
                return false;
            }
            else
            {
                MoveUpDown(lst,a);
            }
        } 
    }
    else
    {
        if(lst.selectedIndex == -1)
        {
            alert('Please select an Item to move down');
        }
        else
        {
            if(lst.selectedIndex == lst.options.length-1)
            {
                alert('Last element cannot be moved down');
            } 
            else
            { 
                MoveUpDown(lst,a);
            } 
        } 
    }
    return false;
}

function MoveUpDown(lst,a)
{
    var tempValue = lst.options[lst.selectedIndex].value; 
    var tempIndex = lst.selectedIndex-1*a; 
    lst.options[lst.selectedIndex].value = lst.options[lst.selectedIndex-1*a].value; 
    lst.options[lst.selectedIndex-1*a].value = tempValue; 
    var tempText = lst.options[lst.selectedIndex].text; 
    lst.options[lst.selectedIndex].text = lst.options[lst.selectedIndex-1*a].text; 
    lst.options[lst.selectedIndex-1*a].text = tempText; 
    lst.selectedIndex = tempIndex;
    StoreItems(lst)
    return false;
}

function AddToFavorite()
{
var s;
s="Press Ctrl+D to bookmark (Command+D for macs) after you click Ok";
var title=document.title;
var url=location.href;
if (window.sidebar) { 
// FF
window.sidebar.addPanel(title, url,"");
} else if( window.external ) { 
  if(window.ActiveXObject) {
  //IE
  window.external.AddFavorite( url, title);
  } else {
  //GC
  alert(s);
  }
} else if(window.opera && window.print) { 
// Opera
alert(s);
  return true; }
 else { 
 //Safri
 alert(s); }
}

function SearchOnFocus(txt, text) 
{
    if (txt.value == text) 
    {
        txt.value = "";
    }
}

function SearchOnBlur(txt, text)
{
    if (txt.value == "")
    {
        txt.value = text;
    }
}