String ajaxCall(String dest, BufferedReader sin) {
			Socket client = null;
			PrintWriter out = null;
			BufferedReader in = null;
			// Get Ajax call
			Scanner scan = new Scanner(sin);
			scan.useDelimiter("\n\n");
			String all = scan.next();	
			//res.log("Sending to " + dest + ": '" + all +"'");
			// clean up dest

			// Connect to dest
			try {
				//res.alert(dest);
				String[] d = dest.split(":");
				//res.alert(Integer.toString( d.length));
				String p = "2600";
				if (d.length > 1)
					p = d[1];
				client = new Socket(d[0], Integer.parseInt(p));
				//InetAddress addr = new InetSocketAddress("127.0.0.1");
				if (!client.isConnected()) 
					res.error("failed to connect!!!!!!!");
				
				out = new PrintWriter(client.getOutputStream(), true);
				in = new BufferedReader(new InputStreamReader(client.getInputStream()));
			} catch (Exception e) {
				res.log( "ERROR> Exception in ajaxCall (Connecting): " + e.toString());	
				return "";
			}
			//res.alert("Established connection");
			// HTTP / AJAX Header + call
			out.print("POST / HTTP/1.1\r\n" +
				"Host: " + dest + "\r\n" +
				"User-Agent: Cortex\r\n" +
				"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" + 
				"Accept-Language: en-us,en;q=0.5\r\n"+
				"Accept-Encoding: gzip,deflate\r\n" + 
				"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" +
				"Keep-Alive: 300\r\n" + 
				"Connection: keep-alive\r\n" +
				"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" + 
				"Referer: " + getIPAddress() + ":" + Integer.toString(res.PORT) + "/client.html\r\n" +
				"Content-Length: " + (all.length()+2) + "\r\n" +
				"Pragma: no-cache\r\n" + 
				"Cache-Control: no-cache\r\n" + 
					"\r\n");
			out.print(all + "\n\n");
			out.flush();
			//res.alert("SENT: " + all);
			//res.log("sent message");
			//out.close();
				
			//res.alert("printed request, trying to read");
			
			// Read response
			String resp = "";

			// read http header
			//res.log("Reading resp header");
			try {
				if (in.ready()) {
					String header = in.readLine();
					if (header.length() >= 3) {
						//res.log("header: " + header);
						header = in.readLine();
					}
				}
			} catch (Exception e) {
				res.error("Exception in ajaxCall (reading HTTP response header): " + e.toString());
				return "";
			}
			//res.log("Reading response body");
			//res.alert("done reading resp header");
			// read actual response
			scan = new Scanner(in);
			scan.useDelimiter("\n\n");
			resp = scan.next();	
			//res.alert("done reading resp");			
			//res.log("Closing ajaxCall");
			try {
				in.close();
				out.close();
				client.close();
			} catch (Exception e) {
				res.error( "Exception in ajaxCall (Closing Connection): " + e.toString());
			}
			//res.alert("closed connections");
			//res.log("ajaxCall returning response to js caller: '" + resp + "'");
			return resp;
		}