﻿
/* ------------------------------------------------------------------ */
/* --- Functies: Algemeen ------------------------------------------- */
/* ------------------------------------------------------------------ */

// Standaardwaarde van tekstveld verbergen onFocus (en css-class aanpassen)
function textFieldFocus(object, defaultValue) {
  if (object.value == defaultValue) {
    object.value = "";
    object.className = "active";
    document.getElementById("txtZoekwoorden").style.color = "#000000";
  }
}

// Standaardwaarde van tekstveld herstellen onBlur (en css-class aanpassen)
function textFieldBlur(object, defaultValue) {
  if (object.value == "") {
    object.value = defaultValue;
    object.className = "";
  }
}


/* ------------------------------------------------------------------ */
/* --- Functies: onLoad --------------------------------------------- */
/* ------------------------------------------------------------------ */

$(document).ready(function() {
  // Lightbox activeren
  $(".lightbox").lightbox();

  // Aanbiedingen-carousel activeren
  $(".carousel").jCarouselLite({
    auto: 4000,
    speed: 1000,
    btnNext: "#knop_carousel_volgende",
    btnPrev: "#knop_carousel_vorige",
    scroll: 1,
    visible: 1
  });

});

/* ------------------------------------------------------------------ */
/* --- Functies: Selectboxen --------------------------------------------- */
/* ------------------------------------------------------------------ */
function changeWinkelCategorie(strCatId, strPagina) {
    location.href = strPagina + "?catid=" + strCatId;
}

function changeActueelCategorie(strCatId, strPagina){
    location.href= strPagina + "?catid=" + strCatId;
}

function changeWebgidsCategorie(strCatId, strPagina){
    location.href= strPagina + "?catid=" + strCatId;
}

function changeAgenda(jaar, maand, strPagina) {
    location.href= strPagina + "?jaar=" + jaar + "&maand=" + maand;
}

function changeAlbum(jaar, strPagina){
    location.href= strPagina + "?jaar=" + jaar;
}

//ZOEKEN
function zoek(zoekUrl, strNegeerwaarde) {
  if (document.getElementById("txtZoekwoorden").value.length > 0 && document.getElementById("txtZoekwoorden").value != strNegeerwaarde){
    window.location = zoekUrl + "?zoek=" + document.getElementById("txtZoekwoorden").value;
    return false;
  }
  else {
  document.getElementById("txtZoekwoorden").style.color = "#dd0000";
  return false;
   //return GS_showCenter('Waarschuwing', "/pages_greybox/alert.aspx?tekst=Er zijn geen zoekwoorden opgegeven", 150, 248);
  }
}

//Webcam via ajax updaten

function AdvAjaxOpenPage(div, page, timeout) {
  field = document.getElementById(div);
  var xmlhttp;
  if (window.ActiveXObject) {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else {
    xmlhttp = new XMLHttpRequest();
  }
  if (xmlhttp) {
    var date = new Date();
    var random = date.getTime();
    xmlhttp.open("GET", page + "&random=" + random, true);
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4) {
        result = xmlhttp.responseText;
        field.innerHTML = result;
        var date = new Date();
        var random = date.getTime();
        field.href = field.href.substring(0, field.href.indexOf("?")) + "?" + random
        //field.innerHTML = parseScript(result);
        setTimeout("AdvAjaxOpenPage('" + div + "','" + page + "', '" + timeout + "');", timeout);
      }
    }
    xmlhttp.send(null)
  }
}
