/*
/------------------------------------------------------\
|                    Medley V1.0                       |
|                                                      |
|   Feel free to copy, use and change this script as   |
|   long as this part remains unchanged.               |
|                                                      |
|   If you have any questions and or comments please   |
|   Author:  Ajay Lulia
|   E-mail me 'ajaylulia@hotmail.com'.                 |
|   Please check out my webpage http://www.lulia.com   |
|                                                      |
|              Last Updated: 17 July 2003              |
\------------------------------------------------------/
*/

var num_SortList = 1;  // Sorts the Left list as and when it is changed, 1=Sort


function ShiftOption(SelectInstance, ShiftTo, This)
{
   var SelectedNo = SelectInstance.selectedIndex;
   if (ShiftTo == -1)
   {
      if (SelectedNo <= 0)
      {
         SelectInstance.focus();
         return 
      }
   }
   else
   {
      if ((SelectedNo + ShiftTo) == SelectInstance.length)
      {
         SelectInstance.focus();
         return 
      }
   }
   var SelectedValue = SelectInstance.options[SelectedNo].value;
   var SelectedText = SelectInstance.options[SelectedNo].text;
   if ((! SelectedValue) ||  ((SelectedNo + ShiftTo)== SelectInstance.length)) {
      return 
   }

   var AboveValue = SelectInstance.options[SelectedNo + ShiftTo].value;
   var AboveText = SelectInstance.options[SelectedNo + ShiftTo].text;

   SelectInstance.options[(SelectInstance.selectedIndex + ShiftTo)].text = SelectedText;
   SelectInstance.options[(SelectInstance.selectedIndex + ShiftTo)].value = SelectedValue;

   SelectInstance.options[SelectInstance.selectedIndex].text = AboveText;
   SelectInstance.options[SelectInstance.selectedIndex].value = AboveValue;

   SelectInstance.options[SelectedNo + ShiftTo].selected = true;
   SelectInstance.options[SelectedNo].selected = false;
}

function MoveOptions(SourceList, TargetList, obj_Button)
{
   var SelectLength  = SourceList.length;
   var ButtonName    = obj_Button.name;
   var SelectedValue = "";
   var SelectedText  = "";
   var ListDetails = new Array();
   var ArrayCounter = 0;
   var SelectedIndex = SourceList.selectedIndex;

   for(Counter = 0; Counter < SelectLength; Counter++)
   {
      if ((ButtonName == "MoveRight") || (ButtonName == "MoveLeft"))
      {
         if (! SourceList.options[Counter].selected == true)
         {
            continue;
         }
      }
      ListDetails[ArrayCounter] = new Array(3);
      ListDetails[ArrayCounter][0] = SourceList.options[Counter].text;
      ListDetails[ArrayCounter][1] = SourceList.options[Counter].value;
      ListDetails[ArrayCounter][2] = Counter;
      ArrayCounter++;
   }

   if (ListDetails.length == 0)
   {
      alert("Please Select Item From List Box");
      SourceList.focus();
      return false;
   }

   var SourceCounter = 0;
   for (Counter = 0; Counter < ListDetails.length; Counter++)
   {
      TargetList.options[TargetList.length] = new Option(ListDetails[Counter][0]);
      TargetList.options[TargetList.length - 1].value =  ListDetails[Counter][1];
   
      SelectLength = SourceList.length;
      for (SourceCounter = 0; SourceCounter < SelectLength; SourceCounter++)
      {
         if (SourceList.options[SourceCounter].text == ListDetails[Counter][0])
         {
            SourceList.options[SourceCounter] = null;
            break;
         }
      }
   }

   if (SourceList.length > 0)
   {
      if (SourceList.length > SelectedIndex)
         SourceList.options[SelectedIndex].selected = true;
      else
         SourceList.options[SourceList.length - 1].selected = true;
   }

   if(document.isc.LeftList == TargetList)
      SortLeftList(document.isc.LeftList);

   if (document.isc.elements["RightList[]"].length == 0)
   {
      document.isc.MoveLeft.disabled     = true;
      document.isc.MoveAllLeft.disabled  = true;
      document.isc.MoveRight.disabled    = false;
      document.isc.MoveAllRight.disabled = false;
   }
   else if(document.isc.LeftList.length == 0)
   {
      document.isc.MoveLeft.disabled     = false;
      document.isc.MoveAllLeft.disabled  = false;
      document.isc.MoveRight.disabled    = true;
      document.isc.MoveAllRight.disabled = true;
   }
   else
   {
      document.isc.MoveLeft.disabled     = false;
      document.isc.MoveAllLeft.disabled  = false;
      document.isc.MoveRight.disabled    = false;
      document.isc.MoveAllRight.disabled = false;
   }
}

function SortLeftList(SelectInstance)
{
   if (num_SortList == 0)
   {
	   return 
   }
   var TotalNos = SelectInstance.length;
   arr_LeftList = new Array(TotalNos - 1);

   for(Counter = 0; Counter < TotalNos; Counter++)
   {
      arr_LeftList[Counter] = new Array(2);
      arr_LeftList[Counter][0] = SelectInstance.options[Counter].text;
      arr_LeftList[Counter][1] = SelectInstance.options[Counter].value;
   }
   arr_LeftList.sort();
   for(Counter = 0; Counter < TotalNos; Counter++)
   {
      SelectInstance.options[Counter] = new Option(arr_LeftList[Counter][0]);
      SelectInstance.options[Counter].value =  arr_LeftList[Counter][1];
   }
}

function CheckFormValues1()
{

   var RightListLength = document.isc.elements["RightList[]"].length;
   var Counter;

   if (RightListLength <= 0)
   {
      alert("Please select atleast one Column from the left List.");
      return false;
   }

   for(Counter = 0; Counter < RightListLength; Counter++)
   {
      document.isc.elements["RightList[]"].options[Counter].selected = true;
   }
   return true;
}

function sprawdz()
{
   var RightListLength = document.form01.elements["RightList[]"].length;
   var Counter;

   if (RightListLength <= 0)
   {
      alert("Please select atleast one Column from the List.");
      return false;
   }

   for(Counter = 0; Counter < RightListLength; Counter++)
   {
      document.form01.elements["RightList[]"].options[Counter].selected = true;
   }
   return true;
}


function FinishWizard(FormAction)
{
   if (CheckFormValues())
   {
      document.isc.action = FormAction;
      document.isc.submit();
   } else {
      return false;
   }
}

function sprawdz_pola2()
{
	var t = document.isc;
	if(t.num2.value!="" && t.num3.value=="") {
alert('Incorrect phone number');
t.num3.focus();
return false;
}
if(t.num2.value=="" && t.num3.value!="") {
alert('Incorrect phone number');
t.num2.focus();
return false;
}

if(t.num4.value!="" && (t.num3.value=="" || t.num2.value=="")) {
alert('Incorrect phone number');
t.num2.focus();
return false;
}

   var RightListLength = document.isc.elements["RightList[]"].length;
   var Counter;

   if (RightListLength <= 0)
   {
      alert("Please select atleast one Column from the language List.");
      return false;
   }

   for(Counter = 0; Counter < RightListLength; Counter++)
   {
      document.isc.elements["RightList[]"].options[Counter].selected = true;
   }
   return true;
}


