﻿// JavaScript Document
var loadingGraphic = '<img src="/assets/images/loading.gif">';

$(document).ready(function() {
	productSearch.clearData();
	/*
	emailSubscribe.clearData();
	emailSubscribe.processForm();
	*/
	
	$("#homepagePodWrapper div:last").css("margin-right", "0");
	$("#homepageFeatureButtonWrapper a:last").css("margin-right", "0");
	$("#layTopMenu a:last").css("margin-right", "0");
});

$(document).ready(function(){
	$("#ppclubPrice").change(function() {
		var options = '';
		options += '<option value="Mixed">1 Red, 1 White</option>';
		options += '<option value="Red">2 Reds</option>';
		if ($("#ppclubPrice").val() == 29.99) {
			options += '<option value="White">2 Whites</option>';
		}
		$("#ppclubType").html(options);
		$('#ppclubType option:first').attr('selected', 'selected');
		options = '';
		if ($("#ppclubPrice").val() == 29.99) {
			options += '<option value="0">No – Bill me monthly</option>';
			options += '<option value="3">Yes - 3 Month Prepaid $109.99</option>';
			options += '<option value="6">Yes - 6 Month Prepaid $199.99</option>';
			options += '<option value="12">Yes - 12 Month Prepaid $369.99</option>';		
		} else {
			options += '<option value="0">No – Bill me monthly</option>';
			options += '<option value="3">Yes - 3 Month Prepaid $139.99</option>';
			options += '<option value="6">Yes - 6 Month Prepaid $259.99</option>';
			options += '<option value="12">Yes - 12 Month Prepaid $499.99</option>';		
		}
		$("#ppGift").html(options);
		$('#ppGift option:first').attr('selected', 'selected');
	});
});


productSearch = {
	clearData: function() {
		$("#searchForm input").focus(function() {
			$(this).attr('value','');
		});
		$("#searchForm input").blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this)[0].defaultValue);
			}
		});		
	}
}

/*
emailSubscribe = {
	clearData: function() {
		$("#subscribeForm input").focus(function() {
			$(this).attr('value','');
		});
		$("#subscribeForm input").blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this)[0].defaultValue);
			}
		});		
	},
	processForm: function() {
		$("#subscribeForm form").submit(function(){
			formLabelsAndValues=$("#subscribeForm form").serialize();
			$("#subscribeForm").html(loadingGraphic);
			$.post('/components/subscribe/process.cfm',formLabelsAndValues, function(response) {
				emailSubscribe.formResponse(response);
			});
			return false;
		});	
	},
	formResponse: function(response) {
		$("#subscribeForm").html(response);
		emailSubscribe.processForm();
	}
}
*/

/*
var thirsty = new RegExp('promocode=THIRSTY');
var gfree = new RegExp('promocode=GFREE');
var tday20 = new RegExp('promocode=TDAY20');
var bgsfree = new RegExp('promocode=BGSFREE');
var bloom20 = new RegExp('promocode=BLOOM20');
var bloom30 = new RegExp('promocode=BLOOM30');
var bloom40 = new RegExp('promocode=BLOOM40');
var bloomfs = new RegExp('promocode=BLOOMFS');
var popcorn20 = new RegExp('promocode=POPCORN20');
var popcorn30 = new RegExp('promocode=POPCORN30');
var popcorn40 = new RegExp('promocode=POPCORN40');
var popcornfs = new RegExp('promocode=POPCORNFS');
var cheryls20 = new RegExp('promocode=CHERYLS20');
var cheryls30 = new RegExp('promocode=CHERYLS30');
var cheryls40 = new RegExp('promocode=CHERYLS40');
var cherylsfs = new RegExp('promocode=CHERYLSFS');
var fannie20 = new RegExp('promocode=FANNIE20');
var fannie30 = new RegExp('promocode=FANNIE30');
var fannie40 = new RegExp('promocode=FANNIE40');
var fanniefs = new RegExp('promocode=FANNIEFS');
var baskets20 = new RegExp('promocode=BASKETS20');
var baskets30 = new RegExp('promocode=BASKETS30');
var baskets40 = new RegExp('promocode=BASKETS40');
var basketsfs = new RegExp('promocode=BASKETSFS');
var celeb20 = new RegExp('promocode=CELEB20');
var celeb30 = new RegExp('promocode=CELEB30');
var celeb40 = new RegExp('promocode=CELEB40');
var celebfs = new RegExp('promocode=CELEBFS');


$(document).ready(function() {

if (document.URL.match(gfree))
	$('#backgroundWrapper').append('<div id="gfreecode"></div>');
	$('#gfreecode').load('/assets/js/promo-codes/gfree.html').dialog({
	modal: true,
	width: 350,
	height: 250,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Discount Applied!'
	});

if (document.URL.match(thirsty))
	$('#backgroundWrapper').append('<div id="thirstycode"></div>');
	$('#thirstycode').load('/assets/js/promo-codes/thirsty.html').dialog({
	modal: true,
	width: 350,
	height: 250,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Discount Applied!'
	});

if (document.URL.match(tday20))
	$('#backgroundWrapper').append('<div id="tday20code"></div>');
	$('#tday20code').load('/assets/js/promo-codes/tday20.html').dialog({
	modal: true,
	width: 350,
	height: 250,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Discount Applied!'
	});
	
if (document.URL.match(bgsfree))
	$('#backgroundWrapper').append('<div id="bgsfreecode"></div>');
	$('#bgsfreecode').load('/assets/js/promo-codes/bgsfree.html').dialog({
	modal: true,
	width: 350,
	height: 250,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Discount Applied!'
	});

if (document.URL.match(bloom20))
	$('#backgroundWrapper').append('<div id="bloom20code"></div>');
	$('#bloom20code').load('/assets/js/promo-codes/bloomnet.html #bloom20div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, BloomNet Member!'
	});

if (document.URL.match(bloom30))
	$('#backgroundWrapper').append('<div id="bloom30code"></div>');
	$('#bloom30code').load('/assets/js/promo-codes/bloomnet.html #bloom30div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, BloomNet Member!'
	});

if (document.URL.match(bloom40))
	$('#backgroundWrapper').append('<div id="bloom40code"></div>');
	$('#bloom40code').load('/assets/js/promo-codes/bloomnet.html #bloom40div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, BloomNet Member!'
	});

if (document.URL.match(bloomfs))
	$('#backgroundWrapper').append('<div id="bloomfscode"></div>');
	$('#bloomfscode').load('/assets/js/promo-codes/bloomnet.html #bloomfsdiv').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, BloomNet Member!'
	});

if (document.URL.match(popcorn20))
	$('#backgroundWrapper').append('<div id="popcorn20code"></div>');
	$('#popcorn20code').load('/assets/js/promo-codes/popcorn.html #popcorn20div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Popcorn Factory Friend!'
	});

if (document.URL.match(popcorn30))
	$('#backgroundWrapper').append('<div id="popcorn30code"></div>');
	$('#popcorn30code').load('/assets/js/promo-codes/popcorn.html #popcorn30div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Popcorn Factory Friend!'
	});

if (document.URL.match(popcorn40))
	$('#backgroundWrapper').append('<div id="popcorn40code"></div>');
	$('#popcorn40code').load('/assets/js/promo-codes/popcorn.html #popcorn40div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Popcorn Factory Friend!'
	});

if (document.URL.match(popcornfs))
	$('#backgroundWrapper').append('<div id="popcornfscode"></div>');
	$('#popcornfscode').load('/assets/js/promo-codes/popcorn.html #popcornfsdiv').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Popcorn Factory Friend!'
	});

if (document.URL.match(fannie20))
	$('#backgroundWrapper').append('<div id="fannie20code"></div>');
	$('#fannie20code').load('/assets/js/promo-codes/fannie.html #fannie20div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Fannie May Friend!'
	});

if (document.URL.match(fannie30))
	$('#backgroundWrapper').append('<div id="fannie30code"></div>');
	$('#fannie30code').load('/assets/js/promo-codes/fannie.html #fannie30div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Fannie May Friend!'
	});

if (document.URL.match(fannie40))
	$('#backgroundWrapper').append('<div id="fannie40code"></div>');
	$('#fannie40code').load('/assets/js/promo-codes/fannie.html #fannie40div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Fannie May Friend!'
	});

if (document.URL.match(fanniefs))
	$('#backgroundWrapper').append('<div id="fanniefscode"></div>');
	$('#fanniefscode').load('/assets/js/promo-codes/fannie.html #fanniefsdiv').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Fannie May Friend!'
	});

if (document.URL.match(cheryls20))
	$('#backgroundWrapper').append('<div id="cheryls20code"></div>');
	$('#cheryls20code').load('/assets/js/promo-codes/cheryls.html #cheryls20div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Cheryl\'s Friend!'
	});

if (document.URL.match(cheryls30))
	$('#backgroundWrapper').append('<div id="cheryls30code"></div>');
	$('#cheryls30code').load('/assets/js/promo-codes/cheryls.html #cheryls30div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Cheryl\'s Friend!'
	});

if (document.URL.match(cheryls40))
	$('#backgroundWrapper').append('<div id="cheryls40code"></div>');
	$('#cheryls40code').load('/assets/js/promo-codes/cheryls.html #cheryls40div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Cheryl\'s Friend!'
	});

if (document.URL.match(cherylsfs))
	$('#backgroundWrapper').append('<div id="cherylsfscode"></div>');
	$('#cherylsfscode').load('/assets/js/promo-codes/cheryls.html #cherylsfsdiv').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Cheryl\'s Friend!'
	});

if (document.URL.match(baskets20))
	$('#backgroundWrapper').append('<div id="baskets20code"></div>');
	$('#baskets20code').load('/assets/js/promo-codes/baskets.html #baskets20div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, 1-800-Baskets Friend!'
	});

if (document.URL.match(baskets30))
	$('#backgroundWrapper').append('<div id="baskets30code"></div>');
	$('#baskets30code').load('/assets/js/promo-codes/baskets.html #baskets30div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, 1-800-Baskets Friend!'
	});

if (document.URL.match(baskets40))
	$('#backgroundWrapper').append('<div id="baskets40code"></div>');
	$('#baskets40code').load('/assets/js/promo-codes/baskets.html #baskets40div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, 1-800-Baskets Friend!'
	});

if (document.URL.match(basketsfs))
	$('#backgroundWrapper').append('<div id="basketsfscode"></div>');
	$('#basketsfscode').load('/assets/js/promo-codes/baskets.html #basketsfsdiv').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, 1-800-Baskets Friend!'
	});

if (document.URL.match(celeb20))
	$('#backgroundWrapper').append('<div id="celeb20code"></div>');
	$('#celeb20code').load('/assets/js/promo-codes/celeb.html #celeb20div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Celebrations Friend!'
	});

if (document.URL.match(celeb30))
	$('#backgroundWrapper').append('<div id="celeb30code"></div>');
	$('#celeb30code').load('/assets/js/promo-codes/celeb.html #celeb30div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Celebrations Friend!'
	});

if (document.URL.match(celeb40))
	$('#backgroundWrapper').append('<div id="celeb40code"></div>');
	$('#celeb40code').load('/assets/js/promo-codes/celeb.html #celeb40div').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Celebrations Friend!'
	});

if (document.URL.match(celebfs))
	$('#backgroundWrapper').append('<div id="celebfscode"></div>');
	$('#celebfscode').load('/assets/js/promo-codes/celeb.html #celebfsdiv').dialog({
	modal: true,
	width: 400,
	height: 300,
	buttons: { "Shop Now": function() { $(this).dialog("close"); } },
	title: 'Welcome, Celebrations Friend!'
	});

});

*/
