function overlayShow(pObj,sPath)
{
  pObj.innerHTML = '<img z-index="10" src="' + sPath + '" />';
  pObj.style.display = 'block';
  var x = pObj.getElementsByTagName('img')[0];
  x.style.left = '' + (650 - x.width) / 2 + 'px';
  x.style.top = '' + (400 - x.height) / 2 + 'px';
  if (document.getElementById('frontNewsBox')!=null) {getObj('frontNewsBox').style.display = 'none';}
}

function overlayHide(pObj)
{
  pObj.innerHTML = '';
  pObj.style.display = 'none';
  if (document.getElementById('frontNewsBox')!=null) {getObj('frontNewsBox').style.display = 'block';}
}

function getObj(pPlace)
{
    if (document.getElementById(pPlace)==null) { alert('Fejl: Objektet '+pPlace+' blev ikke fundet, kontakt venligst webmaster.'); return false;}
    return document.getElementById(pPlace);
}

var mUrl;
var xmlhttp = null;
function loadXMLDoc(url)
{
    xmlhttp=null;
    if (window.XMLHttpRequest)
    { xmlhttp=new XMLHttpRequest(); } // code for Mozilla, IE7+ etc.
    else if (window.ActiveXObject)
    { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } // code for IE6
    
    if (xmlhttp!=null) {
        xmlhttp.onreadystatechange=state_Change;
        xmlhttp.open("GET",url,true);
        xmlhttp.send(null);
    } else { alert("Din webbrowser understøtter ikke XMLHTTP, du kan ikke se siden.\nKontakt evt. webmaster for spørgsmål."); }
}
function state_Change()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
        // if "OK"
        if (xmlhttp.status==200)
        {
            //window.open(mUrl)
            document.getElementById('content').innerHTML = xmlhttp.responseText;
        }
        else
        {
            alert("Siden kunne ikke indlæses, meddel venligst dette til webmaster.")
            alert(url);
            alert(xmlhttp.responseText);
            window.open(mUrl)
        }
    }
}

function newPopupImg(imgTitle, imgPath, imgWidth, imgHeight)
{
	var html = '<html><head><title>'+imgTitle+'<\/title><\/head><body><img src=\"'+imgPath+'\" width=\"'+imgWidth+'\" height=\"'+imgHeight+'\" onclick=\"window.close();\" \/><\/body><\/html>';
	//var newDoc=document.open("text/html","replace");
	//newDoc.write(html);
	//newDoc.close();
	var winPopup = window.open(' ', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+imgWidth+',height='+imgHeight+',left = '+((screen.width-imgWidth)/2)+',top = '+((screen.height-imgHeight)/2)+'');
	winPopup.document.write(html);
	winPopup.document.close();
}

function validateForm(pObj)
{
  var winner = 0; var name = ''; var address = ''; var zipcity = '';
  var error = false;
  var arr = pObj.getElementsByTagName('input');
  for (var i=0; i<arr.length; i++)
  {
    if (arr[i].name == 'winner' && arr[i].checked == true) { winner = arr[i].value; }
    window.status += arr[i].name;
    if (arr[i].name == 'name') { if (arr[i].value == '') { error = true; } else { name = arr[i].value; } }
    if (arr[i].name == 'address') { if (arr[i].value == '') { error = true; } else { address = arr[i].value; } }
    if (arr[i].name == 'zipcity') { if (arr[i].value == '') { error = true; } else { zipcity = arr[i].value; } }
  }
  error = (error == true) || (parseInt(winner) == 0);
  
  if (error==true)
  {
    alert('Vælg det billede du synes er årets foto og udfyld alle kontaktinformationer.')
  }
  else
    if (error==false)
    {
    var url = pObj.action+'?winner='+winner+'&address='+address+'&name='+name+'&zipcity='+zipcity;
    loadXMLDoc(url);
    }
}