//  Copyright (c) Medical Networks Scandinavia AB
//  $Id: medinet.js,v 1.3 2010/09/23 09:56:53 jim Exp $

xhrPool = new DP_RequestPool(8);
xhrPool.startInterval(200);

function ea(name, noLink) {
    var domain = String.fromCharCode(64) + 'medinet' + '.' + 'se';
    var realname = '';
    switch (name) {
    case 'jn': realname = 'jim'; break;
    case 'tc': realname = 'tuomo'; break;
    case 'sch': realname = 'schema'; break;
    }
    if (noLink == null)
	return '<a href="mailto:' + realname + domain + '">' + realname + domain + '</a>';
    else
	return realname + domain;
}



function filterPhone(event) {
    var key;
    if (window.event)
	key = window.event.keyCode;
    else
	key = event.which;
    if (key == 0 || key == 8 || key == 32 || key == 43 || key == 40 || key == 41 || key == 45 || (key >= 48 && key <= 57)) return true;
    return false;
}


function xhrHtmlHandler(result, elementId) {
    document.getElementById(elementId).innerHTML = result;
}


function contact(targetId) {

    xhrParameters = new Object();
    xhrParameters.name = document.getElementById('name').value;
    xhrParameters.company = document.getElementById('company').value;
    xhrParameters.phone = document.getElementById('phone').value;
    xhrParameters.email = document.getElementById('email').value;
    xhrParameters.question = document.getElementById('question').value;

    var url = window.location.protocol + '//' + window.location.host + '/cgi-bin/contact.pl';
    xhrPool.addRequest(new DP_Request('POST', url, xhrParameters, xhrHtmlHandler, [targetId]));

    document.getElementById('name').value = '';
    document.getElementById('company').value = '';
    document.getElementById('phone').value = '';
    document.getElementById('email').value = '';
    document.getElementById('question').value = '';
}

