// (c) 2008 eprintwerx International  www.eprintwerx.com

function mockQuiz() {
  showAjaxAnim();
  $('quiz-button').hide();
  setTimeout('quizResponse();', 1000);
}

function quizResponse() {
  $('ajaxanim').hide();
  $('quiz-answer').show();
  $('quiz-continue').show();
}

function nextQuestion() {
  $('quiz-button').show();
  $('quiz-answer').hide();
  $('quiz-continue').hide();
  $('quiz-question').replace("<p id='quiz-question'>How many people do you think earn over $100,000 in </p>");
}

// Gets random int between min & max
function getRandomInt(min, max) {
  if (min == max) {
    return min;
  }
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

// Hardwired user quotes
var quotes = [ 
             { "quote": "In all my years of working within the direct marketing industry, I've never seen such a user-friendly mailing list procurement system. I don't believe I've ever spent more than 2 minutes building a targeted mailing list using the LeadsPlease tool. Anyone looking to construct an accurate list in a short amount of time has found the right place!", 
             "name": "Dave Nugent", 
             "title": "Tailored Data Source" },
             { "quote": "I'm thoroughly impressed by the Customer Service that the LeadsPlease team provides. They've always been extremely helpful and friendly and it's been a pleasure working with them... Thanks LeadsPlease!",
             "name": "Thadeus Alemao, NY", 
             "title": "Non Profit Organization" },
             { "quote": "I am very satisfied with their service and would recommend them to anyone who might be interested in doing business with them... Top notch service sums it up in a single statement...... Thanks www.leadsplease.com I look forward to working with you in my future endeavors!!!", 
             "name": "Andy", 
             "title": "Madison WI" },
             { "quote": "I did a lot of research before I purchased my mailing list online, but in the end, I chose LeadsPlease. Why? Because LeadsPlease offered the most competitive and affordable pricing, and their site was by far the quickest and easiest to use.",
             "name": "Crystal Fairbairn", 
             "title": "Owner: Kate Bairn Beauty, CO" },
             { "quote": "I purchased a mailing list from LeadsPlease to promote my Chiropractic Center... I've had a great response to my postcard campaign and so far, I've already managed to bring in some 'new' customers - I'm very happy!",
             "name": "Dr. Kim Farias", 
             "title": "Owner- Premier Chiropractic & Acupuncture Center, MO" },
             { "quote": "www.leadsplease.com - truly the best customer service experience EVER! I also loved getting my mailing list in a ready-to-print PDF format - at zero cost - what a great value add!",
             "name": "Alisa", 
             "title": "Novato CA" },
             { "quote": "We provide shelter and care to homeless children and their families and needed a mailing list of Churches and Temples in our area for a particular campaign... LeadsPlease gave us exactly what we wanted, when we needed it - that was the best $37 we've spent in a long, long time!",
             "name": "Clarke Martin", 
             "title": "Executive Director: Guilford Interfaith Hospitality Network, North Carolina" },
             { "quote": "LeadsPlease is all about PERSONAL customer service.  You call them and they answer!  There is no press 1 for this and press 2 for that.  You get a live person everytime!  Thank you for taking care of us.",
             "name": "JS In-Press Printing", 
             "title": "Edmond OK" },
             { "quote": "Your site is fabulous! It was so easy to use and maneuver that in less than 1 minute I had everything that I needed:  a total count for the number of leads available and the total price for the cost of the list!",
             "name": "Dan Spurlock", 
             "title": "Kwik Kopy Printing in Haddonfield, NJ" },
             { "quote": "This is my second order to LeadsPlease and it will not be my last. My first order proved these leads do bring in business! I am not a wiz on the computer so they very patiently led me through the ordering and printing of my labels. They are great people to work with and I am very pleased with their product; and most importantly the leads have brought in business.",
             "name": "Darlene Giordano", 
             "title": "Felix Development, Diamond IL" },
             { "quote": "The LeadsPlease website is easy to use, easy on your pocketbook and the customer service after the sale is outstanding, I honestly believe the people at LeadsPlease really care.",
             "name": "Joseph Surwilo", 
             "title": "Mr. Trophy, LLC - Hartford, CT" },
             { "quote": "I wanted to thank-you for your help this morning with ordering my labels and mailing list.  When I ordered in May from you I had 10,000 postcards that I wanted to use up.  I had decided to stop buying mailing lists and wanted to get the postcards out from under my desk.  The results we got were unbelievable!  So, I decided this morning to order 22,000 more names from you and start doing my own advertising again.",
             "name": "Cathy Moreland", 
             "title": "Sun Cities Tire & Auto, Sun City West, AZ" },
             { "quote": "How nice it is to call a company that not only has friendly and helpful customer service, but employees that go above and beyond. Rather than walking me through what I needed, You took it upon yourself to do the work for me and then email it back! Big smile on my face!",
             "name": "Melissa Keaveney, Office/Salon Manager and Stylist", 
             "title": "Tomy B. Salon Old Westbury NY" }
             ];

var quoteIndex;    // Global

function quoteBackward() {
  quoteIndex--;
  if (quoteIndex < 0) {
    quoteIndex = quotes.length - 1;
  }
  setUserQuote(quoteIndex);
}

function quoteForward() {
  quoteIndex++;
  if (quoteIndex >= quotes.length) {
    quoteIndex = 0;
  }
  setUserQuote(quoteIndex);
}

function setUserQuote(i) {
  $('quote').replace("<span id='quote'>" + quotes[i].quote + "</span>");
  $('owner').replace("<span id='owner'>" + quotes[i].name + ', ' + quotes[i].title + "</span>");
}

function backgroundFace() {
  if ($$('.no-background-image').length > 0) {
    // This page is marked to not have a background
    return;
  }
  var i = getRandomInt(1, 16);
  // Restrict width to prevent horizontal scrollbars. Currently imperfect, think
  // pages with vertical scrollbars don't display face up to edge.
  var w = document.viewport.getWidth() - 990 + 308;
/*  alert(w);*/
  $('background-face').setStyle({
    width: w + 'px',
    background: 'url(/affiliates/lp/images/look_feel/face_' + i + '_full.png) no-repeat'
  });
}

function setupFAQs() {
  var index = 0;
  var accordionFAQs = new Array();
  $$('ul.faq-section').each(function(item) {

    accordionFAQs[index] = new YAHOO.widget.AccordionView(item.id, { collapsible: true, width: '630px' } );

    accordionFAQs[index].on('afterPanelOpen', function(e) {
      var label = $(e).previousSiblings()[0].firstChild.data.strip();
      // Track the FAQ view event w/ GA
      estorePageTracker._trackEvent("faq", "faq-/faq", label);
      return true;
    });

    index++;
    item.setStyle({
      display: 'block'
    });

  });

}

var salePanel;
function initSaleTag() {

  salePanel = new YAHOO.widget.Panel("sale-panel", 
                { 
                  draggable: false,
                  modal: false,
                  visible: false,
                  close: false,
                  context: [ 'sale-tag', 'tl', 'tr' ]
                }
              );

  salePanel.setHeader("Sizzling Summer Sale- July 2009");
  salePanel.setBody("<div id='summer-sale'><p>High Summer, Low Prices</p><p><span id='discount'>15% off</span> all online orders, today through <span id='end-date'>August 31st</span>.</p><p>Enter Promo code <span id='promo-code'>SUMMER09</span> at checkout.</p></div>");
  salePanel.setFooter("<p>Ends August 31st 2009</p>");
  Event.observe(window, 'load', function() {
    salePanel.render(document.body);
    $('sale-tag').observe('mouseover', showSaleTagPanel);
    $('sale-tag').observe('mouseout', hideSaleTagPanel)
  });

}

function showSaleTagPanel() {
  salePanel.show();
}

function hideSaleTagPanel() {
  salePanel.hide();
}
