﻿/// <reference path="../jquery-1.4.2-vsdoc.js" />
/// <reference path="../jquery.validate-vsdoc.js" />
/// <reference path="../jquery.tools.min.js" />
/// <reference path="../MicrosoftAjax.debug.js" />
/// <reference path="../MicrosoftMvcAjax.debug.js" />
/// <reference path="../MicrosoftMvcValidation.debug.js" />

TranceSoft = function ()
{
    var plugings = new Array();
    window.console = window.console || function ()
    {
        var fakeMod = {};
        fakeMod.log = function () { };
        fakeMod.error = function () { };
        return fakeMod;
    } ();

    function setTBodyInnerHTML(tbody, html)
    {
        var temp = tbody.ownerDocument.createElement('div');
        temp.innerHTML = '<table><tbody>' + html + '<tbody></table>';
        var newTbody = temp.firstChild.firstChild;
        newTbody.id = tbody.id;
        newTbody.className = tbody.className;
        tbody.parentNode.replaceChild(newTbody, tbody);
        return newTbody;
    }

    if (typeof Sys.Mvc.MvcHelpers.updateDomElement != 'undefined')
    {
        Sys.Mvc.MvcHelpers.updateDomElement = function Sys_Mvc_MvcHelpers$updateDomElement$updated(target, insertionMode, content)
        {
            /// <param name="target" type="Object" domElement="true">
            /// </param>
            /// <param name="insertionMode" type="Sys.Mvc.InsertionMode">
            /// </param>
            /// <param name="content" type="String">
            /// </param>
            if (target)
            {
                switch (insertionMode)
                {
                    case Sys.Mvc.InsertionMode.replace:
                        if (navigator.appVersion.indexOf('MSIE') > -1 && target.tagName.toUpperCase() == "TBODY")
                        {
                            target = setTBodyInnerHTML(target, content);
                        }
                        else
                        {
                            target.innerHTML = content;
                        }
                        break;
                    case Sys.Mvc.InsertionMode.insertBefore:
                        if (content && content.length > 0)
                        {
                            target.innerHTML = content + target.innerHTML.trimStart();
                        }
                        break;
                    case Sys.Mvc.InsertionMode.insertAfter:
                        if (content && content.length > 0)
                        {
                            target.innerHTML = target.innerHTML.trimEnd() + content;
                        }
                        break;
                }
            }
        }
    }

    return {
        Version: function ()
        {
            return "0.1";
        }
    }
} ();

/**
* jquery no conflict - Wrote by Zeludz
*/
(function ($)
{
    /**
    * on dom loaded
    */
    $(function ()
    {
        /**
        * wykrywanie przegladarki
        */
        if ($.browser.msie) $('body').addClass('msie');
        if ($.browser.mozilla) $('body').addClass('fx');
                
        
        // #left-user-panel.click
        var scrollable = $('.scrollable-panel').scrollable({
            next: '.nextpage',
            prev: '.prevpage'
        });
        scrollable.autoscroll({ autoplay: false });

        /* custom input */

        $('input').customInput();

        /**/

        $('.sitemap-tree li > ul').each(function(){ 	$(this).parent().css('border-bottom', '0'); });
    }); // on dom loaded
})(jQuery); // jquery no conflict

TranceSoft.Forms = function ($)
{
    var forms = {};
    var funcs = [];

    forms.Refresh = function (content, context)
    {
        $('input').customInput();
        for (var i = 0; i < funcs.length; i++)
        {
            var f = funcs[i];
            f(content, context);
        }
    };

    forms.Validate = function (content, context)
    {
        var result = $('#' + context.formId).validate().form();
        return result;
    };

    forms.Version = function ()
    {
        ///<summary>Returns version of current Forms helper implementation.</summary>
        ///<returns type="String" />
        return "1.0";
    }
    forms.AddCallback = function (func) { funcs.push(func); }
    return forms;
} (jQuery);
