String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}

function displayDetails(oid) {
 alert(oid);
//  document.getElementById('STAFF_' + list + '_' + oid).style.display = 'block';
  xmlOID = oid;
  xmlLIST = list;
  ajaxInitRequest('/fileadmin/IAS/scripts/getperson.php?OID=' + oid, retDisplayPerson);
}

function closeDumbBox() {
  el = document.getElementById('dumbBoxWrap');
  el.style.display = 'none';
}

function slShowMap(oid,mapfile) {
  html = document.getElementById('STAFF_' + oid).innerHTML;
  if (!document.getElementById('MAPFILE_' + oid)) {
    document.getElementById('STAFF_' + oid).innerHTML = html + '<div id="MAPFILE_' + oid + '"></div>';
  }
  document.getElementById('MAPFILE_' + oid).innerHTML = '<center><img src="' + mapfile + '"></center>';
}

function peShowMap(mapfile) {
  showOverlay('<img src="' + mapfile + '">',500,340);
}

function slPerson(t,oid,email,phone,room,group,publication,uri) {
    staffDIV = 'STAFF_' + oid;
    var elem = document.getElementById(staffDIV);
    if (elem.style.display == 'block') {
        elem.style.display = '';
        t.innerHTML = 'Details';
    } else {
        var info = new Array();
        if ((email.trim() != '') && (email != '&nbsp;'))       { info.push('<td width="110" height="1%">email-Address</td><td><img src="/typo3conf/ext/tuw_informations/res/img/pic_email.gif"> <a href="mailto:' + email + '">' + email + '</a></td>'); };
        if (oid != '')         { info.push('<td width="110" height="1%">TISS-Entry</td><td><a href="https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/' + oid + '" target="_blank">Link</a></td>'); };
        if (phone.trim() != '')       { info.push('<td width="110" height="1%">phone number</td><td><img src="/typo3conf/ext/tuw_informations/res/img/pic_tel.gif"> ' + phone + '</a></td>'); };
        if ((room.trim() != '') && (room != '&nbsp;'))        { info.push('<td width="110" height="1%">Room</td><td><img src="/typo3conf/ext/tuw_informations/res/img/pic_zimmer.gif"> '+ room + '</a></td>'); };
        if (group.trim() != '') { info.push('<td width="110" height="1%">&nbsp;</td><td>' + group + '</td>'); };
        // if (publication != '') { info.push('<td width="110">Publications</td><td>' + publication + '</td>'); };
        if ((info.length != 0) && (uri != ''))  { info.push('<td width="110">&nbsp</td>'); };
        html = '<table width="500">';
        html = html + '<tr>' + info[0];
        html = html + '<td valign="top" rowspan="' + info.length + '">';
        if (uri == '') {
            html = html + '&nbsp;';
        } else {
            html = html + '<img src="' + uri + '" height="160">';
        }
        html = html + '</td></tr>';
        for (var i=1; i<info.length; i++) {
            html = html + '<tr>' + info[i] + '</tr>';
        }
        html = html + '</table>';    
    
        elem.style.display = 'block';
        elem.innerHTML = html;
        t.innerHTML = 'hide';
    }
}

function slPerson3(lastname,firstname,title,posttitle,oid,email,phone,room,mapfile,group,publication,uri) {
  name = title + ' ' + firstname + ' <b>' + lastname + '</b>';
  if (posttitle != '') { name = name + ', ' + posttitle; };
  html = '<div class="name">' + name.trim() + '</div>';
  html = html + '<div class="data">';
  if ((email.trim() != '') && (email != '&nbsp;')) {
    html = html + '<div class="Description">email-Address</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/pic_email.gif"> <a href="mailto:' + email + '">' + email + '</a></div><div class="clear"></div>';
  }
  if (oid != '')  {
    html = html + '<div class="Description">TISS-Entry</div><div class="Content"><a href="https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/' + oid + '" target="_blank">Link</a></div><div class="clear"></div>';
  };
  if (phone.trim() != '') {
    html = html + '<div class="Description">phone number</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/pic_tel.gif"> ' + phone + '</div><div class="clear"></div>';
  }
  if ((room.trim() != '') && (room != '&nbsp;')) {
    html = html + '<div class="Description">Room</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/pic_zimmer.gif"> '+ room + '</div><div class="clear"></div>';
  }
  if (group.trim() != '') {
    html = html + '<div class="Description">&nbsp;</div><div class="Content">' + group + '</div><div class="clear"></div>';
  }
  if (document.location.href.indexOf('?') == -1) {
    VCFlink = document.location.href + '?type=910&oid=' + oid;
  } else {
    VCFlink = document.location.href + '&type=910&oid=' + oid;
  }
  html = html + '<div class="Description">Businesscard</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/vcard.gif"> <a href="' + VCFlink + '">Download</a></div><div class="clear"></div>';
  html = html + '</div>';
  if (mapfile != '') {
    html = html + '<div class="MAP"><img src="' + mapfile + '"></div>';
  }
  if (uri != '') {
    html = html + '<div class="URI"><img src="' + uri + '" height="160"></div>';
  }
  html = html + '<br>';
  showOverlay(html,640,500);
}

function slPerson3_old(lastname,firstname,title,oid,email,phone,room,mapfile,group,publication,uri) {
  el = document.getElementById("slOverlay");
  el2 = document.getElementById("slOverlayContent");
  html = '<a id="closeModal" href="javascript:overlay();void(0);"><img src="/typo3conf/ext/tuw_informations/res/img/modal_close.png" border="0"/></a>';
  name = title + ' ' + firstname + ' <b>' + lastname + '</b>';
  html = html + '<div class="name">' + name.trim() + '</div>';
  html = html + '<div class="data">';
  if ((email.trim() != '') && (email != '&nbsp;')) {
    html = html + '<div class="Description">email-Address</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/pic_email.gif"> <a href="mailto:' + email + '">' + email + '</a></div><br>';
  }
  if (oid != '')  {
    html = html + '<div class="Description">TISS-Entry</div><div class="Content"><a href="https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/' + oid + '" target="_blank">Link</a></div><br>';
  };
  if (phone.trim() != '') {
    html = html + '<div class="Description">phone number</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/pic_tel.gif"> ' + phone + '</div><br>';
  }
  if ((room.trim() != '') && (room != '&nbsp;')) {
    html = html + '<div class="Description">Room</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/pic_zimmer.gif"> '+ room + '</div><br>';
  }
  if (group.trim() != '') {
    html = html + '<div class="Description">&nbsp;</div><div class="Content">' + group + '</div><br>';
  }
  if (document.location.href.indexOf('?') == -1) {
    VCFlink = document.location.href + '?type=910&oid=' + oid; 
  } else {
    VCFlink = document.location.href + '&type=910&oid=' + oid;
  }
  html = html + '<div class="Description">Businesscard</div><div class="Content"><img src="/typo3conf/ext/tuw_informations/res/img/vcard.gif"> <a href="' + VCFlink + '" target="_blank">Download</a></div><br>';
  html = html + '</div>';
  if (mapfile != '') {
    html = html + '<div class="MAP"><img src="' + mapfile + '"></div>';
  }
  if (uri != '') {
    html = html + '<div class="URI"><img src="' + uri + '" height="160"></div>';
  }

  html = html + '<br>';
  el2.innerHTML = html;
  el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}

function showOverlay(html,w,h) {
  ex1 = document.getElementById("dumbBoxWrap");
  ex2 = document.getElementById("dumbBoxContent");
  ex3 = document.getElementById("dumbBox");
  ex2.innerHTML = html;
  ex3.style.width = w + 'px';
  ex1.style.display = 'block';
}

