// JScript File
$(document).ready(function () {
	formSvc.getToken();
});

var formSvc = {

	getToken: function() {
		if (!("#token").length) return;
		if (window.location.hostname.toLowerCase().indexOf("www.superlativehost") != -1) {
			urlPath = "http://" + window.location.hostname.toLowerCase().replace("www","public");
			var head = document.getElementsByTagName("head")[0];
			var script = document.createElement('script');
			script.type = 'text/javascript';
			script.src = urlPath + "/Services/FormService.ashx/getToken?jsonp=formSvc.getTokenCB";
			head.appendChild(script);
		}
		else {
			$.ajax({
				url: "/Services/FormService.ashx/getToken",
				cache: false,
				dataType: "json",
				jsonpCallback: "jsonp",
				success: function(data) {
					$("#token").val(data.result);
				}
			});
		}
	},
	
	getTokenCB: function(args) {
		$("#token").val(args.result);
	}

}