function imgOn(source, id) {
  document.getElementById(id).src=source;
}

function imgOff(source, id) {
  document.getElementById(id).src=source;
}

function bookmark(url, description) {
  var netscape="Tryck först på OK och sedan på CTRL+D for att lägga till 118110.se bland dina bokmärken.";

  if (navigator.appName=='Microsoft Internet Explorer') {
    window.external.AddFavorite(url, description);
  }
  else if (navigator.appName=='Netscape') {
    alert(netscape);
  }
}

/* Return a mail address link for the recepient at 118110.se */
function mailLink (recipient)
{
  var addr = recipient  + "@" + "118110.se";
  return "<a href=\"mailto:" + addr +"\">" + addr + "</a>";
}

/* Return a mail address link for the recepient at given domain */
function mailLinkExtern (recipient, domain)
{
  var addr = recipient  + "@" + domain;
  return "<a href=\"mailto:" + addr +"\">" + addr + "</a>";
}

/* Set the visibility property of the given element name to 'hidden' */
function hideElement (elemId)
{
    if (document.getElementById)
        document.getElementById (elemId).style.visibility = "hidden";
    else if (document.all)
        document.all[elemId].style.visibility = 'hidden';
    else if (document.layers && document.layers[elemId])
        document.layers[elemId].visibility = 'hidden';
}

/* Set the visibility property of the given element name to 'visible' */
function showElement (elemId)
{
    if (document.getElementById)
        document.getElementById (elemId).style.visibility = "visible";
    else if (document.all)
        document.all[elemId].style.visibility = 'visible';
    else if (document.layers && document.layers[elemId])
        document.layers[elemId].visibility = 'visible';
}

function disableExtendedForm(form)
{
    hideElement ("event_types_label");
    hideElement ("event_types");
    hideElement ("event_name_label");
    hideElement ("event_name");
    hideElement ("organiser_name_label");
    hideElement ("organiser_name");

    form.event_type_fk.value = 0;
    form.event_name.value = '';
    form.organiser_name.value = '';
}

function enableExtendedForm()
{
    showElement ("event_types_label");
    showElement ("event_types");
    showElement ("event_name_label");
    showElement ("event_name");
    showElement ("organiser_name_label");
    showElement ("organiser_name");
}

function toggleExtendedForm(form)
{
    if (form.x.checked) {
        enableExtendedForm();
    }
    else {
        disableExtendedForm(form);
    }
}

function validateEventSearch(form)
{
    if (form.region.value < 1) {
        alert("Välj först vilken stad du vill söka i!");
        return false;
    }
    return true;
}

/* Open window displaying picture */
function showImage (type, image)
{
    height = 800;

    if (type == 'album') {
        width      = 1000;
        windowName = 'PhotoViewer';
    }
    else {
        width = 750;
        windowName = 'ImageViewer';
    }

    openWindow('show_image.php?' + type + '=' + image,
               windowName,
               'height=' + height + ',width=' + width + 
               ',scrollbars=yes,resizable=yes');
}
