﻿if (typeof (MM) === "undefined") { var MM = {}; }
if (typeof (MM.Web) === "undefined") { MM.Web = {}; }
if (typeof (MM.Web.Timepass) === "undefined") {
    MM.Web.Timepass = {};
}

$(document).ready(function() {
    //Any initialisation code here
});

MM.Web.Timepass = (function() {
    // Declare any object-wide variables here with a brief comment about what they are
    var random_display = 0;
    var string_index = 0;
    var string_list = new Array();
    var prevString = '';

    string_list[string_index++] = new stringItem("<object style='padding-top:35px' type='application/x-shockwave-flash' data='http://widgets.clearspring.com/o/4921d1bbde64b665/4af14d97c5f42939/4921d1bbde64b665/f98a3b70/-cpid/59205435cf143958' id='W4921d1bbde64b6654af14d97c5f42939' width='400' height='300'><param name='movie' value='http://widgets.clearspring.com/o/4921d1bbde64b665/4af14d97c5f42939/4921d1bbde64b665/f98a3b70/-cpid/59205435cf143958' /><param name='wmode' value='transparent' /><param name='allowNetworking' value='all' /><param name='allowScriptAccess' value='always' /></object>");
    string_list[string_index++] = new stringItem("<object type='application/x-shockwave-flash' style='outline: none;' data='http://hosting.gmodules.com/ig/gadgets/file/112581010116074801021/fish.swf?up_fishColor2=5E40F4&up_fishColor8=F45540&up_fishColor9=D040F4&up_fishColor7=F45540&up_fishColor6=C740F4&up_numFish=10&up_fishColor4=F4DF40&up_foodColor=FCB347&up_fishColor1=F45540&up_fishColor10=F45540&up_fishColor3=F45540&up_fishColor5=F45540&up_fishName=Fish&up_backgroundImage=http://&up_backgroundColor=454545&' width='600' height='400'><param name='movie' value='http://hosting.gmodules.com/ig/gadgets/file/112581010116074801021/fish.swf?up_fishColor2=5E40F4&up_fishColor8=F45540&up_fishColor9=D040F4&up_fishColor7=F45540&up_fishColor6=C740F4&up_numFish=10&up_fishColor4=F4DF40&up_foodColor=FCB347&up_fishColor1=F45540&up_fishColor10=F45540&up_fishColor3=F45540&up_fishColor5=F45540&up_fishName=Fish&up_backgroundImage=http://&up_backgroundColor=454545&'></param><param name='AllowScriptAccess' value='always'></param><param name='wmode' value='opaque'></param><param name='scale' value='noscale' /><param name='salign' value='tl' /></object>");
    string_list[string_index++] = new stringItem("<object type='application/x-shockwave-flash' data='http://abowman.com/projects/gadgets/discdrop/discDrop.swf' width='600' height='400' id='discDrop'><param name='movie' value='http://abowman.com/projects/gadgets/discdrop/discDrop.swf'/> <param name='quality' value='high' /><param name='wmode' value='opaque' /></object>");

    var number_of_string = string_list.length;

    function stringItem(image_location) {
        this.string_item = new String();
        this.string_item.src = image_location;
    }
    
    var getNextString = function() {
        if (random_display) {
            string_index = generate(0, number_of_string - 1);
        }
        else {
            string_index = (string_index + 1) % number_of_string;
        }
        var new_string = get_StringItemLocation(string_list[string_index]);
        return (new_string);
    }

    var get_StringItemLocation = function(stringObj) {
        return (stringObj.string_item.src)
    }

    var generate = function(x, y) {
        var range = y - x + 1;
        return Math.floor(Math.random() * range) + x;
    }

    var rotateWidget = function() {
        var new_string = getNextString();
        if (prevString == new_string) {
            rotateWidget();
            return;
        }
        prevString = new_string;
        return new_string;
    }

    return {
        RotateWidget: function() {
            $('#rWidgetString').html(rotateWidget());
        }
    }; //end return
} ());

