// B: OLD? /	/	/	/	/	/	/	/	/	/	/	/	/	/
function returnSWFdetails(width, height, filesize) {
		document.getElementById("ad_width").value = width;
		document.getElementById("ad_height").value = height;
		document.getElementById("ad_filesize").value = filesize;
}
	
function displayContent(currContent,currLink) 
{
	var cont = document.getElementById(currContent).style;
	var link = document.getElementById(currLink).style;
	var contVisible = (cont.display == "block");
	cont.display = (contVisible ? "none":"block");
	link.display = (contVisible ? "block":"none");
	return false;
}	
// E: OLD? /	/	/	/	/	/	/	/	/	/	/	/	/	/

// B: no frame
function frame_noframe()
{	
	if (top.location != location)
	{
		top.location.href = window.location.href
	}
}
// E: no frame

// B: blokspambot
function blokspambot(id,domein){
adres=( id+ "@" + domein);
woord=( id+ " @ " + domein);
document.write('<a href=\"mailto:' + adres + '"\>')	;
document.write(woord);
document.write('</a>');
}
function blokspambotalt(id,domein,disp){
adres=(id+ "@" + domein);
woord=(disp);
document.write('<a href=\"mailto:' + adres + '"\>')	;
document.write(woord);
document.write('</a>');
}
function blokspambotsub(id,domein,disp){
adres=(id+ "@" + domein);
woord=( id+ " @ " + domein);
document.write('<a href=\"mailto:' + adres + '?subject=' + disp + '"\>')	;
document.write(woord);
document.write('</a>');
}
// E: blokspambot

// B: close div
function closeDiv(currentDiv) {
	var thisDiv = document.getElementById(currentDiv).style;
	// The above creates a new function that will expand and contract certain menus that are specified.
	thisDiv.display = "none";
	return false
}
// E: close div

// B: tabs
$(document).ready(function() {
	$(".tab_container .tab_content").hide();
	$(".tab_container ul.tabs").find("li:first").addClass("active").show();
	$(".tab_container .tab_container_content").find(".tab_content:first").show();
	
	$(".tab_container ul.tabs li").click(function() {
		var tb = $(this).parent().parent()[0];
		$(this).parent().find("li").removeClass("active");
		$(this).addClass("active");
		var idx = $(this).find("a").attr("tabindex");
		$(tb).find("div.tab_content").hide();
		$(tb).find("div.tab_content").eq(idx-1).fadeIn();
		return false;
	});
	
	$("#reactieBox").click(function() {
		$('html, body').animate({ scrollTop: $(".tab_container").offset().top }, 500);
		$("#aantalReactiesKop").click ();
	});
	
	$("#SpecsLink").click(function() {
		$('html, body').animate({ scrollTop: $(".tab_container").offset().top }, 500);
		$("#SpecsOverview").click ();
	});
	
});
// E: tabs

// B: lightbox
$(document).ready(function() {
	$("a[rel^='lightbox[gallery]'] img").removeAttr("alt");
	$("a[rel^='lightbox[gallery]']").prettyPhoto({image_markup: '<div style="width:300px"><hr style="width:300px" /><img id="fullResImage" src="{path}" /></div>',theme:'pp_default', slideshow:false, social_tools:'', title:false});
	$("a[rel^='floatinglogin']").prettyPhoto({slideshow:false, social_tools:'', show_title:false});
});
// E: lightbox

// START CARROURSEL : start fadomatic
Fadomatic.INTERVAL_MILLIS = 25;

function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) {
  this._element = element;
  this._intervalId = null;
  this._rate = rate;
  this._isFadeOut = true;

  this._minOpacity = 0;
  this._maxOpacity = 99;
  this._opacity = 99;

  if (typeof minOpacity != 'undefined') {
    if (minOpacity < 0) {
      this._minOpacity = 0;
    } else if (minOpacity > 99) {
      this._minOpacity = 99;
    } else {
      this._minOpacity = minOpacity;
    }
  }

  if (typeof maxOpacity != 'undefined') {
    if (maxOpacity < 0) {
      this._maxOpacity = 0;
    } else if (maxOpacity > 99) {
      this._maxOpacity = 99;
    } else {
      this._maxOpacity = maxOpacity;
    }

    if (this._maxOpacity < this._minOpacity) {
      this._maxOpacity = this._minOpacity;
    }
  }
  
  if (typeof initialOpacity != 'undefined') {
    if (initialOpacity > this._maxOpacity) {
      this._opacity = this._maxOpacity;
    } else if (initialOpacity < this._minOpacity) {
      this._opacity = this._minOpacity;
    } else {
      this._opacity = initialOpacity;
    }
  }

  if(typeof element.style.opacity != 'undefined') {

    this._updateOpacity = this._updateOpacityW3c;

  } else if(typeof element.style.filter != 'undefined') {

    if (element.style.filter.indexOf("alpha") == -1) {

      var existingFilters="";
      if (element.style.filter) {
        existingFilters = element.style.filter+" ";
      }
      element.style.filter = existingFilters+"alpha(opacity="+this._opacity+")";
    }

    this._updateOpacity = this._updateOpacityMSIE;
    
  } else {

    this._updateOpacity = this._updateVisibility;
  }

  this._updateOpacity();
}

Fadomatic.prototype.fadeOut = function () {
  this._isFadeOut = true;
  this._beginFade();
}

Fadomatic.prototype.fadeIn = function () {
  this._isFadeOut = false;
  this._beginFade();
}

Fadomatic.prototype.show = function () {
  this.haltFade();
  this._opacity = this._maxOpacity;
  this._updateOpacity();
}

Fadomatic.prototype.hide = function () {
  this.haltFade();
  this._opacity = 0;
  this._updateOpacity();
}

Fadomatic.prototype.haltFade = function () {

  clearInterval(this._intervalId);
}

Fadomatic.prototype.resumeFade = function () {

  this._beginFade();
}

Fadomatic.prototype._beginFade = function () {

  this.haltFade();
  var objref = this;
  this._intervalId = setInterval(function() { objref._tickFade(); },Fadomatic.INTERVAL_MILLIS);
}

Fadomatic.prototype._tickFade = function () {

  if (this._isFadeOut) {
    this._opacity -= this._rate;
    if (this._opacity < this._minOpacity) {
      this._opacity = this._minOpacity;
      this.haltFade();
    }
  } else {
    this._opacity += this._rate;
    if (this._opacity > this._maxOpacity ) {
      this._opacity = this._maxOpacity;
      this.haltFade();
    }
  }

  this._updateOpacity();
}

Fadomatic.prototype._updateVisibility = function () {
  
  if (this._opacity > 0) {
    this._element.style.visibility = 'visible';
  } else {
    this._element.style.visibility = 'hidden';
  }
}

Fadomatic.prototype._updateOpacityW3c = function () {
  
  this._element.style.opacity = this._opacity/100;
  this._updateVisibility();
}

Fadomatic.prototype._updateOpacityMSIE = function () {
  
  this._element.filters.alpha.opacity = this._opacity;
  this._updateVisibility();
}

Fadomatic.prototype._updateOpacity = null;


//start slideshow

var total = 0;
var loaded = 0;
var fadeSpeed = 10;
var showSpeed = 4000;
var current = 1;
var timer1 = null;
var faderNext = null;
var faderCurrent = null;

function init(total_images) {
	for(i=1;i<=999;i++) {
		var slide = document.getElementById('slide'+i);
		if (slide == null) { break; }
		var intro = document.getElementById('intro'+i);
		var readmore = document.getElementById('readmore'+i);
		slide.style.visibility = (i == 1 ? 'visible':'hidden');
		intro.style.visibility = (i == 1 ? 'visible':'hidden');
		readmore.style.visibility = (i == 1 ? 'visible':'hidden');
		total = i;
	}
	if (total_images && total_images > 0) {
		total = total_images;
		timer1 = setTimeout("play()", showSpeed);
	}
}

function imageLoaded() {
	loaded++;
	if (loaded >= total) {
		timer1 = setTimeout("play()", showSpeed);
	}
}

function fadeTo(next) {
	stop();
	
	if (next > total) { next = 1; }
	if (next <= 0) { next = total; }
	
	var nextSlide = document.getElementById('slide'+next);
	var currentSlide = document.getElementById('slide'+current);
	var nextIntro = document.getElementById('intro'+next);
	var currentIntro = document.getElementById('intro'+current);
	var nextReadmore = document.getElementById('readmore'+next);
	var currentReadmore = document.getElementById('readmore'+current);

	if (nextSlide != null) {
		faderNext = new Fadomatic(nextSlide, fadeSpeed, 0, 0, 100);
		faderNext.fadeIn();
	}
	
	if (current != next && currentSlide != null) {
		faderCurrent = new Fadomatic(currentSlide, fadeSpeed, 100, 0, 100);
		faderCurrent.fadeOut();
	}
	
	if (current != next && currentIntro != null) {
		currentIntro.style.visibility = 'hidden';
	}

	if (nextIntro != null) {
		nextIntro.style.visibility = 'visible';
	}
	
	if (current != next && currentReadmore != null) {
		currentReadmore.style.visibility = 'hidden';
	}
	
	if (nextReadmore != null) {
		nextReadmore.style.visibility = 'visible';
	}
	
	current = next;
}

function showNext() {
	fadeTo(current + 1);
}

function showPrevious() {
	fadeTo(current - 1);
}

function play() {
	if (current + 1 > total) {
		stop();
		fadeTo(1);
	} else {
		fadeTo(current + 1);
	}
	timer1 = setTimeout("play()", showSpeed);
	
	if (timer1 != null) {
		playbutton(true);
	}
}

function stop() {
	if (faderNext != null) {
		faderNext.show();
	}
	if (faderCurrent != null) {
		faderCurrent.hide();
	}

	if (timer1 != null) {
		clearTimeout(timer1);
		timer1 = null;
	}
	playbutton(false);
}

function playbutton(play) {
	var playbutton = document.getElementById("playbutton");
	var stopbutton = document.getElementById("stopbutton");
	if (playbutton != null && stopbutton != null) {
		playbutton.style.display = (play ? "none":"inline");
		stopbutton.style.display = (play ? "inline":"none");
	}	
}
// END CARROURSEL : start fadomatic


// START FORM VALIDATION
function msg_error(form_object, input_object, object_value, error_message)
{
	alert(error_message);
	return false;	
}
	
function chk_object(obj, obj_type)
{
	if (obj_type == "text" || obj_type == "password")
	{
		if (obj.value.length == 0) 
			return false;
		else 
			return true;
	}
	else if (obj_type == "select")
	{
		for (i=0; i < obj.length; i++)
		{
			if (obj.options[i].selected && obj.value != 0 && obj.value != "")
				return true;
		}
		return false;	
	}
	else if (obj_type == "single_value_radio" || obj_type == "single_value_checkbox")
	{
		if (obj.checked)
			return true;
		else
			return false;	
	}
	else if (obj_type == "radio" || obj_type == "checkbox")
	{
		for (i=0; i < obj.length; i++)
		{
			if (obj[i].checked)
				return true;
		}
		return false;	
	} 
	else
	{
		return true;
	}
}
	
function chk_integer(obj_value)
{
	if (obj_value.length == 0)
	    return true;
	var decimal_format = ".";
	var check_char;
	check_char = obj_value.indexOf(decimal_format)
	
	if (check_char < 1)
		return chk_number(obj_value);
	else
		return false;
}	
	
function chk_number(obj_value)
    {
    if (obj_value.length == 0)
        return true;
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;
	check_char = start_format.indexOf(obj_value.charAt(0))
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
	for (var i = 1; i < obj_value.length; i++)
	{
		check_char = number_format.indexOf(obj_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    return true
    }	

	function DelConfirm(delURL,delMSG,delPop)
	{							
		if (confirm(delMSG))
		{
			if (delPop)	{	
				window.opener.location.href = delURL;	//delete in content frame
				location.reload(); //refresh van de floating palet
			}
			else {
				location.href = delURL;	//delete in content frame
			}	
		}
	}

// END FORM VALIDATION

