using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;

namespace ExWeb
{
    public partial class Mod_Inline : Mod
    {
        static string resize =
              "  \r\n  $(function () {"
            + "  \r\n      function reSizeIframe() {"
            + "  \r\n        var theFrame = $(\"#***\", parent.document.body);"
            + "  \r\n        theFrame.height($(document.body).height());"
            + "  \r\n      }"
            + "  \r\n      reSizeIframe();"
            + "  \r\n  });";

        public static string resize1 = ""
            + "\r\n $(function(){"
            + "\r\n     var iFrames = $('#***');"
            + "\r\n	    function iResize() {"
            + "\r\n		   for (var i = 0, j = iFrames.length; i < j; i++) {"
            + "\r\n		       iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';"
            + "\r\n		       // iFrames[i].style.width = iFrames[i].contentWindow.document.body.offsetWidth + 'px';"
            + "\r\n		   }"
            + "\r\n	    }"
            + "\r\n    	if ($.browser.safari || $.browser.opera) { "
            + "\r\n    	   iFrames.load(function(){"
            + "\r\n    	       setTimeout(iResize, 0);"
            + "\r\n        });"
            + "\r\n    	   for (var i = 0, j = iFrames.length; i < j; i++) {"
            + "\r\n    			var iSource = iFrames[i].src;"
            + "\r\n    			iFrames[i].src = '';"
            + "\r\n    			iFrames[i].src = iSource;"
            + "\r\n        }"
            + "\r\n    	} else {"
            + "\r\n    	   iFrames.load(function() { "
            + "\r\n    	       this.style.height = this.contentWindow.document.body.offsetHeight + 'px';"
            + "\r\n    	   });"
            + "\r\n    	}"
            + "\r\n });"
        ;

        public static string GetIframe(string _ID, string _File, int _Width, int _Height, string _Scrolling)
        {
            return ""
                + "\r\n<iframe "
                + " ID=\"" + _ID + "\""
                + " name=\"" + _ID + "\""
                + " class=\"iframe\""
                + " frameborder=\"0\""
                + " marginwidth=\"0\""
                + " marginheight=\"0\""
                + " src=\"" + _File + "\""
                + (_Width == -1 ? " width=\"100%\"" : " width=\"" + _Width + "\"")
                + (_Height == -1 ? "" : " height=\"" + _Height + "\"")
                + (_Scrolling == "" ? "" : " scrolling=\"" + _Scrolling + "\"")
                + "></iframe>"
                + "\r\n<script language=\"javaScript\">"
                + "\r\n<!--"
                + resize1.Replace("***", _ID)
                + "\r\n//-->"
                + "\r\n</script>"
                ;
        }
    }
}