Cufon.replace('#content h1, footer nav li.first a');
$(document).ready(function() {
    $('input').toggleVal();
    $("a[rel='lightbox']").fancybox({
        'showNavArrows' : false,
        'titleShow'     : false,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        'easingIn'      : 'easeOutBack',
        'easingOut'     : 'easeInBack'
    });
    $("#content .column-left .ce_text").each(function () {
        $(this).fancybox({
            'titleShow'     : false,
            'transitionIn'	: 'elastic',
            'transitionOut'	: 'elastic',
            'easingIn'      : 'easeOutBack',
            'easingOut'     : 'easeInBack',
            'autoDimensions': false,
            'width'         : 390,
            'height'        : 510,
            'href'          : "#" + this.id + "-form",
			'onComplete'	: formVal
        });
    });
    if ($('.mod_catalogreader').length > 0) {
        placeArrows();
        $('.mod_catalogreader > section > img').load(function () {
            placeArrows();
        });
    }
});
var formVal = function() {
	$(this.href + ' form').validate({
		errorPlacement: function(error, element) {}
	});
}
var placeArrows = function () {
    var pos = $('.mod_catalogreader > section > img').position();
    var width = $('.mod_catalogreader > section > img').width();
    var height = $('.mod_catalogreader > section > img').height();
    if ($('#content .next').length > 0) {
        $('#content .next a').css("display", "block");
        $('#content .next').css("left", pos.left + width + 1);
        $('#content .next').css("top", pos.top + height / 2);
    }
    if ($('#content .previous').length > 0) {
        $('#content .previous a').css("display", "block");
        $('#content .previous').css("left", pos.left - $('#content .previous').width() + 1);
        $('#content .previous').css("top", pos.top + height / 2);
    }
};