﻿$(document).ready(function () {

    // Clear field value when clicked
    $('.has_default_value').focus(function () {
        if ($(this).val() == $(this).attr('title')) {
            $(this).val('');
        }
    });
    $('.has_default_value').blur(function () {
        if ($(this).val() == '') {
            $(this).val($(this).attr('title'));
        }
    });
    // Delay by X milliseconds
    $.fn.delay = function (time, func) {
        return this.each(function () {
            setTimeout(func, time);
        });
    };

//    $(document).ready(function () {
//        var options = {
//            zoomType: 'standard',
//            lens: true,
//            preloadImages: true,
//            preloadText: 'Loading Zoom',
//            alwaysOn: false,
//            zoomWidth: 375,
//            zoomHeight: 525,
//            xOffset: 225,
//            yOffset: 0,
//            showEffect: 'fadein',
//            hideEffect: 'fadeout'
//        };
//        $('.jq-zoom').jqzoom(options);
//    });

    // Product page tabs
    $('div.main_area_product_page div.copy ul.tabs').show();
    $('div.main_area_product_page div.copy div.content').hide();
    $('div.main_area_product_page div.copy div.content h2').hide();
    $('div.main_area_product_page div.copy div.content_description').show();
    $('div.main_area_product_page div.copy ul.tabs li.description').click(function () {
        $('div.main_area_product_page div.copy ul.tabs li').removeClass('current');
        $('div.main_area_product_page div.copy ul.tabs li.description').addClass('current');
        $('div.main_area_product_page div.copy div.content').hide();
        $('div.main_area_product_page div.copy div.content_description').show();
    });
    $('div.main_area_product_page div.copy ul.tabs li.sizing').click(function () {
        $('div.main_area_product_page div.copy ul.tabs li').removeClass('current');
        $('div.main_area_product_page div.copy ul.tabs li.sizing').addClass('current');
        $('div.main_area_product_page div.copy div.content').hide();
        $('div.main_area_product_page div.copy div.content_sizing').show();
    });
    $('div.main_area_product_page div.copy ul.tabs li.fabric').click(function () {
        $('div.main_area_product_page div.copy ul.tabs li').removeClass('current');
        $('div.main_area_product_page div.copy ul.tabs li.fabric').addClass('current');
        $('div.main_area_product_page div.copy div.content').hide();
        $('div.main_area_product_page div.copy div.content_fabric').show();
    });
    // Slide-In Box
    $(document.body).delay(1500, function () {
        $("div#slide_in_box").fadeIn(500);
    });
    $("div#slide_in_box p.close").mouseup(function () {
        $("div#slide_in_box").fadeOut(500);
    });
    // Rollovers (instant)
    rollover_triggered = 'no';
    $('.rollover_instant img, img.rollover_instant').parent('a').focus(function () {
        $(this).children('img').attr('src', $(this).children('img').attr('src').replace(/\_off\./gi, '_on\.'));
        rollover_triggered = 'yes';
    });
    $('.rollover_instant input, input.rollover_instant').focus(function () {
        $(this).attr('src', $(this).attr('src').replace(/\_off\./gi, '_on\.'));
        rollover_triggered = 'yes';
    });
    $('.rollover_instant img, .rollover_instant input, img.rollover_instant, input.rollover_instant').parent('a').blur(function () {
        $(this).children('img').attr('src', $(this).children('img').attr('src').replace(/\_on\./gi, '_off\.'));
        rollover_triggered = 'no';
    });
    $('.rollover_instant input, input.rollover_instant').blur(function () {
        $(this).attr('src', $(this).attr('src').replace(/\_on\./gi, '_off\.'));
        rollover_triggered = 'no';
    });
    $('.rollover_instant img, .rollover_instant input, img.rollover_instant, input.rollover_instant').hover(function () {
        $(this).attr('src', $(this).attr('src').replace(/\_off\./gi, '_on\.'));
    },
	function () {
	    if (rollover_triggered != 'yes') {
	        $(this).attr('src', $(this).attr('src').replace(/\_on\./gi, '_off\.'));
	    }
	});
    // Rollovers (preload)
    $('.rollover_instant img, .rollover_instant input, img.rollover_instant, input.rollover_instant').each(function () {
        var source_image = $(this).attr('src');
        var rollover_image = source_image.replace(/\_off\./gi, '_on\.');
        $('<img>').attr('src', rollover_image);
    });

    // Fix all menu issues
    $('#LeftCategory4021-sale').hover(function () {
        $('#LeftSaleBarDropdown', this).show();
    }, function () {
        $('#LeftSaleBarDropdown', this).hide();
    });
    $('#LeftSaleBarDropdown li').hover(function () {
        $('ul', this).show();
    }, function () {
        $('ul', this).hide();
    });

    //ie6 menu fix
    $('div.main_area ul.navigation ul').hide();
    $('div.main_area ul.navigation li').hover(function () {
        $('ul', this).show();
        $('ul ul', this).hide();
    }, function () {
        $('ul', this).hide();
    });

});

function SendEmail() {
    var email = document.getElementById("field_103323").value;
    location.href = "/Offers/EmailVoucher.aspx?email=" + email;
}


//$(window).load(function () {
//    var product_image_width = $('.large_product_image img').width();
//    $('.large_product_image_container').width(product_image_width);
//});

//$(document).ready(function () {
//    $('ul.small_product_images a').mousedown(function () {
//        var product_image_width = $('.large_product_image img').width();
//        $('.large_product_image a.jq-zoom').width(product_image_width);
//    });
//});
