﻿// Hide/Show Content
// --------------------------------
$(document).ready(function() {

	// Optional message for form fields
    // --------------------------------
    $("a.ArticleTitle").click(function() {
        var CurrentClass = $(this).attr("class")

        if (CurrentClass == "ArticleTitle") {
            $(this).removeClass("ArticleTitle");
            $(this).addClass("ArticleTitleOff");
        } else {
            $(this).removeClass("ArticleTitleOff");
            $(this).addClass("ArticleTitle");
        };

        $(this).parent().next(".ArticleBody").slideToggle("slow");
    });



    // Optional message for form fields
    // --------------------------------
    $(".OptionalInput").each(function() {
        $(this).val($(this).attr("title"));
        $(this).css({ color: "#cccccc" });
    });

    $(".OptionalInput").focus(function() {
        if ($(this).val() == $(this).attr("title")) {
            $(this).val("");
            $(this).css({ color: "#666666" });
        }

    }).blur(function() {
        if ($(this).val() == "") {
            $(this).val($(this).attr("title"));
            $(this).css({ color: "#cccccc" });
        }
    });

});





var defaultSearchText = 'Search...';

$(document).ready(function() {
    $('.searchBox').click(
        function() {
            if (this.value == defaultSearchText) {
                this.value = '';
            }
        }
    );
    $('.searchBox').blur(
        function() {
            if (this.value == '') {
                this.value = defaultSearchText;
            }
        }
    );
});

function selectReviewTab() {
    //$("#productTabs").tabs().tabs('select', $("#productTabs ul a:contains(Reviews)").attr("href"));
            $("#productTabs").tabs().tabs('select', $("#productTabs ul a:contains(Reviews)").attr("href"));

        }

if (typeof jQuery != 'undefined') {
    jQuery(document).ready(function($) {
        var filetypes = /\.(zip|exe|pdf|doc*|xls*|ppt*|mp3)$/i;
        $('a').each(function() {
            var href = $(this).attr('href');
            if ($(this).hasClass('productVideos')) {
                $(this).click(function() {
                    _gaq.push(['_trackEvent', 'image', 'zoom', 'video']);
                });
            }
            else if ($(this).hasClass('productImages')) {
                $(this).click(function() {
                    _gaq.push(['_trackEvent', 'image', 'zoom', 'thumbnail']);
                });
            }
            else if (href && (href.match(/^https?\:/i)) && (!href.match('document.domain'))) {
                $(this).click(function() {
                    var extLink = href.replace(/^https?\:\/\//i, '');
                    _gaq.push(['_trackEvent', 'External', 'Click', extLink]);
                    if ($(this).attr('target') != '_blank') {
                        setTimeout(function() { location.href = href; }, 200);
                        return false;
                    }
                });
            }
            else if (href && href.match(/^mailto\:/i)) {
                $(this).click(function() {
                    var mailLink = href.replace(/^mailto\:/i, '');
                    _gaq.push(['_trackEvent', 'Email', 'Click', mailLink]);
                });
            }
            else if (href && href.match(filetypes)) {
                $(this).click(function() {
                    var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
                    var filePath = href;
                    _gaq.push(['_trackEvent', 'Download', 'Click-' + extension, filePath]);
                    if ($(this).attr('target') != '_blank') {
                        setTimeout(function() { location.href = href; }, 200);
                        return false;
                    }
                });
            }
        });
    });
}

