if (typeof dwr != "undefined" && typeof dwr.engine != "undefined") {
	var domain = document.domain;
	var subdomain = domain.match(/[^.]+\.[^.]+$/);

	if (subdomain) {
		document.domain = subdomain;
	}

	dwr.engine._getJSessionId =  function() {
		var dwrDocument = dwr.engine.dwrDocument;
		if (!dwrDocument) {
		    var dwrFrame = document.getElementById('dwr');
		    if (dwrFrame) {
				dwrDocument = dwrFrame.contentWindow || dwrFrame.contentDocument;
				if (dwrDocument.document) {
				    dwrDocument = dwrDocument.document;
				}
		    } else {
				dwrDocument = document;
			}
			dwr.engine.dwrDocument = dwrDocument;
		}
	    var cookies = dwrDocument.cookie.split(';');
	    for (var i = 0; i < cookies.length; i++) {
	        var cookie = cookies[i];
	        while (cookie.charAt(0) == ' ') {
				cookie = cookie.substring(1, cookie.length);
			}
		    if (cookie.indexOf(dwr.engine._sessionCookieName + "=") == 0) {
		        return cookie.substring(dwr.engine._sessionCookieName.length + 1, cookie.length);
		    }
		}
		
	    return "";
	};
	
	dwr.engine.initServiceURL = function(service) {
		var dwrFrame = document.getElementById('dwr');
		if (dwrFrame) {
			var dwrWindow = dwrFrame.contentWindow || dwrFrame.contentDocument;
			if (!dwrWindow.document) {
				dwrWindow = dwrFrame;	
			}
			var url = dwrWindow.location.protocol + '//' + dwrWindow.location.host;
			service._path = url + service._path;
			dwr.engine.setRpcType(dwr.engine.ScriptTag)
		}
	};
}
