﻿$(document).ready(function(){   
    $('.show-news').livequery(function(){
        $(this).click(function(){
            id = $(this).attr('news_id');
            
            //title
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "News.aspx/GetTitle",
                data: "{id:'"+id+"'}",
                dataType: "json",
                success: function(msg){    
                    $('#pnlTitle').html(msg.d);
                },
                error: function(msg){
                    
                }
            });
            
            //description
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "News.aspx/GetDescription",
                data: "{id:'"+id+"'}",
                dataType: "json",
                success: function(msg){                                
                    $('#pnlDescription').html(msg.d);
                },
                error: function(msg){
                    
                }
            });
            
            //image
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "News.aspx/GetImage",
                data: "{id:'"+id+"'}",
                dataType: "json",
                success: function(msg){                                
                    $('#pnlImage').html(msg.d);
                },
                error: function(msg){
                    
                }
            });
        });
    });
    
    //scroller
    var div;
    var i = 0;    
    var height = 0;
    
    $('.right-side .arrow-down a').livequery(function(){
        height = $('#pnlDescription').height();
        $(this).mousehold(20, function(){
            if(i <= height){
                i = i + 5;
                $(this).parent('div').prev().scrollTop(i);
                i = $(this).parent('div').prev().scrollTop();
                $('.info').html(i+", "+height);
            }
        });
    });
    $('.right-side .arrow-up a').livequery(function(){
        $(this).mousehold(20, function(){
            if(i > 0){
                i = i - 5;
                $(this).parent('div').next().scrollTop(i);
                i = $(this).parent('div').next().scrollTop();
                $('.info').html(i+", "+height);
            }
        });
    });
    
    $('#old-news .arrow-down a').livequery(function(){
        height = $('#pnlDescription').height();
        $(this).mousehold(20, function(){
            if(i <= height){
                i = i + 5;
                $(this).parent('div').prev().scrollTop(i);
                i = $(this).parent('div').prev().scrollTop();
                $('.info').html(i+", "+height);
            }
        });
    });
    $('#old-news .arrow-up a').livequery(function(){
        $(this).mousehold(20, function(){
            if(i > 0){
                i = i - 5;
                $(this).parent('div').next().scrollTop(i);
                i = $(this).parent('div').next().scrollTop();
                $('.info').html(i+", "+height);
            }
        });
    });
});
