public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            ImageRotatorViewModel model = new ImageRotatorViewModel();

            if (block != null)
            {
                var imageList = block.Lists.FindList("Images");
                foreach (var listItem in imageList)
                {
                    ImageRotatorImageViewModel img = new ImageRotatorImageViewModel();
                    img.ImageUrl = ResolveUrl(listItem.Setting1, app);
                    img.Url = listItem.Setting2;
                    if (img.Url.StartsWith("~"))
                    {
                        img.Url = app.CurrentRequestContext.UrlHelper.Content(img.Url);
                    }
                    img.NewWindow = (listItem.Setting3 == "1");
                    img.Caption = listItem.Setting4;
                    model.Images.Add(img);
                }
                string cleanId = MerchantTribe.Web.Text.ForceAlphaNumericOnly(block.Bvin);
                model.CssId = "rotator" + cleanId;
                model.CssClass = block.BaseSettings.GetSettingOrEmpty("cssclass");

                model.Height = block.BaseSettings.GetIntegerSetting("Height");
                model.Width = block.BaseSettings.GetIntegerSetting("Width");

                if (block.BaseSettings.GetBoolSetting("ShowInOrder") == false)
                {
                    RandomizeList(model.Images);
                }
            }

            return RenderModel(model);
        }
        private string RenderModel(ImageRotatorViewModel model)
        {
            StringBuilder sb = new StringBuilder();

            if (model.Images.Count > 0)
            {
                sb.Append("<div class=\"" + model.CssClass + "\">\n");
                sb.Append("<ul id=\"" + model.CssId + "\" class=\"imagerotatorlist\" style=\"height:" + model.Height + "px;width:" + model.Width + "px;\">");
                for (int i = 0; i < model.Images.Count; i++)
                {
                    var img = model.Images[i];
                    sb.Append("<li ");
                    if (i == 0)
                    { sb.Append("class=\"show\""); }
                    sb.Append("><a href=\"" + img.Url + "\" ");
                    if (img.NewWindow == true)
                    { sb.Append(" target=\"_blank\""); }
                    sb.Append(">");
                    sb.Append("<img src=\"" + img.ImageUrl + "\" alt=\"" + HttpUtility.HtmlEncode(img.Caption) + "\" />");
                    sb.Append("</a></li>");
                }
                sb.Append("</ul>\n");
                sb.Append("</div>");
                sb.Append("<script type=\"text/javascript\">\n");
                sb.Append(" $(document).ready(function() {");
                sb.Append(" StartRotator('" + model.CssId + "', " + model.Pause + ");");
                sb.Append(" });");
                sb.Append("\n</script>");
                sb.Append("\n<style type=\"text/css\">");

                sb.Append("\n#" + model.CssId + " {");
                if (model.Height > 0)
                {
                    sb.Append("height: " + model.Height + "px;");
                }
                if (model.Width > 0)
                {
                    sb.Append("width: " + model.Width + "px;");
                }
                sb.Append("position:relative;");
                sb.Append("margin:0;padding:0;");
                sb.Append("}");

                sb.Append("\n#" + model.CssId + " li { ");
                sb.Append("list-style:none;");
                sb.Append("float:left;");
                sb.Append("position:absolute;");
                sb.Append("margin:0;padding:0;");
                sb.Append("}");

                sb.Append("\n#" + model.CssId + " li.show { ");
                sb.Append("z-index:500;");
                sb.Append("}");
                sb.Append("</style>");
            }

            return sb.ToString();
        }