<!--
//==================================================================================
// FILE: class.template.php
// DESC: Templating class (used for shop). Written out of office hours
// AUTH: 22/09/2003 RPN Creation
// MODS: 10/12/2004 RPN Brought code in line with coding standards
//==================================================================================


//==========================================================
// func: formatNumber(price)
// desc: formats a number to british currency
// args: price - the number to be formatted
// retn: the formatted number
//==========================================================
function formatNumber(price)
{
  // check for zero cost
  if (!price)
    output = "0.00";
  else
  {
    // convert to string
    price = price + "";

    // find the separator
    decimal = price.indexOf(".");

    // if no decimal point is specified
    if (decimal != -1)
      pounds = price.substr(0, price.indexOf("."));
    else
      pounds = price + "";

    // work out the number to offset the pounds separators by
    offset = pounds.length % 3;

    // make sure some offset is taken
    if (offset == 0)
      offset = 3;

    // number of separators needed
    number = Math.floor((pounds.length - 1) / 3)

    // add the separators in for the pounds
    for (i = 0; i < number; i ++)
    {
      position = offset + (i * 3) + i;
      pounds   = pounds.substring(0, position) + "," + pounds.substring(position, pounds.length);
    }

    // if no pence are specified
    if (decimal != -1)
    {
      // get the pence
      pence = price.substring(decimal + 1, price.length);

      // work out the pence if needs rounding
      if (pence.length > 2)
        pence = Math.round(pence / (Math.pow(10, pence.length - 2)));

      // turn pence into a string
      pence = pence + "";
    }
    else
      pence = "";

    // catch any pence less than 10
    while (pence.length < 2)
      pence = "0" + pence;

    output = pounds + "." + pence;
  }

  return output;
}


//==================================================================================
// FUNC: updateQuantity
// AUTH: 10/12/2004 RPN
// DESC: updates quantity in box next to each item
// ARGS: form name, and change value
// MODS:
//==================================================================================
function updateQuantity (formName, changeValue)
{
    temp = Number(document.getElementById(formName).quantity.value);
    {

        temp += Number(changeValue);
    }
    if (temp > 0)
    {
        document.getElementById(formName).quantity.value = temp;
    }
}




//==================================================================================
// FUNC: confirmDelete
// AUTH: 14/12/2004 RPN
// DESC: checks to see if user wants to delete a row
// ARGS: none
// RETN: true / false
// MODS:
//==================================================================================
function confirmDelete()
{
    result = confirm("Are you sure you want to delete this variation?");
    return result;
}





//==================================================================================
// FUNC: fullPhoto
// AUTH: 14/12/2004 RPN
// DESC: opens popup window
// ARGS: none
// RETN: true / false
// MODS:
//==================================================================================
function showMap(idLocation)
{
    window.open("viewMap.php?id="+idLocation,"popup_image","width=510,height=510,scrollbars=no,toolbar=no,resizable=no");
}

function resizeWindow()
{
    width  = document.getElementById('map_main').width + 220 ;
    height = document.getElementById('map_main').height ;    
    
    window.resizeTo(width,height+60);
}

function subform(strformname) {
    strformname.submit;
}


function setRadio(buttonname, idx) {
    radioButton = document.getElementById(buttonname);
    radioButton.checked = true;
}



//-->

