function popup(location,name,w,h) {
	var scrw=(screen.width/6)-(w/6);
	var scrh=(screen.height/6)-(h/6);
	window.open(location,name,('toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,left='+scrw+',top='+scrh+',width='+w+',height='+h));
}

function isInt(str)
{
  var strValidChars = "1234567890";
  var strChar;
  var bin = true;

  if(str.lenght==0)
    return false;

  for(i=0; i<str.length && bin==true; i++)
  {
    strChar = str.charAt(i);
    if(strValidChars.indexOf(strChar)==-1)
    {
      bin = false;
    }
  }
  return bin;
}

function addleden(frm)
{
  if(frm.form.gebruikeraan.value>0 && document.getElementById('numberPersons'))
  {
    number = prompt('Aantal personen die mee gaan','');
    if(number)
    {
      if(isInt(number))
      {
        document.getElementById('numberPersons').value = number;
        frm.form.submit();
      }
      else
      {
        alert("Aantal personen is geen nummer.");
      }
    }
    else
    {
      frm.form.gebruikeraan.value=0;
    }
  }
}

function Verplicht(formulierVeld,soort) {

if (soort == 1) { var verplichtVeld = Array("naam", "plaats", "organisator[]", "begindag", "beginmaand", "beginjaar", "einddag", "eindmaand", "eindjaar"); }
else if (soort == 2) { var verplichtVeld = Array("foto", "omschrijving"); }
else if (soort == 3) { var verplichtVeld = Array("omschrijving"); }
else if (soort == 4) { var verplichtVeld = Array("type", "naam", "omschrijving"); }
else if (soort == 5) { var verplichtVeld = Array("titel"); }
else if (soort == 6) { var verplichtVeld = Array("titel", "omschrijving"); }
else if (soort == 7) { var verplichtVeld = Array("name", "website", "text"); }
else if (soort == 8) { var verplichtVeld = Array("titel", "omschrijving", "naam", "email"); }
else if (soort == 9) { var verplichtVeld = Array("banner", "naam", "actief", "website"); }
else if (soort == 10) { var verplichtVeld = Array("naam", "actief", "website"); }
else if (soort == 11) { var verplichtVeld = Array("voornaam", "achternaam", "email"); }
else { var verplichtVeld = Array("omschrijvinggg"); }

var alertBoodschap = "Gelieve alle velden met een * in te vullen";
var alertLength = "alert";
var Boodschap = alertLength.length;
for (var i = 0; i < verplichtVeld.length; i++){var obj = formulierVeld.elements[verplichtVeld[i]];if (obj){switch(obj.type) {
case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "") { alertLength += "-\n"; } break;
case "select-multiple": if (obj.selectedIndex == -1){ alertLength += " -\n"; } break;
case "text":case "textarea": if (obj.value == "" || obj.value == null){ alertLength += " - \n";} break;
default: if (obj.value == "" || obj.value == null){ alertLength += " - \n";}}}}
if (alertLength.length == Boodschap){ return true; } else { alert(alertBoodschap);return false; }
}

/**
* Toggle price of markplaats
*/
function togglePrice(elem)
{
  priceElem = document.getElementById('price_type_price_div');
  if (priceElem)
    priceElem.style.display = (elem.value == 'bedrag') ? 'block' : 'none';
}

// Enable fancebox
$(document).ready(function()
{
  $(".lightbox-external").fancybox({
    'width'           : '1024',
    'height'          : '1024',
    'autoScale'       : true,
    'transitionIn'    : 'none',
    'transitionOut'   : 'none',
    'type'            : 'iframe'
  });

  $(".lightbox-flickr").fancybox({
    'width'           : $(window).height() - 100,
    'height'          : $(window).height() - 100,
    'autoScale'       : true,
    'transitionIn'    : 'none',
    'transitionOut'   : 'none',
    'type'            : 'iframe',
    'scrolling'       : 'no'
  });

  $(".lightbox").fancybox({
    'autoScale'       : true,
    'transitionIn'    : 'none',
    'transitionOut'   : 'none',
  });

  $(".lightbox-img-update").fancybox({
    'autoScale'       : true,
    'transitionIn'    : 'none',
    'transitionOut'   : 'none',
    'onComplete'      : function()
      {
        $.ajax({
          type   : "GET",
          cache  : false,
          url    : '/save/image_update.php?image=' + this.href
        });
      }
  });
});
