﻿shop = function(){};

shop.prototype = {
    main : function(e){
        $('.itembox_close').click(function(){                
                $('.itembox').css('display', 'none');
        });            
        $('.item').click(function(){                
            $('.contents').attr('scrollTop', '0'); 
            $('.title').text($(this).children('input:eq(0)').val());
            $('.price').text($(this).children('input:eq(1)').val());                 
            $('.commnet').html($(this).children('input:eq(2)').val());  
            $('.contents').html($(this).children('input:eq(3)').val());                
            $('.itemimg').attr('src', $(this).children('input:eq(4)').val());
            $('.item_buy').attr('id',$(this).children('input:eq(5)').val());
            $('.itembox').css('display', 'block');
            $('.itembox').focus();
        });
        $('.item_buy').click(function(){
            open_pop('pop_buy.aspx?o=' + $(this).attr('id'),'500','390');                 
            $('.itembox').fadeOut('slow'); 
        });  
    }, 
    item_tamer : function(e){
         $('.itembox_close').click(function(){                
            $('.itembox').css('display', 'none');
        });
        $('.item').click(function(e){  
            $('.contents').attr('scrollTop', '0'); 
            $('.title').text($(this).parent().children('input:eq(0)').val());
            $('.price').text($(this).parent().children('input:eq(1)').val());                 
            $('.commnet').html($(this).parent().children('input:eq(2)').val());  
            $('.contents').html($(this).parent().children('input:eq(3)').val());                
            $('.itemimg').attr('src', $(this).parent().children('input:eq(4)').val());
            $('.item_buy').attr('id',$(this).parent().children('input:eq(5)').val());
            $('.itembox').css('display', 'block');
            $('.itembox').focus();
            
            $('.itembox').css('top', $(this).offset().top + 25);
            $('.itembox').css('left', $(this).offset().left - 130); 
        });
        $('.item_buy').click(function(){
            open_pop('pop_buy.aspx?o=' + $(this).attr('id'),'500','390');                 
            $('.itembox').fadeOut('slow'); 
        });  
        $('.item_buy_1').click(function(){
            open_pop('pop_buy.aspx?o=' + $(this).parent().children('input:eq(5)').val(),'500','390');                 
            $('.itembox').fadeOut('slow'); 
        });
    },
    item_tamer_ex : function(e){
         
    },   
    pop_buy : function(e){
        $('body').fadeIn("slow");
        new BorwserSet().menu_off();        
        $(document).keydown(function(e) { return new Validate().key(e, ['116']); } );        
        $('#submit').click(function(e){            			
			if($('#title').text()=='X부스터+25'||$('#title').text()=='X부스터+50'){
				if($('#svr_list').val()=='0'||$('#svr_list').val()==''){
					alert('서버를 선택하세요.');
					$('#svr_list').focus();
					return false;
				}	
				var val=$('#tm_list_'+$('#svr_list').val()).val();				
				if(val==''||val==null){
					alert('케릭터를 선택하세요.');
					return false;
				}
				$('#tamer_list').val(val);
			}
            if(parseInt($('#current_drcash').val()) < parseInt($('#pay_price').val())) {
                $('#submit_form').attr('action', '/shop/pop_buy_enough.aspx').submit();
                return false;
            }
            else
            {
                $.modal.defaults.opacity = 70;
                $.modal.defaults.overlayId = 'payment_back';
                $.modal.defaults.containerId = 'payment_loading';
                $.modal.defaults.close = false;
                $('#loading_content').modal();  
            }              
        }); 
       $('#svr_list').change(function(e){			
			var svrVal=$(this).val();
			$('select[ID*=tm_list]').each(function(i){
				if($(this).attr('id')=='tm_list_'+svrVal){										
					$('option',this).length!=0?$(this).show():$(this).hide();
				}
				else{
					$(this).hide();
				}
			});
       });
       $('#tamer_list').hide();
       $('#tm_list_1').hide();
       $('#tm_list_2').hide();
       $('#tm_list_3').hide();       
    },
    pop_buy_enough : function(e){ 
        $('body').fadeIn("slow"); 
        new BorwserSet().menu_off();
        $(document).keydown(function(e) { return new Validate().key(e, ['116', '8']); } );
    },
    pop_buy_error : function(e){ 
        $('body').fadeIn("slow"); 
        new BorwserSet().menu_off();
        $(document).keydown(function(e) { return new Validate().key(e, ['116', '8']); } );
    },
    pop_buy_ok : function(e){ 
        $('body').fadeIn("slow"); 
        new BorwserSet().menu_off();
        $(document).keydown(function(e) { return new Validate().key(e, ['116', '8']); } );
    }   
} 