function getSelectBoxOption (ArrayName, BoxObj, DefaultValue)
{

   if ( (typeof (ArrayName) == "undefined") || (typeof (BoxObj) == "undefined") )
   {

      return false;

   }

   for (var i = BoxObj.options.length-1 ; i >= 0 ; i--)
   {

       BoxObj.options[i] = null;

   }

   for (var i = 0 ; i < ArrayName.length ; i++)
   {

       BoxObj.options[i] = new Option(ArrayName[i].text, ArrayName[i].value);

       if (ArrayName[i].value == DefaultValue)
       {

          BoxObj.options[i].selected = true;

       }

   }

}


function getPostcode (PostcodeArray, CityVar, AreaVar)
{

   if (typeof (PostcodeArray) == "undefined")
   {

      return "";

   }

   return PostcodeArray[CityVar][AreaVar];

}


function redirect (ArrayName, Obj, SelectVar)
{

   if ( (typeof (Obj) == "undefined") || (typeof (ArrayName) == "undefined") )
   {

      return false;

   }

   for (var i = Obj.options.length-1 ; i >= 0 ; i--)
   {

       Obj.options[i] = null;

   }

   for (var i = 0 ; i < ArrayName.length ; i++)
   {

       Obj.options[i] = new Option(ArrayName[i].text, ArrayName[i].value);

       if (ArrayName[i].value == SelectVar)
       {

          Obj.options[i].selected = true;

       }

   }

}


function setCheckBox (FormObj, CheckboxName, Logic)
{

   var cbs = FormObj.elements[CheckboxName];

   if (typeof (cbs) != "undefined")
   {

      if (typeof (cbs.length) == "undefined")
      {

         cbs.checked = Logic;

      }

      else
      {

         for (var i = 0 ; i < cbs.length ; i++)
         {

             cbs[i].checked = Logic;

         }

      }

   }

}


function OpenPopupWindow (WindowUrl, WindowName, WindowWidth, WindowHeight, WindowTop, WindowLeft, WindowStatus, WindowScrollbars)
{

   WindowName = ( ( typeof (WindowName) == "undefined") || (WindowName == "") ) ? "PopupWindow" : WindowName;
   WindowWidth = ( (typeof (WindowWidth) == "undefined") || (WindowWidth == "") ) ? 0 : WindowWidth;
   WindowHeight = ( (typeof (WindowHeight) == "undefined") || (WindowHeight == "") ) ? 0 : WindowHeight;
   WindowTop = ( (typeof (WindowTop) == "undefined") || (WindowTop == "") ) ? ( (eval (WindowHeight) == 0) ? 0 : (((screen.availHeight - WindowHeight) - ((screen.availHeight - WindowHeight) % 2)) / 2) ) : WindowTop;
   WindowLeft = ( (typeof (WindowLeft) == "undefined") || (WindowLeft == "") ) ? ( (eval (WindowWidth) == 0) ? 0 : (((screen.availWidth - WindowWidth) - ((screen.availWidth - WindowWidth) % 2)) / 2) ) : WindowLeft;
   WindowStatus = ( (typeof (WindowStatus) == "undefined") || (WindowStatus == "") ) ? "" : WindowStatus;
   WindowScrollbars = ( (typeof (WindowScrollbars) == "undefined") || (WindowScrollbars == "") ) ? "" : WindowScrollbars;

   var WindowConfig = "";

   WindowConfig = ( (eval (WindowWidth) == 0) ? "" : "width=" + eval (WindowWidth) + "px" );
   WindowConfig += ( (eval (WindowHeight) == 0) ? "" : ( (WindowConfig == "") ? "" : ", " ) + "height=" + eval (WindowHeight) + "px" );
   WindowConfig += ( (WindowConfig == "") ? "" : ", " ) + ( (eval (WindowTop) == 0) ? "top=" + ((screen.availHeight - (screen.availHeight % 2)) / 2) + "px" : "top=" + eval (WindowTop) + "px" );
   WindowConfig += ( (eval (WindowLeft) == 0) ? "" : ( (WindowConfig == "") ? "" : ", " ) + "left=" + eval (WindowLeft) + "px" );
   WindowConfig += ( (WindowStatus == "") ? "" : ( (WindowConfig == "") ? "" : ", " ) + "status=" + WindowStatus );
   WindowConfig += ( (WindowScrollbars == "") ? "" : ( (WindowConfig == "") ? "" : ", " ) + "scrollbars=" + WindowScrollbars );

   window.open (WindowUrl, WindowName, WindowConfig);

}

function changWinSize (imageId)
{

   if (document.getElementById(imageId))
   {

      var winWidth = ( ( typeof (window.outerWidth) == "undefined") ? (document.body.clientWidth + 27) : window.outerWidth );
      var winHeight = document.getElementById(imageId).height + ( ( typeof (window.outerWidth) == "undefined") ? 190 : 185 );
      winHeight = ( (winHeight > 653) ? 659 : winHeight );
      window.resizeTo (winWidth, winHeight);

   }

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_preloadImages() { //v3.0  document.MM_p[5].src
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function changeImg (DivName, ImgSrc, ImgWidth, ImgHeight, ImgTitle, ImgAlt)
{

   if (document.getElementById(DivName))
   {

      document.getElementById(DivName).innerHTML = ('<img src="' + ImgSrc + '" width="' + ImgWidth + '" height="' + ImgHeight + '" border="0" title="' + ImgTitle + '" alt="' + ImgAlt + '" />');

   }

}


function changePicItem (IdName, ExceptionId)
{

   var i = 0;

   while (document.getElementById(IdName + "[" + i + "]"))
   {

       if (document.getElementById(IdName + "[" + i + "]"))
       {

          if ( i == ExceptionId)
          {

             document.getElementById(IdName + "[" + i + "]").style.display = "none";

          }

          else
          {

             document.getElementById(IdName + "[" + i + "]").style.display = "";

          }

       }

       i++;

   }

}


function changeText (IdName, TextString)
{

   if ( (document.getElementById(IdName)) && (typeof (TextString) != "undefined") && (TextString != "") )
   {
      document.getElementById(IdName).innerHTML = TextString;

   }

}

var PriceMenuOpen = false;
var OnPriceMenu = false;

function openPriceMenu (DivId)
{

   if (document.getElementById(DivId))
   {

      document.getElementById(DivId).style.display = "";
      PriceMenuOpen = true;

   }

}

function closePriceMenu (DivId, DelayTime)
{

   if (document.getElementById(DivId))
   {

      if ( (typeof (DelayTime) != "undefined") )
      {

         //setTimeout ('document.getElementById("' + DivId + '").style.display = "none"', DelayTime);
         setTimeout ('closePriceMenu("' + DivId + '")', DelayTime);
         //alert (DelayTime);

      }

      else if ( (PriceMenuOpen) && (!OnPriceMenu) )
      {

         document.getElementById(DivId).style.display = "none";
         PriceMenuOpen = false;

      }


      //document.getElementById(DivId).style.display = "none";

   }

}

function checkPriceMenu (DivId)
{

   if (document.getElementById(DivId))
   {

      if (PriceMenuOpen)
      {

         //setTimeout ('closePriceMenu ("' + DivId + '")', 500);
         closePriceMenu (DivId);

      }

      else
      {

         var clientOldHeight = document.body.clientHeight;
         openPriceMenu (DivId);
         var clientNewHeight = document.body.clientHeight;

         if (clientOldHeight != clientNewHeight)
         {

            scrollTo (0, 260);

         }
         //OnPriceMenu = true;

      }

      OnPriceMenu = false;

   }

}