/*
  This script contains all the functions that we need 
  to use the jQuery Tools in this website.
  
*/

/* 
  First some extra functions and inits
*/

	// Equalize all columns:
	function equalColumns() {
//alert($j("#col-a").height()+"/"+$j("#col-b").height());
		var x=$j("#col-a").height();
		if ( $j("#col-b").height() > x ) {
			x = $j("#col-b").height();
		}
//		if ( $j("#kol3").height() > x ) {
//			x = $j("#kol3").height();
//		}
		x = x + 5;
		x = x + 'px';
		$j("#col-a").height(x);
		$j("#col-b").height(x);
//		$j("#kol3").height(x);
//alert($j("#col-a").height()+"/"+$j("#col-b").height());

	}




/**
 * jQuery Default Value Plugin v1.0
 * Progressive enhancement technique for inital input field values
 *
 * The MIT License
 * 
 * Copyright (c) 2007 Paul Campbell (pauljamescampbell.co.uk)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @param		String
 * @return		Array
 */
(function($) {
	
	$.fn.defaultvalue = function() {
		
		// Scope
		var elements = this;
		var args = arguments;
		var c = 0;
		
		return(
			elements.each(function() {

        var el = $(this);
        var def = args[c++];
  
        $(this).css("color","#222222");
        if(el.val() == def) {
          $(this).css("color","#999999");
        }

			  if(el.val() == "") {
          el.val(def);
          $(this).css("color","#999999");
        }

        el.focus(function() {
          if(el.val() == def) {
            el.val("");
  					$(this).css("color","#222222");
  				}
  				el.blur(function() {
  				  if(el.val() == "") {
  					 el.val(def);
              $(this).css("color","#999999");
  						}
  					});
  				});
			})
		);
	}
})(jQuery)

/*
  $j will be the reference to jQuery
  ==================================
*/
  var $j = jQuery.noConflict();
  
  // Voor de validatie van het formulier: Doneren
  // Zie ook fileadmin/assets/scripts/formulier-doneren.php !
  var def_naam      = '(Achter)naam';
  var def_voornaam  = 'Voorna(a)m(en)';

var addthis_config = {
   ui_click: true
};

  
/*
  Run the scripts when the document is loaded
*/
$j(document).ready(function() {

  // Columns at equal heigt:
  // equalColumns('col-a', 'col-b');
  
  // Init the formfields
  $j(function($) {
  
    // Donatieformulier
    $("#doneren_naam").defaultvalue(def_naam);
    $("#doneren_voornaam").defaultvalue(def_voornaam);


    // Tussenstandservice
    $("#formulier-tussenstand .veld-activiteitnummer").defaultvalue('Activiteitnummer');
    $("#formulier-tussenstand .veld-toegangscode").defaultvalue('Toegnagscode');
    
    // Premiecalculator
    $("#formulier-premiecalculator .veld-bedrag").defaultvalue('In gehele euros');

    $("#formulier-tip .veld-uw-naam").defaultvalue('(Achter)naam');
    $("#formulier-tip .veld-uw-email").defaultvalue('E-mailadres');
    $("#formulier-tip .veld-geadresseerde-naam").defaultvalue('Naam geadresseerde');
    $("#formulier-tip .veld-geadresseerde-email").defaultvalue('E-mailadres geadresseerde');

  });
  
  $j(function() {

  // select the thumbnails and make them trigger our overlay
  $j("a.overlayed").overlay({

	  // each trigger uses the same overlay with the id "gallery"
	  target: '#gallery',

	  // optional exposing effect
	  expose: '#a1a1a1'

    // let the gallery plugin do its magic!
  }).gallery({
    	 // the plugin accepts its own set of configuration options
	     speed: 800
     });
  });

}); // document ready?