// ************************************************************
function RedirectWithConfirm()
{
  var message = "The link you clicked will take you out of Preview Mode and into the live website \n(the target page is not managed by XML-Totem). \nClick OK to proceed, Cancel to stay in Preview Mode.";
  return confirm(message);
}

// ************************************************************
function jumpFormPaging( obj )
{
  //var url = "";
  //var guide = document.FormSelectPage.selectPage.options[document.FormSelectPage.selectPage.selectedIndex].value;
  //document.location = guide;
  
  document.location = obj.form.selectPage.options[obj.form.selectPage.selectedIndex].value;
 // alert(list.form.selAge.selectedIndex);
                      
 // alert(list.form.selAge.options[list.form.selAge.selectedIndex].value);
  
}
// ************************************************************

// ********************************************************
// ********************************************************
function jumpForm( obj )
{
  var url = "";
  var guide = document.FormGuide.guide_url.options[document.FormGuide.guide_url.selectedIndex].value;
  
  if (guide != '') 
  {
  document.location = guide;
  }
}

// ************************************************************************************************************************
var ListUtil = new Object();

// ************************************************************************************************************************
 ListUtil.move = function (oListboxFrom, oListboxTo, iIndex)
  {
      var oOption = oListboxFrom.options[iIndex]
                         
      if (oOption != null)
      {
          oListboxTo.appendChild(oOption);
      }
}
// ************************************************************************************************************************
 function moveToSelected(fromList,toList)
 {
      var oListSelected = document.getElementById(toList);
      var oListSelect = document.getElementById(fromList);
      var selectedItem = oListSelect.selectedIndex;
      ListUtil.move(oListSelect ,oListSelected ,selectedItem );
      sort(toList);
}
// ************************************************************************************************************************
 function moveToSelect(fromList,toList)
 {
      var oListSelected = document.getElementById(toList);
      var oListSelect = document.getElementById(fromList);
      var selectedItem = oListSelected.selectedIndex;
      ListUtil.move(oListSelected ,oListSelect ,selectedItem );
      sort(fromList);
}		      
// ************************************************************************************************************************
function SelectAllCountries()
{
      var oListSelected = document.getElementById("selectedCountries");
      for (var i=oListSelected.options.length-1; i >= 0; i--)
      {
	 oListSelected.options[i].selected = "selected";
      }
}
// ************************************************************************************************************************
function SelectAllKeywords()
{
      var oListSelected = document.getElementById("selectedKeywords");
      for (var i=oListSelected.options.length-1; i >= 0; i--)
      {
	 oListSelected.options[i].selected = "selected";
      }
}
// ************************************************************************************************************************
ListUtil.moveUp = function (oListbox, iIndex)
{
   if (iIndex > 0) 
   {
     var oOption = oListbox.options[iIndex];
     var oPrevOption = oListbox.options[iIndex-1];
     oListbox.insertBefore(oOption, oPrevOption);
   }
}
// ***************************************************************************************************************************
function sort (listName)
{
    var oList = document.getElementById(listName);
    var listValue, listValueBefore;
    
    for (var i=oList.options.length-1; i > 0; i--)
    {
            listValue = oList.options[i].text;
            listValueBefore= oList.options[i-1].text;
             
            if (listValue  < listValueBefore) 
            {
            
                ListUtil.moveUp(oList,i);
            }
    }
}


