$(function () {
    if (scripts_isIE6) $(document).pngFix();

    $('.ro').mbRollover();

    // call blank bloodyrare.com page via iframe to set cookie 
    if( $("#loadBRifrm").length > 0) {
  	var html = '<div style="visibility:hidden;"><iframe src="http://www.bloodyrare.com/blank.php" width="1" height="1"></iframe></div>';
  	$("#loadBRifrm").append(html);
    }

    if ($.fn.prettyPhoto) {
        $("a[rel^='lightbox']").prettyPhoto({
            animationSpeed: 'slow',
            padding: 40,
            opacity: 0.80,
            showTitle: false,
            allowresize: true,
            counter_separator_label: '/',
            theme: 'dark_square'
        });
    }
    
    if ($.fn.mbBookShowcase) {
        $("#tray-wrapper").mbBookShowcase({
            targetTray: 'showcaseTrays', //div id of tray in your php fetch file trays.php
            detailsImg: 'book',
            itemClass: 'book',
            imgClass: 'bookImg',
            mOvrClass: 'book-ovr',
            selClass: 'book-sel',
            phpFetchFile: 'showcaseBooks.php',
            klass: 'mbBookShowcase',
            bookId: g_showcaseRecord,
            followLink: false,
            easeInOut: true,
            easeInOutAmt: 8,
            loadTrayFromExternalFile: false
        }, function() {
            var str = this.clickid;
            str = str.substring(1);
            $("#showcaseHiddenRecord").val(str);
            if (this.event == "click") {
                $.ajax({
                    url: "/showcaseSaveItem.php?record=" + str
                });
            }
        });

        $("#book").live('click', function () {
            document.showcaseForm.submit();
        });
        
        /*
        $(".showcase-ro").hoverIntent({
		over: function(){ stopPulsate = false; pulsate($(this).attr("id"), false) }, 
		timeout: 300, 
		out: function(){ unpulsate($(this).attr("id")) }
	});
	*/
    }

});

var stopPulsate = false;
function pulsate(id, fromCallback)
{
	var toPulsate = (id == "trayPrev" ? "showcase-left-hover" : "showcase-right-hover");
	if(!stopPulsate){
		if(fromCallback){
			$("#"+toPulsate).animate({opacity: '1'},800,function(){
				$("#"+toPulsate).animate({opacity: '.5'}, 600, function(){
					pulsate(id, true);
				});
	    		});
	    	}else{
			$("#"+toPulsate).fadeIn(800,function(){
				$("#"+toPulsate).animate({opacity: '.5'}, 600, function(){
					pulsate(id, true);
				});
	    		});
	    	
	    	}
	}
}

function unpulsate(id)
{
	stopPulsate = true;
	var toPulsate = (id == "trayPrev" ? "showcase-left-hover" : "showcase-right-hover");
	$("#"+toPulsate).fadeOut();
}
