var _CommonBaseClientId = "";
var _BaseId = "";
var _CommonDialogAreaStack = new Array();

var _ProjectEdited = false;
var _allowPrompt = true;
var _projectId = 0;
var _elementId = 0;
var _revieweeId = 0;
var _profStdSectionId = 0;
var _reportSectionId = 0;
var _aspectElementId = 0;
var _perManObjectiveId = 0;
var _characteristicIds = "";

Common =
{
    ServicesURL: '',
    Trim: function (s) {
        s = s.replace(/^\s+/, "");  // Trim leading white space
        s = s.replace(/\s+$/, "");  // Trim trailing white space
        s = s.replace(/\s+/g, " "); // Convert white space to single space
        return s;
    }
	,
    TrimPreserveLines: function (s) {
        s = s.replace(/^\s+/, "");                     // Trim leading white space
        s = s.replace(/\s+$/, "");                     // Trim trailing white space
        s = s.replace(/\r/g, "");                      // Standardise new lines - remove carriage-returns (replace later)
        var ss = s.split('\n');
        for (var i = 0, len = ss.length; i < len; i++) // Trim each line
            ss[i] = Common.Trim(ss[i]);
        s = ss.join("\r\n");                           // Standardise new lines - ensure new lines are carriage-return line-feeds
        return s;
    }
	,
    HtmlDecode: function (s) {
        s = s.replace(/<style[^>]*>[^<]+<\/style>/g, " ");   // Remove <style>...</style>
        s = s.replace(/<script[^>]*>[^<]+<\/script>/g, " "); // Remove <script>...</script>
        s = s.replace(/<[^>]+>/g, " ");                      // Remove all <tags>
        s = s.replace(/\r/g, "");                            // Standardise new lines - remove carriage-returns (replace later)
        s = s.replace(/\s*\n\s*/g, "\n");                    // Remove multiple line feeds and white spaces, preserving one line feed
        s = s.replace(/\n/g, "\r\n");                        // Standardise new lines - ensure new lines are carriage-return line-feeds
        s = s.replace(/&lt;/g, "<");
        s = s.replace(/&gt;/g, ">");
        s = s.replace(/&nbsp;/g, " ");
        s = s.replace(/&quot;/g, "'");
        s = s.replace(/&amp;/g, "&");
        s = Common.TrimPreserveLines(s);
        return s;
    }
	,
    HtmlEncode: function (s, preserveLines) {
        s = s.replace(/&/g, "&amp;");
        s = s.replace(/</g, "&lt;");
        s = s.replace(/>/g, "&gt;");
        if (!preserveLines) {
            s = Common.Trim(s);
        }
        else {
            s = Common.TrimPreserveLines(s);
            s = s.replace(/\r\n/g, "<br />\r\n");
        }
        return s;
    }
	,
    HtmlEncodePreserveLines: function (s) {
        return Common.HtmlEncode(s, true);
    }
	,
    /*
    code from: http://www.devarticles.com/c/a/JavaScript/JavaScript-and-XML/2/
    */
    ParseXML: function (txt) {
        if (typeof DOMParser != "undefined") {
            // Mozilla, Firefox, and related browsers
            return (new DOMParser()).parseFromString(txt, "application/xml");
        }
        else if (typeof ActiveXObject != "undefined") {
            // Internet Explorer.
            var doc = new ActiveXObject("MSXML2.DOMDocument");   // Create an empty document
            doc.loadXML(txt);              //  Parse text into it
            return doc;                     // Return it
        }
        else {
            // As a last resort, try loading the document from a data: URL
            // This is supposed to work in Safari. Thanks to Manos Batsis and
            // his Sarissa library (sarissa.sourceforge.net) for this technique.
            var url = "data:text/xml;charset=utf-8," + encodeURIComponent(txt);
            var request = new XMLHttpRequest();
            request.open("GET", url, false);
            request.send(null);
            return request.responseXML;
        }
    }
	,
    ParseXMLMessage: function (xmlMessage) {

        var rtn = { "MessageType": "", "Content": "", "Progress": 0 };

        var child = xmlMessage.getElementsByTagName("MessageType")[0];
        var txtNode = child.childNodes[0];
        rtn.MessageType = txtNode.nodeValue;
        child = xmlMessage.getElementsByTagName("Progress")[0];
        if (child != null) {
            txtNode = child.childNodes[0];
            rtn.Progress = txtNode.nodeValue;
        }
        child = xmlMessage.getElementsByTagName("Content")[0];
        var mesgData;
        if (child.childNodes.length != 0) {
            txtNode = child.childNodes[0];
            rtn.Content = txtNode.nodeValue;
        }

        return rtn;
    }
	,
    /**
    *@deprecated please use KaledioServices/Scripts/AJAXDialog.js instead
    */
    DialogAreaOpen: function (dialogAreaId, html, top, bottom, isHelpDialog) {
        // Hide 'windowed' form controls, otherwise they would appear above the floating <div> dialog area container.
        var selects = document.getElementsByTagName("select");
        for (var i = 0; i < selects.length; i++)
            selects[i].style.display = "none";
        // Prevent main body scrolling so IE doesn't replace the select elsewhere. (Help dialogs only)
        if (isHelpDialog)
            document.getElementsByTagName("html")[0].style.overflow = "hidden";

        // Get top most open dialog area container
        var activeDialog = null;
        if (_CommonDialogAreaStack.length > 0)
            activeDialog = _CommonDialogAreaStack[_CommonDialogAreaStack.length - 1];

        // Show the dialog area container
        var div = document.getElementById(dialogAreaId);
        if (div) {
            div.innerHTML = html;
            div.style.display = "block";

            // Horizontal position
            if (activeDialog && activeDialog.id == dialogAreaId)
            // Is top most dialog, so keep at same position
                div.style.left = activeDialog.style.left;
            else if (activeDialog)
            // Position slightly right of existing dialog
                div.style.left = (parseInt(activeDialog.style.left, 10) + 20) + "px";
            else
            // Default position
                div.style.left = "136px";

            // Vertical position
            if (activeDialog && activeDialog.id == dialogAreaId)
            // Is top most dialog, so keep at same position
                div.style.top = activeDialog.style.top;
            else if (activeDialog)
            // Position slightly right of existing dialog
                div.style.top = (parseInt(activeDialog.style.top, 10) + 20) + "px";
            else if (top && !isNaN(top))
            // Specified position
                div.style.top = top + "px";
            else if (bottom && !isNaN(bottom))
            // Specified position
                div.style.top = (bottom - Common.GetHeight(div)) + "px";
            else
            // Default position
                div.style.top = "136px";

            // Make sure the bottom is visible, scroll as necessary
            var bottom = Common.GetBottom(div);
            if (bottom > document.documentElement.scrollTop + Common.GetClientHeight())
                document.documentElement.scrollTop = bottom - Common.GetClientHeight() + 16;

            // Make sure the top is visible, scroll as necessary
            var top = Common.GetTop(div);
            if (top < document.documentElement.scrollTop)
                document.documentElement.scrollTop = top - 16;

            // Maintain stack of open dialog area containers
            if (!activeDialog || activeDialog.id != dialogAreaId)
                _CommonDialogAreaStack.push(div);
        }
    }
	,
    /**
    *   @deprecated please use KaledioServices/Scripts/AJAXDialog.js instead
    */
    DialogAreaClose: function (isHelpDialog) {
        // Hide top most open dialog area container
        if (_CommonDialogAreaStack.length > 0) {
            var div = _CommonDialogAreaStack.pop();
            if (div) {
                div.style.display = "none";

                // Remove children from dialog area container
                while (div.lastChild != null)
                    div.removeChild(div.lastChild);
            }
        }

        // Get next top most open dialog area container
        var activeDialog = null;
        if (_CommonDialogAreaStack.length > 0)
            activeDialog = _CommonDialogAreaStack[_CommonDialogAreaStack.length - 1];

        // Show 'windowed' form controls
        var selects;
        if (activeDialog)
            selects = activeDialog.getElementsByTagName("select"); // For top most open dialog area container only
        else {
            selects = document.getElementsByTagName("select"); // For document
            if (isHelpDialog)
                document.getElementsByTagName("html")[0].style.overflow = "scroll";
        }

        var isWebKit = (navigator.userAgent.indexOf("WebKit") > 0);
        for (var i = 0; i < selects.length; i++)
            selects[i].style.display = "";
    }
	,
    /**
    *   @deprecated please use KaledioServices/Scripts/AJAXDialog.js instead
    */
    DialogAreaCloseAll: function () {
        // Hide all open dialog area containers
        while (_CommonDialogAreaStack.length > 0)
            Common.DialogAreaClose();
    }
	,
    /**
    *   @deprecated please use KaledioServices/Scripts/AJAXDialog.js instead
    */
    DialogAreaCloseOne: function (dialogAreaId) {
        // Hide a specific open dialog area container (only if top most)
        if (_CommonDialogAreaStack.length > 0) {
            var activeDialog = _CommonDialogAreaStack[_CommonDialogAreaStack.length - 1];
            if (activeDialog.id == dialogAreaId)
                Common.DialogAreaClose();
        }
    }
	,
    GetBaseClientId: function (s) {
        return _CommonBaseClientId;
    }
	,
    SetBaseClientId: function (s) {
        _CommonBaseClientId = s;
        if (_CommonBaseClientId != "")
            _CommonBaseClientId = _CommonBaseClientId + "_";
    }
	,
    GetId: function (s) {
        return _BaseId;
    }
	,
    SetId: function (s) {
        _BaseId = s;
        if (_BaseId != "")
            _BaseId = _BaseId + "_";
    }
	,
    GetDate: function (date) {
        re = /^ *([0-3]?[0-9]) *[\\\/\-\.] *([0-1]?[0-9]) *[\\\/\-\.] *([12][0-9][0-9][0-9]|[0-9][0-9]) *$/;

        // Check string matches the regular expression
        matches = re.exec(date);
        if (matches == null || matches.length == 0)
            return null;

        var day = parseInt(matches[1], 10);
        var month = parseInt(matches[2], 10);
        var year = parseInt(matches[3], 10);

        // Check day
        if (day < 1 || day > 31)
            return null;
        if ((month == 4 || month == 6 || month == 9 || month == 11) && day == 31)
            return null;
        var isLeapYear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (month == 2 && (day > 29 || (day == 29 && !isLeapYear))) // February
            return null;

        // Check month
        if (month < 1 || month > 12)
            return null;

        // Check year
        if ((year < 1900 || year > 2200) && year > 99)
            return null;


        return (day < 10 ? "0" : "") + day + "/" + (month < 10 ? "0" : "") + month + "/" + (year < 100 ? year + 2000 : year);
    }
	,
    GetBottom: function (element) {
        return Common.GetTop(element) + Common.GetHeight(element);
    }
	,
    GetLeft: function (element) {
        if (!element) return 0;

        var left = element.offsetLeft;
        var parent = element.offsetParent;
        while (parent != null) {
            left += parent.offsetLeft;
            parent = parent.offsetParent;
        }

        return left;
    }
	,
    GetHeight: function (element) {
        if (!element) return 0;

        return element.offsetHeight;
    }
	,
    GetRight: function (element) {
        return Common.GetLeft(element) + Common.GetWidth(element);
    }
	,
    GetTop: function (element) {
        if (!element) return 0;

        var top = element.offsetTop;
        var parent = element.offsetParent;
        while (parent != null) {
            top += parent.offsetTop;
            parent = parent.offsetParent;
        }

        return top;
    }
	,
    GetWidth: function (element) {
        if (!element) return 0;

        return element.offsetWidth;
    }
	,
    GetClientHeight: function () {
        if (document.body)
        // Quirks - IE/Firefox/Opera + Webkit (Safari/Chrome)
            return document.body.clientHeight;
        else if (document.documentElement && document.documentElement.clientHeight)
        // IE/Firefox/Opera Strict Mode
            return document.documentElement.clientHeight;
        else if (self.innerHeight)
        // fallback
            return self.innerHeight;
    }
	,
    GetClientWidth: function () {
        if (self.innerWidth)
        // All except IE
            return self.innerWidth;
        else if (document.documentElement && document.documentElement.clientWidth)
        // IE 6 Strict Mode
            return document.documentElement.clientWidth;
        else if (document.body)
        // Other IE
            return document.body.clientWidth;
    }
	,
    ShowHideHover: function (hoverId, show, top, left, evt) {
        var target = document.getElementById(hoverId + "Target");
        var panel = document.getElementById(hoverId + "Panel");
        if (target && panel) {
            var scrollY = document.documentElement.scrollTop;
            var scrollX = document.documentElement.scrollLeft;

            if (show && panel.style.display == "none") {
                var clientHeight = Common.GetClientHeight();
                var clientWidth = Common.GetClientWidth();

                // Don't show hover if an open dialog exists
                if (_CommonDialogAreaStack.length > 0)
                    return;

                // Show hover
                panel.style.display = "block";

                // Calculate vertical position, make sure panel is not off the window
                if (!top || isNaN(top))
                    top = Common.GetTop(target);
                var height = Common.GetHeight(panel);
                var bottom = top + height;
                if (bottom > scrollY + clientHeight - 8)
                    top = scrollY + clientHeight - height - 8;
                if (top < 0) top = 0;

                // Calculate horizontal position, make sure panel is not off the window
                if (!left || isNaN(left))
                    left = Common.GetLeft(target);
                var width = Common.GetWidth(panel);
                var right = left + width;
                if (right > scrollX + clientWidth - 20)
                    left = scrollX + clientWidth - width - 20;
                if (left < 0) left = 0;

                panel.style.left = left + "px";
                panel.style.top = top + "px";
            }
            else if (!show && panel.style.display == "block") {
                var pointerY = scrollY + evt.clientY;
                var pointerX = scrollX + evt.clientX;

                // To avoid flicker, if pointer is still over the target then ignore
                if (Common.GetLeft(target) < pointerX - 1 && pointerX + 12 <= Common.GetRight(target)
					&& Common.GetTop(target) < pointerY - 1 && pointerY + 12 <= Common.GetBottom(target))
                    return;

                // To avoid flicker, if pointer is still over the panel then ignore
                if (Common.GetLeft(panel) < pointerX - 1 && pointerX < Common.GetRight(panel)
					&& Common.GetTop(panel) < pointerY - 1 && pointerY < Common.GetBottom(panel))
                    return;

                // Hide panel
                panel.style.display = "none";
            }
        }
    }
	,
    CheckJavascript: function () {
        document.getElementById('Login').style.display = 'block';
        document.getElementById('Error').style.display = 'none';
    }
	,
    UpdateProjectEdited: function (changed) {
        _ProjectEdited = changed;
    }
	,
    CheckChanges: function () {
        if (_ProjectEdited && _allowPrompt) {
            return "THE CHANGES YOU HAVE MADE WILL BE LOST IF YOU DO NOT CLICK 'SAVE'.";
        }
        else {
            _allowPrompt = true;
        }
    }
	,
    CheckProjectHistory: function () {
        var table = document.getElementById("uxHistoryTable");
        if (table)
            setTimeout("ProjectHistory.ScrollTableAdd(document.getElementById('uxHistoryTable'), 45, 290, 30, null, null)", 1);
    }
	,
    NoPrompt: function () {
        _allowPrompt = false;
    }
	,
    DisplayGuides: function () {
        //Hides any dialog boxes already open
        Common.DialogAreaCloseAll();

        var html = '<div>'
            + '<div class="Heading"><i>SWIFT</i> User Guide - Contents</div>'
            + '<div class="Updates">Clicking a link below will open/download a PDF. No file is larger than 2MB.<br /><br />'
            + '<div style="margin-left:10px;">'
            + '<a href="Files/guide/QuickStart-Admin.pdf" target="_blank">Quick Start Guide for Administrators</a><br />'
            + '<a href="Files/guide/QuickStart-User.pdf" target="_blank">Quick Start Guide for Users</a><br />'
            + '<a href="Files/guide/QuickStart-Fmsis.pdf" target="_blank">Quick Start Guide - FMSiS</a>'
            + '</div>&nbsp;'
            + '<div style="margin-left:10px;"><table class="UserGuide">'
            + '<tr><td><a href="Files/guide/01 - Intro and Login.pdf" target="_blank">01 - Introduction and Logging on to the System</a></td>'
            + '<td><a href="Files/guide/10 - Resources.pdf" target="_blank">10 - Managing Resources</a></td></tr>'
            + '<tr><td><a href="Files/guide/02 - Navigating.pdf" target="_blank">02 - Navigating Bluewave <i>SWIFT</i></a></td>'
            + '<td><a href="Files/guide/11 - Analysis.pdf" target="_blank">11 - Project Analysis</a></td></tr>'
            + '<tr><td><a href="Files/guide/03 - Editing Users, Teams and Permissions.pdf" target="_blank">03 - Editing Users, Teams and Permissions</a></td>'
            + '<td><a href="Files/guide/12 - Reports.pdf" target="_blank">12 - Reporting</a></td></tr>'
            + '<tr><td><a href="Files/guide/04 - Priority Analysis Projects.pdf" target="_blank">04 - Priority Analysis Projects</a></td>'
            + '<td><a href="Files/guide/13 - Adding Reports.pdf" target="_blank">13 - Adding a Report</a></td></tr>'
            + '<tr><td><a href="Files/guide/05 - SWIFT Projects.pdf" target="_blank">05 - <i>SWIFT</i> Projects</a></td>'
            + '<td><a href="Files/guide/14 - Performance Management.pdf" target="_blank">14 - Performance Management</a></td></tr>'
            + '<tr><td><a href="Files/guide/06 - SDP.pdf" target="_blank">06 - Building a School Development Plan</a></td>'
            + '<td><a href="Files/guide/15 - Professional Standards.pdf" target="_blank">15 - Professional Standards</a></td></tr>'
            + '<tr><td><a href="Files/guide/07 - Entering Evidence.pdf" target="_blank">07 - Entering Evidence</a></td>'
            + '<td><a href="Files/guide/16a - CPD - Administrators.pdf" target="_blank">16a - CPD - Administrators</a></td></tr>'
            + '<tr><td><a href="Files/guide/08 - Promoting Evidence.pdf" target="_blank">08 - Promoting Evidence</a></td>'
			+ '<td><a href="Files/guide/16b - CPD - Users.pdf" target="_blank">16a - CPD - Users</a></td></tr>'
			+ '<tr><td><a href="Files/guide/09 - SEF.pdf" target="_blank">09 - SEF</a></td>'
			+ '<td><a href="Files/guide/16c - CPD - Strengths and Weaknesses.pdf" target="_blank">16a - CPD - Strengths and Weaknesses</a></td></tr>'
            + '</table></div>'
            + '<div class="ButtonPanel"><button class="Button" onclick="Common.DialogAreaCloseAll(); return false">Close</button></div>'
            + '</div></div>';

        Common.DialogAreaOpen("HelpDialogAreaContainer", html, null, Common.GetBottom(document.body) - 20);
    }
    ,
    DisplayArticles: function () {
        //Hides any dialog boxes already open
        Common.DialogAreaCloseAll();

        var html = '<div>'
            + '<div class="Heading">Related Articles - Contents</div>'
            + '<br /><a href="Files/articles/DCSF_Light_Touch_PM.doc" target="_blank">DCSF :- Performance Management and Pay Checklist for Light Touch Validation</a><br />'
            + '<a href="Files/articles/pay-guidance.pdf" target="_blank">Guidance on School Teachers Pay</a><br />'
			+ '<a href="Files/articles/cpd_impact_evaluation.pdf" target="_blank">TDA :- Impact Evaluation of CPD</a><br />'
            + '<a href="Files/articles/ofsted-guidance-0-intro.pdf" target="_blank">Ofsted Guidance :- Introduction</a><br />'
            + '<a href="Files/articles/ofsted-guidance-1-pupil-achievement.pdf" target="_blank">Ofsted Guidance :- Achievement of Pupils at the School</a><br />'
            + '<a href="Files/articles/ofsted-guidance-2-teaching-quality.pdf" target="_blank">Ofsted Guidance :- The Quality of Teaching</a><br />'
            + '<a href="Files/articles/ofsted-guidance-3-behaviour-safety.pdf" target="_blank">Ofsted Guidance :- Behaviour and Safety of Pupils</a><br />'
            + '<a href="Files/articles/ofsted-guidance-4-leadership-management.pdf" target="_blank">Ofsted Guidance :- The Quality of Leadership and Management of the School</a>'
			+ '<a href="Files/articles/ofsted-guidance-5-overall-effectiveness.pdf" target="_blank">Ofsted Guidance :- Overall Effectiveness</a>'
            + '<div class="ButtonPanel"><button class="Button" onclick="Common.DialogAreaCloseAll(); return false">Close</button></div>'
            + '</div></div>';

        Common.DialogAreaOpen("ArticleDialogAreaContainer", html, null, Common.GetBottom(document.body) - 20);
    }
	,
    SearchTextEntered: function (e, element) {
        var charCode;
        var button = document.getElementById(element);

        if (e && e.which) {
            e = e;
            charCode = e.which; //if which property of event object is supported (netscape)
        }
        else {
            e = event
            charCode = e.keyCode; //character code is contained in IE's keyCode property
        }

        //if generated character code is equal to ascii 13 (enter key), simulate button click
        if (charCode == 13) {

            //focus() required for firefox as click() won't work
            //but simulates 2 clicks in other browsers (harmless as ajax code blocks simultaneous requests)
            button.focus();
            button.click();
        }
    }
	,
    ProfStdProjectView: function (projectId, elementId, characteristicIds, revieweeId, profStdSectionId, stageId, perManObjectiveId, reportSectionId, aspectElementId, isProfile) {
        // If personal project is accessed then load level 1 view
        var url = "ProjectHome.aspx";

        if (window.location.href.search(url) != -1) {
            _projectId = projectId;
            _elementId = elementId;
            _revieweeId = revieweeId;
            _profStdSectionId = profStdSectionId;
            _stageId = stageId;
            _perManObjectiveId = perManObjectiveId;
            _reportSectionId = reportSectionId;
            _aspectElementId = aspectElementId;
            _characteristicIds = characteristicIds;

            if (_elementId != 0) {
                ProjectLayer2.EditDisplay(_projectId, _elementId, _characteristicIds, null, _revieweeId, _profStdSectionId, _stageId, _perManObjectiveId, _reportSectionId);
            }
            else {
                if (!isProfile) {//if its not profile the display the default of ProfStd
                    // Display the view for the selected project level
                    AJAX.HTTPRequest((window.location.href.search("Personal/") != -1 ? "../" : "")
                    + "AJAXServiceGet.ashx"
		            , "Action=ProjectLayer2ProfStdProject"
		            + "&ProjectId=" + encodeURIComponent(projectId)
		            , Common.ViewProfStdProjectDisplayCallback);
                }
            }

        }
    }
	,
    ViewProfStdProjectDisplayCallback: function (HTTPStatus, HTTPResponseText) {
        if (HTTPResponseText == "True") {
            // Display the view for the selected project level
            AJAX.HTTPRequest("AJAXServiceGet.ashx"
				, "Action=ProjectLayer2ProfStdView"
				+ "&StageId=" + encodeURIComponent(3)
				+ "&ProjectId=" + encodeURIComponent(_projectId)
				, Common.ViewProfStdDisplayCallback);
        }
    }
	,
    ViewProfStdDisplayCallback: function (HTTPStatus, HTTPResponseText) {
        var div;

        // Check HTTP request was successful
        if (!AJAX.HTTPRequestCheck(HTTPStatus, HTTPResponseText))
            return;

        // Hide the hier display area
        div = document.getElementById("HierAreaContainer");
        if (div)
            div.style.display = "none";

        // Show the report display area
        div = document.getElementById("ReportAreaContainer");
        if (div) {
            div.innerHTML = HTTPResponseText;
            div.style.display = "block";
        }

        // Display selected element
        ProjectLayer2.UpdateSelectedDisplay(_ProjectLayer2SelectedElementId);
    }
	,
    SetClipboardLinkText: function (tagName) {
        var s = "";

        if (tagName == "a") s = '<a href="URL" target="_new">TITLE</a>';
        else if (tagName == "b") s = '<b>TITLE</b>';
        else if (tagName == "i") s = '<i>TITLE</i>';
        else if (tagName == "u") s = '<u>TITLE</u>';

        //only works in IE
        window.clipboardData.setData('text', s);
    }
	,
    SetCursorWait: function () {
        //used to set egg-timer icon, primarily for AJAX functions
        document.body.style.cursor = "wait";

        var hyperlinks = document.getElementsByTagName("a");
        for (var x = 0; x < hyperlinks.length; x++)
            hyperlinks[x].style.cursor = "wait";

        var buttons = document.getElementsByTagName("button");
        for (var x = 0; x < buttons.length; x++)
            buttons[x].style.cursor = "wait";
    }
	,
    SetCursorDefault: function () {
        //used to unset egg-timer icon, primarily for AJAX functions
        document.body.style.cursor = "auto";

        var hyperlinks = document.getElementsByTagName("a");
        for (var x = 0; x < hyperlinks.length; x++)
            hyperlinks[x].style.cursor = "auto";

        var buttons = document.getElementsByTagName("button");
        for (var x = 0; x < buttons.length; x++)
            buttons[x].style.cursor = "pointer";
    }
    ,
    EnableDragging: function (dialogId) {
        $("#" + dialogId).draggable({ handle: "#Drag" }); //requires jquery-ui-1.8.11.draggable.js
    }
}

