﻿function Hyperref(HyperRef)
{
  window.location=HyperRef;
}

function MenuButtonHover(button,image) {
  document.getElementById(button).src=image;
}

function GoBack()
{
  window.history.back();
}

function SetLabelHeight(image,height) {
  document.getElementById(image).style.height=height;
}

//Används i LedigaTomter.php
function getOptionValue(InputId)
{
  alert(document.getElementById(InputId).value)
}

//Används i LedigaTomter.php  
function formSubmit(InputId)
{
  document.getElementById(InputId).submit()
}

//Används i ShowLedigaTomter.php
function openTab(HyperRef)
{
  window.document.open=HyperRef;
}

//Används i ShowLedigaTomter.php
function ChangeOrderBy(Attribute,Interval)
{
  document.getElementById('orderInput').value=Attribute;
  document.getElementById('intervalInput').value=Interval;
  document.getElementById('changeOrderByForm').submit();
}

//Används i LaggTillTomt.php
function getFileExtension(inputId)
{
  var fileinput = document.getElementById(inputId);
  if(!fileinput ) return "";
  var filename = fileinput.value;
  if( filename.length == 0 ) return "";
  var dot = filename.lastIndexOf(".");
  if( dot == -1 ) return "";
  var extension = filename.substr(dot,filename.length);
  return extension;
}

//Används i LaggTillTomt.php
function checkFileType(inputId,allowedExt)
{
  var ext = getFileExtension(inputId).toLowerCase();
  var name = document.getElementById(inputId).value;
  if( ext == '.gif' || ext == '.jpg' || ext == '.png' || name == "" ) {
    document.getElementById("tomtForm").action="SparaLaggTillTomt.php";
    document.getElementById("tomtForm").submit();
    }
  else {
    alert("Endast bilder av typen gif, jpg eller png tillåts!");
  }
}