/* Lightbox  function */
function displayLightbox(state,content) {         
  if (state == 'show') { 
    // fill lightbox
    $('.lightbox_detail').html('<img src="img/lmts_ticketpoints_'+content+'.gif" onClick="displayLightbox(\'hide\',\'\')">');

    $('#overlay_bg_container').fadeIn();                 
    TOP = (getBrowserSize()[1]-500)/2;
    LEFT = (((getBrowserSize()[0]-600)/2));
    $('#overlay_details').css("top",TOP);          //Plaats de overlay in het midden van het scherm
    $('#overlay_details').css("left",LEFT);        //Plaats de overlay in het midden van het schermm
    window.setTimeout("$('#overlay_details').fadeIn()", 600);  //Fade de overlay in

  } else {
    $('#overlay_details').hide();
    $('#overlay_bg_container').hide();   
  }
}

function getBrowserSize() {
          
    var theWidth, theHeight;
  // Window dimensions: 
  if (window.innerWidth) {
  theWidth=window.innerWidth;
  }
  else if (document.documentElement && document.documentElement.clientWidth) {
  theWidth=document.documentElement.clientWidth;
  }
  else if (document.body) {
  theWidth=document.body.clientWidth;
  }
  if (window.innerHeight) {
  theHeight=window.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
  theHeight=document.documentElement.clientHeight;
  }
  else if (document.body) {
  theHeight=document.body.clientHeight;
  }

  return [theWidth,theHeight];
}

/* updatePS('".$a['activiteit_id']."','".$record['prijs_voor']."','".$record['prijs_na']."','".$record['ticketcode']."') */
function updatePS(id,voor,na,code) {
  //alert(id+'|'+voor+'|'+na+'|'+code);

  $.ajax({
    type: "GET",
    url:  "../ajax/ajax_calls.php", 
    data: "action=updateps&id="+id+"&voor="+voor+"&na="+na+"&code="+code,
    dataType: "json",
    success: function(data){
      // als update ok is dan 1 anders 0      
      if (data == '1') 
        $("#"+id).html('<span style="color:red;">gegevens actief</span> <span style="float:right; margin-right:5px;"><a href="javascript:;" onClick="emptyTicketCode(\''+id+'\')">zet op inactief</a></span>');
      if (data == '0') 
        $("#"+id).html('<span style="color:red;">Upload data mislukt</span>');
      }
    });
    return false;
}

function emptyTicketCode(id) {
  $.ajax({
    type: "GET",
    url:  "../ajax/ajax_calls.php", 
    data: "action=zetinactief&id="+id,
    dataType: "json",
    success: function(data){
      // als update ok is dan 1 anders 0      
      if (data == '1') 
        $("#"+id).html('<span style="color:red;">gegevens inactief (refresh pagina)</span>');
      if (data == '0') 
        $("#"+id).html('<span style="color:red;">Upload data mislukt</span>');
      }
    });
    return false;
}
