

var tcdacmd="dt";
var ANS_customer_id="e9681d3e-eead-4276-805a-74d2888d2419";
function popupWindow(url){window.open(url, 'popupWindow', 'toolbar = no, location = no, directories = no, status = no, menubar = no, scrollbars = yes, resizable = yes, copyhistory = no, width = 400, height = 400, screenX = 150, screenY = 150, top = 150, left = 150');}
function popupWindowExtra(url){window.open(url, 'popupWindow', 'toolbar = no, location = no, directories = no, status = no, menubar = no, scrollbars = yes, resizable = yes, copyhistory = no, width = 400, height = 400, screenX = 150, screenY = 150, top = 150, left = 150');}
function toggle(element){var id = document.getElementById(element);if(id.style.display == 'none'){id.style.display = '';}else{id.style.display = 'none';}}
function disable(element){document.getElementById(element).style.display = 'none';}
function enable(element){document.getElementById(element).style.display = '';}
function setBookmark(){if (document.all)window.external.AddFavorite(location.href, document.title);else alert('Click \'OK\' then Press CTRL and D to add a bookmark to:\n"' + document.title);} 
function phpOnlinePopupWindow() 
{
  var url = "http://thepartyworks.com/livechat/client.php";
  window.open(url,'popupWindow2','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=550,height=400,screenX=150,screenY=150,top=150,left=150');
}

function checkSelections(options, checkColor)
{
  var msg = '';
  var form = document.getElementById('cart_qty');
  var selects = form.getElementsByTagName('select');

  var notifyElements = false;
  
  var j = 0;
  
  for (var i = 0; i < selects.length; i++)
  {
    var optionsRow = document.getElementById(selects[i].id);
    var optionsIDArray = optionsRow.id.split('_');

    // reset the color to white
    // for each select on the page, set the background color to white if the id has optionsRow as the first part.
    if (optionsIDArray[0] == 'optionsRow')
    {
      var optionsContainer = document.getElementById("optionsContainer_" + optionsIDArray[1]);
     optionsContainer.style.backgroundColor="#ffffff";
     optionsContainer.style.border="1px solid #ffffff";
      
      if (selects[i].value == 0)
      {
        optionsContainer.style.backgroundColor="#99ff33";
        optionsContainer.style.border="1px solid #dd0000";
        
        var notifyElements = true;
      }
    }
  }
  
  if (notifyElements == true)
  {
    var msg = 'One or more options have not been selected.<br /><br />Please check the highlighted fields below before proceeding.';
  }
  
  if (options == true)
  {
    // reset color back to defaults;
    if (checkColor == true)
    {
      form.elements['text1'].style.backgroundColor="#ffffff";
      document.getElementById('colorPalette_1').style.border="3px solid #ffffff";
      document.getElementById('colorPalette_2').style.border="3px solid #ffffff";
      document.getElementById('colorPalette_3').style.border="3px solid #ffffff";
    }
    
    if (isEmpty(form.elements['text1']))
    {
      var msg = msg + '<br /><br />*Banners require that the 1st line of text be entered';
      form.elements['text1'].style.backgroundColor="#99ff33";
    }
  
    if (!isEmpty(form.elements['text1']) && (checkColor == true && isEmpty(form.elements['color1'])))
    {
      var msg = msg + '<br /><br />You must choose the color for the banner text (1st line)';
      document.getElementById('colorPalette_1').style.border="3px solid #99ff33";
    }
    
    if (!isEmpty(form.elements['text2']) && (checkColor == true && isEmpty(form.elements['color2'])))
    {
      var msg = msg + '<br /><br />You must choose the color for the banner text (2nd line)';
      document.getElementById('colorPalette_2').style.border="3px solid #99ff33";
    }

    if (!isEmpty(form.elements['text3']) && (checkColor == true && isEmpty(form.elements['color3'])))
    {
      var msg = msg + '<br /><br />You must choose the color for the banner text (3rd line)';
      document.getElementById('colorPalette_3').style.border="3px solid #99ff33";
    }
  }
  
  if (msg != '')
  {
     var msgBox = document.getElementById('optionMsg');
     msgBox.innerHTML = msg;
     msgBox.style.display = '';
    //alert(msg);
    return false;
  }
  return true;
}

function isEmpty(textField) 
{
  if ((textField.value.length==0) || (textField.value==null)) 
  {
    return true;
  }
  else
  { 
    return false; 
  }
}

function enableColor(productId, line, colorId, color)
{
 var el = 'pal_' + line + '_' + colorId;
 var el1 = 'pal_' + line + '_1';
 var el2 = 'pal_' + line + '_2';
 var el3 = 'pal_' + line + '_3';
 
 var textElement = 'bannerText_' + productId + '_' + line;
 
 document.getElementById(el1).style.border='3px solid #fff';
 document.getElementById(el2).style.border='3px solid #fff';
 document.getElementById(el3).style.border='3px solid #fff';
 document.getElementById(el).style.border='3px solid #333';
 
 document.getElementById(textElement).style.color='#' + color;
 element = "color" + line;

 document.forms['cart_qty'].elements[element].value=color;
}
// preload images
var img_0         = new Image().src = "/int/productInfo/fonts/0.png";
var img_alexander = new Image().src = "/int/productInfo/fonts/alexander.png";
var img_beard     = new Image().src = "/int/productInfo/fonts/beard.png";
var img_boxer     = new Image().src = "/int/productInfo/fonts/boxer.png";
var img_bubble   = new Image().src = "/int/productInfo/fonts/bubble.png";
var img_fantasyb  = new Image().src = "/int/productInfo/fonts/fantasyb.png";
var img_harvardbi = new Image().src = "/int/productInfo/fonts/harvardbi.png";
var img_hotdog    = new Image().src = "/int/productInfo/fonts/hotdog.png";
var img_lilyb     = new Image().src = "/int/productInfo/fonts/lilyb.png";
var img_simon     = new Image().src = "/int/productInfo/fonts/simon.png";
var img_stylezb   = new Image().src = "/int/productInfo/fonts/stylezb.png";

function setImage(imageSelect, imageName)
{
  theImageIndex = imageSelect.options[imageSelect.selectedIndex].value;
 
  if (document.images)
  {
    document.images[imageName].src = eval("img_" + theImageIndex);
  }
}
function setImageLocation(src, pid, img)
{
  var imgDiv = document.getElementById('productsMediumImage');
  var zoomDiv = document.getElementById('zoomImage');

  var link = '<a onclick="javascript: popupWindow(\'http://thepartyworks.com/popup_image.php/pID/' + pid + '/e/' + img + '\');" style="cursor: pointer;">';
  
  imgDiv.innerHTML = link + src + '</a>';
  zoomDiv.innerHTML = link + '<img src="/int/productInfo/icon_zoom.png" width="42" height="41" alt="zoom image" /></a>';
}
