//----------------------------------------------------------------------------
// functions used by the menu bar 
// 
// Used by:
//   tmp\menu.cnx
//
//----------------------------------------------------------------------------
function preloadImages() {
  var d=document;
  
  if (d.images) {
    if (!d.p)
      d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments;

    for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0) {
        d.p[j]=new Image; d.p[j++].src=a[i];
      }
  }
}

function swapImgRestore() {
  var i,x,a=document.sr;
  
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
    x.src=x.oSrc;
}

function findObj(n, d) {
  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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById)
    x=d.getElementById(n);
  return x;
}

function swapImage() {
  var i,j=0,x,a=swapImage.arguments;

  document.sr=new Array;

  for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null) {
     document.sr[j++]=x;
     if(!x.oSrc)
       x.oSrc=x.src;
     x.src=a[i+2];
   }
}

//----------------------------------------------------------------------------
// function to determine the cost of the hosting plan and time period chosen
// by a user.
//
// Used by:
//   forms\hosting.cnx
//
// hostingOption - option selected from the hosting Select object. Can be "",
//   "Lite Plan", "Mid Plan", "Plus Plan"
// timeOption - option selected from the time period Select object. Can be
//   "1", "2", "3", "6", "11", "22", "55", "110" The time period Select object
//   has discount functionality built into it, e.g., when a user orders a full
//   year of hosting they only have to pay for 11 months. In order to reflect
//   this discount, the value associated with the 1 year option is 11.
//
// 15 Dec 2002 - Ken Baker
//----------------------------------------------------------------------------
function calculateHostingCost(hostingPlan, TimePeriod, TotalCost) {
  // Retrieve value of Hosting Plan Option
  var plan = hostingPlan.options[hostingPlan.selectedIndex].value;
  // Retrieve value of Time Period Option
  var period = TimePeriod.options[TimePeriod.selectedIndex].value;
//  alert(period);
  var cost = 0;
  TotalCost.disabled=false;
  TotalCost.value = "$" + period*plan;
  TotalCost.disabled=true;
  return;
}

//----------------------------------------------------------------------------
// function to determine the cost of the maintenance plan and time period chosen
// by a user.
//
// Used by:
//   forms\maintain.cnx
//
// maintainOption - option selected from the hosting Select object. Can be "",
//   "A Helping Hand", "Right by Your Side"
// timeOption - option selected from the time period Select object. Can be
//   "1", "2", "3", "6", "11", "22", "55", "110" The time period Select object
//   has discount functionality built into it, e.g., when a user orders a full
//   year of hosting they only have to pay for 11 months. In order to reflect
//   this discount, the value associated with the 1 year option is 11.
//
// 18 Dec 2002 - Ken Baker
//----------------------------------------------------------------------------
function calculateMaintainCost(maintainPlan, TimePeriod, TotalCost) {
  // Retrieve value of Maintain Plan Option
  var plan = maintainPlan.options[maintainPlan.selectedIndex].value;
  // Retrieve value of Time Period Option
  var period = TimePeriod.options[TimePeriod.selectedIndex].value;
//  alert(period);
  var cost = 0;
  TotalCost.disabled=false;
  TotalCost.value = "$" + period*plan;
  TotalCost.disabled=true;
}

//----------------------------------------------------------------------------
// function to check if the given checkbox object has been selected.
//
// Used by:
// 
// 15 Dec 2002 - Ken Baker
//----------------------------------------------------------------------------
function isChecked(object) {
  if (object.checked)
    return true;
  else
    return false;
}

//----------------------------------------------------------------------------
// function to open a window 500 high x 550 wide with the given url
//
// Used by:
//   forms/maintain.cnx
//
// strURL - the url (given as a string) to display in the window being opened.
//
// 18 Dec 2002 - Ken Baker
//----------------------------------------------------------------------------
//function openWindow(strURL) {
//  addWindow = self.open(strURL,'addWindow','height=500,width=550,scrollbars=1,toolbar=1','alwaysRaised=true');
//  addWindow.focus();
//}
function openWindow(strURL) {
  addWindow = self.open(strURL,'addWindow','scrollbars=1,toolbar=0,menubar=0,resizable=1,status=0,location=0,left=30,top=30,width=800,height=523,innerWidth=790,innerHeight=523','alwaysRaised=true');
  if (window.focus) {addWindow.focus()}
}

//----------------------------------------------------------------------------
// function to open the connexis domain name registration page in a window
// 800 wide x 523 high
//
// Used by:
//   content/reg.cphp
//
// 13 Jan 2003 - Ken Baker
//----------------------------------------------------------------------------
function openPricingWindow() {
  addWindow = self.open('http://www.planetdomain.com/connexis/newdnr/pricing.jsp','addWindow','scrollbars=1,toolbar=0,menubar=0,status=0,location=0,left=30,top=30,width=800,height=523,innerWidth=790,innerHeight=523','alwaysRaised=true');
  if (window.focus) {addWindow.focus()}
}
