﻿/// <reference path="jquery-1.2.6.js" />

$(document).ready(function() {

    $('a.clueTip').cluetip({
        width: '350px'
	, height: '200px'
	, showTitle: false
	, arrows: true
	, cluetipClass: 'jtip'
    });

    $('div.instructions').moreText();
    $('div.sysreq').moreText();

    if (!$.browser.opera) {
        $('#carouseltop').jcarousel({
            vertical: true
		, scroll: 5
		, auto: 3
		, wrap: 'last'
		, initCallback: carousel_initCallback
        });
    }
    else {
        $('#carouseltop li').css({'clear' : 'both', 'margin-bottom' : '10px'});
    }


});

function carousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$(function() {
	$('a[@rel*=lightbox]').lightBox({
	imageLoading:			'/images/lightbox-ico-loading.gif',
	imageBtnPrev:			'/images/lightbox-btn-prev.gif',
	imageBtnNext:			'/images/lightbox-btn-next.gif',
	imageBtnClose:			'/images/lightbox-btn-close.gif',
	imageBlank:				'/images/lightbox-blank.gif',
	txtImage: 'Превью',
	txtOf: 'из'
	});
});


(function($) {

  $.fn.moreText = function(options) {

	var defaults = {
		moreText: "[Показать]", 
		lessText: "[Спрятать]"
	}

	var options = $.extend(defaults, options);

	return this.each(function() {
		obj = $(this);

		var body = obj.html();
		obj.html('<span class="truncate_more">' + body + '</span>');

		obj.prepend(
			'<a href="#" class="truncate_more_link">' + options.moreText + '</a><br />'
		);
		var moreLink = $('.truncate_more_link', obj);
		var moreContent = $('.truncate_more', obj);
		moreLink.click(function() {
			if(moreLink.text() == options.moreText) {
				moreContent.show('normal');
				moreLink.text(options.lessText);
			} else {
				moreContent.hide('normal');
				moreLink.text(options.moreText);
			}
			return false;
			});
		moreContent.hide();
		
	}); // end each

};
})(jQuery);
