/// <reference path="jquery-1.3.2-vsdoc2.js" />

$(document).ready(function() {

    //Menu Setup
$("ul.dmc-menu").superfish({ delay: 1000 });


    //Back to Top
    $('a.top').click(function() {
        $('html, body').animate({ scrollTop: '0px' }, 300);
        return false;
    });

    //Set AJAX Defaults [overridable]
    $.ajaxSetup({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        data: "{}",
        dataFilter: function(data) {
            var _msg;
            if (typeof (JSON) !== 'undefined' && typeof (JSON.parse) === 'function') { _msg = JSON.parse(data); }
            else { _msg = eval('(' + data + ')'); }

            if (_msg.hasOwnProperty('d')) { return _msg.d; }
            else { return _msg; }

        }
    });

    //Serialise the JSON.

    $.fn.serializeJSON = function() {
        var o = {};
        var a = this.serializeArray();
        $.each(a, function() {
            if (o[this.name]) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return $.toJSON(o);
    };
        


});


function __registerGooglePage(_url) {
    var pageTracker = _gat._getTracker("UA-9612546-1");
    pageTracker._trackPageview(_url);
};

function _openDownload(oPath){
if(window.open){
window.open('/_common/downloads/download.ashx?path='+ oPath,'downloadWin','toolbar=0,location=no,directories=0,status=0,scrollbars=yes,resizable=1,width=200,height=1,top=0,left=0');
}
}

function _openDownloadById(oId){
if(window.open){
window.open('/_common/downloads/download.ashx?did='+ oId,'downloadWin','toolbar=0,location=no,directories=0,status=0,scrollbars=yes,resizable=1,width=200,height=1,top=0,left=0');
}
}

function HTMLEncode(v) {
    return $('<div/>').text(v).html();
}

function HTMLDecode(v) {
    return $('<div/>').html(v).text();
}

function HTMLEscape(v) {
    try {
        if (v.length > 0) { return escape(v); }
        else { return v; }
    }
    catch (ex) {return "";}
}



