;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
$(document).ready(function(){
	$.ajaxSetup ({
		cache: false
	});

    $('form input[title!=""]').hint();

	$('.logout').click(function(){
		$.ajax({
			url: $(this).attr('href') ,
				cache: false, 
			success: function(data){
				window.location.reload();			
			}
		});
		return false;
	});
  	
	
	$('.clc_incatalog').click(function(){
		$('body').scrollTo( 600, 520, { queue:true } );
		return false;
	});
	
	$('.clc_more').click(function(){
		$('body').scrollTo( 600, 520, { queue:true } );
		return false;
	});
	
	$('.lost-pass,.profilelink').fancybox({'padding':0,'fitToView':true,'closeClick':false,'aspectRatio':true,'autoSize':true});

	if($(".catalog-carousel-item").length){
		$(".catalog-carousel-item .carousel-inner").carousel( { pagination: true, direction: "vertical", btnsPosition:"outside", prevBtn:'', nextBtn:''} );
	}
	$('.articles-cantainer .tabs').delegate('li:not(.current)', 'click', function() {
		$(this).addClass('current').siblings().removeClass('current')
			.parents('div.articles-cantainer').find('div.box').hide().eq($(this).index()).fadeIn(150);
		$('#article_name span').text($(this).text());
	});
	
	$('.yamies li').each(function () {
            var distance = 10;
            var time = 250;
            var hideDelay = 500;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $(this).find('.yami');
            var info = $(this).find('.popup').css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    return;
                } else {
                    beingShown = true;

                    info.css({
                        bottom: 90,
                        left: 10,
                        display: 'block'
                    }).animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
	if($(".maincarousel").length){
		$(".maincarousel").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible:1,
			circular: false
		});
	}
	if($(".related-carousel").length){
		$(".related-carousel").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible:2
		});
	}
	if($('#thumbs').length){
		var gallery = $('#thumbs').galleriffic({
			delay:                     100, // in milliseconds
			numThumbs:                 20, // The number of thumbnails to show page
			preloadAhead:              40, // Set to -1 to preload all images
			imageContainerSel:		   '#slideshow',
			enableTopPager:            false,
			enableBottomPager:         false,
			renderSSControls:          false, // Specifies whether the slideshow's Play and Pause links should be rendered
			renderNavControls:         false, // Specifies whether the slideshow's Next and Previous links should be rendered
			enableHistory:             false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes
			enableKeyboardNavigation:  false, // Specifies whether keyboard navigation is enabled
			autoStart:                 false, // Specifies whether the slideshow should be playing or paused when the page first loads
			syncTransitions:           false, // Specifies whether the out and in transitions occur simultaneously or distinctly
			defaultTransitionDuration: 100, // If using the default transitions, specifies the duration of the transitions
		});
	}
});
function userform(form) {
	var frm = form;
  	$.ajax({
		url: frm.attr('action') ,
		data: frm.serialize(),
		type: 'POST',
	        cache: false, 
		success: function(data){
			$('.ajax-login-form').html($(data+ '.ajax-login-form').html());
window.location.reload();			
		}
	});
	return false;
}
function getusereditor(form){
	var frm = form;
	$.ajax({
		url: frm.attr('action') ,
		data: frm.serialize(),
		type: 'POST',
	        cache: false, 
		success: function(data){
			$('.ajax-register-form').html($(data+ '.ajax-register-form').html());					  
		}
	});
	return false;
}
function regform(form) {
	var frm = form;
  	$.ajax({
		url: frm.attr('action') ,
		data: frm.serialize(),
		type: 'POST',
	        cache: false, 
		success: function(data){
			$('.ajax-register-form').html($(data+ '.ajax-register-form').html());
	
		}
	});
	return false;
}
function resetform(form) {
	var frm = form;
  	$.ajax({
		url: frm.attr('action') ,
		data: frm.serialize(),
		type: 'POST',
	        cache: false, 
		success: function(data){
			$('.ajax-reset-form').html($(data+ '.ajax-reset-form').html());		
window.location.reload();			
		}
	});
	return false;
}

function submitFeedBack(form){
	var frm = form;
			  	$.ajax({
					url: frm.attr('action') ,
					data: frm.serialize(),
					type: 'POST',
				        cache: false, 
					success: function(data){
						$('.ajax-form').html($(data+ '.ajax-form').html());
					}
				});
				return false;
}
function setCartActionsCallback(){
$.ajax({
					url: '/getyamies.html',
					type: 'POST',
				    cache: false, 
					success: function(data){
						$('#yamieslist').html($(data).html());
					}
				});
}

