;(function($) {
    $.DubaiClass = function() {
        this.construct();
    },
    
    $.extend($.DubaiClass.prototype, {
        construct: function() {
            this.getWeather();
            this.getTweets();
        },
        
        getWeather: function() {
            $.get('http://dubai92.com/wordpress/wp-content/themes/D92/d92_ajax.php', {action:'getWeather'}, function(data) {
                var t = $('temp_c', data).attr('data');
                var h = $('humidity', data).attr('data');
                $('span#temp_c').html(t);
                $('span#humidity').html(h);
            }, 'xml');
        },
        
        getTweets: function() {
            $.get('http://dubai92.com/wordpress/wp-content/themes/D92/d92_ajax.php', {action:'getTweets'}, function(data) {
                for (var i=0; i<3; i++) {
                    var p = $('pubDate:eq('+(parseFloat(i)+1)+')', data).text();
                    var g = $('guid:eq('+(parseFloat(i)+1)+')', data).text();
                    var t = $('description:eq('+(parseFloat(i)+1)+')', data).text();
                    
                    $('a.guid:eq('+i+')').attr('href',g);
                    $('a.linkz:eq('+i+')').attr('href',g);
                    $('span.pubdate:eq('+i+')').html(p);
                    $('span.tweets:eq('+i+')').html(t);
                }
            }, 'xml');
        }
    });
    
    $(document).ready(function() {
        if (typeof $.Dubai === 'undefined') {
            $.Dubai = new $.DubaiClass();
        }
    });
})
(jQuery);

