﻿var defaultSearchText = 'Search products';

$(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"));

        }
function selectDescriptionTab() {
    //$("#productTabs").tabs().tabs('select', $("#productTabs ul a:contains(Reviews)").attr("href"));


            $("#productTabs").tabs().tabs('select', $("#productTabs ul a:contains(Description)").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]);
                    //alert("external");
                    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;
                    }
                });
            }
        });
    });
}

