/**
 * @file
 * Custom javascript utilities.
 *
 * @author Shannon M. Rause <shannon.rause@creativeflavor.com>
 * @version $Revision: 1.9 $
 * @version $Name: HUTDOGS_2010-06-29_24 $
 * @version $Id: main.js,v 1.9 2008/08/21 18:13:06 smr Exp $
 *
 * These files are copyrighted to Creative Flavor Inc. and are
 * subject to the terms of the applicable Service Agreement.
 * If no service agreement is available you must contact us at
 * legal@creativeflavor.com or 303-379-9450.
 * 
 * These files may be watermarked to ensure traceability.
 */
function clickSwatch(layoutId, schemeId, color, image)
{
   document.getElementById('scheme' + layoutId).value = schemeId;
   document.getElementById('swatch' + layoutId).value = color;
   document.getElementById('thumb' + layoutId).value = image;
   document.getElementById('thumbLink' + layoutId).href = '/quicksite/sample/layout/' + layoutId + '/scheme/' + schemeId + '/';
} // clickSwatch


function hideSwatchPopup()
{
   Popup.hide('colorSelector');
} // hideSwatchPopup


function overSwatch(layoutId, color, image)
{
   document.getElementById('swatchDiv' + layoutId).style.backgroundColor = color;
   document.getElementById('thumbImg' + layoutId).src = image;
} // overSwatch


function outSwatch(layoutId)
{
   document.getElementById('swatchDiv' + layoutId).style.backgroundColor = document.getElementById('swatch' + layoutId).value;
   document.getElementById('thumbImg' + layoutId).src = document.getElementById('thumb' + layoutId).value;
} // outSwatch


function selectTemplate(layoutId)
{
   document.getElementById('template').value = layoutId;
   document.getElementById('scheme').value = document.getElementById('scheme' + layoutId).value;
   document.qsTemplateForm.submit();
} // selectTemplate


function showSwatchPopup(layoutId)
{
   var input = document.getElementById('quicksiteSchemeId');
   var color = document.getElementById('swatchColor' + layoutId + '_' + input.value).value;
   var image = document.getElementById('swatchThumbUrl' + layoutId + '_' + input.value).value;

   document.getElementById('scheme' + layoutId).value = input.value;
   document.getElementById('swatch' + layoutId).value = color;
   document.getElementById('thumb' + layoutId).value = image;
   document.getElementById('thumbLink' + layoutId).href = '/quicksite/sample/layout/' + layoutId + '/scheme/' + input.value + '/';
   document.getElementById('swatchDiv' + layoutId).style.backgroundColor = color;
   document.getElementById('thumbImg' + layoutId).src = image;
   Popup.show('colorSelector',
              '290ab');
} // showSwatchPopup


function updateDomain(input)
{
   var s = '';

   for (var i = 0; i < input.value.length; i++)
   {
      var cc = input.value.charCodeAt(i);

      if (((cc > 47) && (cc < 58)) ||
            ((cc > 64) && (cc < 91)) ||
            ((cc > 96) && (cc < 123)) ||
            (input.value.charAt(i) == '_'))
      {
         s += input.value.charAt(i);

         if (s.length >= 20)
         {
            break;
         } // if
      } // if
   } // for

   document.getElementById('domain').value = s.toLowerCase();
} // updateDomain


function updateColorSelect(layoutId)
{
   var scheme = document.getElementById('scheme' + layoutId).value;
   var select = document.getElementById('quicksiteSchemeId');

   select.value = scheme;
   hideSwatchPopup();
} // updateColorSelect
