﻿down = function(){};

down.prototype = {
    artwork : function(e){        
        $('.preview').click(function(){
            $("#preview").remove(); 
            $('.imageview').remove();
            var src = $(this).attr('src');
            var image = new Image();
            image.src = src;
            var width = image.width;
            var height = image.height;    	        
            var top = $('html').attr('scrollTop') + 100;
            var left = (parseInt($('body').css('width')) - height) / 2;
            $('body').append('<div class="imageview"><div class="imageview_top"><img src="/images/photo_top.gif" alt="" /></div></div>');
            $('.imageview').css('left', left).css('top', top); 
            $('.imageview').animate({width : width + 2, height : height + 31, 'min-width' : 300, 'min-height' : 300},'show');
            setTimeout(function(){                    
                $('.imageview').append('<img src="'+ src +'" alt="" style="width:'+ width +'px; height:'+ height +'px;">');
            }, '500'); 
            $('.imageview').click(function(){$(this).remove();}); 
        }); 
    },
    artwork_sub : function(e){
        $('.comment').click(function(){
            var comment_img;
            if($('#comment_text').val() < 2){
                alert('내용을 입력해주세요');
                $('#comment_text').focus();
                return; 
            }
            $('input[name="comment"]').each(function(){if($(this).attr('checked')) comment_img = $(this).val();});
            $.post('/inc/xml/community.aspx', {'type' : 'screenshot_comment', 'o' : $('#ssIdx').val(), 'comment' : $('#comment_text').val(), 'imgNum' : comment_img}, function(data){
                $(data).find("result").each(function(i){                        
                    if($(this).attr('value') == '-1') alert('처리중 문제가 생겼습니다.');                        
                    else {
                        alert('댓글이 추가되었습니다.');
                        location.href = location.href;
                    }
                });
            });
        });  
        $('.preview').click(function(){
            $("#preview").remove(); 
            $('.imageview').remove();
            var src = $(this).attr('src');
            var image = new Image();
            image.src = src;
            var width = image.width;
            var height = image.height;    	        
            var top = $('html').attr('scrollTop') + 100;
            var left = (parseInt($('body').css('width')) - height) / 2;
            $('body').append('<div class="imageview"><div class="imageview_top"><img src="/images/photo_top.gif" alt="" /></div></div>');
            $('.imageview').css('left', left).css('top', top); 
            $('.imageview').animate({width : width + 2, height : height + 31, 'min-width' : 300, 'min-height' : 300},'show');
            setTimeout(function(){                    
                $('.imageview').append('<img src="'+ src +'" alt="" style="width:'+ width +'px; height:'+ height +'px;">');
            }, '500'); 
            $('.imageview').click(function(){$(this).remove();}); 
        }); 
    }
}