﻿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','430');                 
            $('.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());

            //추후 수정요망.
            var item_id = $(this).parent().children('input:eq(5)').val();
            if(item_id == 38 || item_id == 39 || item_id == 40 ){  //X부스터 25, 50, 100
                $('p.time').css('display','');
                $('p.nomal').css('display','none');
            }
            else{
                $('p.nomal').css('display','');
                $('p.time').css('display','none');
            }
            //

            $('.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','430');                 
            $('.itembox').fadeOut('slow'); 
        });  
        $('.item_buy_1').click(function(){
            open_pop('pop_buy.aspx?o=' + $(this).parent().children('input:eq(5)').val(),'500','430');                 
            $('.itembox').fadeOut('slow'); 
        });
    },
    item_tamer_ex : function(e){
         
    },   
    pop_buy : function(e){
        $('body').fadeIn("slow");

        //2011.06.27.최진영 추후 필히....ㅠ 수정요망.        
        if($('#title').text()=='X부스터+25'||$('#title').text()=='X부스터+50'||$('#title').text()=='X부스터+100'){  //X부스터 25, 50, 100
            $('p.time').css('display','');
            $('p.nomal').css('display','none');
        }
        else{
            $('p.nomal').css('display','');
            $('p.time').css('display','none');
        }
        //

        new BorwserSet().menu_off();        
        $(document).keydown(function(e) { return new Validate().key(e, ['116']); } );        
        $('#submit').click(function(e){            			
			if(parseInt($('#current_drcash').val()) < parseInt($('#pay_price').val())) {
                $('#submit_form').attr('action', '/shop/pop_buy_enough.aspx').submit();
                return false;
            }
            else
            {
                if($('#title').text()=='X부스터+25'||$('#title').text()=='X부스터+50'||$('#title').text()=='X부스터+100'){
                    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(!confirm('서   버 : '+$('#svr_list option:selected').text() + '\n캐릭터 : '+$('#tm_list_'+$('#svr_list').val()+' option:selected').text() + '\n구매하신 아이템은 환불되지 않습니다.\n결제를 진행하겠습니까?'))    
                        return false;
                }
                else{
                    if(!confirm('구매하신 아이템은 환불되지 않습니다.\n결제를 진행하겠습니까?'))    
                        return false;
                }
                                
                $.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']); } );
    }   
} 
