/**
 * Copyright(c) 2008-2009,Playerassist.com Inc. Some rights reserved.
 * Created April 23, 2009
 */
$(document).ready(function(){

    // show quick buy gold pacakge form
    function quick_gold_form(productid, pacakge, server, price){
        $.ajax({
            url: "../add_item_cart.php?productid="+productid+"&pacakge=" + pacakge + "&price=" + price + "&server=" + server, 
            type: 'GET',
            dataType: 'html',
            timeout: 20000,
            
            error: function(){
                alert('Failed to connect to server');
            },
            success: function(msg){
                $.blockUI({
                    fadeIn: 0,
                    message: $('#login').html(msg)
                });
            }
        });        
    }
    
    // get category quick buy gold full list
    function get_gold_package(){    	
    	var serverid = $("#sel_gold_server").val();    	
    	$.ajax({
            url:"js/itm/"+serverid+"_item_pack.htm",
            type: 'GET',
            dataType: 'html',
            timeout: 20000,
            
            error: function(){
                //alert('Failed to connect to server');
            },
            success: function(msg){
                if(msg!="")
                {
                	$(".selected_gold_list").html(msg);
	            	// show add to cart form layout
	            	$('.dis_list_sub img').each(function(){
	                	$(this).click(function(){
	                    	server = $('#sel_gold_server option:selected').text();
	                    	price = $(this).parents().find('.price').html();
	                    	mount = $(this).parents().find('.mount').html();
	                    	productid = $(this).attr('id');
	                    	// show add to cart form               	                   	
	                    	quick_gold_form(productid, mount, server, price);
	                	});                
	            	}); 
                }           	 
            }
        });
    };
    
    // loaded gold list by default open page
    get_gold_package();
    
    // load gold full list by selected different server
    $('#sel_gold_server').change(function(){
        get_gold_package();
    });
})