 $(document).ready(function(){

    var supernote = new SuperNote('supernote', {});
    
        
    }); 	


$(document).ready(function() {
			$("a#single_image").fancybox();
		});

$(document).ready(function() {
	  $(".pRightCol").css('height', $(".pLeftCol").height());

      
      flowplayer('a.player2', "/player/flowplayer.commercial-3.2.1.swf", { 
    // product key from your account 
    key: '#$f24812add95c118ed6a',
    clip: {   
            autoPlay: true,
            scaling: 'fit', 
            autoBuffering: true 
        },
    canvas: { 
 
    // use a wicked backgound color 
    backgroundColor: '#000000', 
 
    // a gradient 
    backgroundGradient: 'none', 
 
    // and "curved" corners 
    borderRadius: 2 
    },
    contextMenu: [
          {'Oneligh' : function() { 
          location.href = "http://www.onelight.tv"; 
          }},
          'Onelight beta 2.0'
          ],
     plugins:  { 
        controls:  { 
            backgroundGradient: 'none', 
            backgroundColor: 'transparent', 
            scrubber:true,
            height: 25,
            autoHide: true  
        } 
    },
   
    screen: { 
        bottom:0         
    }             
}); 

  flowplayer('a.player3', "/player/flowplayer.commercial-3.2.1.swf", { 
    // product key from your account 
    key: '#$f24812add95c118ed6a',
    clip: {   
            autoPlay: false,
            scaling: 'fit', 
            autoBuffering: true 
        },
    canvas: { 
 
    // use a wicked backgound color 
    backgroundColor: '#000000', 
 
    // a gradient 
    backgroundGradient: 'none', 
 
    // and "curved" corners 
    borderRadius: 2 
    },
    contextMenu: [
          {'Oneligh' : function() { 
          location.href = "http://www.onelight.tv"; 
          }},
          'Onelight beta 2.0'
          ],
     plugins:  { 
        controls:  { 
            backgroundGradient: 'none', 
            backgroundColor: 'transparent', 
            height: 25,
time:false,
            autoHide: true  
        } 
    },
   
    screen: { 
        bottom:0         
    }             
}); 












      
});
//CAROUSEL
$(window).load(function() {

//    SEND MESSAGE
    jq('#send_message_submit').live('click', function(){
         //$.post("compose.php",  $("#compose_form").serialize(),
//          function(data){
//               alert(data);
//          });
          $.ajax({
           type: "POST",
           url: "/compose.php",
           data: $("#compose_form").serialize(),
           success: function(msg){
                $("#inner_send").html(msg + '<input type="button" id="send_message_trigger_off" value="CLOSE">');  
           }
         });

    });
//      END SEND MESSAGE
      
      $('#loading').fadeOut(1000,function(){
      $('.c_carousel_container').fadeIn(1000);    
      
      
      
              
     $('.c_carousel_li img').mouseover(function(){
          $(this).css({'opacity':1});
     });
     
      $('.c_arrow').hover(function(){
            $(this).animate({'opacity':1},500);
     },function(){
            $(this).animate({'opacity':'0.5'},500);
     });
     
     
            
            
            //var amount = $('.c_carousel_ul').children().size();
            var window_width = $(window).width() - 210;
            var li_width = $('.c_carousel_li').outerWidth();
            
            var new_width = Math.floor(window_width/li_width);
            
            var current = new_width;
            new_width = new_width * li_width ;
            var amount = $('.c_carousel_ul').children().size();
            $('.c_carousel_content').width(new_width);
            
            
            $('#c_hidden_current').val(current);
            $('#c_hidden_amount').val(amount);
            
            
            var current_page = parseInt($('.c_carousel_content').css('margin-left')) / parseInt($('#c_hidden_current').val()) ;
            
            //NUMBER OF PAGES
            var num_pages = Math.ceil($('#c_hidden_amount').val() / $('#c_hidden_current').val());
            $('#c_hidden_pages_No').val(num_pages);
            
            
            //ADD EXTRA LIST ITEMS TO FILL THE GAPS
            var additional_items = num_pages * current - amount;
            var i = 0;
            var additional = '';
            while(i < additional_items){
                additional += '<li class="additional"><img src="#" style="width:230px;height:1px;"></li>';  
                i++;  
            }
            
            $('.c_carousel_li:last').after(additional);
            
            
            
            //CLONES
            var visible = $('#c_hidden_current').val();
            
            $('.c_carousel_li:first').before($('.c_carousel_ul li').slice(-visible).clone().addClass('cloned'));
            $('.c_carousel_ul li:last').after($('.c_carousel_li').slice(visible ,visible*2).clone().addClass('cloned'));
            
            
            //SET MARGIN TO SHOW THE NORMAL NOT THE CLONES
            var margin_ = $('.c_carousel_content').width() * -1;
            $('.c_carousel_ul').css({'margin-left': margin_});
            
            
            });
        $(window).resize(function(){
            
            var window_width = $(window).width() - 210;
            var li_width = $('.c_carousel_li').outerWidth();
            
            var new_width = Math.floor(window_width/li_width);
            var current = new_width;
            new_width = new_width * li_width;
            
            $('.c_carousel_content').width(new_width);
            
            $('#c_hidden_current').val(current);
            
            //num pages
            var num_pages = Math.ceil($('#c_hidden_amount').val() / $('#c_hidden_current').val());
            $('#c_hidden_pages_No').val(num_pages);
            
            var amount = $('#c_hidden_amount').val(amount);
            //number of pages * showing on page - amount of items
            var additional_items = num_pages * current - amount;
            
            //REMOVE CURRENT ADDITIONALS AND CLONED
            $('.additional').remove();
            $('.cloned').remove();
            
            //CALCULATE IT AGAIN
            var additional_items = num_pages * current - amount;
            var i = 0;
            var additional = '';
            while(i < additional_items){
                additional += '<li class="additional"><img src="#" style="width:230px;height:1px;"></li>';  
                i++;  
            }
            
            $('.c_carousel_li:last').after(additional);
            
            //CLONES
            var visible = $('#c_hidden_current').val();
            
            $('.c_carousel_li:first').before($('.c_carousel_ul li').slice(-visible).clone().addClass('cloned'));
            $('.c_carousel_ul li:last').after($('.c_carousel_li').slice(visible ,visible*2).clone().addClass('cloned'));
            
            
            //SET MARGIN TO SHOW THE NORMAL NOT THE CLONES
            var margin_ = $('.c_carousel_content').width() * -1;
            $('.c_carousel_ul').css({'margin-left': margin_});
            
            
            
            
            
        });
        
        $('.c_carousel_left').click(function(){
        
            var ul_width = $('.c_carousel_ul').css('marginLeft');
           var new_width = $('.c_carousel_content').css('width');
           new_width = parseInt(ul_width) + parseInt(new_width);
           
          
            
            $('.c_carousel_ul').animate({
            
               marginLeft: new_width
            },1500, "swing", function(){
            var current_page = Math.ceil(parseInt($('.c_carousel_ul').css('margin-left')) / parseInt($('#c_hidden_current').val() * $('.c_carousel_li').outerWidth())) * -1 + 1 ;    
            $('#c_hidden_page').val(current_page);
            if(current_page == 1){
                var margin_ = $('.c_carousel_content').width() * $('#c_hidden_pages_No').val() * -1;
                $('.c_carousel_ul').css('margin-left', margin_);    
            }
            }); 
            
        });
        
        
        //
        
            
        $('.c_carousel_right').click(function(){
             var ul_width = $('.c_carousel_ul').css('marginLeft');
           var new_width = $('.c_carousel_content').css('width');
            new_width = parseInt(ul_width) - parseInt(new_width);
            
            $('.c_carousel_ul').animate({
               marginLeft: new_width
            },1500, "swing", function(){
            var current_page = Math.ceil(parseInt($('.c_carousel_ul').css('margin-left')) / parseInt($('#c_hidden_current').val() * $('.c_carousel_li').outerWidth())) * -1 + 1 ;    
            $('#c_hidden_page').val(current_page);
            if(current_page > parseInt($('#c_hidden_pages_No').val())+1){
                var margin_ = $('.c_carousel_content').width() * -1;
                $('.c_carousel_ul').css('margin-left', margin_);    
            }
            }); 
            
           
        });
        
//        send message
          jq('#send_message_trigger').live('click', function(){
                $("#send_message_ajax").fadeIn(500);
          });
          jq('#send_message_trigger_off').live('click', function(){
                $("#send_message_ajax").fadeOut(500);
          });
//        end send message    
  });
//END CAROUSEL 
//START THE CAROUSEL FOR Pictures
  $(window).load(function() {
      
      $('#loading2').fadeOut(1000,function(){
      $('.c_carousel_container2').fadeIn(1000);    
      
      
      
              
     $('.c_carousel_li2 img').mouseover(function(){
          $(this).css({'opacity':1});
     });
     
      $('.c_arrow2').hover(function(){
            $(this).animate({'opacity':1},500);
     },function(){
            $(this).animate({'opacity':'0.5'},500);
     });
     
     
            
            
            //var amount = $('.c_carousel_ul').children().size();
            var window_width = $('.channel_post_container').width() - 110;
            var li_width = $('.c_carousel_li2').outerWidth();
            
            var new_width = Math.floor(window_width/li_width);
            
            var current = new_width;
            new_width = new_width * li_width ;
            var amount = $('.c_carousel_ul2').children().size();
            $('.c_carousel_content2').width(new_width);
            
            
            $('#c_hidden_current2').val(current);
            $('#c_hidden_amount2').val(amount);
            
            
            var current_page = parseInt($('.c_carousel_content2').css('margin-left')) / parseInt($('#c_hidden_current2').val()) ;
            
            //NUMBER OF PAGES
            var num_pages = Math.ceil($('#c_hidden_amount2').val() / $('#c_hidden_current2').val());
            $('#c_hidden_pages_No2').val(num_pages);
            
            
            //ADD EXTRA LIST ITEMS TO FILL THE GAPS
            var additional_items = num_pages * current - amount;
            var i = 0;
            var additional = '';
            while(i < additional_items){
                additional += '<li class="additional2"><img src="#" style="width:200px;height:1px;"></li>';  
                i++;  
            }
            
            $('.c_carousel_li2:last').after(additional);
            
            
            
            //CLONES
            var visible = $('#c_hidden_current').val();
            
            $('.c_carousel_li2:first').before($('.c_carousel_ul2 li').slice(-visible).clone().addClass('cloned2'));
            $('.c_carousel_ul2 li:last').after($('.c_carousel_li2').slice(visible ,visible*2).clone().addClass('cloned2'));
            
            
            //SET MARGIN TO SHOW THE NORMAL NOT THE CLONES
            var margin_ = $('.c_carousel_content2').width() * -1;
            $('.c_carousel_ul2').css({'margin-left': margin_});
            
            
            });
        $(window).resize(function(){
            
            var window_width = $('.channel_post_container').width() - 110;
            var li_width = $('.c_carousel_li2').outerWidth();
            
            var new_width = Math.floor(window_width/li_width);
            var current = new_width;
            new_width = new_width * li_width;
            
            $('.c_carousel_content2').width(new_width);
            
            $('#c_hidden_current2').val(current);
            
            //num pages
            var num_pages = Math.ceil($('#c_hidden_amount2').val() / $('#c_hidden_current2').val());
            $('#c_hidden_pages_No2').val(num_pages);
            
            var amount = $('#c_hidden_amount2').val(amount);
            //number of pages * showing on page - amount of items
            var additional_items = num_pages * current - amount;
            
            //REMOVE CURRENT ADDITIONALS AND CLONED
            $('.additional2').remove();
            $('.cloned2').remove();
            
            //CALCULATE IT AGAIN
            var additional_items = num_pages * current - amount;
            var i = 0;
            var additional = '';
            while(i < additional_items){
                additional += '<li class="additional2"><img src="#" style="width:200px;height:1px;"></li>';  
                i++;  
            }
            
            $('.c_carousel_li2:last').after(additional);
            
            //CLONES
            var visible = $('#c_hidden_current2').val();
            
            $('.c_carousel_li2:first').before($('.c_carousel_ul2 li').slice(-visible).clone().addClass('cloned2'));
            $('.c_carousel_ul2 li:last').after($('.c_carousel_li2').slice(visible ,visible*2).clone().addClass('cloned2'));
            
            
            //SET MARGIN TO SHOW THE NORMAL NOT THE CLONES
            var margin_ = $('.c_carousel_content2').width() * -1;
            $('.c_carousel_ul2').css({'margin-left': margin_});
            
            
            
            
            
        });
        
        $('.c_carousel_left2').click(function(){
        
            var ul_width = $('.c_carousel_ul2').css('marginLeft');
           var new_width = $('.c_carousel_content2').css('width');
           new_width = parseInt(ul_width) + parseInt(new_width);
           
          
            
            $('.c_carousel_ul2').animate({
            
               marginLeft: new_width
            },1500, "swing", function(){
            var current_page = Math.ceil(parseInt($('.c_carousel_ul2').css('margin-left')) / parseInt($('#c_hidden_current2').val() * $('.c_carousel_li2').outerWidth())) * -1 + 1 ;    
            $('#c_hidden_page2').val(current_page);
            if(current_page == 1){
                var margin_ = $('.c_carousel_content2').width() * $('#c_hidden_pages_No2').val() * -1;
                $('.c_carousel_ul2').css('margin-left', margin_);    
            }
            }); 
            
        });
        
        
        //
        
            
        $('.c_carousel_right2').click(function(){
             var ul_width = $('.c_carousel_ul2').css('marginLeft');
           var new_width = $('.c_carousel_content2').css('width');
            new_width = parseInt(ul_width) - parseInt(new_width);
            
            $('.c_carousel_ul2').animate({
               marginLeft: new_width
            },1500, "swing", function(){
            var current_page = Math.ceil(parseInt($('.c_carousel_ul2').css('margin-left')) / parseInt($('#c_hidden_current2').val() * $('.c_carousel_li2').outerWidth())) * -1 + 1 ;    
            $('#c_hidden_page2').val(current_page);
            if(current_page > parseInt($('#c_hidden_pages_No2').val())+1){
                var margin_ = $('.c_carousel_content2').width() * -1;
                $('.c_carousel_ul2').css('margin-left', margin_);    
            }
            }); 
            
           
        });
  });
//END THE CAROUSEL

