function onMouseBg(obj)
{
  obj.style.backgroundColor='#E6E6E6';
}

function outMouseBg(obj)
{
  if (!/menuItemTextSelected/.test(obj.className))
    obj.style.backgroundColor='#FFFFFF'
}

function createCookie(name,value,days)
{
  if (days)
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

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 c.substring(nameEQ.length,c.length);
  }
  return null;
}

function getActiveStyleSheet()
{
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
  {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("title") && a.getAttribute("title") != 'common'
       && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function setActiveStyleSheet(size, col) {
  var i, a, main;

  if (size != '')
    sizeSheet = size;
  if (col != '')
    color = col;

  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") != 'common')
    {
      a.disabled = true;

      if(a.getAttribute("title") == myStyles[sizeSheet][color])
      {
        a.disabled = false;
      }
    }

    for(var idx in linkButtons)
    {
      var obj = document.getElementById(linkButtons[idx]);
      if (obj)
        if (idx == sizeSheet)
        {
          obj.className = 'fontSizeLinkSelected';
          obj.style.color = 'red';
        }
        else if(idx == color)
        {
          obj.className = 'siteColorSelected';
        }
        else
        {
          obj.className = '';
          obj.style.color = '';
        }
    }
  }
}

function changeShipping(radio)
{
  window.location.href = 'checkout2.php?change=' + radio.value;
}

function viewTerms()
{
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  window.open('terms_popup.php','s','toolbar=no,scrollbars=yes,height=500,width=680, left=20, top=20');
}

function viewLicense()
{
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  window.open('terms_popup.php#pic_license','s','toolbar=no,scrollbars=yes,height=500,width=680, left=20, top=20');
  return false;
}


function printOrder(id)
{
  if (id != '')
    window.open('printOrder.php?id='+id,'s','toolbar=no,scrollbars=yes,height=500,width=680, left=20, top=20');
}

function printProduct(queryStr, type)
{
  var link = 'printProduct';
  
  if (type == 2)
    link = 'printPictureBank';
  
  if (queryStr != '')
    window.open(link+'.php?'+queryStr,'s','toolbar=no,scrollbars=yes,height=700,width=700, left=20, top=20');
}