// JavaScript Document

jQuery.noConflict();
jQuery(document).ready(function($){
 
 // Voting mechanism
 $('a.vote').one('click',function(){
   var id = $(this).attr("id");
   var i = id.split("_");
   var i = i[1];
   $.ajax({
      type:"POST",
      url:'http://www.bbycks.com/shop/gallery_vote.php',
      data:{image:i},
      beforeSend: function(){
        $('#heart_'+i).attr( {src: 'images/heart-loader.gif'} );
      },
      success:function(data){
        $('#heart_'+i).attr( {src: 'images/heart.png'} );
        $('span#votes_'+i).css({color:"#009900"}).html(data);
      }
    });
    return false;
  });
  
 $(function () {
/*
 		// Image Rotate
		var angle = 0;
		var dir = 'left';
		setInterval ( function (e) {
		    rotate();
		}, 60 );
		function rotate() {
			if(dir == 'left') {
		    	$('#logo').rotate(1);
		    	$('#logo').css({ marginTop : "-" + Math.round(angle * 1.5) + "px", marginLeft : "-" + Math.round(angle / 2) + "px" });
				angle = angle + 1;
				if(angle > 29) {
					dir = 'right';
				};
			} else {
		    	$('#logo').rotate(-1);
		    	$('#logo').css({ marginTop : "-" + Math.round(angle * 1.5) + "px", marginLeft : "-" + Math.round(angle / 2) + "px"});
				angle = angle - 1;
				if(angle < 1) {dir = 'left'};
			};
		};
*/
        
        $('#countdown marquee').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
            if ($(this).data('drag') == true) {
                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
            }
        }).mousedown(function (event) {
            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        }).mouseup(function () {
            $(this).data('drag', false);
        });
        
    });
    
 });

