//<script type="text/javascript">
//<!--
function doit() {
var colours = 0;
var i=0;
while (i<4096)
{
  var j = i;
  var count = 0;
  var k=32;
  while (k!=0)
  {
    if (j & 1) count = count + 1;
    j = j>>>1;
    k = k-1;
  }
  if (count>4) colours = colours+1;
  i = i+1;
}
document.writeln
  (colours + " colours.");
return colours;
}

var temp;

/**
 * debugFunctions.js
 *
 * This file contains a collection of debug functions for javascript.
 *
 * This source file is subject to version 2.1 of the GNU Lesser
 * General Public License (LPGL), found in the file LICENSE that is
 * included with this package, and is also available at
 * http://www.gnu.org/copyleft/lesser.html.
 * @package     Javascript
 *
 * @author      Dieter Raber <dieter@dieterraber.net>
 * @copyright   2004-12-27
 * @version     1.0
 * @license     http://www.gnu.org/copyleft/lesser.html
 *
 */

/**
 * TOC
 *
 * - getObjectProperties
 * - print_ob
 * - alert_ob
 * - window_ob
 *
 * - format_r
 * - print_r
 * - alert_r
 * - window_r
 */

/**
 * showProps
 *
 * Shows the properties of an given object
 *
 * object object
 * return array
 *
 * Use print_ob(), alert_ob() or window_ob() to display the result
 */
function getObjectProperties(item)
{
  var retVal = '';
  for (var prop in item)
  {
    if (item[prop].constructor != Function)
    {
      retVal += prop + ' => ' + item[prop] + "\n";
    }
  }
  return retVal;
}




/**
 * showProps
 *
 * Shows the properties of an given object
 *
 * object object
 * return array
 *
 * Use print_ob(), alert_ob() or window_ob() to display the result
 */
function getUserFunctions()
{
  var retVal = '';
  for (var prop in document)
  {
//    if (document[prop].constructor == Function)
//    {
//      retVal += prop + ' => ' + document[prop] + "\n";
//    }
  }
  return document;
}



/**
 * print_ob(), alert_ob(), window_ob()
 *
 * These three functions are different ways to display the result of getObjectProperties()
 * print_ob uses document.write and can hence only be called onload
 * alert_ob displays the result in an alert box
 * window_ob opens a popup window and writes the results there
 */
function alert_ob(expr)
{
  alert(getObjectProperties(expr))
}

function window_ob(expr)
{
  win = window.open('', 'format','width=400,height=300,left=50,top=50,status,menubar,scrollbars,resizable');
  win.document.open();
  win.document.write('<pre>' + getObjectProperties(expr) + '</pre>');
  win.document.close()
  win.focus();
}

function print_ob(expr)
{
  document.write('<pre>' + getObjectProperties(expr) + '</pre>');
}


/**
 * format_r
 *
 * Returns human-readable information about a variable
 *
 * format_r() returns information about a variable in a way that's readable by humans.
 * If given a string, integer or float, the value itself will be printed.
 * If given an array, values will be presented in a format that shows keys and elements.
 *
 * example:
 *   test = new Array ('foo', 'bar', 'foobar')
 *   format_r(test)
 *   returns: Array
 *            {
 *                 [0] => foo
 *                 [1] => bar
 *                 [3] => foobar
 *            }
 *
 */
function format_r(expr)
{
  var dim    = 0;
  var padVal = '\xA0\xA0\xA0\xA0\xA0';

  switch(typeof expr)
  {
    case 'string':
    case 'number':
      retVal = expr;
      break;
    case 'object':
      retVal = 'Array\n{\n' + outputFormat(expr, dim) + '\n}';
      break;
    default:
      retVal = false;
  }

  function pad(dim)
  {
    padding = '';
    for (i = 0; i < dim; i++)
    {
      padding += padVal;
    }
    return padding;
  }

  function outputFormat(expr, dim)
  {
    var retVal = '';
    for (var key in expr)
    {
        if (typeof expr[key] == 'object' && expr[key].constructor == Array)
        {
          retVal += padVal + pad(dim) + '[' + key + '] => Array\n'
                  + padVal + pad(dim) + '{\n'
                  + outputFormat(expr[key], dim + 1) + padVal + pad(dim) + '}\n';
        }
        else if (expr[key].constructor == Function)
        {
          continue;
        }
        else
        {
          retVal = retVal + padVal + pad(dim) + '[' + key + '] => ' + expr[key] + '\n';
        }
    }
    return retVal;
  }
  return retVal;
}

/**
 * print_r(), alert_r(), window_r()
 *
 * These three functions are just different ways to display the result of format_r()
 * print_r uses document.write and can hence only be called onload
 * alert_r displays the result in an alert box
 * window_r opens a popup window and writes the results there
 */
function alert_r(expr)
{
  alert(format_r(expr))
}

function window_r(expr)
{
  win = window.open('', 'format','width=400,height=300,left=50,top=50,status,menubar,scrollbars,resizable');
  win.document.open();
  win.document.write('<pre>' + format_r(expr) + '</pre>');
  win.document.close()
  win.focus();
}

function print_r(expr)
{
  document.write('<pre>' + format_r(expr) + '</pre>');
}

/////////////////////// Cookie reading and writing ////////////////////////////////////

function writeCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else
    var expires = "";
  document.cookie = name+"="+escape(value)+expires+"; path=/";
}

function writeArrayCookie(name,valueArray,days) {
  writeCookie(name, valueArray.join("|"), days);
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
  }
  return null;
}

function readArrayCookie(name) {
  var cookieArray = readCookie(name);
  if (cookieArray)
    return cookieArray.split("|");
  return null;
}

function eraseCookie(name) {
  writeCookie(name,"",-20*365);
}

//////////////////////////// Navigation Menu handling /////////////////////////////////

function initiate(name) {
  var cookieCount = 0;
  var cookieArray = readArrayCookie(name);
  // try to write a cookie that the shop can read to determine if cookies are enabled
  writeCookie("Cookies","",0);
  if (!cookieArray)
    cookieArray = new Array;
  temp=document.getElementById("containerul");
  for (var o=0;o<temp.getElementsByTagName("li").length;o++) {
    if (temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0) {
      var temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = //"none";
      (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(/minus.png)":"url(/plus.png)"):"url(/plus.png)";
      temp2.onclick=function() {
        showhide(this.parentNode);
        writeNavCookie(name);
      }
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)
      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";
      if (cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }
      cookieCount++;
    }
    else {
      var temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = "none";
      //"url(/page.png)";
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);
    }
  }
}

function showhide(el) {
  el.getElementsByTagName("ul")[0].style.display=
     (el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";
  el.getElementsByTagName("span")[0].style.backgroundImage=//"none"
     (el.getElementsByTagName("ul")[0].style.display=="block")?"url(/minus.png)":"url(/plus.png)";
}

function writeNavCookie(name){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.
  var cookieArray=new Array();
  for (var q=0; q<temp.getElementsByTagName("li").length; q++) {
    if (temp.getElementsByTagName("li")[q].childNodes.length>0) {
      if (temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0) {
        cookieArray[cookieArray.length] = (temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");
      }
    }
  }
  writeArrayCookie(name, cookieArray, 2*365);
}

////////////////////////// Read / Write user details cookie ////////////////////////////

function writeDetailsCookie(detailsArray) {
  writeArrayCookie("details", detailsArray, 2*365);
}

var details;
function updateDetailsCookie()
{
  details[0] = document.clientdetails.Ecom_BillTo_Online_Email.value;
  details[1] = document.clientdetails.Ecom_BillTo_Online_Email_Confirm.value;
  details[2] = document.clientdetails.Ecom_BillTo_Telecom_Phone_Number.value;
  details[3] = document.clientdetails.Ecom_BillTo_Telecom_Phone_Number_Evening.value;
  details[4] = String(document.clientdetails.Ecom_BillTo_Postal_Name_Prefix.options.selectedIndex);
  details[5] = String(document.clientdetails.Ecom_BillTo_Postal_StateProv.options.selectedIndex);
  details[6] = document.clientdetails.Ecom_BillTo_Postal_Name_First.value;
  details[7] = document.clientdetails.Ecom_BillTo_Postal_Name_Last.value;
  details[8] = document.clientdetails.Ecom_BillTo_Postal_Company.value;
  details[9] = document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value;
  details[10] = document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value;
  details[11] = document.clientdetails.Ecom_BillTo_Postal_City.value;
  details[12] = document.clientdetails.Ecom_BillTo_Postal_PostalCode.value;
  details[13] = String(document.clientdetails.Ecom_ShipTo_Postal_Name_Prefix.options.selectedIndex);
  details[14] = String(document.clientdetails.Ecom_ShipTo_Postal_StateProv.options.selectedIndex);
  details[15] = document.clientdetails.Ecom_ShipTo_Postal_Name_First.value;
  details[16] = document.clientdetails.Ecom_ShipTo_Postal_Name_Last.value;
  details[17] = document.clientdetails.Ecom_ShipTo_Postal_Company.value;
  details[18] = document.clientdetails.Ecom_ShipTo_Postal_Street_Line1.value;
  details[19] = document.clientdetails.Ecom_ShipTo_Postal_Street_Line2.value;
  details[20] = document.clientdetails.Ecom_ShipTo_Postal_City.value;
  details[21] = document.clientdetails.Ecom_ShipTo_Postal_PostalCode.value;
  details[22] = document.clientdetails.Ecom_ShipTo_Instructions.value;
  writeDetailsCookie(details);
}

//////////////////////////// other fns //////////////////////////////////////

function checkpostcode(postcode, whatpostcode)
{
  updateDetailsCookie();
  if (postcode=="")
    return true; // allow no postcode
  if (!/^[A-Z]?[A-Z][0-9][A-Z0-9 ]? [0-9][ABD-HJLNP-UW-Z][ABD-HJLNP-UW-Z]$/.test(postcode.toUpperCase()))
  {
    alert(postcode+" is not a valid "+whatpostcode+", please re-enter. \n\n\
Valid postcodes have two parts separated by a space.\n\
The first part must start with a letter and end with a number.\n\
The second part must start with a number and end with a letter.\n\
     ");
    return false;
  }
  return true;
}

// email

function checkemail (strng, whatemail) {
  updateDetailsCookie();
  if (strng == "") {
    alert("You have not supplied your "+whatemail+".\n\
We need this information to process your order.\n");
    return false;
  }

  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(strng))) { 
    alert("You have not supplied a valid "+whatemail+",\n\
it should be something like me@place.com\n\
please re-enter.\n");
    return false;
  }
  else {
    //test email for illegal characters
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]\|]/
    if (strng.match(illegalChars)) {
      alert("Your "+whatemail+" contains unacceptable charaters,\n\
please re-enter.\n");
      return false;
    }
  }
  return true;    
}

function checkconfirmationemail (email, confirmation) {
  if (!checkemail(confirmation, "Confirmation E-mail address"))
    return false;
  if (email != confirmation)
  {
    alert("Your Confirmation E-mail address does not match your entered E-mail address,\n\
please correct it.\n");
    return false;
  }
  return true;
}

// phone number - strip out delimiters and check for 11 digits

function checkphone (strng, whatphone) {
  updateDetailsCookie();
  if (strng != "") {
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
      alert("Your "+whatphone+" phone number contains unacceptable characters,\n\
please re-enter.\n");
      return false;
    }
    if (stripped.length < 11) {
      alert("Your "+whatphone+"phone number is the wrong length.\n\
Make sure you included an area code,\n\
please re-enter.\n");
      return false;
    }
  } 
  return true;
}

// a persons first or last name
function checkname (strng, whatname, musthavecontent) {
  updateDetailsCookie();
  if (strng=='') {
    if (musthavecontent==true) {
      alert("You have not supplied a "+whatname+" name.\n\
We need this information to process your order.\n");
      return false;
    }
    return true;
  }

  var illegalChars = /[0-9\(\)\,\-\'\`\¬\!\"\£\$\%\^\&\*\_\+\=\{\}\[\]\:\;\@\~\#\<\>\?\/\|\\]/i; // allow a-z and spaces
  if (illegalChars.test(strng)) {
    alert(whatname+" name can only contain the letters A-Z and spaces,\n\
please re-enter.\n");
    return false;
  }
  return true;
}       

function checkaddress (strng, whatname, musthavecontent) {
  updateDetailsCookie();
  if (strng=='') {
    if (musthavecontent==true) {
      alert("You have not supplied the "+whatname+".\n\
We need this information to process your order.\n\
       ");
      return false;
    }
    return true;
  }

  var illegalChars = /[\`\¬\!\"\£\$\%\^\&\*\_\+\=\{\}\[\]\:\;\@\~\#\<\>\?\/\|\\]/i; // allow a-z0-9(),-' and spaces
  if (illegalChars.test(strng)) {
    alert("The "+whatname+" can only contain the characters\n\
A-Z,0-9,(),comma,-,space or single quote, please re-enter.\n");
    return false;
  }
  return true;
}

function checktext (strng) {
  updateDetailsCookie();
  if (strng=='') {
    return true;
  }

  var illegalChars = /[\&\|]/i; // allow all except = & and |
  if (illegalChars.test(strng)) {
    alert("The "+whatname+" can not contain a '&', '=' or a '|', please re-enter.\n");
    return false;
  }
  return true;
}

function checkSelect () {
  updateDetailsCookie();
  return true;
}

function checkalldetails()
{
  if (!checkemail(document.clientdetails.Ecom_BillTo_Online_Email.value, "E-mail address")) return false;
  if (!checkconfirmationemail(document.clientdetails.Ecom_BillTo_Online_Email.value, document.clientdetails.Ecom_BillTo_Online_Email_Confirm.value)) return false;
  if (!checkphone(document.clientdetails.Ecom_BillTo_Telecom_Phone_Number.value, "Daytime")) return false;
  if (!checkphone(document.clientdetails.Ecom_BillTo_Telecom_Phone_Number_Evening.value, "Evening")) return false;
  if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_First.value, "Billing First", false)) return false;
  if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_Last.value, "Billing Last", true)) return false;
  if (!checktext(document.clientdetails.Ecom_BillTo_Postal_Company.value, "Billing Company Name")) return false;
  if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value, "First line of billing address", true)) return false;
  if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value, "Second line of billing address", false)) return false;
  if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_City.value, "Billing City", true)) return false;
  if (!checkpostcode(document.clientdetails.Ecom_BillTo_Postal_PostalCode.value, "Billing post code")) return false;
  if (!checkname(document.clientdetails.Ecom_ShipTo_Postal_Name_First.value, "Delivery First", false)) return false;
  if (!checkname(document.clientdetails.Ecom_ShipTo_Postal_Name_Last.value, "Delivery Last", true)) return false;
  if (!checktext(document.clientdetails.Ecom_ShipTo_Postal_Company.value, "Delivery Company Name")) return false;
  if (!checkaddress(document.clientdetails.Ecom_ShipTo_Postal_Street_Line1.value, "First line of delivery address", true)) return false;
  if (!checkaddress(document.clientdetails.Ecom_ShipTo_Postal_Street_Line2.value, "Second line of delivery address", false)) return false;
  if (!checkaddress(document.clientdetails.Ecom_ShipTo_Postal_City.value, "Delivery City", true)) return false;
  if (!checkpostcode(document.clientdetails.Ecom_ShipTo_Postal_PostalCode.value, "Delivery post code")) return false;
  if (!checktext(document.clientdetails.Ecom_ShipTo_Instructions.value, "Delivery Instructions")) return false;
  //var CurrentTime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_GMT" -->' //SSI method of getting server date
  //var CurrentTime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' //SSI method of getting server date
  //var PHPcurrentTime = '<?php  print time()?>' //PHP method of getting server date
  //var currentDate = new Date(CurrentTime);
  //document.clientdetails.timenow.value = CurrentTime+''; //currentDate.getTime()+'';

  var currentDate = new Date();

  document.clientdetails.timenow.value = currentDate.getTime()+'';
  // details verified, now generate the encrypted data and write into document.clientdetails.Crypt
  return true;
}

//  <select type="hidden" id='Ecom_ShipTo_Postal_Name_Prefix' name='Ecom_ShipTo_Postal_Name_Prefix'>
//    <option selected>Mr</option>
//    <option>Mrs</option>
//    <option>Ms</option>
//    <option>Miss</option>
//    <option>Dr</option>
//    <option>Mr and Mrs</option>
//    <option>Lord</option>
//    <option>Lady</option>
//    <option>Sir</option>
//    <option></option>
//  </select>

function getStateProv(index)
{
  switch (index) {
  case 0: 
    return ("England");
  case 1: 
    return ("N Ireland");
  case 2: 
    return ("Scotland");
  case 3: 
    return ("Wales");
  default : return ("Unknown");
  }
}

function getPersonTitle(index)
{
  switch (index) {
  case 0: 
    return ("Mr");
  case 1: 
    return ("Mrs");
  case 2: 
    return ("Ms");
  case 3: 
    return ("Miss");
  case 4: 
    return ("Dr");
  case 5: 
    return ("Mr and Mrs");
  case 6: 
    return ("Lord");
  case 7: 
    return ("Lady");
  case 8: 
    return ("Sir");
  default : return ("");
  }
}


function initialiseDetails2()
{
  details = readArrayCookie("details");
  if (!details)
  {
    details = new Array("","","","","0","0","","","","","","","","0","0","","","","","","","","");
    writeDetailsCookie(details);
  }
  document.clientdetails.Ecom_BillTo_Online_Email.value = details[0];
  document.clientdetails.Ecom_BillTo_Online_Email_Confirm.value = details[1];
  document.clientdetails.Ecom_BillTo_Telecom_Phone_Number.value = details[2];
  document.clientdetails.Ecom_BillTo_Telecom_Phone_Number_Evening.value = details[3];
  document.clientdetails.Ecom_BillTo_Postal_Name_Prefix.value = getPersonTitle(parseInt(details[4]));
  document.clientdetails.Ecom_BillTo_Postal_StateProv.value = getStateProv(parseInt(details[5]));
  document.clientdetails.Ecom_BillTo_Postal_Name_First.value = details[6];
  document.clientdetails.Ecom_BillTo_Postal_Name_Last.value = details[7];
  document.clientdetails.Ecom_BillTo_Postal_Company.value = details[8];
  document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value = details[9];
  document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value = details[10];
  document.clientdetails.Ecom_BillTo_Postal_City.value = details[11];
  document.clientdetails.Ecom_BillTo_Postal_PostalCode.value = details[12];
  document.clientdetails.Ecom_ShipTo_Postal_Name_Prefix.value = getPersonTitle(parseInt(details[13]));
  document.clientdetails.Ecom_ShipTo_Postal_StateProv.value = getStateProv(parseInt(details[14]));
  document.clientdetails.Ecom_ShipTo_Postal_Name_First.value = details[15];
  document.clientdetails.Ecom_ShipTo_Postal_Name_Last.value = details[16];
  document.clientdetails.Ecom_ShipTo_Postal_Company.value = details[17];
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line1.value = details[18];
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line2.value = details[19];
  document.clientdetails.Ecom_ShipTo_Postal_City.value = details[20];
  document.clientdetails.Ecom_ShipTo_Postal_PostalCode.value = details[21];
  document.clientdetails.Ecom_ShipTo_Instructions.value = details[22];
}

function initialiseDetails()
{
  details = readArrayCookie("details");
  if (!details)
  {
    details = new Array("","","","","0","0","","","","","","","","0","0","","","","","","","","");
    writeDetailsCookie(details);
  }
  document.clientdetails.Ecom_BillTo_Online_Email.value = details[0];
  document.clientdetails.Ecom_BillTo_Online_Email_Confirm.value = details[1];
  document.clientdetails.Ecom_BillTo_Telecom_Phone_Number.value = details[2];
  document.clientdetails.Ecom_BillTo_Telecom_Phone_Number_Evening.value = details[3];
  document.clientdetails.Ecom_BillTo_Postal_Name_Prefix.options.selectedIndex = parseInt(details[4]);
  document.clientdetails.Ecom_BillTo_Postal_StateProv.options.selectedIndex = parseInt(details[5]);
  document.clientdetails.Ecom_BillTo_Postal_Name_First.value = details[6];
  document.clientdetails.Ecom_BillTo_Postal_Name_Last.value = details[7];
  document.clientdetails.Ecom_BillTo_Postal_Company.value = details[8];
  document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value = details[9];
  document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value = details[10];
  document.clientdetails.Ecom_BillTo_Postal_City.value = details[11];
  document.clientdetails.Ecom_BillTo_Postal_PostalCode.value = details[12];
  document.clientdetails.Ecom_ShipTo_Postal_Name_Prefix.options.selectedIndex = parseInt(details[13]);
  document.clientdetails.Ecom_ShipTo_Postal_StateProv.options.selectedIndex = parseInt(details[14]);
  document.clientdetails.Ecom_ShipTo_Postal_Name_First.value = details[15];
  document.clientdetails.Ecom_ShipTo_Postal_Name_Last.value = details[16];
  document.clientdetails.Ecom_ShipTo_Postal_Company.value = details[17];
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line1.value = details[18];
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line2.value = details[19];
  document.clientdetails.Ecom_ShipTo_Postal_City.value = details[20];
  document.clientdetails.Ecom_ShipTo_Postal_PostalCode.value = details[21];
  document.clientdetails.Ecom_ShipTo_Instructions.value = details[22];
}

function clearcontact()
{
  document.clientdetails.Ecom_BillTo_Online_Email.value = '';
  document.clientdetails.Ecom_BillTo_Online_Email_Confirm.value = '';
  document.clientdetails.Ecom_BillTo_Telecom_Phone_Number.value = '';
  document.clientdetails.Ecom_BillTo_Telecom_Phone_Number_Evening.value = '';
  details[0] = '';
  details[1] = '';
  details[2] = '';
  details[3] = '';
  writeDetailsCookie(details);
}

function clearbilling()
{
  document.clientdetails.Ecom_BillTo_Postal_Name_Prefix.options.selectedIndex = 0;
  document.clientdetails.Ecom_BillTo_Postal_StateProv.options.selectedIndex = 0;
  document.clientdetails.Ecom_BillTo_Postal_Name_First.value = '';
  document.clientdetails.Ecom_BillTo_Postal_Name_Last.value = '';
  document.clientdetails.Ecom_BillTo_Postal_Company.value = '';
  document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value = '';
  document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value = '';
  document.clientdetails.Ecom_BillTo_Postal_City.value = '';
  document.clientdetails.Ecom_BillTo_Postal_PostalCode.value = '';
  details[4] = '0';
  details[5] = '0';
  details[6] = '';
  details[7] = '';
  details[8] = '';
  details[9] = '';
  details[10] = '';
  details[11] = '';
  details[12] = '';
  writeDetailsCookie(details);
}

function cleardelivery()
{
  document.clientdetails.Ecom_ShipTo_Postal_Name_Prefix.options.selectedIndex = 0;
  document.clientdetails.Ecom_ShipTo_Postal_StateProv.options.selectedIndex = 0;
  document.clientdetails.Ecom_ShipTo_Postal_Name_First.value = '';
  document.clientdetails.Ecom_ShipTo_Postal_Name_Last.value = '';
  document.clientdetails.Ecom_ShipTo_Postal_Company.value = '';
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line1.value = '';
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line2.value = '';
  document.clientdetails.Ecom_ShipTo_Postal_City.value = '';
  document.clientdetails.Ecom_ShipTo_Postal_PostalCode.value = '';
  document.clientdetails.Ecom_ShipTo_Instructions.value = '';
  details[13] = '0';
  details[14] = '0';
  details[15] = '';
  details[16] = '';
  details[17] = '';
  details[18] = '';
  details[19] = '';
  details[20] = '';
  details[21] = '';
  details[22] = '';
  writeDetailsCookie(details);
}

function transferdetails()
{
  document.clientdetails.Ecom_ShipTo_Postal_Name_Prefix.options.selectedIndex = document.clientdetails.Ecom_BillTo_Postal_Name_Prefix.options.selectedIndex;
  document.clientdetails.Ecom_ShipTo_Postal_StateProv.options.selectedIndex = document.clientdetails.Ecom_BillTo_Postal_StateProv.options.selectedIndex;
  document.clientdetails.Ecom_ShipTo_Postal_Name_First.value = document.clientdetails.Ecom_BillTo_Postal_Name_First.value;
  document.clientdetails.Ecom_ShipTo_Postal_Name_Last.value = document.clientdetails.Ecom_BillTo_Postal_Name_Last.value;
  document.clientdetails.Ecom_ShipTo_Postal_Company.value = document.clientdetails.Ecom_BillTo_Postal_Company.value;
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line1.value = document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value;
  document.clientdetails.Ecom_ShipTo_Postal_Street_Line2.value = document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value;
  document.clientdetails.Ecom_ShipTo_Postal_City.value = document.clientdetails.Ecom_BillTo_Postal_City.value;
  document.clientdetails.Ecom_ShipTo_Postal_PostalCode.value = document.clientdetails.Ecom_BillTo_Postal_PostalCode.value;
  details[13] = details[4];
  details[14] = details[5];
  details[15] = details[6];
  details[16] = details[7];
  details[17] = details[8];
  details[18] = details[9];
  details[19] = details[10];
  details[20] = details[11];
  details[21] = details[12];
  writeDetailsCookie(details);
}

// Image Flipper -  Cameron Gregory - http://www.bloke.com/
// http://www.bloke.com/javascript/Flipper/
// http://www.bloke.com/javascript/Flipper/link.html

function setOpacity(r, value)
{
  r.style.opacity = value/10;
  r.style.filter = 'alpha(opacity=' + value*10 + ')';
}

var fadedpic;
function changeImage(r,i,speed)
{
  r.src=i;
  fadedpic = document.getElementById('flip');
  for (var i=0;i<=10;i++)
    setTimeout('setOpacity(fadedpic,'+i+')',(speed/30)*i);
  for (i=10;i>=0;i--)
    setTimeout('setOpacity(fadedpic,'+i+')',(2*speed/3)+((speed/30)*(10-i)));
}

function goFlipURL()
{
  document.location = urlSet[currentFlip];
}

function flipFlipper(imageSet,textSet,speed)
{
  currentFlip ++;
  if (currentFlip == imageSet.length)
    currentFlip=0;
  changeImage(document.flip,imageSet[currentFlip],speed);
  if (textSet.length>0)
    document.getElementById('pictext').innerHTML=textSet[currentFlip];
  setTimeout("flipFlipper(imageSet,textSet,speed)", speed)
}



function FlipperLong(width,height,s,images,texts,hoverText,ignoredurls)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 speed = s;
 si = 0;
 cc=0;
 imageSet = new Array();
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ') {
      imageSet[cc] = "watermark.php?src="+images.substring(si,i);
      cc++;
      si=i+1;
    }
  }

  textSet = new Array();
  cc = 0;
  si = 0;
  ei = texts.length;
  for (i=1;i<ei;i++) {
    if (texts.charAt(i) == '|') {
      textSet[cc] = texts.substring(si,i);
      cc++;
      si=i+1;
    }
  }

  currentFlip = 0;
   
  document.write("<a title=\""+hoverText+"\"><img name='flip' id='flip'");
  if (width >0)
    document.write("width="+width);
  if (height >0)
    document.write(" height=" +height);
  document.writeln(" src=watermark.php?src=" +imageSet[0]+ "></a>");
  changeImage(document.flip,imageSet[currentFlip], speed);

  setTimeout("flipFlipper(imageSet,textSet,speed)", speed)
}

function Flipper(width,height,images,texts,hoverText)
{
  speed=5000;
  FlipperLong(width,height,speed,images,texts,hoverText);
}


function FlipperLinkLong(width,height,s,images,hoverText,urls)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 speed = s;
 imageSet = new Array();
 urlSet = new Array();

 si = 0; 
 ci=0;
 cc=0;
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ') {
      imageSet[cc]= images.substring(si,i);
      cc++;
      si=i+1;
      }
    }

 si = 0; 
 ci=0;
 ccu=0;
 ei = urls.length;
  for (i=1;i<ei;i++) {
    if (urls.charAt(i) == ' ') {
      urlSet[ccu]= urls.substring(si,i);
      ccu++;
      si=i+1;
      }
    }

  currentFlip = 0;
   
 document.write("<a title=\""+hoverText+"\" href=\"javascript:goFlipURL()\"><img name='flip'");
 if (width >0)
    document.write("width="+width);
 if (height >0)
    document.write(" height=" +height);
  document.writeln(" src=watermark.php?src=" +imageSet[0]+ "></a>");

  setTimeout("flipFlipper(imageSet,speed)", speed)
}

function FlipperLink(width,height,images,hoverText,urls)
{
  speed=1000;
  FlipperLinkLong(width,height,speed,images,hoverText,urls);
}

function changeText(r,i)
{
document.getElementById(r).innerHTML=i;
}

function flipTextFlipper(textSet,speed)
{
  currentTextFlip ++;
  if (currentTextFlip == textSet.length)
    currentTextFlip=0;
  changeText('pictext',textSet[currentTextFlip]);
  setTimeout("flipTextFlipper(textSet,speed)", speed)
}

function TextFlipperLong(s,text)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 speed = s;
 si = 0; 
 ci=0;
 cc=0;
 textSet = new Array();
 ei = text.length;
  for (i=1;i<ei;i++) {
    if (text.charAt(i) == '|') {
      textSet[cc] = text.substring(si,i);
      cc++;
      si=i+1;
    }
  }
  currentTextFlip = 0;
   
  document.write("<a id='pictext'>");
//  document.writeln(textSet[currentTextFlip]+"</a>");
  document.writeln(textSet[currentTextFlip]+"</a>");

  setTimeout("flipTextFlipper(textSet,speed)", speed)
}

function TextFlipper(text)
{
  speed=5000;
  FlipperLong(text);
}

function OpenPicture(pic,title,css,w,h,extra)
{
  border = 4;
  cellspacing = 2;
  hspacing = (border*2)+(cellspacing*2);  // 2 borders and one cell wide (so 2 lots of cell spacing)
  vspacing = (border*2)+(cellspacing*3);  // 2 borders and two cells deep (so 3 lots of cell spacing)
  tablesurround = 16*2;
  vtextcell = 24;
  htable = w+hspacing;
  vtable = h+vspacing+vtextcell;
  hwindow = htable+tablesurround;
  vwindow = vtable+tablesurround;

  OpenWin = window.open("/photo.htm", "PicWin", "height="+vwindow+",width="+hwindow+",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,status=no,directories=no,copyhistory=no,channelmode=no");
  OpenWin.document.writeln('<html><head><title>'+title+'</title>');
  if (css.length>0) {
    OpenWin.document.writeln('<link rel="stylesheet" href="'+css+'">');
  }
  OpenWin.document.writeln('</head><body class="pagebody">');
  OpenWin.document.writeln('<table class="photoborder" frame="border" rules="all" border="'+border+'" cellpadding="0" cellspacing="'+cellspacing+'" width="'+htable+'" height="'+vtable+'" align="center" valign="middle">');
  OpenWin.document.writeln('<tr><td align="center"><img  width="'+w+'" height="'+h+'" src="watermark.php?src='+pic+'">');
  OpenWin.document.writeln('</td></tr><tr><td align="center" height="'+vtextcell+'">');
  OpenWin.document.writeln(title+' '+extra);
  OpenWin.document.writeln('</td></tr>');
  OpenWin.document.writeln('</table>');
  OpenWin.document.writeln('</body></html>');
  OpenWin.document.close();

  if (window.focus) { OpenWin.focus() }

  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      OpenWin.outerWidth=w;
      OpenWin.outerHeight=h;
    }
    else OpenWin.resizeTo(hwindow+4+4,vwindow+26+26+26); // 4 is for 2 window borders and 26 is for Header, IE7about, and Footer bars
  }
  else  OpenWin.resizeTo(hwindow+4+4,vwindow+26+26); // 4 is for 2 window borders and 26 is for Header and Footer bars
}

function OpenWeddingPicture(pic,title,css,w,h,extra)
{
  border = 4;
  cellspacing = 2;
  hspacing = (border*2)+(cellspacing*2);  // 2 borders and one cell wide (so 2 lots of cell spacing)
  vspacing = (border*2)+(cellspacing*3);  // 2 borders and two cells deep (so 3 lots of cell spacing)
  tablesurround = 16*2;
  vtextcell = 24;
  htable = w+hspacing;
  vtable = h+vspacing+vtextcell;
  hwindow = htable+tablesurround;
  vwindow = vtable+tablesurround;

  OpenWin = window.open("/photo.htm", "PicWin", "height="+vwindow+",width="+hwindow+",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,status=no,directories=no,copyhistory=no,channelmode=no");
  OpenWin.document.writeln('<html><head><title>'+'Large photo'+'</title>');
  if (css.length>0) {
    OpenWin.document.writeln('<link rel="stylesheet" href="'+css+'">');
  }
  OpenWin.document.writeln('</head><body class="weddingpagebody">');
  OpenWin.document.writeln('<table class="weddingphotoborder" frame="border" rules="all" border="'+border+'" cellpadding="0" cellspacing="'+cellspacing+'" width="'+htable+'" height="'+vtable+'" align="center" valign="middle">');
  OpenWin.document.writeln('<tr><td align="center"><img  width="'+w+'" height="'+h+'" src="watermark.php?src='+pic+'">');
  OpenWin.document.writeln('</td></tr>');
  OpenWin.document.writeln('<tr><td align="center" height="'+vtextcell+'">');
  OpenWin.document.writeln(title+' '+extra);
  OpenWin.document.writeln('</td></tr>');
  OpenWin.document.writeln('</table>');
  OpenWin.document.writeln('</body></html>');
  OpenWin.document.close();

  if (window.focus) { OpenWin.focus() }

  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      OpenWin.outerWidth=w;
      OpenWin.outerHeight=h;
    }
    else OpenWin.resizeTo(hwindow+4+4,vwindow+26+26+26); // 4 is for 2 window borders and 26 is for Header, IE7about, and Footer bars
  }
  else  OpenWin.resizeTo(hwindow+4+4,vwindow+26+26); // 4 is for 2 window borders and 26 is for Header and Footer bars
}

//-->
//</script>
