﻿var isSoundPlaying = true;

$(document).ready(function () {
    $("ul.product.images a").fancybox();

    //settings images sizes for the product lists.
    $("ul.products li img").each(function (index, item) {
        var width = 160;
        var height = 120;
        var keepDimensions = true;
        var realSize = false;

        //-----------------------------------------------------------
        var fullUrl = $(item).attr("src");
        if (fullUrl != "") {
            var url = fullUrl.match(/(.+)(?:\?)/)[1];

            var newUrl = url + decodeURIComponent($.query.load(fullUrl).set("width", width).set("height", height).set("realSize", realSize.toString()).set("keepDimensions", keepDimensions.toString()).toString());

            $(item).attr("src", newUrl);
        }
    });

    //settings images sizes for the categories lists.
    $("ul.listCategories li img").each(function (index, item) {
        var width = 120;
        var height = 100;
        var keepDimensions = true;
        var realSize = false;

        //-----------------------------------------------------------
        var fullUrl = $(item).attr("src");
        if (fullUrl != "") {
            var url = fullUrl.match(/(.+)(?:\?)/)[1];

            var newUrl = url + decodeURIComponent($.query.load(fullUrl).set("width", width).set("height", height).set("realSize", realSize.toString()).set("keepDimensions", keepDimensions.toString()).toString());

            $(item).attr("src", newUrl);
        }
    });
    $(".icon-sound a").click(function (e) {
        e.preventDefault();
        if (isSoundPlaying) {
            $(".icon-sound").addClass("soundoff");
            $("#myytplayer")[0].pauseVideo();
            isSoundPlaying = false;
        }
        else {
            $(".icon-sound").removeClass("soundoff");
            $("#myytplayer")[0].playVideo();
            isSoundPlaying = true;
        }
    });

    //    $("#listOrderItems").bind('DOMSubtreeModified', function (e) {
    //        $("#listOrderItems").jScrollPane();

    //    });

});
//Cufon.replace('.box h1', {
//    hover: true
//});
/*embedding youtube video by using swfobject*/
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
var musicId = "2qtg39ddNYE";
if (musicId != "") {
    swfobject.embedSWF("http://www.youtube.com/v/" + musicId + "?enablejsapi=1&playerapiid=ytplayer&autoplay=1", "mysound", "1", "1", "8", null, null, params, atts);
}
