$(document).ready(function() {

//$("a[rel^='lightbox']").fancybox();
//$(".fbox").fancybox({
$("a[rel^='lightbox']").fancybox({
    'hideOnContentClick': true,
    'overlayShow': true
});
$("a.fancy").fancybox({
    'hideOnContentClick': true,
    'overlayShow': true
});

    if ($("#prepRotate").length > 0) {
        $("#prepRotate").wslide({
            width: 155,
            height: 280,
            pos: 1,
            horiz: true,
            duration: 500,
            autolink: "pageMenu",
            numberOrder: "reversal",
            timer: 1,
            tdelay: 4000
        });

        $("#prodBl").wslide({
            width: 510,
            internalWidth: 170,
            height: 45,
            pos: 1,
            fade: false,
            visible: 3,
            horiz: true,
            autolink: false,
            duration: 3000,
            timer: 1,
            tdelay: 7100
        });
    }

    var alst = $("#prodRotBl li a");

    if (alst.length > 0) {
        var plst = $("#prodBt > div");
        var bplst = $("#prodBe > div");
        var cnt = plst.length;

        for (var i = 0; i < alst.length; i++) {
            var idx = i % cnt;
            if (idx > 0) {
                $(bplst[idx]).css("display", "none");
                $(plst[idx]).css("display", "none");
            }

            $(plst[idx]).attr("id", "pId" + idx);
            $(alst[i]).attr("pId", "pId" + idx).attr("bpId", "bpId" + idx);
            $(bplst[idx]).attr("id", "bpId" + idx);
            $(alst[i]).click(function() {
                $("#prodBe > div").css("display", "none");
                $("#prodBt > div").css("display", "none");
                var pId = $(this).attr("pId");
                var bpId = $(this).attr("bpId");

                $("#" + bpId).css("display", "block");
                $("#" + pId).css("display", "block");

                return false;
            });
        }
    }
});

var IE = document.all ? true : false;
var timerT;

function showSmall(elem, imgUrl) {
    var url = $(elem).parent("a").attr("href");
    var title = $(elem).parent("a").attr("title");
    var smallDiv = $("#smallDiv");
    if (timerT) clearTimeout(timerT);

    if (smallDiv.length == 0) {
        var divElem = document.createElement("div");
        divElem.id = "smallDiv";
        if (!IE)
        {
	        divElem.addEventListener("mouseover", function() { clearTimeout(timerT); }, false);
	        divElem.addEventListener("mouseout", hideSmall, false);
        }
        else
        {
            divElem.onmouseover = function() { clearTimeout(timerT); };
            divElem.onmouseout = hideSmall;
		}
        smallDiv = $(divElem);
        $("#main").append(divElem);
    }

    smallDiv.html("<a href='" + url + "'><strong>" + title + "</strong><br /><img src='" + imgUrl + "' alt='" + title + "' title='" + title + "' /></a>");
    smallDiv.positionBy({ target: elem, targetPos: 0, elementPos: 0 });
    timerT = setTimeout("delayedShow()", 600);
}
function delayedShow() {
    clearTimeout(timerT);
    $("#smallDiv").css("visibility", "visible");
}

function delayedHide() {
    clearTimeout(timerT);
    $("#smallDiv").css("visibility", "hidden");
}

function hideSmall() {
    clearTimeout(timerT);
    timerT = setTimeout("delayedHide()", 600);
}

