﻿

var __serviceName = "Service.svc";
var __wcfCDName = "wcfCD.ashx";

Sys.Net.WebServiceProxy.invoke = function Sys$Net$WebServiceProxy$invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout) {
    var e = Function._validateParams(arguments, [
        { name: "servicePath", type: String },
        { name: "methodName", type: String },
        { name: "useGet", type: Boolean, optional: true },
        { name: "params", mayBeNull: true, optional: true },
        { name: "onSuccess", type: Function, mayBeNull: true, optional: true },
        { name: "onFailure", type: Function, mayBeNull: true, optional: true },
        { name: "userContext", mayBeNull: true, optional: true },
        { name: "timeout", type: Number, optional: true }
    ]);
    if (e) throw e;
    if (!params) params = {};
    var urlParams = params;

    if (!urlParams) urlParams = {};
    var callback = onSuccess.toString();
    var f1 = callback.indexOf("function");
    var f2 = callback.indexOf("(", f1);
    callback = callback.substring(f1 + 8, f2);
    callback = callback.replace(" ", "");
    var url1 = servicePath;
    url1 = url1.replace(__serviceName, __wcfCDName);
    url1 += "?";
    url1 += "_method=" + encodeURIComponent(methodName);
    url1 += "&";
    url1 += "_callback=" + callback;
    url1 = Sys.Net.WebRequest._createUrl(url1, urlParams);
    var body = null;
    if (timeout && timeout > 0) request.set_timeout(timeout);
    var script = document.createElement("script");
    script.src = url1;
    var heads = document.getElementsByTagName("head");
    if (heads && heads.length > 0)
        heads[0].appendChild(script);
}
