function next_day(){
    
    
    year = parseInt(UserInfo.year);
    month = parseInt(UserInfo.month);
    day = parseInt(UserInfo.day);
    
    if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
            {
                if(day == 31)
                {
                    if(month == 12)
                    {
                    year = year + 1;
                    month = 1;
                    day = 1;
                    }
                    else
                    {
                    month = month + 1;
                    day = 1;
                    }
                }
                else
                    day = day + 1;
            }
            
                                                            
            
            else
            {
                if(day == 30)
                {
                    month = month + 1;
                    day = 1;
                }
                else
                    day = day + 1;
            }
            //console.log(year + " " + month + " " + day + "<br>");
            
            year = String(year);
            if(month < 10)
            {
              month = String(month);
              month = "0" + month;
            }
            else
              month = String(month);
            if(day < 10)
            {
              day = String(day);
              day = "0" + day;
            }
            else
              day = String(day);
              
            document.getElementById("today_user").innerHTML = year + " / " + month + " / " + day + "<br/>" + "Your Tomorrow`s Tarot";
            document.getElementById("card_content_date").innerHTML = year + " / " + month + " / " + day + "<br/>";
            
            
    
}

var OpenSocial = {

        os: null,
        os_token: null,
        dataReqObj: null,

        init : function (callback) {
                this.os = opensocial.Container.get();
                this.os_token = MyOpenSpace.MySpaceContainer.OSToken;

                this.dataReqObj = this.os.newDataRequest();

                if (typeof (callback) === 'function')
                {
                                callback();
                }
        },

        ajax : function (url, data, callback) {
                if (typeof(callback) === 'function') {
                        var params = {};
        
                        params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
                        params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
                        params[gadgets.io.RequestParameters.POST_DATA]= gadgets.io.encodeValues(data);
                        params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
                        
                        gadgets.io.makeRequest(url, callback, params);
                }
                else {
                        try {   
                                console.log('callback parameter makes error.');
                        }
                        catch (e) {
                        }
                }
        }
};

var UserInfo = {

        url: 'http://tarottarot2.appspot.com/',
        title: 'Tarot',
        link: 'http://profile.myspace.com/Modules/Applications/Pages/Canvas.aspx?appId=132885&appvers=live',
        logo: 'http://tarottarot2.appspot.com/images/send_icon.gif',
        page: '',
        today_page: null,
        tomorrow: false,

        uid : null,
        name : null,
        thumb : null,
        profile_link : null,
        key: null,
        year: null,
        month: null,
        day: null,
        now_date : null,
        has_checked_today : null, 
        has_set : null,
        set_value: null,

        req : function () {
                
                var viewerReq = OpenSocial.os.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER);

                OpenSocial.dataReqObj.add(viewerReq, 'userInfo');
                OpenSocial.dataReqObj.send(UserInfo.reqCallback);
        },
        reqCallback : function (res) {
                if (res.hadError()) {

                        var data = res.get('userInfo');
                        try {
                                        console.log(data.getErrorCode() + '\n' + data.getErrorMessage());	
                        }
                        catch(e) {
                                        
                        }
                }

                else {
                        var viewer = res.get('userInfo').getData();

                        UserInfo.uid = viewer.getId();
                        UserInfo.name = viewer.getDisplayName();
                        UserInfo.thumb = viewer.getField(opensocial.Person.Field.THUMBNAIL_URL);
                        UserInfo.profile_link = viewer.getField(opensocial.Person.Field.PROFILE_URL);
                        UserInfo.update();
                }
        },
        update : function () {
                var now_date2 = new Date();

                var date = new Date();

                var year = date.getFullYear(); 
                var month = date.getMonth() + 1;
                var day = date.getDate();

                if (("" + month).length==1){month = "0"+month;}
                if (("" + day).length==1){day = "0"+day;}
                UserInfo.year = year;
                UserInfo.month = month;
                UserInfo.day = day;
                
                UserInfo.now_date = year+month+day;

                var data = {
                        uid: this.uid,
                        name: this.name,
                        thumb: this.thumb,
                        profile_link: this.profile_link,
                        now_date: this.now_date
                };
                
                var prefs = gadgets.views.getParams();

                var url = UserInfo.url + 'member/add';

                OpenSocial.ajax(url, data, function (res) {
                        if (res.data['error'] === 0) {

                                UserInfo.key = res.data['data']['user_key'];	// for google app engine datastore
                                UserInfo.has_set = res.data['data']['has_set'];
                                UserInfo.has_checked_today = res.data['data']['has_checked_today'];
                                UserInfo.set_value = res.data['data']['set_value'];
                        }
                
                        UserInfo.page = prefs['page'] !== undefined ? prefs['page'] : 'today_not_defined';

                        if(UserInfo.has_set === false)
                                UserInfo.today_page = "not_set";
                        else if(UserInfo.has_checked_today === false)
                                UserInfo.today_page = "not_check";
                        else 
                                UserInfo.today_page = "checked";
                
                        Event.observe($('header').getElementsByTagName('a')[0], 'click', function (event) {
                                var canvas_view = new gadgets.views.View('canvas');

                                if(UserInfo.has_set === false)
                                    UserInfo.today_page = "not_set";
                                else if(UserInfo.has_checked_today === false)
                                    UserInfo.today_page = "not_check";
                                else 
                                    UserInfo.today_page = "checked";
                                    
                                var canvas_view = new gadgets.views.View('canvas');
                                gadgets.views.requestNavigateTo(canvas_view, {
                                    'page': 'today_not_defined'
                                });
                        
                        });
                        Event.observe($('header').getElementsByTagName('a')[1], 'click', function (event) {
                                var canvas_view = new gadgets.views.View('canvas');
                                gadgets.views.requestNavigateTo(canvas_view, {
                                        'page': 'invite_page'
                                });
                        });
                        Event.observe($('header').getElementsByTagName('a')[2], 'click', function (event) {
                                var canvas_view = new gadgets.views.View('canvas');
                                gadgets.views.requestNavigateTo(canvas_view, {
                                        'page': 'friends_page'
                                });
                        });
                        Event.observe($('header').getElementsByTagName('a')[3], 'click', function (event) {
                                var canvas_view = new gadgets.views.View('canvas');
                                gadgets.views.requestNavigateTo(canvas_view, {
                                        'page': 'love_page'
                                });
                        });
                        Event.observe($('header').getElementsByTagName('a')[4], 'click', function (event) {
                                var canvas_view = new gadgets.views.View('canvas');
                                gadgets.views.requestNavigateTo(canvas_view, {
                                        'page': 'setting_page'
                                });
                        });
                        
                        switch (UserInfo.page) {
                                case 'today_not_defined':
                                    if(UserInfo.today_page == "not_set")
                                    {
                                        $('today_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_1f.gif";
                                        $('today_not_setting').show();
                                        $('today_not_checked').hide();
                                        $('friends').hide();
                                        $('invite_friends').hide();
                                        
                                        $('love').hide();
                                        $('setting').hide();
                                        
                                        $('today_tarot_page').className="current";
                                        
                                        $('invite_page').className="";
                                        $('friends_page').className="";
                                        $('love_page').className="";
                                        $('setting_page').className="";
                                        
                                        Event.observe($('go_set_button'), 'click', function(event){
                                                var canvas_view = new gadgets.views.View('canvas');
                                                gadgets.views.requestNavigateTo(canvas_view, {
                                                        'page': 'setting_page'
                                                });
                                         });
                                    }
                                    else if(UserInfo.today_page == "not_check")
                                    {
                                        $('today_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_1f.gif";
                                        $('today_not_setting').hide();
                                        $('today_not_checked').show();
                                        $('friends').hide();
                                        $('invite_friends').hide();
                                        $('love').hide();
                                        $('setting').hide();
                                        
                                        $('today_tarot_page').className="current";
                                        $('invite_page').className="";
                                        $('friends_page').className="";
                                        $('love_page').className="";
                                        $('setting_page').className="";
                                        
                                        document.getElementById("today_user").innerHTML = UserInfo.year + " / " + UserInfo.month + " / " + UserInfo.day + "<br/>" + "Your Today`s Tarot";
                                        document.getElementById("card_content_date").innerHTML = UserInfo.year + " / " + UserInfo.month + " / " + UserInfo.day + "<br/>";
                                        
                                        Event.observe($('rolling_card'), 'click', function(event){
                                        
                                                UserInfo.tomorrow = false;
                                                make_today_tarot.init();
                                                
                                                feed_today_check.init();

                                                setTimeout("$('today_before_content').hide();$('today_content').show();", 1800);
                                                $('go_next_day_div').hide();
												$('go_next_day_div2').show();
                                        
                                         });
                                    }
                                    else if(UserInfo.today_page == "checked")
                                    {
                                        
                                        $('today_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_1f.gif";
                                        $('today_not_setting').hide();
                                        $('today_not_checked').show();
                                        $('friends').hide();
                                        $('invite_friends').hide();
                                        $('love').hide();
                                        $('setting').hide();
                                        
                                        $('today_tarot_page').className="current";
                                        $('invite_page').className="";
                                        $('friends_page').className="";
                                        $('love_page').className="";
                                        $('setting_page').className="";
                                        
                                        $('today_before_check_button').hide();
                                        $('today_before_content').hide();
                                        $('today_content').show();
                                        
                                        document.getElementById("today_user").innerHTML = UserInfo.year + " / " + UserInfo.month + " / " + UserInfo.day + "<br/>" + "Your Today`s Tarot";
                                        document.getElementById("card_content_date").innerHTML = UserInfo.year + " / " + UserInfo.month + " / " + UserInfo.day + "<br/>";
                                        
                                        UserInfo.tomorrow = false;
                                        make_today_tarot.init();
                                        
                                        Event.observe($('go_next_day'), 'click', function(event){
                                                
                                                $('today_not_setting').hide();
                                                $('today_not_checked').show();
                                                $('friends').hide();
                                                $('invite_friends').hide();
                                                $('love').hide();
                                                $('setting').hide();
                                                
                                                $('today_content').hide();
                                                
                                                $('today_before_check_button').show();
                                                $('today_before_content').show();
                                                document['rolling_card_img'].src = "http://tarottarot2.appspot.com/images/tarot_spin.gif";
                                                document.getElementById("card_name").innerHTML = "&nbsp;";
                                                
                                                next_day();
                                                
                                                Event.observe($('rolling_card'), 'click', function(event){
                                                    
	                                                UserInfo.tomorrow = true;
                                                    make_today_tarot.init();
                                                    $('go_next_day_div').hide();
                                                    
                                        
                                                    setTimeout("$('today_before_content').hide();$('today_content').show();", 1800);
                                                 });
                                         });
                                    }
									break;
                                case 'invite_page':
                                        $('invite_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_2f.gif";
                                        $('today_not_setting').hide();
                                        $('today_not_checked').hide();
                                        $('friends').hide();
                                        $('invite_friends').show();
                                        $('love').hide();
                                        $('setting').hide();
                                        
                                        $('today_tarot_page').className="";
                                        $('invite_page').className="current";
                                        $('friends_page').className="";
                                        $('love_page').className="";
                                        $('setting_page').className="";
                                        FriendsInfo.init('app', FriendsSelector.viewFriendsList);

                                        Event.observe($('send_invite'), 'click', function(event){
                                                Feed.init();
                                        });
                                        break;
                                case 'friends_page':
                                        if(UserInfo.has_set === false)
                                        {
                                                $('friends_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_3f.gif";
                                                $('today_not_setting').show();
                                                $('today_not_checked').hide();
                                                $('friends').hide();
                                                $('invite_friends').hide();
                                                
                                                $('love').hide();
                                                $('setting').hide();
                                                
                                                $('today_tarot_page').className="";
                                                $('invite_page').className="";
                                                $('friends_page').className="current";
                                                $('love_page').className="";
                                                $('setting_page').className="";
                                                Event.observe($('go_set_button'), 'click', function(event){
                                                        var canvas_view = new gadgets.views.View('canvas');
                                                        gadgets.views.requestNavigateTo(canvas_view, {
                                                                'page': 'setting_page'
                                                        });
                                                 }); 
                                        }
                                        else
                                        {
                                                $('friends_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_3f.gif";
                                                $('today_not_setting').hide();
                                                $('today_not_checked').hide();
                                                $('friends').show();
                                                $('invite_friends').hide();
                                                $('love').hide();
                                                $('setting').hide();
                                                
                                                $('today_tarot_page').className="";
                                                $('invite_page').className="";
                                                $('friends_page').className="current";
                                                $('love_page').className="";
                                                $('setting_page').className="";
                                                
                                                FriendsInfo.init('app', FriendsSelector.viewFriendsList);
                                                
                                                Event.observe($('tarot_with_friends_button'), 'click', function(event){

                                                        get_friend_info.init();
                                                        if(FriendsSelector.selected === true)
                                                        {
                                                            make_with_tarot.init();

                                                        $('friends').hide();
                                                        $('friends2').show();
                                                        }
                                                });
                                        }

                                        break;
                                case 'love_page':
                                        if(UserInfo.has_set === false)
                                        {
                                                $('love_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_4f.gif";
                                                $('today_not_setting').show();
                                                $('today_not_checked').hide();
                                                $('friends').hide();
                                                $('invite_friends').hide();
                                                
                                                $('love').hide();
                                                $('setting').hide();
                                                
                                                $('today_tarot_page').className="";
                                                $('invite_page').className="";
                                                $('friends_page').className="";
                                                $('love_page').className="current";
                                                $('setting_page').className="";
                                                Event.observe($('go_set_button'), 'click', function(event){
                                                        var canvas_view = new gadgets.views.View('canvas');
                                                        gadgets.views.requestNavigateTo(canvas_view, {
                                                                'page': 'setting_page'
                                                        });
                                                 }); 
                                        
                                        }
                                        else
                                        {
                                            $('love_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_4f.gif";
                                            $('today_not_setting').hide();
                                            $('today_not_checked').hide();
                                            $('friends').hide();
                                            $('invite_friends').hide();
                                            $('love').show();
                                            $('setting').hide();
                                            
                                            $('today_tarot_page').className="";
                                            $('invite_page').className="";
                                            $('friends_page').className="";
                                            $('love_page').className="current";
                                            $('setting_page').className="";
                                            
                                            FriendsInfo.init('app', FriendsSelector.viewFriendsList);
                                            
                                            Event.observe($('tarot_with_love_button'), 'click', function(event){

                                                        
                                                        get_friend_info.init();
                                                        if(FriendsSelector.selected === true)
                                                        {
                                                            make_with_tarot.init();
                                                        

                                                            $('love').hide();
                                                            $('love2').show();
                                                        }
                                                });
                                        }
                                        
                                        break;
                                case 'setting_page':
                                        $('setting_tarot').src="http://tarottarot2.appspot.com/images/menu/menu_5f.gif";
                                        $('today_not_setting').hide();
                                        $('today_not_checked').hide();
                                        $('invite_friends').hide();
                                        $('friends').hide();
                                        $('love').hide();
                                        $('setting').show();
                                        
                                        $('today_tarot_page').className="";
                                        $('invite_page').className="";
                                        $('friends_page').className="";
                                        $('love_page').className="";
                                        $('setting_page').className="current";
                                        Event.observe($('submitdata'), 'click', function(event){
                                            setting_feed.init();
                                        });
                                        break;
                        }	
                
            });
        }
};

var feed_today_check = {

        init: function (){
                var data = {
                        uid: UserInfo.uid,
                        name: UserInfo.name,
                        thumb: UserInfo.thumb,
                        profile_link: UserInfo.profile_link,
                        now_date: UserInfo.now_date,
                        today_clicked: true
                };
                var url2 = UserInfo.url + 'member/add';

                OpenSocial.ajax(url2, data, function (res) {
                        if (res.data['error'] === 0) {
                                UserInfo.has_checked_today = res.data['data']['has_checked_today'];
                        }
                });
        }

};

var FriendsInfo = {

        mode: 'app',
        added: [],
        data: [],
        callback: null,
        first: 1,
        max: 80,

        init : function (mode, callback) {
                FriendsInfo.mode = mode;
                FriendsInfo.first = 1;

                if (typeof (callback) === 'function') {
                        FriendsInfo.callback = callback;
                }
                        
                if (FriendsInfo.mode === 'app') {
                        FriendsInfo.added = [];
                }
                else if (FriendsInfo.mode === 'all') {
                        FriendsInfo.data = [];
                }
                
                FriendsInfo.req();
        },
        req : function () {
                var params = {};
                params[opensocial.DataRequest.PeopleRequestFields.FIRST] = FriendsInfo.first;
                params[opensocial.DataRequest.PeopleRequestFields.MAX] = FriendsInfo.max;
                params[opensocial.DataRequest.PeopleRequestFields.SORT_ORDER] = opensocial.DataRequest.SortOrder.NAME;
                
                if (FriendsInfo.mode === 'all') {
                        params[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.ALL;
                }
                else if (FriendsInfo.mode === 'app') {
                        params[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.HAS_APP;
                }

                var friendsIdSpec = opensocial.newIdSpec({'userId' : 'VIEWER', 'groupId' : 'FRIENDS'});
                
                var viewerFriendsReq = OpenSocial.os.newFetchPeopleRequest(friendsIdSpec, params);
                OpenSocial.dataReqObj.add(viewerFriendsReq, 'friendsReq');
                
                OpenSocial.dataReqObj.send(FriendsInfo.reqCallback);
        },
        reqCallback : function (res) {
                if (res.hadError()) {
                        var data = res.get('friendsReq');
                        try {
                                console.log(data.getErrorCode() + '\n' + data.getErrorMessage());	
                                FriendsInfo.max -= 1;
                                FriendsInfo.req();
                        }
                        catch (e) {
                                
                        }
                }
                else {
                        var obj = res.get('friendsReq').getData();
                        
                        if (FriendsInfo.mode === 'app') {
                                obj.each(function (friend) {
                                        FriendsInfo.added.push(friend.getId());
                                });
                        }
                        else if (FriendsInfo.mode === 'all') {
                                var handle_list = false;
                                obj.each(function (friend) {
                                        FriendsInfo.data.push({
                                                'uid': friend.getId(),
                                                'name': friend.getDisplayName(),
                                                'thumb': friend.getField(opensocial.Person.Field.THUMBNAIL_URL),
                                                'profile_link': friend.getField(opensocial.Person.Field.PROFILE_URL),
                                                'has_app': FriendsInfo.added.indexOf(friend.getId()) === -1 ? false : true
                                        });
                                });
                        }
                        
                        if (obj.getTotalSize() < FriendsInfo.max) {
                                FriendsInfo.first = 1;
                                
                                if (typeof (FriendsInfo.callback) === 'function') {
                                        FriendsInfo.callback();
                                }
                                
                                if (FriendsInfo.mode === 'app') {
                                        FriendsInfo.added.push(UserInfo.uid);

                                        FriendsInfo.init('all');
                                }
                        }
                        else {
                                FriendsInfo.first += FriendsInfo.max;
                                FriendsInfo.req();
                        }
                }
        }
};

var FriendsSelector = {
        list: null,
        size: 0,
        selected_num: 0,
        handleInputBox: 'init',
        selected_friend: {},
        selected: false,

        clear: function () {
                for (var idx = 0; idx < FriendsSelector.size; ++idx) {
                        FriendsSelector.list[idx].className = '';
                }
                
        },

        seeAll: function () {
                for (var idx = 0; idx < FriendsSelector.size; ++idx) {
                        FriendsSelector.list[idx].parentNode.style.display = '';
                }
        },
        selectAll: function () {
                $('searchUsersField').value = 'Start Typing a Friend\'s Name';
                FriendsSelector.handleInputBox = 'init';
                
                for (var idx = 0; idx < FriendsSelector.size; ++idx) {
                        var friend = FriendsSelector.list[idx];

                        friend.parentNode.style.display = '';
                        
                        if (!friend.hasClassName('selected')) {
                                friend.toggleClassName('selected');
                        }

                        FriendsSelector.selected_num = FriendsSelector.size;
                }
        },
        viewFriendsList: function () {
                if (FriendsInfo.data.size() > 0) {
                        
                        if(UserInfo.page == 'invite_page')
                        {
                            var strTemplate =   '<li>' +
                                                '   <a id=\"challengeUser_#{uid}\">' +
                                                '	<span class="name">#{name}</span>' +
                                                '	<span class="thumb">' +
                                                '		<img src=\"#{thumb}\" />' +
                                                '	</span>' +
                                                '       <img class=\"msgType\" src=\"#{msg_img}\" alt=\"#{msg_type}\" />' +
                                                '   </a>' +
                                                '   <input type=\"hidden\" name=\"hasapp[]\" id=\"hasapp_#{uid}\" value=\"#{has_app}\" />' +
                                                '</li>';
                        }
                        else if(UserInfo.page == 'love_page' || UserInfo.page == 'friends_page')
                        {
                            var strTemplate =   '<li>' +
                                                '   <a id=\"challengeUser_#{uid}\">' +
                                                '	<span class="name">#{name}</span>' +
                                                '	<span class="thumb">' +
                                                '		<img src=\"#{thumb}\" />' +
                                                '	</span>' +
                                                '   </a>' +
                                                '   <input type=\"hidden\" name=\"hasapp[]\" id=\"hasapp_#{uid}\" value=\"#{has_app}\" />' +
                                                '</li>';
                        }
                        
                        var friendsTemplate = new Template(strTemplate);

                        if(UserInfo.page == 'invite_page')		
                        {
                                $('friendslist').update('');

                                FriendsInfo.data.each(
                                        function (friend) {
                                                
                                                    $('friendslist').insert(
                                                            friendsTemplate.evaluate({
                                                                    'uid': friend['uid'],
                                                                    'thumb': friend['thumb'],
                                                                    'name': friend['name'],
                                                                    'msg_img': UserInfo.url + (friend['has_app'] ? 'images/comment_icon.gif' : 'images/invite_icon.gif'),
                                                                    'msg_type': friend['has_app'] ? 'added' : 'have not added',
                                                                    'has_app': friend['has_app']
                                                            })
                                                    );
                                                        
                                                
                                        }
                                );
                        }
                        
                        else if(UserInfo.page == 'love_page' || UserInfo.page == 'friends_page')			
                        {

                                $('friendslist_added').update('');
                                $('friendslist_added_f').update('');

                                FriendsInfo.data.each(
                                        function (friend) {
                                                if(friend['has_app'])		
                                                {
                                                        if(UserInfo.page == 'love_page')
                                                        {
                                                            $('friendslist_added').insert(
                                                                            friendsTemplate.evaluate({
                                                                                    'uid': friend['uid'],
                                                                                    'thumb': friend['thumb'],
                                                                                    'name': friend['name'],
                                                                                    
                                                                                   
                                                                                    'has_app': friend['has_app']
                                                                            })
                                                            );
                                                        }
                                                        
                                                        else if(UserInfo.page == 'friends_page')
                                                        {
                                                             $('friendslist_added_f').insert(												  
                                                                            friendsTemplate.evaluate({
                                                                                    'uid': friend['uid'],
                                                                                    'thumb': friend['thumb'],
                                                                                    'name': friend['name'],
                                                                                    
                                                                                    'has_app': friend['has_app']
                                                                        })
                                                            );    
                                                            
                                                        }
                                                                        
                                                }
                                        }
                                )
                        }
                        FriendsSelector.init();
                }
        },
        init: function () {

                if(UserInfo.page == 'love_page' || UserInfo.page == 'friends_page')
                {
                        if(UserInfo.page == 'love_page')
                        {
                            FriendsSelector.list = $('friendslist_added').getElementsByTagName('a');
                        }
                        else if(UserInfo.page == 'friends_page')
                        {
                            FriendsSelector.list = $('friendslist_added_f').getElementsByTagName('a');
                        }
                        FriendsSelector.size = FriendsSelector.list.length;
                        FriendsSelector.selected_num = 0;
                        FriendsSelector.handleInputBox = 'init';

                        var already_selected = false;

                        for (var idx = 0; idx < FriendsSelector.size; ++idx) {
                                Event.observe(FriendsSelector.list[idx], 'click', function (event) {
                                        
                                        if(Event.findElement(event, 'a').hasClassName('selected'))
                                                already_selected = true;
                                        else
                                                already_selected = false;

                                        FriendsSelector.clear();
                                        FriendsSelector.selected = false;

                                        if(already_selected == false)
                                        {
                                                Event.findElement(event, 'a').className='selected';
                                                FriendsSelector.selected = true;
                                        }
                                                
                                        else
                                                Event.findElement(event, 'a').className='';
                                                
                                        if(UserInfo.page == 'love_page')
                                        {
                                            FriendsSelector.selected_friend = $('friendslist_added').getElementsByClassName('selected').parentNode;
                                        }
                                        else if(UserInfo.page == 'friends_page')
                                        {
                                            FriendsSelector.selected_friend = $('friendslist_added_f').getElementsByClassName('selected').parentNode;
                                        }

                                });
                        }
                }

                else if(UserInfo.page == 'invite_page')
                {
                        FriendsSelector.list = $('friendslist').getElementsByTagName('a');
                        FriendsSelector.size = FriendsSelector.list.length;
                        FriendsSelector.selected_num = 0;
                        FriendsSelector.handleInputBox = 'init';
                        
                        $('searchUsersField').value = 'Start Typing a Friend\'s Name';
                        
                        for (var idx = 0; idx < FriendsSelector.size; ++idx) {
                                Event.observe(FriendsSelector.list[idx], 'click', function (event) {
                                        Event.findElement(event, 'a').toggleClassName('selected');
                                });
                        }
                        
                        Event.observe($('selectAllBtn'), 'click', function(){
                                FriendsSelector.selectAll();
                        });

                        Event.observe($('clearBtn'), 'click', function(){
                                for (var idx = 0; idx < FriendsSelector.size; ++idx) {
                                        var friend = FriendsSelector.list[idx];
                                        
                                        if (!friend.parentNode.style.display !== 'none' && friend.hasClassName('selected')) {
                                                friend.toggleClassName('selected');
                                        }

                                        --FriendsSelector.selected_num;
                                }
                        });
                 

                        Event.observe($('searchUsersField'), 'focus', function () {
                        if (FriendsSelector.handleInputBox === 'init') {
                                $('searchUsersField').value = '';
                                FriendsSelector.handleInputBox = 'set';

                                        new Form.Element.Observer('searchUsersField', 0.2, function (element, value) {
                                                
                                                if (value !== '' && FriendsSelector.handleInputBox !== 'init') {
                                                        for (var idx = 0; idx < FriendsSelector.size; ++idx) {
                                                                var lower_value = value.toLowerCase();
                                                                var nameSpan = FriendsSelector.list[idx].getElementsByClassName('name')[0];
                                                                var lower_name = nameSpan.innerHTML.toLowerCase();
                                                                
                                                                if (lower_name.include(lower_value)) {
                                                                        FriendsSelector.list[idx].parentNode.style.display = '';
                                                                }
                                                                else {
                                                                        FriendsSelector.list[idx].parentNode.style.display = 'none';
                                                                }
                                                        }
                                                }
                                                else {
                                                        FriendsSelector.seeAll();
                                                }
                                        });
                                }
                        });
                        
                         Event.observe($('searchUsersField'), 'blur', function () {
                                var inputBox = $('searchUsersField');

                                if (inputBox.value.blank()) {
                                        inputBox.value = 'Start Typing a Friend\'s Name';
                                        FriendsSelector.handleInputBox = 'init';
                                }
                        });
                        
                        Event.observe($('seeAllBtn'), 'click', function () {
                                $('searchUsersField').value = 'Start Typing a Friend\'s Name';
                                FriendsSelector.handleInputBox = 'init';

                                FriendsSelector.seeAll();
                        });
                }
        }
};

var get_friend_info = {
        selectedFriends: null,
        init : function () {
                get_friend_info.exist = null;
                get_friend_info.selectedFriends = [];
                if(UserInfo.page == 'love_page')
                {
                    var selected = $('friendslist_added').getElementsByClassName('selected');
                }
                else if(UserInfo.page == 'friends_page')
                {
                    var selected = $('friendslist_added_f').getElementsByClassName('selected');
                }
                for (var idx = 0; idx < selected.length; ++idx) {
                         var uid = selected[idx].id.split('_')[1];
                         get_friend_info.selectedFriends.push({
                                 uid: uid,
                                 name: selected[idx].getElementsByClassName('name')[0].innerHTML,
                                 thumb: selected[idx].getElementsByTagName('img')[0].src,
                                 hasapp: $('hasapp_' + uid).value
                         });
                 }
                
        }
        
        
};

var Feed = {
        selectedFriends: null,
        idx: 0,
        callback: null,

        init : function (callback) {
                Feed.selectedFriends = [];
                var selected = $('friendslist').getElementsByClassName('selected');
                
                for (var idx = 0; idx < selected.length; ++idx) {
                        var uid = selected[idx].id.split('_')[1];
                        Feed.selectedFriends.push({
                                uid: uid,
                                name: selected[idx].getElementsByClassName('name')[0].innerHTML,
                                thumb: selected[idx].getElementsByTagName('img')[0].src,
                                hasapp: $('hasapp_' + uid).value
                        });
                }
                
                Feed.idx = 0;
                
                if (typeof (callback) === 'function') {
                        Feed.callback = callback;
                }
                
                if (Feed.selectedFriends.size() > 0) {
                        Feed.send();
                }
        },
        send : function () {
                if (typeof (Feed.callback) === 'function') {
                        Feed.callback(Feed.selectedFriends[Feed.idx].uid);
                }
                 try
                 {
                 console.log('send hit');			
                 }
                 catch (e)
                 {
                 }

                if (Feed.selectedFriends[Feed.idx].hasapp === 'true') {
                        
                        var strTemplate =   '<div><a href=\"#{link}\"><img src=\"#{logo}\" alt=\"#{title}\"/ align= "middle"></a>' +
                                            '<span style="font-size:14px;">' +
                                            '   Hey! #{sender} sent you a Tarot card!<br/> ' +
                                            '   <a href=\"#{link}\">Click here to receive the Tarot.</a>' +
                                            '</span></div>';

                        var template = new Template(strTemplate);
                        
                        var msg = opensocial.newMessage(template.evaluate({
                                sender: UserInfo.name,
                                title: UserInfo.title,
                                logo: UserInfo.logo,
                                link: UserInfo.link
                        }));
                        
                        msg.setField(opensocial.Message.Field.TITLE, "Tarot");
                        msg.setField(opensocial.Message.Field.TYPE, opensocial.Message.Type.PUBLIC_MESSAGE);

                        OpenSocial.os.requestSendMessage(Feed.selectedFriends[Feed.idx].uid, msg, Feed.sendCallback);
                }
                else {
                        var strTemplate =  'Hey! #{receiver}, #{sender} has invited you at #{title}. ' + '#{sender} wants to share Tarot with you! ' + 'Click \"Add\" below to see your fortune.';
                        var template = new Template(strTemplate);
                        
                        var msg = opensocial.newMessage(template.evaluate({
                                receiver: Feed.selectedFriends[Feed.idx].name,
                                sender: UserInfo.name,
                                title: UserInfo.title
                        }));
                        
                        msg.setField(opensocial.Message.Field.TITLE, "Tarot");

                        OpenSocial.os.requestShareApp(Feed.selectedFriends[Feed.idx].uid, msg, Feed.sendCallback);
                }
        },

        sendCallback : function (res) {

            if(res.data_===1)
            {
                    ++Feed.idx;
                    if (Feed.idx < Feed.selectedFriends.size()) {
                            Feed.send();
                    }
					else{
						UserInfo.link = 'http://profile.myspace.com/Modules/Applications/Pages/Canvas.aspx?appId=132885&friendId=464193639&appParams=%7B%22page%22%3A%22invite_page%22%7D';
						window.parent.location = UserInfo.link;
					}
            }
            else
            {
                    ++Feed.idx;
                    if (Feed.idx < Feed.selectedFriends.size()) {
                            Feed.send();
                    }
                    else {
                            UserInfo.link = 'http://profile.myspace.com/Modules/Applications/Pages/Canvas.aspx?appId=132885&friendId=464193639&appParams=%7B%22page%22%3A%22invite_page%22%7D';
                            window.parent.location = UserInfo.link;
                    }
            }
        }
};

var setting_feed = {
        init: function (){
                var name = $('fname').value + $('lname').value;
                var date = $('year').value + $('month').value + $('day').value;
                date = parseInt(date);
                var set_value = (name.length * 100) + date;
                set_value = set_value.toString();
                UserInfo.set_value = set_value;
                
                var data = {
                        uid: UserInfo.uid,
                        name: UserInfo.name,
                        thumb: UserInfo.thumb,
                        profile_link: UserInfo.profile_link,
                        now_date: UserInfo.now_date,
                        set_value: UserInfo.set_value
                };
                var url2 = UserInfo.url + 'member/add';

                OpenSocial.ajax(url2, data, function (res) {
                        if (res.data['error'] === 0) {
                                UserInfo.set_value = res.data['data']['set_value'];
                                UserInfo.today_page = "not_check";
                                var canvas_view = new gadgets.views.View('canvas');
                                gadgets.views.requestNavigateTo(canvas_view, {
                                    'page': 'today_not_defined'
                                });
                                
                        }
                });
        
                
                
                
        }
};

var make_with_tarot = {

    init: function () {

        var love_mate = {
                name: get_friend_info.selectedFriends[0].name,
                uid: get_friend_info.selectedFriends[0].uid
        };

        var myself = {
                name : UserInfo.name,
                uid : UserInfo.uid
        };
                                                        
        love_mate.uid = love_mate.uid.substring(12);
        myself.uid = UserInfo.uid.substring(12);
        
        var now_date = parseInt(UserInfo.now_date);
        now_date = now_date % 1000;
        var now_365 = Math.floor(((now_date / 100) * 30) + (now_date % 100));

        
        if(UserInfo.page =='friends_page')
        {
            var random_key = (parseInt(love_mate.uid) + parseInt(myself.uid)) / 2;
            var random_key2 = (parseInt(love_mate.uid) + parseInt(myself.uid)) / 3;
            var random_key3 = (parseInt(love_mate.uid) + parseInt(myself.uid)) / 5;
        }
        else if(UserInfo.page == 'love_page')
        {
            var random_key = ((parseInt(love_mate.uid) / 2) + parseInt(myself.uid)) / 2;
            var random_key2 = ((parseInt(love_mate.uid) / 2) + parseInt(myself.uid)) / 3;
            var random_key3 = ((parseInt(love_mate.uid) / 2) + parseInt(myself.uid)) / 5;
            
        }
        
        random_key = Math.floor(random_key);
        random_key2 = Math.floor(random_key2);
        random_key3 = Math.floor(random_key3);
        
        function get_card_number(random_key, now_365){
               var numbers = Math.floor(random_key / now_365);
			   numbers = Math.floor(numbers % 23);
               if(numbers !== 0)
                    numbers = numbers - 1;
                return numbers
        }
        function get_card_content_number(random_key, now_365){
               var numbers = Math.floor(random_key / now_365);
				numbers = Math.floor(numbers % 45);
               if(numbers !== 0)
                    numbers = numbers - 1;
                return numbers
        }
        
                                                
        var card_number = get_card_number(random_key, now_365);
        var card_number2 = get_card_number(random_key2, now_365);
        var card_number3 = get_card_number(random_key3, now_365);
        
        while(card_number == card_number2)
        {
            var i = 4;
			var re_random = Math.floor(random_key2 * i);
			re_random = Math.floor(re_random / 3);
            card_number2 = get_card_number(re_random, now_365);
            i = i + 1;
        }
        
        while(card_number == card_number3 || card_number2 == card_number3)
        {
            var i = 4;
			var re_random = Math.floor(random_key3 * i);
			re_random = Math.floor(re_random / 3);
            card_number3 = get_card_number(re_random, now_365);
            i = i + 1;
        }
        var card_content = get_card_content_number(random_key, now_365);
        var card_reverse = false;
                    
        if(card_content > 21)
        {
            card_content = card_content - 22;
            card_reverse = true;    
        }
        
        function Card(number, name) {
          this.number = number;
          this.name = name;
          this.image = "";
          this.content = "";
          this.content_r = "";
          this.content_f = "";
        }
        
        var Cards = new Array(22);
                   
        function initCards() {
          for(var i=0; i<22; i++){
                Cards[i] = new Card("", "");
          }
          with(Cards[0]) {
                number = "O";
                name = "THE FOOL";
                image = "00";
                content = "You're full of energy. Enjoy every minute and don't try to be ahead of the circumstances for fear of being wasting the future. You'll probably find love. You loving somebody means that someone has the right to love you. Let him do that.";
                content_r = "You have to understand that if you want your relationship to work, you have to give your partner time and space and SHOW him confidence and love with facts not words. You'll see that love and passion grow and you find the happiness that you want.";
                content_f = "Your energy flows freely and you are not afraid any more. You can be alone without thinking of you as a hermit because you are in contact with yourself. Your friends will share many moments with you and you'll have fun together. ";

          }
          with(Cards[1]) {
                number = "I";
                name = "THE MAGICIAN ";
                image = "01";
                content = "Period of abstraction. It is time now to take care of you, to love you, to boost your ego. Enhancing your self-esteem will make everything possible to achieve. Give up your fantasies, reality is waiting for you; your friends are waiting for you, have fun. Among them you'll find the true love.";
                content_r = "Be brave enough to change what you have now, if he is not what you really want. The world is full of wonderful people. Your concept of what a relationship should be will come true when you experience real love.";
                content_f = "You are now on a period of personality development. For that reason, you need your good friends, the conversations, the childhood memories and the nights out. You need to have fun with the people who know you well. If you haven't been around lately, this is the time to win them back. Don't let them down; be loyal, reliable and respectful. You'll have a strong influence over your friends; you are in a position to give them good advice.";

          }
          with(Cards[2]) {
                number = "II";
                name = "THE HIGH PRIESTESS ";
                image = "02";
                content = "Look at all the things that surround you. A new kind of energy has sprung in you, filling you with love; it is time now to learn how to use all this. Enjoy even the smaller things of life. Your bright ideas will favor the people around you. Favorable period to start a stable relationship.";
                content_r = "This is a favorable period to enter INTO a new stage. You are feeling a renewed sense of freedom; for that reason, you need someone who can make you live nights of burning passion, without any restriction, without any limits. A new relationship is waiting for you; you'll be amazed by the things that destiny has in store for you.";
                content_f = "The time has come for you to reflect about and SELECT the people that you can trust. Only those who are real friends can walk with you through this difficult but interesting path of self-discovery. A trip to the mystical cultures will increase your energy and help you transmit it to your friends.";

          }
          with(Cards[3]) {
                number = "III";
                name = "THE EMPRESS";
                image = "03";
                content = "You are ready to seduce or to be seduced; you are sexy and fun, take advantage of these qualities! You have lots of love to give; it all depends on your ability to express it. Don't forget that a relationship will prosper if there is mutual trust, respect and communication.";
                content_r = "You find yourself submerged INTO a process of spiritual growth that you can't share. Your creative imagination will wander freely to explore the world of thoughts. Focus your attention entirely on yourself if you want to draw some benefit FROM this experience and if you want to be filled with new energy to face the exciting future.";
                content_f = "A family instinct has grown in you; your friends will understand that and will be with you to share it. Celebrate with them this experience. They will appreciate your new feelings and will share unforgettable moments. ";

          }
          with(Cards[4]) {
                number = "IV";
                name = "THE EMPEROR";
                image = "04";
                content = "You are capable of loving in a sensible way. Don't let yourself be impressed. Prove that you are not just a pretty face; try to start a serious relationship in which the sense of humor, friendship and the intellectual aspect constitute the most important elements. You won't regret it.";
                content_r = "The time has come for you to start creating a home or to fill the one that you share with your partner with a new and wonderful being, product of your love. The light of joy will shine in your home.";
                content_f = "Don't shut yourself off; trust all those people who have always been by your side even though they may tell you things that right now you don't want to hear. Listen and take the advice FROM good friends, it may be more helpful than what you imagine. These people love you, know you and can have an objective position; however, the final decision will always be yours. ";

          }
          with(Cards[5]) {
                number = "V";
                name = "THE HIEROPHANT";
                image = "05";
                content = "you have opened up the doors to a more fulfilling and spiritual love. Leave behind the material things and head towards the true love. Give and don't expect to receive anything in exchange. Your optimistic and enthusiastic mood will help you seduce him.";
                content_r = "Get away FROM that person with a strong and domineering personality. Around you there is a sensitive, caring, dreamy but rational being in whom you can trust; he¡¯ll seduce you with his enthusiasm and friendliness.";
                content_f = "Be open to the new friendships that are arising FROM your new activities. Share with your friends all the new knowledge that you're acquiring; share also a new experience related to their and your spiritual growth. You'll make true friends that will be with you in the good and bad moments.";

          }
          with(Cards[6]) {
                number = "VI";
                name = "THE LOVERS";
                image = "06";
                content = "You are recovering your self-confidence. You should increase your self esteem; try to boost your ego! This is a period loaded with emotions. Love has arrived in your life; you'll find it among your friends. Don't let it go away!";
                content_r = "Communication will solve all the problems. Burning passion generates life and joy. Feed that passion; a creative ability will grow in you and will transform your life in a positive way. You'll achieve the happiness that you wish.";
                content_f = "You'll learn that friendship is selfless; it demands tolerance, permanence, strength, trust and love. You'll form a deep friendship sooner than what you expect. You can be sure that the person will have all those qualities. Always tell the truth; as usual, be genuine. ";

          }
          with(Cards[7]) {
                number = "VII";
                name = "THE CHARIOT";
                image = "07";
                content = "It is time for you to assume the consequences of your past actions; however, you still have time to mend them. All these are learning experiences that enrich your life and will be helpful in the future. This period will be constructive if you deal with the situations with calmness and tolerance.";
                content_r = "Be open to new feelings and friendships. Passion grows and fades away and there's nothing we can do to change that if there is no true love. Everything works as a learning experience that will help you discover the important things for a relationship. Try to spot among those around you the one who loves you in silence.";
                content_f = "Don't let yourself be influenced by false, selfish, opportunist friends. Identify the good friends; they may not be many but they are precious. Share your friends with your family; you'll see that everything will be in harmony. Enjoy very moment, live intensely each day; you'll find the real meaning of your life. ";

          }
          with(Cards[8]) {
                number = "VIII";
                name = "STRENGTH";
                image = "08";
                content = "You can't really love someone if you don't love yourself first. Devote some time to get to know you. Love is within you; you just have to learn to transmit it. Venture to see yourself FROM an external perspective. FROM this time on you'll have many experiences, enjoy them intensely. Learn FROM them, they will help you deal with the people that you know in a balanced and prudent way.";
                content_r = "You have to accept that your partner is different FROM you. If you love him, take him with his faults and virtues. Give him time and space to be himself. He will be faithful and loyal and honest if you don't suffocate him with your lack of confidence. If you change, your relationship will improve.";
                content_f = "Give your friends some time; taking some distance doesn't imply a break-up. You have to respect their space. Keep your arms open for them, they deserve it. They did the same for you when it was necessary. You have to be genuine and positive. ";

          }
          with(Cards[9]) {
                number = "IX";
                name = "THE HERMIT";
                image = "09";
                content = "You need some time to decide which things are important for your life. Stay away FROM everything and everybody for a while; it is time for you to have some short holidays for reflection and spiritual growth. Being alone will help you discover your true feelings. You'll come back home with renewed strength.";
                content_r = "It is time to make a decision. A serious dialogue with your partner will help you think about your relationship and decide if you want to keep living your life together or not. Only you can decide if it is worth giving him another opportunity. This is a period of important decisions. Listen to your heart but also to your reason.";
                content_f = "Your friends will understand your need of shutting off to find the meaning of life and of the relationships with the people around you. This is the time to be alone and be the person that you really are. Enjoy nature, a good book, swimming, tripping. A new world is waiting for you as well as new friends that will make your days more enjoyable. ";

          }
          with(Cards[10]) {
                number = "X";
                name = "WHEEL OF FORTUNE";
                image = "10";
                content = "Love needs constant dedication, but when everything seems to be all right we forget about nurturing it. Give your partner time and space, don't suffocate him. Take him as he his, with his faults and virtues. He is different FROM you; that's why you should be tolerant and patient. Revise your conscience, reflect; this is a good period to try to grow and reach a higher stage.";
                content_r = "You need to think about you. You have to take a break; you are dominated by the speed at which events are happening without realizing that you've forgotten about you and your feelings. You have the support of your friends. Enjoy loneliness! It will help you discover what you really want but can't have yet. You'll find love sooner than expected.";
                content_f = "The time has come for you to get rid of those people that have caused you trouble but you hadn't realized until now. Don't try to bond with people that don't deserve you. When you become aware of the reality that surrounds you, you'll make new friends and experience new adventures and circumstances.";

          }
          with(Cards[11]) {
                number = "XI";
                name = "JUSTICE";
                image = "11";
                content = "Are you ready for love? You'll be bursting with love; this will be very beneficial. Enjoy it! You've been waiting for this for so long. Remember that honesty, loyalty and fidelity are the secrets for mutual trust and the way to avoid future conflict.";
                content_r = "Future has in store for you a lasting, harmonious and fascinating relationship. Start today a new life with your partner; if you don't have one you'll meet a new person with whom you'll live that wonderful future that is waiting for you. Very positive transformations will take place at home.";
                content_f = "You'll live unforgettable events, adventures and situations. You have to be ready to face unusual circumstances. There will be new ways of spending your free time; count on your friends to make them more enjoyable. Be prudent, the relationship with them will complicate but that will make everything more interesting.";

          }
          with(Cards[12]) {
                number = "XII";
                name = "THE HANGED MAN";
                image = "12";
                content = "Period of transformation and evolution. The things that seemed to be meaningful are meaningless now. You're experiencing a difficult transformation that will take you to a higher stage where love will be one of the feelings that will guide you through this new path. Let love carry you to a surprising territory.";
                content_r = "You'll live sweet moments with your partner. This will make you feel in heaven. You've entered INTO a new period in which you'll have the opportunity of becoming one with your partner. This will guide you towards a deep transformation that will strengthen your love.";
                content_f = "Stop for a moment and think. Your set of values is changing; don't let yourself be influenced by those who say they're your friends but they only guide you to trouble and sectarianism. Focus on those people who are always there for you, in the good and bad times, demanding nothing but your friendship. You'll enjoy the fruits of your efforts. ";

          }
          with(Cards[13]) {
                number = "XIII";
                name = "TRANSFORMATION";
                image = "13";
                content = "State of metamorphosis that disturbs your love life; your feelings are slowly changing, heading towards unknown territory. Be realistic, you'll need lots of love to overcome this situation. You have it inside; make an effort and be brave.";
                content_r = "This is a time to withdraw to some isolated place and think about what you want before moving on. You have to decide if you are willing to share, to commit yourself and to respect him; to accept that he¡¯s different FROM you. Be brave and try to ANALYZE your love life FROM a different perspective.";
                content_f = "You'll undergo a deep transformation and change of outlook. Even though at the beginning this evolution may seem painful and difficult, it is leading you to a new and better place where you'll find new friends, circumstances and opportunities. Don't be anxious, soon you'll see the results of your efforts.";

          }
          with(Cards[14]) {
                number = "XIV";
                name = "TEMPERANCE";
                image = "14";
                content = "You're entering INTO a period of harmony. Don't get too excited about presumptuous, unreal feelings; feelings that will only disappoint you. You know who you are and you know the kind of love that you want and where to find it. Go for it!";
                content_r = "This is a period of internal and external transformation. It is necessary that you channel your energy; your gift is your rhetoric; you have the ability to give good advice. This will favor you when showing your feelings. Start new projects with your partner. Be creative.";
                content_f = "Everybody deserves a new opportunity. You'll cement your relationship with your friends if you make things together like going for a walk, going camping or getting together to discuss your personal concerns. ";

          }
          with(Cards[15]) {
                number = "XV";
                name = "THE DEVIL";
                image = "15";
                content = "You shouldn't be impulsive. You are being deceived; you think that there is love around you but in fact you are surrounded by selfishness and ambition. Think; reason will help you see things clearly. Evaluate your feelings; look inside you and uncover your deepest emotions.";
                content_r = "This is an excellent period for you. A balance between sex appeal and a spiritual correspondence will enrich and strengthen your relationship with your partner, making it stable and lasting. Communication, commitment and cooperation are important. Don't forget that you are now like a team. Everything will be possible if you both make an effort.";
                content_f = "Make sure that your friends are good people and don't belong to that dark world that you seem to be heading for. Get away FROM those selfish friends that make you waste your time and try to engage in other activities, more beneficial for your spirit. You'll realize that there are other people who really love you and have always been with you but you didn't pay attention to.";

          }
          with(Cards[16]) {
                number = "XVI";
                name = "THE TOWER";
                image = "16";
                content = "You are afraid, but this is normal because you know that you need a radical change in your life. You need a metamorphosis to fill you with energy, to help you fight against the monotony and boredom of loneliness. This is a period of spiritual renovation, seduction, well-being and improvement. Now you will be able to start a serious, passionate relationship.";
                content_r = "You're still on time to make him understand that you want a different, more positive relationship. You're strong enough to prevent him FROM HAVING a negative influence on you. Leave your feelings aside and reason; you have the support of the people who really love you. Your luck has taken a positive turn. Surprise, seduction and light in your near future.";
                content_f = "You'll experience many important, even confusing changes in your life. Everything will change: the things, the people, even the circumstances. You'll go through painful moments where everything will seem to be falling apart but don't be afraid; the things that really belong to you will remain. The real friends will always be with you. ";

          }
          with(Cards[17]) {
                number = "XVII";
                name = "THE STAR";
                image = "17";
                content = "This is a good moment. Look for the love that you long for, it will be yours. Take advantage of this period, it will favor you.";
                content_r = "You're entering a dark period in your relationship. You are seeing the consequences of all the things that were not solved at the right time. His versatile personality overwhelms you. All your experiences will teach you something and will help you start a transparent relationship based on communication.";
                content_f = "New friends will appear in your life: people who want to share their time, their worries, their future with you. You have enough space for all of them and the benefit they will bring for your future may be immense. Don't waste this opportunity that life is giving you. ";

          }
          with(Cards[18]) {
                number = "XVIII";
                name = "THE MOON";
                image = "18";
                content = "Don't quit looking for the love that you want. Search inside of you, maybe the answer to your quest is there. You can't spend your life longing for what you can't have. Look around you; the important things are in front of your eyes. Take this as the foundation for a new and wonderful beginning.";
                content_r = "You have to SHOW him your heart; exchange ideas and feelings. Let him see you as you are: genuine, cheerful, and spontaneous. This will lead you to the love, passion and happiness that you desire.";
                content_f = "The bonds of friendship don't change with time. You are going through a period of insecurity in which your friends may be hurt if you are not able to look inside of you and discover who you are. They are there to share your life. Happiness is in you; it's up to you to be able to find it.";

          }
          with(Cards[19]) {
                number = "XIX";
                name = "THE SUN";
                image = "19";
                content = "This is a good period to get to know your partner. Love is blooming. It fills you, comes out FROM you, it is present in every look, every word, it invades your surroundings. Everyone is fascinated with you; you make the people who know you happy. This is a prize, you've earned it.";
                content_r = "Every moment that you share with your partner is important; try to enjoy them or at least learn FROM them. If you are in love, try to think of the changes that are taking place in your relationship as something natural and necessary for its growth.";
                content_f = "This is a favorable period for friendship. Let new people enter in your life. Discover new and interesting friends in your workplace or college. You'll feel protected by people who love you and respect you. Suggest new and exciting activities to share with your friends; you'll live unforgettable moments. ";

          }
          with(Cards[20]) {
                number = "XX";
                name = "JUDGMENT";
                image = "20";
                content = "The time for you to look inside yourself has come. Evaluate your feelings and then try to find a balance and try to find also your destiny. Accept the love that is growing inside of you and you'll be happy. Be honest, loyal and faithful. You may hide things to other people but you can't deceive yourself and live a lie. ";
                content_r = "Your relationship with your partner will prosper if you enjoy every moment that you spend together and you share the new experiences arising FROM it. Physical and spiritual seduction. You'll be morally enriched. This will strengthen the relationship and make it last forever. ";
                content_f = "Supposed ¡°friends¡± dazzle you and at the same time prevent you FROM seeing the reality and the real foundations of friendship. You must establish a set of values to guide your actions and nobody should tell you which ones are the best. Real friends let you see within them and through them. ";

          }
          with(Cards[21]) {
                number = "XXI";
                name = "THE WORLD";
                image = "21";
                content = "You are changing and, as in every other transformation, the good things about you will remain. The true love will be with you no matter where you go. You'll see that all the true feelings hidden in you are still there, growing and giving you nice memories. Cheer up, all those people who don't want your happiness and well-being will go away. ";
                content_r = "This is a period of evaluation and transformation; give up superficiality and frivolity. You'll experience a deep spiritual transformation that will strengthen you and bring harmony INTO your life. You'll bring to light your true feelings which will revive the fire of passion. Use your creativity to avoid monotony. ";
                content_f = "A new cycle begins and all those friends who have not grown as you will be left behind. Don't be sorry for that; it is the best thing that could happen. In the end, you'll see that what remains is the best. New friends that will cause you happiness will appear. ";
          }
        }
        var card_1_check = false;
        var card_2_check = false;
        var card_3_check = false;
        initCards();

        if(UserInfo.page == 'friends_page')
        {
                document.getElementById("friend_user").innerHTML = UserInfo.year + " / " + UserInfo.month + " / " + UserInfo.day + "<br/>" + UserInfo.name + " with " + love_mate.name;
                Event.observe($('rolling_card_f_1'), 'click', function(event){
                    document['rolling_card_f_1'].src = "http://tarottarot2.appspot.com/images/tarot_" + Cards[card_number].image + "f.jpg";
                    document.getElementById("friends_card_1_name").innerHTML = Cards[card_number].number + ".&nbsp;" + Cards[card_number].name;
                    card_1_check = true;
                    if(card_1_check == true && card_2_check == true && card_3_check == true)
                    {
                        
                        setTimeout("$('friends_before_content').hide();$('friends_content').show();", 1800);
                        document.getElementById("friends_card_content").innerHTML = Cards[card_content].content_f;
                        
                    }
                });
                Event.observe($('rolling_card_f_2'), 'click', function(event){
                    document['rolling_card_f_2'].src = "http://tarottarot2.appspot.com/images/tarot_" + Cards[card_number2].image + "f.jpg";
                    document.getElementById("friends_card_2_name").innerHTML = Cards[card_number2].number + ".&nbsp;" + Cards[card_number2].name;
                    card_2_check = true;
                    if(card_1_check == true && card_2_check == true && card_3_check == true)
                    {
                        setTimeout("$('friends_before_content').hide();$('friends_content').show();", 1800);
                        document.getElementById("friends_card_content").innerHTML = Cards[card_content].content_f;
                    }
                });
                Event.observe($('rolling_card_f_3'), 'click', function(event){
                    document['rolling_card_f_3'].src = "http://tarottarot2.appspot.com/images/tarot_" + Cards[card_number3].image + "f.jpg";
                    document.getElementById("friends_card_3_name").innerHTML = Cards[card_number3].number + ".&nbsp;" + Cards[card_number3].name;
                    card_3_check = true;
                    if(card_1_check == true && card_2_check == true && card_3_check == true)
                    {
                        setTimeout("$('friends_before_content').hide();$('friends_content').show();", 1800);
                        document.getElementById("friends_card_content").innerHTML = Cards[card_content].content_f;
                    }
                });
                

        
                 
        }
        
        else if(UserInfo.page == 'love_page')
        {
                document.getElementById("love_user").innerHTML = UserInfo.year + " / " + UserInfo.month + " / " + UserInfo.day + "<br/>" + UserInfo.name + " with " + love_mate.name;
                Event.observe($('rolling_card_l_1'), 'click', function(event){
                    document['rolling_card_l_1'].src = "http://tarottarot2.appspot.com/images/love/love_" + Cards[card_number].image + "f.jpg";
                    document.getElementById("love_card_1_name").innerHTML = Cards[card_number].number + ".&nbsp;" + Cards[card_number].name;
                    card_1_check = true;
                    if(card_1_check == true && card_2_check == true && card_3_check == true)
                    {
                        
                        setTimeout("$('love_before_content').hide();$('love_content').show();", 1800);
                                                        
                        if(card_reverse == true)
                            document.getElementById("love_card_content").innerHTML = Cards[card_content].content;
                        else
                            document.getElementById("love_card_content").innerHTML = Cards[card_content].content_r;
                    }
                });
                Event.observe($('rolling_card_l_2'), 'click', function(event){
                    document['rolling_card_l_2'].src = "http://tarottarot2.appspot.com/images/love/love_" + Cards[card_number2].image + "f.jpg";
                    document.getElementById("love_card_2_name").innerHTML = Cards[card_number2].number + ".&nbsp;" + Cards[card_number2].name;
                    card_2_check = true;
                    if(card_1_check == true && card_2_check == true && card_3_check == true)
                    {
                        setTimeout("$('love_before_content').hide();$('love_content').show();", 1800);
                        if(card_reverse == true)
                            document.getElementById("love_card_content").innerHTML = Cards[card_content].content;
                        else
                            document.getElementById("love_card_content").innerHTML = Cards[card_content].content_r;
                    }
                });
                Event.observe($('rolling_card_l_3'), 'click', function(event){
                    document['rolling_card_l_3'].src = "http://tarottarot2.appspot.com/images/love/love_" + Cards[card_number3].image + "f.jpg";
                    document.getElementById("love_card_3_name").innerHTML = Cards[card_number3].number + ".&nbsp;" + Cards[card_number3].name;
                    card_3_check = true;
                    if(card_1_check == true && card_2_check == true && card_3_check == true)
                    {
                        setTimeout("$('love_before_content').hide();$('love_content').show();", 1800);
                        if(card_reverse == true)
                            document.getElementById("love_card_content").innerHTML = Cards[card_content].content;
                        else
                            document.getElementById("love_card_content").innerHTML = Cards[card_content].content_r;
                    }
                });
        
                    
            
        }
        

                    
    }
};

var make_today_tarot = {
    init: function () {
        
                        
        var uid_number = UserInfo.uid.substring(12);
        uid_number = parseInt(uid_number);
        var set_number = parseInt(UserInfo.set_value);
        
        if(UserInfo.tomorrow == true)
        {
            var now_date = UserInfo.now_date;
            var year = now_date.slice(0, -4);
            var month = now_date.slice(4, -2);
            var day = now_date.slice(6);
            
            year = parseInt(year);
            month = parseInt(month);
            day = parseInt(day);
             
            if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
            {
                if(day == 31)
                {
                    if(month == 12)
                    {
                    year = year + 1;
                    month = 1;
                    day = 1;
                    }
                    else
                    {
                    month = month + 1;
                    day = 1;
                    }
                }
                else
                    day = day + 1;
            }
            
                                                            
            
            else
            {
                if(day == 30)
                {
                    month = month + 1;
                    day = 1;
                }
                else
                    day = day + 1;
            }
            
            year = String(year);
            if(month < 10)
            {
              month = String(month);
              month = "0" + month;
            }
            else
              month = String(month);
            if(day < 10)
            {
              day = String(day);
              day = "0" + day;
            }
            else
              day = String(day);
              
            now_date = month + day;
            
        }
        
        else
        {
            var now_date = parseInt(UserInfo.now_date);
            now_date = now_date % 1000;
        }
        
        var now_365 = ((now_date / 100) * 30) + (now_date % 100);   
        var random_key = uid_number + set_number;
        
        function get_card_number(random_key, now_365){
               var numbers = Math.floor((random_key / now_365) % 45);
               if(numbers == 44)
                    numbers = 43;
                return numbers
        }
        var card_reverse = false;
        var card_number = get_card_number(random_key, now_365);
        
        if(card_number > 21)
        {
            card_number = card_number - 22;
            card_reverse = true;    
        }
        
        function Card(number, name) {
          this.number = number;
          this.name = name;
          this.image = "";
          this.content = "";
          this.content_r = "";
        }


        var Cards = new Array(22);
        
        function initCards() {
          for(var i=0; i<22; i++){
                Cards[i] = new Card("", "");
          }
          with(Cards[0]) {
                number = "O"
                name = "THE FOOL";
                image = "00";
                content = "New ways open up as a consequence of your words and there are no commitments, no prejudices that can subdue your ideas. Express what you think freely. Tell your ideas to those who want to listen without any prejudice. Try to be genuine, spontaneous and honest; people will value that. ";
                content_r ="You are going through a period of instability due to your worries and your supposedly ¡°rational¡± reflections which in fact are shallow and superficial. This is a period of independence, autonomy, liberty. You have to do what you feel, love whoever you want, work where you always wanted to. Happiness and joy have arrived in your life; this is a period to recover energy.";

          }
          with(Cards[1]) {
                number = "I";
                name = "THE MAGICIAN";
                image = "01";
                content = "This is a period for communication, a period for social life, for meeting new people. Pursue new activities. You'll find in them the solution to many problems; you'll be positively surprised.";
                content_r ="You are heading INTO a new period of positive changes; it will be advantageous for you. Your inner strength will grow providing you with the confidence and self assurance that you need to deal with everything that may come. Relationships and money go hand in hand. Get rid of those things that make your life monotonous; be creative, innovative, try to have firm and cleapr ideas. The results of your efforts will bring about a transformation. Your new outlook on life will change your way of seeing your world. ";

          }
          with(Cards[2]) {
                number = "II";
                name = "THE HIGH PRIESTESS ";
                image = "02";
                content = "The time has come for you to create your own ¡°language¡± and to use it. Try to uncover your inner self. You need to SHOW what you feel. Some yoga classes will help you understand and take care of your body and soul, go for it! You'll meet people like you and make new friendships. ";
                content_r ="You are living your best period; you've found out who you are and all the things that you can contribute to the world. Your future is up to you; get ready to enjoy it. Open the doors of your soul and let the light in.! Relationships will be consolidated. Increase your self confidence and self esteem; SHOW what you are capable of.";
          }
          with(Cards[3]) {
                number = "III";
                name = "THE EMPRESS ";
                image = "03";
                content = "You have an ability that very few people have. You know how to express what you feel, you have persuasive power and for that reason you'll exert an important influence on people. You are sensitive; you are willing to listen and help with whatever you can. Channel this gift, write a book. It will be a success!";
                content_r ="You are enjoining your home in peace. A great need to SHOW your creativity keeps you in motion; try to channel that energy INTO the material world and you¡¯ll reach a state of leadership. Make an evaluation of your life and set new goals and discover new experiences that will enrich your life and enhance your self esteem. ";

          }
          with(Cards[4]) {
                number = "IV";
                name = "THE EMPEROR ";
                image = "04";
                content = "Listen and take other people's advice, broaden your mind¡¦ this is the right time to be fair and let other people communicate with us. When you listen, you discover amazing facets of the people who speak. Stay alert and be prudent when expressing your opinions. Be ready to learn FROM others. Tune in to people. ";
                content_r ="You are surrounded by people with a powerful persuasive power who are imposing their way of thinking. SHOW your self-worth and don't let them intimidate you. SHOW your talent, your ideas will be taken INTO consideration. Work hard to get the relationship that you want; don't be ashamed of being the one who takes the first step. ";

          }
          with(Cards[5]) {
                number = "V";
                name = "THE HIEROPHANT ";
                image = "05";
                content = "This is the time to have new perspectives, new company; time to achieve new goals, increase knowledge¡¦ of course, you won't be the same. Get rid of monotony, try new ways of communication; however, don't refuse to listen to those who love you.";
                content_r ="Time has been a teacher for you; you are full of new spiritual values, you have inner harmony and balance; your outlook on life has changed. You are seeing a new reality. Your creativity will grow and nothing will be impossible for you. Trust in this new period and take a chance on the relationship that you¡¯ve been longing for.! Your spirit is in harmony and your intuition will be your guide.";

          }
          with(Cards[6]) {
                number = "VI";
                name = "THE LOVERS";
                image = "06";
                content = "Try to find some time to talk, with a good mood and without arguing. Honesty, understanding and tolerance must be the foundations of all your relationships. You have to face reality and find stability for your situatio";
                content_r ="You will innovate and decide upon the course of the future. Devote more time to yourself. SHOW your self esteem; don't let other people influence you. This is a period in which new feelings will arise; you¡¯ll be able to seduce that person that soon will break INTO your life. You¡¯ll enjoy romantic moments. Don't be afraid of showing your feelings. ";

          }
          with(Cards[7]) {
                number = "VII";
                name = "THE CHARIOT";
                image = "07";
                content = "SHOW all your feelings and emotions. A strong impulse guides you and removes the obstacles that until now had sunk your love life in gloom. It is a period for communication, if you assume your responsibilities. Try not to be influenced in your decisions.";
                content_r ="This is the time to see the results of what you¡¯ve built. Be happy! You¡¯ll see the outcomes of your previous efforts. Success is coming and it will bring joy to your personal and professional life as well. This is the time to carry on with your plans. The true love will come. This is a favorable period for the growth of the relationship with your new partner. ";

          }
          with(Cards[8]) {
                number = "VIII";
                name = "STRENGTH ";
                image = "08";
                content = "Stop for a moment and make an evaluation of the things that you've lived so far. Try to stop taking your friends¡¯ advice; take a risk and decide for yourself. Your life and love are yours and you should be the only one who deals with them. Analyzing your life will stimulate your perception in ORDER not to be deceived by appearances and external influences. You'll have new experiences after the change.";
                content_r ="Be careful about taking hasty decisions; they may bring about unexpected outcomes. This is a period of wait, of introspection. Focus on your thoughts; this will stimulate your perception in ORDER not to be deceived by the external world. This period will be very important and necessary for you to grow and acquire new experiences. This is a time for being right, faithful and loyal. You'll strike up reliable and meaningful friendships. ";

          }
          with(Cards[9]) {
                number = "IX";
                name = "THE HERMIT ";
                image = "09";
                content = "Isolate yourself FROM everything and shut yourself away. Don't use any means of communication for a while. A stage in your life has just finished and it is time to find a meaning for everything. Get connected with your id; search inside of you for a goal and focus all your energies in trying to accomplish it. You'll be successful if you work hard.";
                content_r ="A stage in your life has come to an end. This is a time of wait and reflection before acting. Stop for a moment and get rid of the past! Take some time before heading with renovated energy towards a new period in your love life. It is important that you devote all your attention to yourself. The best things are about to come. ";

          }
          with(Cards[10]) {
                number = "X";
                name = "WHEEL OF FORTUNE";
                image = "10";
                content = "Be open to conversation, to amazing changes in your life, to new challenges and meetings that will make your life more exciting. Your inspiration and intuition will help you accomplish your goals. Your predisposition towards conversation will help you find the love of your life.";
                content_r ="You are ready to face the challenges that destiny will put before you; your life may change for good. You deal with the new challenges every morning. A successful future is waiting for you; this is what you¡¯ve been longing for. This is the right time to SHOW your abilities; your ideas will be accepted. This period of transition will be favorable for the relationship with your friends. Your wishes will come true! ";

          }
          with(Cards[11]) {
                number = "XI";
                name = "JUSTICE";
                image = "11";
                content = "This is the time to talk, to SHOW yourself as you are; overcome the shyness and submissiveness that makes other people make decisions for you. Break free. The mental harmony that you are experiencing will bring about material and affective results. You'll wake up to a new reality. ";
                content_r ="You are going through a period in which interesting things and favorable changes are happening. You should take advantage of them. Justice has shown to you the charms of life and it is giving you an opportunity to enjoy them. Reflect upon this and act sensibly. This is a period in which you'll have serious conversations with your partner. This will contribute to the growth of the relationship.";

          }
          with(Cards[12]) {
                number = "XII";
                name = "THE HANGED MAN";
                image = "12";
                content = "Period of transition and readjustment to new ideas and conditions. Your new outlook on life will change your perspective. You'll face with courage and determination all the obstacles that may appear. You spirit is in harmony, guided by your intuition. Whatever you start now will produce excellent results.";
                content_r ="You are experiencing a revolution of ideas; your prospects are improving and therefore your knowledge is expanding; you are becoming a demanding person. You are in a position where you can ask whatever you want; however, be careful with selfishness. You'll feel generous and selfless in love, and you'll feel a need of helping a helpless person. ";

          }
          with(Cards[13]) {
                number = "XIII";
                name = "TRANSFORMATION";
                image = "13";
                content = "Don't resist change; destiny demands rebirth and transformation. You'll be a new person. New relationships, new situations and new possibilities appear. ";
                content_r ="Don't resist change; try to take firm steps when it comes to your development and growth. New opportunities will arise soon; you¡¯ll experience unexpected economic success. Your life needs solid foundations, try with logic, ORDER and reason. This is a good period for the relationship with friends. Conditions are favorable for the growth of the relationship with your partner. ";

          }
          with(Cards[14]) {
                number = "XIV";
                name = "TEMPERANCE";
                image = "14";
                content = "It is time now for you to discover the things around you. It is time to practice meditation and recover the love for the things. Spirituality invades your body and your mind. A sense of harmony and balance will guide you to success in any enterprise. Your transformation will take you closer to love.";
                content_r ="Your creative imagination will wander along the paths of spirituality; you¡¯ll be ready to uncover the real meaning of things and of love. Be tolerant, calmed and sympathetic with your partner and your friends. This is a period to think FROM a more spiritual point of view about what has happened in your love life so far and to get ready to change those things that you don't like. You should try to evolve; you are ready for it.";

          }
          with(Cards[15]) {
                number = "XV";
                name = "THE DEVIL";
                image = "15";
                content = "Negative influences are leading you to a dark world that has nothing to do with your real personality. Fight against everything that is not a part of you. Try not to argue, chose dialogue. Reflect upon the cause of your outbursts. Try to use the subtle art of cooperation, tact and diplomacy. ";
                content_r ="Come back to earth; stop dreaming. Stop taking risks for impossible things. Be happy with what you have and enjoy it. Get away FROM those negative influences or feelings; look for strength in your individuality and in that need that you have for being yourself. Don't worry about other people¡¯s opinions. Fight for what you deserve, nobody is going to give you anything. Open your heart and don't be afraid of showing your feelings. ";

          }
          with(Cards[16]) {
                number = "XVI";
                name = "THE TOWER";
                image = "16";
                content = "Favorable period to clear things up. Try to avoid misunderstandings. You'll be surprised by some violent changes but, even though things are confusing now, soon you'll have new opportunities for communication with other people. Soon the sun will shine and a renewed sense of satisfaction will be born thanks to your dedication and effort to overcome all obstacles. ";
                content_r ="This is an excellent period for extraordinary and impetuous changes. Your world is falling apart and you want to save it by clinging to certain things. The only thing that you're going to get is being dragged down to the abyss with them. Let things happen; in this way everything will be faster and less painful. Be patient, the good things in you will remain. Relax, new opportunities will arise soon.";

          }
          with(Cards[17]) {
                number = "XVII";
                name = "THE STAR";
                image = "17";
                content = "You should share your knowledge and experience and give advice only when you are asked. Use your knowledge to communicate with people. It is time to be altruistic and consider the rest of the people. New relationships will develop to fill your heart with joy. ";
                content_r ="New hopes, new love, new luck; don't waste this strike of good luck. New opportunities for improving your lifestyle arise. This is a period for love, passion; get ready to be happy. Venture to change your outlook, surprise yourself. ";

          }
          with(Cards[18]) {
                number = "XVIII";
                name = "THE MOON";
                image = "18";
                content = "This is a period for introspection; find your real you, your language, your world, the things that you have to communicate and SHOW to everybody else. You'll grow spiritually; light and joy will stimulate your energies to help you make people be fond of you. ";
                content_r ="A longing for the past don't let you focus on the present. This causes insecurity and lack of confidence in you. You feel that something is missing in your life and this situation may cause you depression. You must open your eyes to a new reality. Try to engage in new activities, there you'll find the company that you need; you'll find that someone who will try to make you happy. ";

          }
          with(Cards[19]) {
                number = "XIX";
                name = "THE SUN";
                image = "19";
                content = "Don't prevent yourself FROM doing things; express what you feel. You'll be filled with happiness. Transmit this overwhelming energy to other people and feel the energy, vitality and self confidence coming FROM within you. Transmit this happiness. This will be a successful cycle. You have the necessary abilities, self confidence and determination to achieve success in all your projects. ";
                content_r ="All the things that surround you are wonderful. Wherever you go you make friends; in your workplace everything is great, you are successful. The relationship with your friends is excellent; you are happy and full of an overwhelming energy. Live each moment intensely. This is a period for spiritual growth. ";

          }
          with(Cards[20]) {
                number = "XX";
                name = "JUDGMENT";
                image = "20";
                content = "You must achieve a balance and establish which values are important for you and which possessions are really necessary to discover your true destiny, your real you. You'll start a period of spiritual communication, of introversion. Try to identify and get rid of those people who hamper your growth and communication with others. ";
                content_r ="Devote some time to yourself and discover who you are. Give up everything that is not necessary to achieve happiness. This is about leaving behind the frivolities and banalities of your life. You have to find the path that will help you find a place where you feel comfortable and happy. You'll have to make an effort to be able to do better but you can do it.!";

          }
          with(Cards[21]) {
                number = "XXI";
                name = "THE WORLD";
                image = "21";
                content = "Try to find the truth. A serious and mystical communication will help you end that exchange of shallow thoughts and words that lead nowhere, nor enrich your spirit. Don't judge other people; try to understand their motivation and attitudes. Learn to love people in spite of their faults or virtues.";
                content_r ="You are seeing the results of your efforts and this stimulates you; you¡¯re getting closer to the goals that you¡¯ve set. Think carefully before taking any decision, this is a period of drastic changes in your life. You'll have enough confidence to move forward with courage and not to give up. Period of spiritual growth. A dream will be reborn. New lovers and relationships. ";
          }
        }

        initCards();
        
        if(card_reverse == false)
        {
            document['rolling_card_img'].src = "http://tarottarot2.appspot.com/images/tarot_" + Cards[card_number].image + "f.jpg";
            document['tarot_image2'].src = "http://tarottarot2.appspot.com/images/tarot_" + Cards[card_number].image + "f.jpg";
            document.getElementById("card_name").innerHTML = Cards[card_number].number + ".&nbsp;" + Cards[card_number].name;
            document.getElementById("card_name2").innerHTML = Cards[card_number].number + ".&nbsp;" + Cards[card_number].name;
            document.getElementById("card_content").innerHTML = Cards[card_number].content;
        }
        else if(card_reverse == true)
        {
            document['rolling_card_img'].src = "http://tarottarot2.appspot.com/images/tarot_" + Cards[card_number].image + "b.jpg";
            document['tarot_image2'].src = "http://tarottarot2.appspot.com/images/tarot_" + Cards[card_number].image + "b.jpg";
            document.getElementById("card_name").innerHTML = Cards[card_number].number + ".&nbsp;" + Cards[card_number].name + "&nbsp;[Reverse]";
            document.getElementById("card_name2").innerHTML = Cards[card_number].number + ".&nbsp;" + Cards[card_number].name + "<br/>[Reverse]";
            document.getElementById("card_content").innerHTML = Cards[card_number].content_r;
        }
        


    }
};



Event.observe(window, 'load', function(){
        OpenSocial.init(UserInfo.req);
});
