<!--
var ns4 = document.layers;
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1)||(navigator.userAgent.indexOf("Opera/5")!=-1);
var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1);
var agt = navigator.userAgent.toLowerCase();
var mac = (agt.indexOf("mac")!=-1);
var ie = (agt.indexOf("msie") != -1);
var mac_ie = mac && ie;

function PopUp(url, header, width, height)
{
  myWindow = window.open(url, header, "width="+width+",height="+height+",resizable=yes");
  window.myWindow.focus();
}

function resizeWindow(width, height)
{
  window.resizeTo(width, height);
}

function setShipping(obj)
{
  if(obj.shippingMode.checked == true)
  {
    obj.shippingFirstName.value         = obj.billingFirstName.value;
    obj.shippingLastName.value          = obj.billingLastName.value;
    obj.shippingCompanyName.value       = obj.billingCompanyName.value;

    obj.shippingCountryId.selectedIndex = obj.billingCountryId.selectedIndex;

    obj.shippingAddress1.value          = obj.billingAddress1.value;
    obj.shippingAddress2.value          = obj.billingAddress2.value;
    obj.shippingCity.value              = obj.billingCity.value;


    obj.shippingStateId.selectedIndex   = obj.billingStateId.selectedIndex;
    obj.shippingZip.value               = obj.billingZip.value;
    obj.shippingPhone.value             = obj.billingPhone.value;
    obj.shippingFax.value               = obj.billingFax.value;
    xajax_getStates('selectShippingStateId', obj.shippingCountryId.value, obj.billingStateId.value, 'shippingStateId', 'inputText2');
    updateUPScost();
  }
  else
  {
    obj.shippingFirstName.value         = '';
    obj.shippingLastName.value          = '';
    obj.shippingCompanyName.value       = '';
    obj.shippingCountryId.selectedIndex = '';
    obj.shippingAddress1.value          = '';
    obj.shippingAddress2.value          = '';
    obj.shippingCity.value              = '';

    obj.shippingStateId.selectedIndex   = '';
    obj.shippingZip.value               = '';
    obj.shippingPhone.value             = '';
    obj.shippingFax.value               = '';
    xajax_getStates('selectShippingStateId', obj.shippingCountryId.value, '', 'shippingStateId', 'inputText2');
    updateUPScost();
  }
}

function getElementHeight(Elem)
{
	 if (ns4)
	 {
		  var elem = getObjNN4(document, Elem);
		  return elem.clip.height;
	 }
	 else
	 {
		  if(document.getElementById)
			   var elem = document.getElementById(Elem);
		  else if (document.all)
			   var elem = document.all[Elem];

			 if (op5)
			   xPos = elem.style.pixelHeight;
		  else
			   xPos = elem.offsetHeight;

		  return xPos;
	 }
}

function getElementWidth(Elem)
{
	 if (ns4)
	 {
		  var elem = getObjNN4(document, Elem);
		  return elem.clip.width;
	 }
	 else
	 {
		  if(document.getElementById)
			   var elem = document.getElementById(Elem);
		  else if (document.all)
			   var elem = document.all[Elem];

		  if (op5)
		    xPos = elem.style.pixelWidth;
		  else
		    xPos = elem.offsetWidth;

		  return xPos;
	 }
}

function hideAdditionalDiamondInfo (rowNo)
{
  document.getElementById('diaPopup' + rowNo).style.visibility = 'hidden';
}

function showAdditionalDiamondInfo (rowNo, rowsCount, diaId)
{
  var minPopUpHeight = 325;
  var topOffset = 0;
  var leftOffset = -198;
  var arrowHeight = 47;
  var arrowTopOffset = 0;
  var arrowTargetOffset = 0; //point to wich arrow should target.. from this we should calculate popUp offset and then recalculate arrowTopOffset to local coordinates of popUp

  //rowsCount
  //arrowTargetOffset = document.getElementById('trid' + rowNo).offsetTop;
  //topOffset = document.getElementById('trid' + rowNo).offsetTop - Math.round(arrowHeight/4);

  var arrowOffset = document.getElementById('trid' + rowNo).offsetTop - Math.round(arrowHeight/4) + 3;

  if(document.getElementById('diaPopup' + rowNo))
  {
    if (document.getElementById('popArrow' + rowNo))
    {
      document.getElementById('popArrow' + rowNo).style.top = arrowOffset + 'px';
    }
    document.getElementById('diaPopup' + rowNo).style.top = topOffset + 'px';
    document.getElementById('diaPopup' + rowNo).style.left = leftOffset + 'px';
    document.getElementById('diaPopup' + rowNo).style.display = 'block';
    document.getElementById('diaPopup' + rowNo).style.visibility = 'visible';
  }
  else
  {
    currentPopup = document.createElement('div');
    currentPopup.setAttribute('id','diaPopup' + rowNo);
    document.getElementById('diamondsSearchResults').appendChild(currentPopup);

    currentPopup.style.width = '198px';
    currentPopup.style.position = 'absolute';

    currentPopup.style.top = topOffset + 'px';
    currentPopup.style.left = leftOffset + 'px';

    currentPopup.style.display = 'block';
    currentPopup.style.visibility = 'visible';

    document.getElementById('diaPopup' + rowNo).style.zIndex = 5002;

    var resultsTableHeight = document.getElementById('resultsTable').offsetHeight + 5;
    if (resultsTableHeight < minPopUpHeight) resultsTableHeight = minPopUpHeight;

    xajax_getDiaAddInfo(rowNo, diaId, resultsTableHeight, arrowOffset);
  }
}

function f(tdName) {
  var td = document.getElementById(tdName);
  td.style.backgroundImage='url(images/menuOverBg.gif)';
  td.style.backgroundRepeat='repeat-x';
  td.style.backgroundPosition='bottom';
}

function showPleaseWait(flag, element)
{
  var divWait = document.getElementById('pleaseWait');
  var divContent = document.getElementById(element);
  var tableWait = document.getElementById('pleaseWaitTable');

  if(flag==true)
  {
    tableWait.style.height = getElementHeight(element) + "px";
    divWait.style.display = "block";
    divContent.style.display = "none";
  }
  else
  {
    divWait.style.display = "none";
    divContent.style.display = "block";
  }
}

function fo(tdName) {
  var td = document.getElementById(tdName);
  td.style.background='transparent';
}

function getBrowser(objectName)
{
  if (document.all) {
    if (window.ActiveXObject) document.getElementById(objectName).style.marginLeft='0px';
    else document.getElementById(objectName).style.marginLeft='50%';
  } else {
    document.getElementById(objectName).style.marginLeft='50%';
  }
}

function fullInfoView(id, id1)
{
  var trFullInfo = document.getElementById(id);
  var tdFullInfo = document.getElementById(id1);

  if (trFullInfo.style.display == "none")
  {
    tdFullInfo.innerHTML = "<a href='#' onClick=\"fullInfoView('"+id+"', '"+id1+"'); return false;\" style=\"font-size: 16px; text-decoration: none;\" title=\"View Details\">-</a>";
    if (ie)
      trFullInfo.style.display = "inline";

    else
      trFullInfo.style.display = "table-row";
  }
  else
  {
    tdFullInfo.innerHTML = "<a href=\"#\" onClick=\"fullInfoView('"+id+"', '"+id1+"'); return false;\" style=\"font-size: 16px; text-decoration: none;\" title=\"View Details\">+</a>";
    trFullInfo.style.display = "none";
  }
}

function mail(id, section)
{
  PopUp('mail.php?section='+section+'&id='+id, 'email', 300, 700);
}


function ieCheck()
{
  if(ie)
    return true;
  else
    return false;
}

/// RENAME !!!!!!!!!!!!!!!!!!!!!!
function filterProducts()
{
  var metal = document.getElementById('metal').options[document.getElementById('metal').options.selectedIndex].innerHTML;
  var arTmp = [];
  var i=0;

  for (key in productListTable)
  {
    var value = productListTable[key];
    var matchMetal = false;
    var matchFingerSize = false;
    var matchMillimeterSize = false;

    if (metal != 'Please select...')
    {
      if(value.metalName == metal) matchMetal = true;
    }
    else matchMetal = false;

    if (matchMetal)
    {
      arTmp[i] = productListTable[key];
      i++;
    }
  }

  var htTable = document.getElementById('tbodyId');
  var htBody = document.createElement("tbody");
  var htTR, htTD, htCB;

  // clear table body
  htTable.removeChild(htTable.tBodies[0]);
  htTable.appendChild(htBody);


  for (key=0; key<arTmp.length; key++)
  {
    htTR = htBody.insertRow(key);
    if (key % 2 != 0) htTR.style.backgroundColor='#EDF3F3';

    var j=0;
    for (field in arListFieldsView)
    {
      j++;

      htTD = document.createElement("td");
      htTD.align="center";
      if (arTmp[key][arListFieldsView[field].selectAs] !='' && arTmp[key][arListFieldsView[field].selectAs] !='0')
        htTD.innerHTML = arTmp[key][arListFieldsView[field].selectAs];
      htTR.appendChild(htTD);

      if (arListFieldsView[field].selectAs == 'styleName')
      {
        htTD = document.createElement("td");
        htTD.align="center";
        htCB = document.createElement("input");
        htCB.type = 'text';
        htCB.maxLength = 3;
        htCB.className = 'inputTextSmall';
        htCB.name = 'qty[' + arTmp[key].id + ']';
        htCB.value = '';
        htTD.appendChild(htCB);
        htTR.appendChild(htTD);
      }
    }
  }
}

//UPS cost
function updateUPScost()
{
//  dst_zip = document.getElementById('dst_zip').value;
  dst_zip = document.getElementById('shippingZip').value;
//  dst_city = document.getElementById('dst_city').value;
  dst_city = document.getElementById('shippingCity').value;
  weight = document.getElementById('weight').value;

  product = document.getElementById('n13_product').value;
  container = document.getElementById('n48_container').value;
  rescom = document.getElementById('n49_residential').value;
  rate = document.getElementById('n47_rate_chart').value;
  xajax_updateUpsCost(dst_zip, dst_city, weight, product, rate, container, rescom);
}


//-->
