﻿var question = question || {};


/**
* Konfigurationsdaten
*/

// HTML-Seite für die Frage (wird in der Lightbox angezeigt)
question.html = 'question.html';

// Abmessungen der Lightbox
question.width = 520;
question.height = 340;

// Umleitung, wenn der Besucher ein Endkunde ist
question.redirect = 'http://cibavision.de';


/**
* @fn void question.close(type)
* Lightbox schließen.
* Handelt es sich um einen Händler Cookie setzen.
* Bei allen anderen handelt es sich um Endkunden. Dann weiterleiten auf 'cibavision.de'
* @param type dealer, *
* @author Peter Adelmann, trilobit GmbH
* @date 2011-04-05
*/
question.close = function(type) {
  $.fancybox.close();
  
  if (typeof(type) !== 'undefined'
      && type != 'dealer'
  ) {
    document.location.replace(question.redirect);
  }
  else {
    document.cookie = 'dealer=true;';
  }
};

/**
* @fn void question.open(href)
* Lightbox öffnen
* Ist ein Händler-Cookie gesetzt lightbox nicht noch einmal öffnen
* @author Peter Adelmann, trilobit GmbH
* @date 2011-04-05
*/
question.open = function() {
  if (document.cookie.indexOf ('dealer=true') !== -1) return;
  
  $.fancybox({
    'modal'  : true,
    'type'   : 'iframe',
    'href'   : question.html,
    'width'	 : question.width,
    'height' : question.height
  });
};


/**
* @fn void ready, load, resize
* Initialisierungen
* @author Peter Adelmann, trilobit GmbH
* @date 2011-04-05
*/
jQuery(document).ready(function() {
  question.open();
});

