
	
$(document).ready(function(){ 
	// action timer
	//$("#countdown-example").countdown(new Date(2012, 00, 01, 00, 00, 00), {prefix:'До нового года осталось: ', finish: 'С Новым годом!'});
	//$("#actionlink").html( 'Акция началась!');
	
	//$("#actionlink").countdown(new Date(2012, 00, 01, 00, 00, 00), {prefix:'Акция продлена! До окончания акции осталось: ', finish: 'Акция закончилась!'});
	//
    // popup for bottom catalog
    $('.serlist').cluetip({
        topOffset:        0,
        leftOffset:       1,
        arrows: false,
        cluetipClass: 'jtip',
        positionBy: 'mouse',
        dropShadow:false,
        dropShadowSteps:  1,
        waitImage:false,
        fx: {
            open:'fadeIn', // can be 'show' or 'slideDown' or 'fadeIn'
            openSpeed: '1000'
        }
    });
    

      /*   CATALOGUE  */
    /*    
     //lightbox
    $('.lightbox').lightBox({
                maxHeight: 400,
                maxWidth: 400,
               containerResizeSpeed: 300,
               overlayOpacity: 0.6,
        	     keyToClose:'esc'
    });
     
     
     
     //lightbox peolples
    $('.peoples').lightBox({
                maxHeight: 400,
            maxWidth: 400,
        containerResizeSpeed: 300,
        overlayOpacity: 0.6,
        keyToClose:'esc'
    });
    */
    
    $("a[rel='colorbox']").colorbox({transition:"elastic",speed:"100",maxWidth:"90%",maxHeight:"90%",slideshow:true,slideshowAuto:false});
    $("a[rel='pimgs']").colorbox({slideshow:true,maxWidth:"90%",maxHeight:"90%"});
    $(".3dface").colorbox();    
    
    
    // lightbox for serais and items
    //$('.itemimg').lightBox({fixedNavigation:true});    
   
   
     
});


jQuery.fn.countdown = function (date, options) {
		options = jQuery.extend({
			lang: {
				years:   ['год', 'года', 'лет'],
				months:  ['месяц', 'месяца', 'месяцев'],
				days:    ['день', 'дня', 'дней'],
				hours:   ['час', 'часа', 'часов'],
				minutes: ['минута', 'минуты', 'минут'],
				seconds: ['секунда', 'секунды', 'секунд'],
				plurar:  function(n) {
					return (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
				}
			}, 
			prefix: "Осталось: ", 
			finish: "Всё"			
		}, options);
 
		var timeDifference = function(begin, end) {
		    if (end < begin) {
			    return false;
		    }
		    var diff = {
		    	seconds: [end.getSeconds() - begin.getSeconds(), 60],
		    	minutes: [end.getMinutes() - begin.getMinutes(), 60],
		    	hours: [end.getHours() - begin.getHours(), 24],
		    	days: [end.getDate()  - begin.getDate(), new Date(begin.getYear(), begin.getMonth() + 1, 0).getDate() - 1],
		    	months: [end.getMonth() - begin.getMonth(), 12],
		    	years: [end.getYear()  - begin.getYear(), 0]
		    };
		    var result = new Array();
		    var flag = false;
		    for (i in diff) {
		    	if (flag) {
		    		diff[i][0]--;
		    		flag = false;
		    	}    	
		    	if (diff[i][0] < 0) {
		    		flag = true;
		    		diff[i][0] += diff[i][1];
		    	}
		    	if (!diff[i][0]) continue;
			    result.push(diff[i][0] + ' ' + options.lang[i][options.lang.plurar(diff[i][0])]);
		    }
		    return result.reverse().join(' ');
		};
		var elem = $(this);
		var timeUpdate = function () {
		    var s = timeDifference(new Date(), date);
		    if (s.length) {
		    	elem.html(options.prefix + s);
		    } else {
		        clearInterval(timer);
		        elem.html(options.finish);
		    }		
		};
		timeUpdate();
		var timer = setInterval(timeUpdate, 1000);		
	};
	
