$(function() {
    /* main dialog */
    $('#dialog').dialog({										
        autoOpen:false,
        draggable:true,
        modal:true,
        resizable:false,
        buttons:{
            'Close':function() { 
                $(this).dialog('close'); 
            }
        }
    });

    $('#logout-dialog').dialog({										
        autoOpen:false,
        draggable:true,
        modal:true,
        resizable:false,
        buttons:{
            'Cancel':function() { 
                $(this).dialog('close'); 
            }
        }
    });

    $('#dialog-2').dialog({
        autoOpen:false,
        dragable:true,
        resizable:true,
        minWidth:720,
        width:900,
        height:400,
        buttons: {
            'Close': function() { 
                $(this).dialog('close'); 
            }
        }
    });

    /* ajax loading */
    $('#loading').ajaxStart(function() {
        var loading = $('#loading');
        loading.css({
            position:'absolute',
            left:'50%',
            'margin-left':0 - loading.width()/2,
            top:'135px'
        });

        $(this).show();
    });

    $('#loading').ajaxStop(function() {
        $(this).hide();
    });

    /* forgot password */
    $('#forgot-birthday').datepicker({
        showOn:'both',
        dateFormat:"dd M yy",
        changeYear:true,
        yearRange:"c-100:c+0",
        changeMonth:true,
        firstDay:1,
        changeFirstDay:false,
        duration:'' ,
        buttonImage:'/images/datepicker.gif',
        buttonImageOnly:true
    });

    /* purchase history & sms history */
    $('#start_date, #end_date').datepicker({
        showOn:'both',
        dateFormat:'dd M yy',
        changeYear:true,
        changeMonth:true,
        firstDay:1, 
        changeFirstDay:false,
        duration:'',
        buttonImage:'/images/datepicker.gif',
        buttonImageOnly:true,
        minDate:new Date(2009, 10, 1),
        maxDate:0
    });

    /* sms */
    $('#schedule-date').datepicker({
        showOn:'both',
        dateFormat:"dd M yy",
        changeYear:true,
        yearRange:"c-100:c+0",
        changeMonth:true,
        firstDay:1,
        changeFirstDay:false,
        duration:'' ,
        buttonImage:'/images/datepicker.gif',
        buttonImageOnly:true
    });

    $("#sms-history-bttn").click(function() {
        $.post("action.php", $("#sms-history-form").serialize(), function(data) {
            $("#sms-report").html(data);
        });
        return false;
    });

});

