/*==============================================================================
(C)2010 Yezhoff Oleg (mailbox@yezhoff.ru)
==============================================================================*/
$(window).load(function (){

$('.intro .link_bubble').mouseenter(function(){
$(this).animate({'top':'0px'},200,'');
});


$('.intro .link_bubble').mouseleave(function(){
$(this).animate({'top':'20px'},1000,'easeOutElastic');
});


$('.bubble').mouseenter(function(){

$(this).attr('src','/img/buble_boom.png').fadeOut(200);


});


/*==============================================================================
end of onload
==============================================================================*/

});


/*==============================================================================
ready
==============================================================================*/
$(document).ready(function()
{



var height=$(window).height();



$('.intro #content').css({'margin-top':height+'px'});


$('#photos .img').mouseenter(function(){
$(this).next('.title').slideUp(0);
});

$('#photos .img .title').mouseenter(function(){
$(this).slideUp(0);
});

$('#photos .img').mouseleave(function(){
$(this).next('.title').slideDown(200);
});


/*==============================================================================
//basket status
==============================================================================*/
        $('#basket_status').load('/public/basket.php?op=status');


/*==============================================================================
//add to basket
==============================================================================*/
        $('.ajax_add').click(function()
            {
                var link = $(this);


                if ($(link).hasClass('loading')) {
                    return false;
                }
                else {

                    var url = $(link).attr('href');
                    $(link).addClass('loading');
                    $(link).html('Обработка запроса...');

                    $('#basket_status').load(url, function()
                        {

                            $(link).html('Товар добавлен в корзину');

                            $(link).delay(2000).fadeOut(500, function()
                                {
                                    $(link).html('Добавить в корзину');
                                    $(link).fadeIn(500, function()
                                        {
                                            $(link).removeClass('loading');

                                        }
                                    );
                                }
                            );

                        }
                    );

                }


                return false;
            }
        );



/*==============================================================================
submit
==============================================================================*/

$('.submit').click(function(){
$('.req').removeClass('err');
$('#err').html('');


$(".req").each(function(){
if (!$(this).val()){
$(this).addClass('err').focus();
var name=$(this).attr('title');

$('#err').html('Необходимо заполнить поле <b>'+name+'</b>');
return false;
}

});

var err=$('#err').html();

if (err){
return false;
  }



});

/*==============================================================================
********************************************************************************
==============================================================================*/
//end of ready
});
/*==============================================================================
********************************************************************************
==============================================================================*/




var no = 10; // bubles
var init = 0;

var dx, xp, yp;
var am, stx, sty;
var i;


//    var doc_width = 800, doc_height = 600;
doc_width = $(window).width();
doc_height = $(window).height();


    dx = new Array();
    xp = new Array();
    yp = new Array();
    am = new Array();
    stx = new Array();
    sty = new Array();



function bubbles_move() {

    for (i = 0; i < no; ++i) {
        yp[i] -= sty[i];


        //init
        if (yp[i] < 0 || init==0) {
            dx[i] = 0;
            am[i] = Math.random()*20;
            xp[i] = Math.random()*(doc_width-am[i]-60);
            yp[i] = doc_height-50;
            stx[i] = 0.5 + Math.random()/10;
            sty[i] = i/2*2+5;

        }

        dx[i] += stx[i];
        document.getElementById("dot"+i).style.top = yp[i]+"px";
        document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i])+"px";
    }

    init = 1;
    setTimeout("bubbles_move()", 50);
}


/*==============================================================================

==============================================================================*/

hs.graphicsDir = '/public/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];

hs.outlineType = 'rounded-white';

hs.fadeInOut = true;
//hs.dimmingOpacity = 0.75;

// Add the controlbar
hs.addSlideshow({
  //slideshowGroup: 'group1',
  interval: 5000,
  repeat: false,
  useControls: true,
  fixedControls: 'fit',
  overlayOptions: {
    opacity: 0.75,
    position: 'bottom center',
    hideOnMouseOut: true
  }
});
