﻿$(document).ready(function() {
    $(".featured-product-2 ul.products li.product").css("margin-right", "10px");
    $(".featured-product-2 ul.products li.product:nth-child(3n)").css("margin-right", "0");
    $(".featured-product-3 ul.products li.product").css("margin-right", "10px");
    $(".featured-product-3 ul.products li.product:nth-child(3n)").css("margin-right", "0");
    $("#product-search-listing ul.products li.product").css("margin-right", "10px");
    $("#product-search-listing ul.products li.product:nth-child(4n)").css("margin-right", "0");
    $("#category-product-listing ul.products li.product").css("margin-right", "10px");
    $("#category-product-listing ul.products li.product:nth-child(3n)").css("margin-right", "0");
    $("img.product-image-thumbnail").click(function() {
        $(".product-image-main")[0].src = this.src;
    });
    $("img.product-image-thumbnail").css("cursor", "hand");
});

$(function() {
    var spt = $('span.mailme');
    var at = / at /;
    var dot = / dot /g;
    var addr = $(spt).text().replace(at, "@").replace(dot, ".");
    var htmlTag = 'a';
    $(spt).after('<' + htmlTag + ' href="mailto:' + addr + '" title="Send an email">' + addr + '</' + htmlTag + '>')
			.hover(function() { window.status = "Send a letter!"; }, function() { window.status = ""; });
    $(spt).remove();
});

$(function() {
    $('a.popup-window').click(function() {
        window.open(this.href, 'ExternalLink', "height=600,width=800,status=yes,toolbar=no,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
        return false;
    });
});

$(function() {
    $('.search-field').keydown(function(e) {
        if (e.keyCode == 13) {
            productSearch();
            return false;
        }
    });
});

function productSearch() {
    window.location = '/ProductSearch.aspx?Query=' + document.getElementById('SearchQuery').value + '&amp;ProductCategoryId=' + document.getElementById('ProductCategoryId').value + '';
}		