// All contents are Copyright The True Solution Co. Ltd. 2005
// email enquiries@absolutepages.com

var mywin = null;
var closewin = "'javascript:window.close()'";
var mycompwin = null;
var closeMsg = "'Click to close'";

var numRevImgs = 0;
var currRevImg = 0;

//
// This holds the data for the review list.
//
var reviewList = new Array(200);
for (i = 0; i < 200; i++)
{
  reviewList[i] = new Array(2);
  reviewList[i][0] = "";
  reviewList[i][1] = -1;
}    

function thisIs()
{
  agent = navigator.userAgent.toLowerCase();

  this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
  this.ie = (agent.indexOf("msie") != -1);
}

var currentData = "";

function getCurrentData()
{
  return currentData;
}

function showData (dataType)
{
  var elName;

  if (dataType == "CVDATA")
  {
    cvElement = document.getElementById("CVFDATA");
    cvElement.src = "lizcv.htm";
  }

  if (dataType == "INFODATA")
  {
    cvElement = document.getElementById("CVFDATA");
    cvElement.src = "info.htm";
  }

  if (dataType == "INFODATA") elName = "CVDATA"; else elName = dataType;

  if ((currentData != "") && (currentData != elName)) closeData(currentData);

  theElement = document.getElementById(elName);
  theElement.scrollTop = 0;
  theElement.style.visibility = "visible";

  currentData = dataType;
}

function closeData (dataType)
{
  var elName;

  if (dataType == "CVDATA")
  {
    cvElement = document.getElementById("CVFDATA");
    cvElement.src = "";
  }

  if (dataType == "INFODATA")
  {
    cvElement = document.getElementById("CVFDATA");
    cvElement.src = "";
  }

  if (currentData != "")
  {
    if (dataType == "INFODATA") elName = "CVDATA"; else elName = dataType;
    theElement = document.getElementById(elName);
    theElement.style.visibility = "hidden";

    currentData = "";
  }
}

function getCookieValue(cookieName)
{
  var cookieValue = document.cookie;
  var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
  
  if (cookieStartsAt == -1)
  {
    cookieStartsAt = cookieValue.indexOf(cookieName + "=");
  }
  
  if (cookieStartsAt == -1)
  {
    cookieValue = "";
  }
  else
  {
    cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
    var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
    if (cookieEndsAt == -1)
    {
      cookieEndsAt = cookieValue.length;
    }
    cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));    
  }
  return cookieValue;
}

function open_window(url,w,h)
{
  close_window();
  mywin=window.open
  ("","win","TOOLBAR=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=0,top=0,width="+w+",height="+h);
  mywin.document.write("<HTML><HEAD><TITLE>LIZ TYLER JEWELLERY</TITLE><STYLE TYPE='text/css'>body {color: #FFFFFF; background-color: #0000FF; background-image: url('images/waitingsign.gif'); background-repeat: no-repeat; background-position: center; font-family: sans-serif; text-align: center;} IMG {border-color: #0000FF; width: 443px; height: 443px;}</STYLE></HEAD><BODY><CENTER><B>CLICK ON IMAGE TO CLOSE</B></CENTER><BR><A HREF="+closewin+"><IMG SRC='"+url+"' ALT="+closeMsg+"></A></BODY></HTML>");
  mywin.focus();
}

function close_window()
{
  close_comp_window();

  if (!(mywin==null))
  {
    if (!(mywin.closed)) mywin.close();
    mywin = null;
  }
}

function open_comp_window(url1,url2,w,h)
{
  close_comp_window();
  mycompwin=window.open
  ("","win","TOOLBAR=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=0,top=0,width="+w+",height="+h);
  mycompwin.document.write("<HTML><HEAD><TITLE>LIZ TYLER JEWELLERY</TITLE><STYLE TYPE='text/css'>body {color: #FFFFFF; background-color: #0000FF; font-family: sans-serif;} IMG {border-color: #0000FF; width: 443px; height: 443px;}</STYLE></HEAD><BODY><CENTER><B>CLICK ON EITHER IMAGE TO CLOSE</B><BR>&nbsp;<BR><A HREF="+closewin+"><IMG SRC='"+url1+"' ALT="+closeMsg+"></A>&nbsp;&nbsp;<A HREF="+closewin+"><IMG SRC='"+url2+"' ALT="+closeMsg+"></A></CENTER></BODY></HTML>");
  mycompwin.focus();
}

function close_comp_window()
{
  if (!(mycompwin==null))
  {
    if (!(mycompwin.closed)) mycompwin.close();
    mycompwin = null;
  }
}

function handleImage ()
{

  theHrefs = document.getElementsByTagName("A");

  //
  // Display the thumbnail and change href
  //
  switch (reviewList[currRevImg][0])
  {
    case 'sets' :

      theHrefs.item(12).href = setsUrls[0][((reviewList[currRevImg][1]) - 1)];
      document.images[2].src = setsSels[0][((reviewList[currRevImg][1]) - 1)];
      break;

    case 'col' :
    
      theHrefs.item(12).href = colUrls[0][((reviewList[currRevImg][1]) - 1)];
      document.images[2].src = colSels[0][((reviewList[currRevImg][1]) - 1)];
      break;

    case 'diam' :
    
      theHrefs.item(12).href = diamUrls[0][((reviewList[currRevImg][1]) - 1)];
      document.images[2].src = diamSels[0][((reviewList[currRevImg][1]) - 1)];
      break;

    case 'earr' :
    
      theHrefs.item(12).href = earrUrls[0][((reviewList[currRevImg][1]) - 1)];
      document.images[2].src = earrSels[0][((reviewList[currRevImg][1]) - 1)];
      break;

    case 'oths' :
    
      theHrefs.item(12).href = othUrls[0][((reviewList[currRevImg][1]) - 1)];
      document.images[2].src = othSels[0][((reviewList[currRevImg][1]) - 1)];
      break;

    default :
    
      break;
  }
}

var labelTextNode = null;

function handleLabel ()
{
  //
  // Display the item label
  //
  theLabelNode = document.getElementById("REVDESCID");
  if (labelTextNode != null) theLabelNode.removeChild(labelTextNode);
  
  switch (reviewList[currRevImg][0])
  {
    case 'sets' :

      labelTextNode = document.createTextNode(setsAlts[0][((reviewList[currRevImg][1]) - 1)]);
      break;

    case 'col' :
    
      labelTextNode = document.createTextNode(colAlts[0][((reviewList[currRevImg][1]) - 1)]);
      break;

    case 'diam' :
    
      labelTextNode = document.createTextNode(diamAlts[0][((reviewList[currRevImg][1]) - 1)]);
      break;

    case 'earr' :
    
      labelTextNode = document.createTextNode(earrAlts[0][((reviewList[currRevImg][1]) - 1)]);
      break;

    case 'oths' :
      labelTextNode = document.createTextNode(othAlts[0][((reviewList[currRevImg][1]) - 1)]);
      break;

    default :
    
      break;

  }
  theLabelNode.appendChild(labelTextNode);
}

var countTextNode = null;
var countStr = "";

function handleCount ()
{
   //
   // Create the string to show where we are in the item list.
   //
   if ((currRevImg + 1) < 10) prefixCurrZero = "00";   
   else if ((currRevImg + 1) < 100) prefixCurrZero = "0";
   else prefixCurrZero = "";
   if (numRevImgs < 10) prefixNumZero = "00";
   else if (numRevImgs < 100) prefixNumZero = "0";
   else prefixNumZero = "";
   countStr = "Review item " + prefixCurrZero + (currRevImg + 1) + " of " + prefixNumZero + numRevImgs;
   countNode = document.getElementById("REVCOUNID");
   if (countTextNode != null) countNode.removeChild(countTextNode);
   countTextNode = document.createTextNode(countStr);
   countNode.appendChild(countTextNode);
}

function displayItem(action)
{
  switch (action)
  {

    case 'opened' :

      if (numRevImgs == 0)
      {
        //
        // No items - just output a string to say and remove buttons.
        //
        countNode = document.getElementById("REVCOUNID");
        textNode = document.createTextNode("No review items selected");
        countNode.appendChild(textNode);
        theElement1 = document.getElementById("REVITEMID");
        theElement1.style.visibility = "hidden";
        theElement2 = document.getElementById("REMITEMID");
        theElement2.style.visibility = "hidden";
        theElement3 = document.getElementById("COMPAREID");
        theElement3.style.visibility = "hidden";
        theElement4 = document.getElementById("GOBUTTID");
        theElement4.style.visibility = "hidden";
        if (countTextNode != null) countNode.removeChild(countTextNode);
        if (labelTextNode != null) theLabelNode.removeChild(labelTextNode);
      }
      else
      {
        //
        // Display the count, first image in the list and the item description.
        //
        theElement1 = document.getElementById("REVITEMID");
        theElement1.style.visibility = "visible";
        handleCount();
        handleImage();
        handleLabel();
      }

      if (numRevImgs < 2)
      {
        //
        // Remove the nav buttons
        //
        theElement1 = document.getElementById("REVBACKID");
        theElement1.style.visibility = "hidden";
        theElement2 = document.getElementById("REVFORWID");
        theElement2.style.visibility = "hidden";
        theElement3 = document.getElementById("COMPAREID");
        theElement3.style.visibility = "hidden";
        theElement4 = document.getElementById("GOBUTTID");
        theElement4.style.visibility = "hidden";
      }

      break;

    case 'forward' :

      if ((currRevImg + 1) >= numRevImgs) currRevImg = 0; else currRevImg++;
      handleCount();
      handleImage();
      handleLabel();

      break;

    case 'backward' :

      if (currRevImg <= 0) currRevImg = (numRevImgs - 1); else currRevImg--;
      handleCount();
      handleImage();
      handleLabel();

      break;

    default :

      break;
  }
}

function retrieveRev ()
{
  //
  // Open the cookie, split the data and place it in the array.
  //
  var cookieStr = getCookieValue("liztylerreview");
  cookieStr = cookieStr.split(";");
  if (cookieStr != "")
  {
    for (i = 0; i < (cookieStr.length - 1); i+=2)
    {
      reviewList[(i/2)][0] = cookieStr[i];
      reviewList[(i/2)][1] = parseInt(cookieStr[i+1]);
      numRevImgs++;
    }
  }
}

function review()
{
  //
  // Retrieve the cookie stuff and save it.
  //
  retrieveRev();

  //
  // Call the display function.
  //
  displayItem("opened");
}

function setCookie (cookieName, cookieValue, cookiePath, cookieExpires)
{
  cookieValue = escape(cookieValue);
  
//  if (cookieExpires == "")
//  {
//    var nowDate = new Date();
//    nowDate.setMonth(nowDate.getMonth() + 6);
//    cookieExpires = nowDate.toGMTString();
//  }
//  
//  if (cookiePath != "")
//    cookiePath = ";Path=" + cookiePath;
//  else
//    cookiePath = "/";
  
  document.cookie = cookieName + "=" + cookieValue + ";expires=Wed, 21 Oct 2037 12:00:00 UTC; path=/";
}

function writeRev ()
{
  //
  // Overwrite the cookie - take the data from the array and combine it.
  //
  var savedData = "";

  for (i = 0; i < reviewList.length; i++)
  {
    if (!(reviewList[i][0] == ""))
    {
      for (j = 0; j < 2; j++)
      {
        savedData = savedData + reviewList[i][j] + ";";
      }
    }
  }
  
 setCookie("liztylerreview", savedData, "", "");
 
}

function removeItem()
{

  //
  // Remove the item data from reviewList, rewrite the cookie.
  // Clear the list, get the cookie data back and display the current item.
  //
  reviewList[currRevImg][0] = "";
  reviewList[currRevImg][1] = -1;

  writeRev();

  for (i = 0; i < 200; i++)
  {
    reviewList[i][0] = "";
    reviewList[i][1] = -1;
  }    

  numRevImgs = 0;

  retrieveRev();

  if ((numRevImgs < 2) || (currRevImg >= numRevImgs)) currRevImg = 0;

  displayItem("opened");
}

function compareItems()
{
  var href1;
  var href2;

  close_window();
  comp1 = document.getElementById("COMP1");
  comp1Val = parseInt(comp1.value);
  comp2 = document.getElementById("COMP2");
  comp2Val = parseInt(comp2.value);
  if ((comp1Val < 1) || (comp1Val > numRevImgs) || (isNaN(comp1Val)) || (comp2Val < 1) || (comp2Val > numRevImgs) || (isNaN(comp2Val)))
     alert("Please enter numbers between 1 and " + numRevImgs);
  else
  {
    switch (reviewList[comp1Val-1][0])
    {
      case 'sets' :

        href1 = setsUrls[0][((reviewList[comp1Val-1][1]) - 1)];
        break;

      case 'col' :
    
        href1 = colUrls[0][((reviewList[comp1Val-1][1]) - 1)];
        break;

      case 'diam' :
    
        href1 = diamUrls[0][((reviewList[comp1Val-1][1]) - 1)];
        break;

      case 'earr' :
    
        href1 = earrUrls[0][((reviewList[comp1Val-1][1]) - 1)];
        break;

      case 'oths' :
    
        href1 = othUrls[0][((reviewList[comp1Val-1][1]) - 1)];
        break;

      default :
    
        break;
    }
    switch (reviewList[comp2Val-1][0])
    {
      case 'sets' :

        href2 = setsUrls[0][((reviewList[comp2Val-1][1]) - 1)];
        break;

      case 'col' :
    
        href2 = colUrls[0][((reviewList[comp2Val-1][1]) - 1)];
        break;

      case 'diam' :
    
        href2 = diamUrls[0][((reviewList[comp2Val-1][1]) - 1)];
        break;

      case 'earr' :
    
        href2 = earrUrls[0][((reviewList[comp2Val-1][1]) - 1)];
        break;

      case 'oths' :
    
        href2 = othUrls[0][((reviewList[comp2Val-1][1]) - 1)];
        break;

      default :
    
        break;
    }
    href1 = href1.replace("javascript:open_window('", "");
    href1 = href1.replace("',510,520)", "");
    href2 = href2.replace("javascript:open_window('", "");
    href2 = href2.replace("',510,520)", "");

    open_comp_window(href1,href2,950,520);
  }
}

//*******************************************
// CHANGE THIS IN LIZOTHERS.JS AS WELL!!!!!!
//*******************************************
function loadExhib()
{
  exhibNode = document.getElementById("EXHIBDATA");

  //
  // Put the exhib info into the exhibition div
  //
  liText = document.createTextNode("EXHIBITIONS :");
  exhibNode.appendChild(liText);
  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  liText = document.createTextNode("DESIRE, March 4th to 6th, 2011 in London at The Bank of England Sports Centre 10am-5pm daily. This is the UK's leading mixed media jewellery and silversmithing show of 80 established & emerging British designer/makers. There is a private viewing on the evening of 3rd March and due to demand this time there will  be a special bus service from Barnes station to the centre.");
  exhibNode.appendChild(liText);

//--------------------------------------------------

  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  liText = document.createTextNode("LONDON JEWELLERY WEEK, June 10th to 12th, 2011. As part of a week full of events across London, Liz Tyler will be exhibiting at TREASURE with many individual designer jewellers and many familiar faces from The Goldsmiths' Fair. Venue : Victoria House, Southampton Row, London WC1B 4DA. Open to the public 10am-5pm Friday 10th, 10am-6pm Saturday & Sunday.");
  exhibNode.appendChild(liText);

//-------------------------------------------------

  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  liText = document.createTextNode("THE GOLDSMITHS' FAIR, Sept 26th to Oct 2nd & Oct 4th to 9th, 2011, at The Goldsmiths' Hall, Foster Lane, London, EC2V 6BN. The leading exhibition of 90 contemporary Jewellers and Silversmiths' in the UK over 2 weeks. NOTE : closed the middle Monday.");
  exhibNode.appendChild(liText);

//--------------------------------------------------

  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  liText = document.createTextNode("CLOSE");
  aNode = document.createElement("A");
  aNode.href = "javascript:closeData('EXHIBDATA')";
  aNode.appendChild(liText);
  brNode = document.createElement("BR");
  exhibNode.appendChild(brNode);
  exhibNode.appendChild(aNode);
}

function loadAbout()
{
  aboutNode = document.getElementById("ABOUTDATA");

  //
  // Put the About Liz info into the about div
  //
  liText = document.createTextNode("ABOUT LIZ :");
  aboutNode.appendChild(liText);
  brNode = document.createElement("BR");
  aboutNode.appendChild(brNode);
  brNode = document.createElement("BR");
  aboutNode.appendChild(brNode);
  liText = document.createTextNode("I aim to produce essentially feminine, graceful jewellery and silverware with a strong sense of movement in the design. A recurring feature in whatever scale I am working is that the fittings and decoration frequently form an integral part of the item, so there is no interruption in the flow of the design.");
  brNode = document.createElement("BR");
  brNode2 = document.createElement("BR");
  aboutNode.appendChild(liText);
  aboutNode.appendChild(brNode);
  aboutNode.appendChild(brNode2);
  liText = document.createTextNode("I work primarily to commission and, having trained as a diamond sorter and stone buyer, delight in selecting beautiful diamonds and fabulous coloured gemstones - usually from Germany, for their exquisite and unusual gem cutting skills. I specialise in using the hammering technique, anti-clastic raising, whereby I produce two curves in opposite directions, saddle-like, which allows me to create curvaceous pieces - large and light, flexible yet strong. These I complement or combine with carved and cast pieces with sympathetic fluid lines.");
  brNode = document.createElement("BR");
  brNode2 = document.createElement("BR");
  aboutNode.appendChild(liText);
  aboutNode.appendChild(brNode);
  aboutNode.appendChild(brNode2);
  liText = document.createTextNode("I have won several awards, most significantly Best Design in Diamonds at the UK Jewellery Awards 1998, and most recently, second prize in the Kayman Awards 2002. My designs regularly feature in The Platinum Collection and the World Gold Council trend setting collections. My most important pieces are now signed by laser and the larger diamonds I use are certificated to confirm their unique quality.");
  brNode = document.createElement("BR");
  aboutNode.appendChild(liText);
  aboutNode.appendChild(brNode);
  liText = document.createTextNode("CLOSE");
  aNode = document.createElement("A");
  aNode.href = "javascript:closeData('ABOUTDATA')";
  aNode.appendChild(liText);
  liText2 = document.createTextNode("CV");
  aNode2 = document.createElement("A");
  aNode2.href = "javascript:showData('CVDATA')";
  aNode2.appendChild(liText2);
  brNode = document.createElement("BR");
  aboutNode.appendChild(brNode);
  aboutNode.appendChild(aNode);
  liText = document.createTextNode(" | ");
  aboutNode.appendChild(liText);
  aboutNode.appendChild(aNode2);
  brNode = document.createElement("BR");
  aboutNode.appendChild(brNode);
  brNode = document.createElement("BR");
  aboutNode.appendChild(brNode);
}

function loadInfoData()
{
  infoNode = document.getElementById("INFODATA");

  //
  // Put the Sales Info into the info div
  //
  liText = document.createTextNode("SALES INFORMATION :");
  infoNode.appendChild(liText);
  brNode = document.createElement("BR");
  infoNode.appendChild(brNode);
  brNode = document.createElement("BR");
  infoNode.appendChild(brNode);
  liText = document.createTextNode("My diamond rings start from around £1,000.");
  brNode = document.createElement("BR");
  brNode2 = document.createElement("BR");
  infoNode.appendChild(liText);
  infoNode.appendChild(brNode);
  infoNode.appendChild(brNode2);
  liText = document.createTextNode("They can be made in several scales in order to work to your required price range.");
  brNode = document.createElement("BR");
  brNode2 = document.createElement("BR");
  infoNode.appendChild(liText);
  infoNode.appendChild(brNode);
  infoNode.appendChild(brNode2);
  liText = document.createTextNode("Diamonds are selected to be eye clean and white against white metal certification system and all purchased from suppliers who are signed up to the Kimberley Agreement.");
  brNode = document.createElement("BR");
  infoNode.appendChild(liText);
  infoNode.appendChild(brNode);
  liText = document.createTextNode("CLOSE");
  aNode = document.createElement("A");
  aNode.href = "javascript:closeData('INFODATA')";
  aNode.appendChild(liText);
  brNode = document.createElement("BR");
  infoNode.appendChild(brNode);
  infoNode.appendChild(aNode);
  brNode = document.createElement("BR");
  infoNode.appendChild(brNode);
  brNode = document.createElement("BR");
  infoNode.appendChild(brNode);
}

