﻿/// <reference path="jquery-1.3.2.min-vsdoc.js" />

(function ($) {
    $.fn.vAlign = function () {
        return this.each(function (i) {
            var ah = $(this).height();
            var ph = $(this).parent().height();
            var mh = (ph - ah) / 2;
            $(this).css('margin-top', mh);
        });
    };
})(jQuery);

$(document).ready(function() {
    $('div#productcolumn01 div#smallImages ul.small_product_images a').click(function() {

        var x = $('div#productcolumn01 div#productimagecontainer img.product_image').attr('src');

        var y = $(this).children('img').attr('src').replace('/Medium/', '/Larger/').replace('width=80&maxHeight=85', 'width=340&maxHeight=350')

        $(this).children('img').attr('src', x.replace('/Larger/', '/Medium/').replace('width=340&maxHeight=350', 'width=80&maxHeight=85'));
        $('div#productcolumn01 div#productimagecontainer img.product_image').attr('src', y);

        return false;
    });
    $('div#productcolumn01 div#YouTubeVideoImages ul.small_product_images a').click(function() {
        $(this).parents('ul').children('li').removeClass('hidden');
        $(this).parents('li').addClass('hidden');

        var imgId = $(this).parents('li').attr('id').substring(10, 12);

        var youTubeVideoWrapper = $('div#productcolumn01 div#youtubevideo div.videowrapper');
        youTubeVideoWrapper.addClass('hidden');

        var youTubeCurrentVideoWrapper = $('div#productcolumn01 div#youtubevideo div#video' + imgId);

        youTubeCurrentVideoWrapper.removeClass('hidden');

        var p = $('div#productcolumn01 div#youtubevideoscontainer p');
        var s = $('div#productcolumn01 div#YouTubeVideoImages li#videoImage' + imgId + ' img');
        p.html(s.attr('alt'));

        return false;
    });
});
