// JavaScript Document

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: '/content/afbeeldingen/blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		/*  fix css background pngs -- does something to the anchors
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		fix css background pngs -- does something to the anchors
		*/
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);


jQuery.fn.fauxColumnHeights=function(columns)
{
	var total=$(this).length;
	var maxRowHeight=0;
	var allElements=$(this);
	$(this).each(function(index)
	{
		var hindex=index+1;
		var theight=$(this).height();
		if(theight>maxRowHeight)
		{
			maxRowHeight=theight;
		}
		if(parseInt(hindex/columns)==parseFloat(hindex/columns))
		{
			for(i=0;i<columns;i++)
			{
				$(allElements[index-i]).height(maxRowHeight).addClass('adjusted');
			}
			maxRowHeight=0;
		}
		if(total==hindex)
		{
			$(allElements).not('.adjusted').each(function()
			{
				$(this).height(maxRowHeight).addClass('adjusted');
			});
	}});
}



function validateForms() {
	var forms = document.forms;
	for (var i=0;i<forms.length;i++) {
		forms[i].onsubmit = validate;
	}
}


var validationFunctions = new Object();
validationFunctions["required"] = isRequired;
validationFunctions["pattern"] = isPattern;
validationFunctions["postcode"] = isPostCode;
validationFunctions["numeric"] = isnumeric;
validationFunctions["email"] = isEmail;

function isRequired(formField) {
	switch (formField.type) {
		case 'text':
		case 'textarea':
		case 'select-one':
			if (formField.value)
				return true;
			return false;
		case 'radio':
			var radios = formField.form[formField.name];
			for (var i=0;i<radios.length;i++) {
				if (radios[i].checked) return true;
			}
			return false;
		case 'checkbox':
			return formField.checked;
	}	
}

function isPattern(formField,pattern) {
	var pattern = pattern || formField.getAttribute('pattern');
	var regExp = new RegExp("^"+pattern+"$","");
	var correct = regExp.test(formField.value);
	if (!correct && formField.getAttribute('patternDesc'))
		correct = formField.getAttribute('patternDesc');
	return correct;
}

function isPostCode(formField) {
	return isPattern(formField,"\\d{4}\\s*\\D{2}");
}

function isnumeric(formField) {
	return isPattern(formField,"\\d+");
}

/* loopt vast op punten uin adressen
function isEmail(formField) {
	return isPattern(formField,"\\w*@\\w*\.\\w{2,4}")
}
function isEmail(formField) {
   var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   if (regex.test(email)) return true;
   else return false;
}
*/
function isEmail(formField) {
	//alert(formField.value);
	   var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   if (regex.test(formField.value)) return true;
   else return false;
}

function emptyFunction() {
	return true;
}

/*********************************/

function validate() {
	var els = this.elements;
	var validForm = true;
	var firstError = null;
	for (var i=0;i<els.length;i++) {
		if (els[i].removeError)
			els[i].removeError();
		var req = els[i].className;
		// classname
		//alert(req);
		if (!req) continue;
		var reqs = req.split(' ');
		if (els[i].getAttribute('pattern'))
			reqs[reqs.length] = 'pattern';
		for (var j=0;j<reqs.length;j++) {
			if (!validationFunctions[reqs[j]])
				validationFunctions[reqs[j]] = emptyFunction;
			var OK = validationFunctions[reqs[j]](els[i]);
			if (OK != true) {
				var errorMessage = OK || validationErrorMessage[reqs[j]];
				writeError(els[i],errorMessage);
				validForm = false;
				if (!firstError)
					firstError = els[i];
				break;
			}
		}
	}

	if (!validForm) {
		alert(validationErrorMessage['checkform']);
		//location.hash = '#startOfForm';
		this.className = this.className.replace(/isvalid/,'');
	}
	else
	{
		this.className += ' isvalid';
	}
	return validForm;
	
}

function writeError(obj,message) {
	obj.parentNode.className += ' errorMessage';
	obj.onchange = removeError;
	if (obj.errorMessage || obj.parentNode.errorMessage) return;
	var errorMessage = document.createElement('label');
	errorMessage.className = 'errorMessage';
	errorMessage.setAttribute('for',obj.id);
	errorMessage.setAttribute('htmlFor',obj.id);
	errorMessage.appendChild(document.createTextNode(message));
	obj.parentNode.appendChild(errorMessage);
	obj.errorMessage = errorMessage;
	obj.parentNode.errorMessage = errorMessage;
}

function removeError() {
	this.parentNode.className = this.parentNode.className.replace(/errorMessage/,'');
	if (this.errorMessage) {
		this.parentNode.removeChild(this.errorMessage);
		this.errorMessage = null;
		this.parentNode.errorMessage = null;
	}
	this.onchange = null;
}





/*
 * jQuery Media Plugin for converting elements into rich media content.
 *
 * Examples and documentation at: http://malsup.com/jquery/media/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @author: M. Alsup
 * @version: 0.90 (10-MAY-2009)
 * @requires jQuery v1.1.2 or later
 * $Id: jquery.media.js 2460 2007-07-23 02:53:15Z malsup $
 *
 * Supported Media Players:
 *    - Flash
 *    - Quicktime
 *    - Real Player
 *    - Silverlight
 *    - Windows Media Player
 *    - iframe
 *
 * Supported Media Formats:
 *   Any types supported by the above players, such as:
 *     Video: asf, avi, flv, mov, mpg, mpeg, mp4, qt, smil, swf, wmv, 3g2, 3gp
 *     Audio: aif, aac, au, gsm, mid, midi, mov, mp3, m4a, snd, rm, wav, wma
 *     Other: bmp, html, pdf, psd, qif, qtif, qti, tif, tiff, xaml
 *
 * Thanks to Mark Hicken and Brent Pedersen for helping me debug this on the Mac!
 * Thanks to Dan Rossi for numerous bug reports and code bits!
 * Thanks to Skye Giordano for several great suggestions!
 */
;(function($) {

/**
 * Chainable method for converting elements into rich media.
 *
 * @param options
 * @param callback fn invoked for each matched element before conversion
 * @param callback fn invoked for each matched element after conversion
 */
$.fn.media = function(options, f1, f2) {
    return this.each(function() {
        if (typeof options == 'function') {
            f2 = f1;
            f1 = options;
            options = {};
        }
        var o = getSettings(this, options);
        // pre-conversion callback, passes original element and fully populated options
        if (typeof f1 == 'function') f1(this, o);

        var r = getTypesRegExp();
        var m = r.exec(o.src.toLowerCase()) || [''];

        o.type ? m[0] = o.type : m.shift();
        for (var i=0; i < m.length; i++) {
            fn = m[i].toLowerCase();
            if (isDigit(fn[0])) fn = 'fn' + fn; // fns can't begin with numbers
            if (!$.fn.media[fn])
                continue;  // unrecognized media type
            // normalize autoplay settings
            var player = $.fn.media[fn+'_player'];
            if (!o.params) o.params = {};
            if (player) {
                var num = player.autoplayAttr == 'autostart';
                o.params[player.autoplayAttr || 'autoplay'] = num ? (o.autoplay ? 1 : 0) : o.autoplay ? true : false;
            }
            var $div = $.fn.media[fn](this, o);

            $div.css('backgroundColor', o.bgColor).width(o.width);
            // post-conversion callback, passes original element, new div element and fully populated options
            if (typeof f2 == 'function') f2(this, $div[0], o, player.name);
            break;
        }
    });
};

/**
 * Non-chainable method for adding or changing file format / player mapping
 * @name mapFormat
 * @param String format File format extension (ie: mov, wav, mp3)
 * @param String player Player name to use for the format (one of: flash, quicktime, realplayer, winmedia, silverlight or iframe
 */
$.fn.media.mapFormat = function(format, player) {
    if (!format || !player || !$.fn.media.defaults.players[player]) return; // invalid
    format = format.toLowerCase();
    if (isDigit(format[0])) format = 'fn' + format;
    $.fn.media[format] = $.fn.media[player];
    $.fn.media[format+'_player'] = $.fn.media.defaults.players[player];
};

// global defautls; override as needed
$.fn.media.defaults = {
    width:         400,
    height:        400,
    autoplay:      1,         // normalized cross-player setting
    bgColor:       'transparent', // background color
    params:        { wmode: 'transparent'},  // added to object element as param elements; added to embed element as attrs
    attrs:         {},        // added to object and embed elements as attrs
    flvKeyName:    'file',    // key used for object src param (thanks to Andrea Ercolino)
    flashvars:     {},        // added to flash content as flashvars param/attr
    flashVersion:  '7',       // required flash version
    expressInstaller: null,   // src for express installer

    // default flash video and mp3 player (@see: http://jeroenwijering.com/?item=Flash_Media_Player)
    flvPlayer:     '/js/flv/mediaplayer.swf',
    mp3Player:     '/js/flv/mediaplayer.swf',

    // @see http://msdn2.microsoft.com/en-us/library/bb412401.aspx
    silverlight: {
        inplaceInstallPrompt: 'true', // display in-place install prompt?
        isWindowless:         'true', // windowless mode (false for wrapping markup)
        framerate:            '24',   // maximum framerate
        version:              '0.9',  // Silverlight version
        onError:              null,   // onError callback
        onLoad:               null,   // onLoad callback
        initParams:           null,   // object init params
        userContext:          null    // callback arg passed to the load callback
    }
};

// Media Players; think twice before overriding
$.fn.media.defaults.players = {
    flash: {
        name:         'flash',
        types:        'flv,mp3,swf',
        oAttrs:   {
            classid:  'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
            type:     'application/x-oleobject',
            codebase: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + $.fn.media.defaults.flashVersion
        },
        eAttrs: {
            type:         'application/x-shockwave-flash',
            pluginspage:  'http://www.adobe.com/go/getflashplayer'
        }
    },
    quicktime: {
        name:         'quicktime',
        types:        'aif,aiff,aac,au,bmp,gsm,mov,mid,midi,mpg,mpeg,mp4,m4a,psd,qt,qtif,qif,qti,snd,tif,tiff,wav,3g2,3gp',
        oAttrs:   {
            classid:  'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
            codebase: 'http://www.apple.com/qtactivex/qtplugin.cab'
        },
        eAttrs: {
            pluginspage:  'http://www.apple.com/quicktime/download/'
        }
    },
    realplayer: {
        name:         'real',
        types:        'ra,ram,rm,rpm,rv,smi,smil',
        autoplayAttr: 'autostart',
        oAttrs:   {
            classid:  'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'
        },
        eAttrs: {
            type:         'audio/x-pn-realaudio-plugin',
            pluginspage:  'http://www.real.com/player/'
        }
    },
    winmedia: {
        name:         'winmedia',
        types:        'asx,asf,avi,wma,wmv',
        autoplayAttr: 'autostart',
        oUrl:         'url',
        oAttrs:   {
            classid:  'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6',
            type:     'application/x-oleobject'
        },
        eAttrs: {
            type:         $.browser.mozilla && isFirefoxWMPPluginInstalled() ? 'application/x-ms-wmp' : 'application/x-mplayer2',
            pluginspage:  'http://www.microsoft.com/Windows/MediaPlayer/'
        }
    },
    // special cases
    iframe: {
        name:  'iframe',
        types: 'html,pdf'
    },
    silverlight: {
        name:  'silverlight',
        types: 'xaml'
    }
};

//
//  everything below here is private
//


// detection script for FF WMP plugin (http://www.therossman.org/experiments/wmp_play.html)
// (hat tip to Mark Ross for this script)
function isFirefoxWMPPluginInstalled() {
    var plugs = navigator.plugins;
    for (i = 0; i < plugs.length; i++) {
        var plugin = plugs[i];
        if (plugin['filename'] == 'np-mswmp.dll')
            return true;
    }
    return false;
}

var counter = 1;

for (var player in $.fn.media.defaults.players) {
    var types = $.fn.media.defaults.players[player].types;
    $.each(types.split(','), function(i,o) {
        if (isDigit(o[0])) o = 'fn' + o;
        $.fn.media[o] = $.fn.media[player] = getGenerator(player);
        $.fn.media[o+'_player'] = $.fn.media.defaults.players[player];
    });
};

function getTypesRegExp() {
    var types = '';
    for (var player in $.fn.media.defaults.players) {
        if (types.length) types += ',';
        types += $.fn.media.defaults.players[player].types;
    };
    return new RegExp('\\.(' + types.replace(/,/ig,'|') + ')\\b');
};

function getGenerator(player) {
    return function(el, options) {
        return generate(el, options, player);
    };
};

function isDigit(c) {
    return '0123456789'.indexOf(c) > -1;
};

// flatten all possible options: global defaults, meta, option obj
function getSettings(el, options) {
    options = options || {};
    var $el = $(el);
    var cls = el.className || '';
    // support metadata plugin (v1.0 and v2.0)
    var meta = $.metadata ? $el.metadata() : $.meta ? $el.data() : {};
    meta = meta || {};
    var w = meta.width  || parseInt(((cls.match(/w:(\d+)/)||[])[1]||0));
    var h = meta.height || parseInt(((cls.match(/h:(\d+)/)||[])[1]||0));

    if (w) meta.width  = w;
    if (h) meta.height = h;
    if (cls) meta.cls = cls;

    var a = $.fn.media.defaults;
    var b = options;
    var c = meta;

    var p = { params: { bgColor: options.bgColor || $.fn.media.defaults.bgColor } };
    var opts = $.extend({}, a, b, c);
    $.each(['attrs','params','flashvars','silverlight'], function(i,o) {
        opts[o] = $.extend({}, p[o] || {}, a[o] || {}, b[o] || {}, c[o] || {});
    });

    if (typeof opts.caption == 'undefined') opts.caption = $el.text();

    // make sure we have a source!
    opts.src = opts.src || $el.attr('href') || $el.attr('src') || 'unknown';
    return opts;
};

//
//  Flash Player
//

// generate flash using SWFObject library if possible
$.fn.media.swf = function(el, opts) {
    if (!window.SWFObject && !window.swfobject) {
        // roll our own
        if (opts.flashvars) {
            var a = [];
            for (var f in opts.flashvars)
                a.push(f + '=' + opts.flashvars[f]);
            if (!opts.params) opts.params = {};
            opts.params.flashvars = a.join('&');
        }
        return generate(el, opts, 'flash');
    }

    var id = el.id ? (' id="'+el.id+'"') : '';
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id + cls + '>');

    // swfobject v2+
    if (window.swfobject) {
        $(el).after($div).appendTo($div);
        if (!el.id) el.id = 'movie_player_' + counter++;

        // replace el with swfobject content
        swfobject.embedSWF(opts.src, el.id, opts.width, opts.height, opts.flashVersion,
            opts.expressInstaller, opts.flashvars, opts.params, opts.attrs);
    }
    // swfobject < v2
    else {
        $(el).after($div).remove();
        var so = new SWFObject(opts.src, 'movie_player_' + counter++, opts.width, opts.height, opts.flashVersion, opts.bgColor);
        if (opts.expressInstaller) so.useExpressInstall(opts.expressInstaller);

        for (var p in opts.params)
            if (p != 'bgColor') so.addParam(p, opts.params[p]);
        for (var f in opts.flashvars)
            so.addVariable(f, opts.flashvars[f]);
        so.write($div[0]);
    }

    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};

// map flv and mp3 files to the swf player by default
$.fn.media.flv = $.fn.media.mp3 = function(el, opts) {
    var src = opts.src;
    var player = /\.mp3\b/i.test(src) ? $.fn.media.defaults.mp3Player : $.fn.media.defaults.flvPlayer;
    var key = opts.flvKeyName;
    src = encodeURIComponent(src);
    opts.src = player;
    opts.src = opts.src + '?'+key+'=' + (src);
    var srcObj = {};
    srcObj[key] = src;
    opts.flashvars = $.extend({}, srcObj, opts.flashvars );
    return $.fn.media.swf(el, opts);
};

//
//  Silverlight
//
$.fn.media.xaml = function(el, opts) {
    if (!window.Sys || !window.Sys.Silverlight) {
        if ($.fn.media.xaml.warning) return;
        $.fn.media.xaml.warning = 1;
        alert('You must include the Silverlight.js script.');
        return;
    }

    var props = {
        width: opts.width,
        height: opts.height,
        background: opts.bgColor,
        inplaceInstallPrompt: opts.silverlight.inplaceInstallPrompt,
        isWindowless: opts.silverlight.isWindowless,
        framerate: opts.silverlight.framerate,
        version: opts.silverlight.version
    };
    var events = {
        onError: opts.silverlight.onError,
        onLoad: opts.silverlight.onLoad
    };

    var id1 = el.id ? (' id="'+el.id+'"') : '';
    var id2 = opts.id || 'AG' + counter++;
    // convert element to div
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id1 + cls + '>');
    $(el).after($div).remove();

    Sys.Silverlight.createObjectEx({
        source: opts.src,
        initParams: opts.silverlight.initParams,
        userContext: opts.silverlight.userContext,
        id: id2,
        parentElement: $div[0],
        properties: props,
        events: events
    });

    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};

//
// generate object/embed markup
//
function generate(el, opts, player) {
    var $el = $(el);
    var o = $.fn.media.defaults.players[player];

    if (player == 'iframe') {
        var o = $('<iframe' + ' width="' + opts.width + '" height="' + opts.height + '" >');
        o.attr('src', opts.src);
        o.css('backgroundColor', o.bgColor);
    }
    else if ($.browser.msie) {
        var a = ['<object width="' + opts.width + '" height="' + opts.height + '" '];
        for (var key in opts.attrs)
            a.push(key + '="'+opts.attrs[key]+'" ');
        for (var key in o.oAttrs || {}) {
            var v = o.oAttrs[key];
            if (key == 'codebase' && window.location.protocol == 'https:')
                v = v.replace('http','https');
            a.push(key + '="'+v+'" ');
        }
        a.push('></ob'+'ject'+'>');
        var p = ['<param name="' + (o.oUrl || 'src') +'" value="' + opts.src + '">'];
        for (var key in opts.params)
            p.push('<param name="'+ key +'" value="' + opts.params[key] + '">');
        var o = document.createElement(a.join(''));
        for (var i=0; i < p.length; i++)
            o.appendChild(document.createElement(p[i]));
    }
    else {
        var a = ['<embed width="' + opts.width + '" height="' + opts.height + '" style="display:block"'];
        if (opts.src) a.push(' src="' + opts.src + '" ');
        for (var key in opts.attrs)
            a.push(key + '="'+opts.attrs[key]+'" ');
        for (var key in o.eAttrs || {})
            a.push(key + '="'+o.eAttrs[key]+'" ');
        for (var key in opts.params) {
            if (key == 'wmode' && player != 'flash') // FF3/Quicktime borks on wmode
            	continue;
            a.push(key + '="'+opts.params[key]+'" ');
        }
        a.push('></em'+'bed'+'>');
    }
    // convert element to div
    var id = el.id ? (' id="'+el.id+'"') : '';
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id + cls + '>');
    $el.after($div).remove();
    ($.browser.msie || player == 'iframe') ? $div.append(o) : $div.html(a.join(''));
    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};


})(jQuery);
 


/**
 * 
 * @desc Replace matching elements with a flash movie.
 * @author Luke Lutman
 * @version 1.0.1
 *
 * @name flash
 * @param Hash htmlOptions Options for the embed/object tag.
 * @param Hash pluginOptions Options for detecting/updating the Flash plugin (optional).
 * @param Function replace Custom block called for each matched element if flash is installed (optional).
 * @param Function update Custom block called for each matched if flash isn't installed (optional).
 * @type jQuery
 *
 * @cat plugins/flash
 * 
 * @example $('#hello').flash({ src: 'hello.swf' });
 * @desc Embed a Flash movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { version: 8 });
 * @desc Embed a Flash 8 movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { expressInstall: true });
 * @desc Embed a Flash movie using Express Install if flash isn't installed.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { update: false });
 * @desc Embed a Flash movie, don't show an update message if Flash isn't installed.
 *
**/
$$ = jQuery.fn.flash = function(htmlOptions, pluginOptions, replace, update) {
	
	// Set the default block.
	var block = replace || $$.replace;
	
	// Merge the default and passed plugin options.
	pluginOptions = $$.copy($$.pluginOptions, pluginOptions);
	
	// Detect Flash.
	if(!$$.hasFlash(pluginOptions.version)) {
		// Use Express Install (if specified and Flash plugin 6,0,65 or higher is installed).
		if(pluginOptions.expressInstall && $$.hasFlash(6,0,65)) {
			// Add the necessary flashvars (merged later).
			var expressInstallOptions = {
				flashvars: {  	
					MMredirectURL: location,
					MMplayerType: 'PlugIn',
					MMdoctitle: jQuery('title').text() 
				}					
			};
		// Ask the user to update (if specified).
		} else if (pluginOptions.update) {
			// Change the block to insert the update message instead of the flash movie.
			block = update || $$.update;
		// Fail
		} else {
			// The required version of flash isn't installed.
			// Express Install is turned off, or flash 6,0,65 isn't installed.
			// Update is turned off.
			// Return without doing anything.
			return this;
		}
	}
	
	// Merge the default, express install and passed html options.
	htmlOptions = $$.copy($$.htmlOptions, expressInstallOptions, htmlOptions);
	
	// Invoke $block (with a copy of the merged html options) for each element.
	return this.each(function(){
		block.call(this, $$.copy(htmlOptions));
	});
	
};
/**
 *
 * @name flash.copy
 * @desc Copy an arbitrary number of objects into a new object.
 * @type Object
 * 
 * @example $$.copy({ foo: 1 }, { bar: 2 });
 * @result { foo: 1, bar: 2 };
 *
**/
$$.copy = function() {
	var options = {}, flashvars = {};
	for(var i = 0; i < arguments.length; i++) {
		var arg = arguments[i];
		if(arg == undefined) continue;
		jQuery.extend(options, arg);
		// don't clobber one flash vars object with another
		// merge them instead
		if(arg.flashvars == undefined) continue;
		jQuery.extend(flashvars, arg.flashvars);
	}
	options.flashvars = flashvars;
	return options;
};
/*
 * @name flash.hasFlash
 * @desc Check if a specific version of the Flash plugin is installed
 * @type Boolean
 *
**/
$$.hasFlash = function() {
	// look for a flag in the query string to bypass flash detection
	if(/hasFlash\=true/.test(location)) return true;
	if(/hasFlash\=false/.test(location)) return false;
	var pv = $$.hasFlash.playerVersion().match(/\d+/g);
	var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($$.pluginOptions.version).match(/\d+/g);
	for(var i = 0; i < 3; i++) {
		pv[i] = parseInt(pv[i] || 0);
		rv[i] = parseInt(rv[i] || 0);
		// player is less than required
		if(pv[i] < rv[i]) return false;
		// player is greater than required
		if(pv[i] > rv[i]) return true;
	}
	// major version, minor version and revision match exactly
	return true;
};
/**
 *
 * @name flash.hasFlash.playerVersion
 * @desc Get the version of the installed Flash plugin.
 * @type String
 *
**/
$$.hasFlash.playerVersion = function() {
	// ie
	try {
		try {
			// avoid fp6 minor version lookup issues
			// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
			var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
			try { axo.AllowScriptAccess = 'always';	} 
			catch(e) { return '6,0,0'; }				
		} catch(e) {}
		return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
	// other browsers
	} catch(e) {
		try {
			if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
				return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
			}
		} catch(e) {}		
	}
	return '0,0,0';
};
/**
 *
 * @name flash.htmlOptions
 * @desc The default set of options for the object or embed tag.
 *
**/
$$.htmlOptions = {
	height: 240,
	flashvars: {},
	pluginspage: 'http://www.adobe.com/go/getflashplayer',
	src: '#',
	type: 'application/x-shockwave-flash',
	width: 320		
};
/**
 *
 * @name flash.pluginOptions
 * @desc The default set of options for checking/updating the flash Plugin.
 *
**/
$$.pluginOptions = {
	expressInstall: false,
	update: true,
	version: '6.0.65'
};
/**
 *
 * @name flash.replace
 * @desc The default method for replacing an element with a Flash movie.
 *
**/
$$.replace = function(htmlOptions) {
	this.innerHTML = '<div class="alt">'+this.innerHTML+'</div>';
	jQuery(this)
		.addClass('flash-replaced')
		.prepend($$.transform(htmlOptions));
};
/**
 *
 * @name flash.update
 * @desc The default method for replacing an element with an update message.
 *
**/
$$.update = function(htmlOptions) {
	var url = String(location).split('?');
	url.splice(1,0,'?hasFlash=true&');
	url = url.join('');
	var msg = '<p>This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>. Already have Flash Player? <a href="'+url+'">Click here.</a></p>';
	this.innerHTML = '<span class="alt">'+this.innerHTML+'</span>';
	jQuery(this)
		.addClass('flash-update')
		.prepend(msg);
};
/**
 *
 * @desc Convert a hash of html options to a string of attributes, using Function.apply(). 
 * @example toAttributeString.apply(htmlOptions)
 * @result foo="bar" foo="bar"
 *
**/
function toAttributeString() {
	var s = '';
	for(var key in this)
		if(typeof this[key] != 'function')
			s += key+'="'+this[key]+'" ';
	return s;		
};
/**
 *
 * @desc Convert a hash of flashvars to a url-encoded string, using Function.apply(). 
 * @example toFlashvarsString.apply(flashvarsObject)
 * @result foo=bar&foo=bar
 *
**/
function toFlashvarsString() {
	var s = '';
	for(var key in this)
		if(typeof this[key] != 'function')
			s += key+'='+encodeURIComponent(this[key])+'&';
	return s.replace(/&$/, '');		
};
/**
 *
 * @name flash.transform
 * @desc Transform a set of html options into an embed tag.
 * @type String 
 *
 * @example $$.transform(htmlOptions)
 * @result <embed src="foo.swf" ... />
 *
 * Note: The embed tag is NOT standards-compliant, but it 
 * works in all current browsers. flash.transform can be
 * overwritten with a custom function to generate more 
 * standards-compliant markup.
 *
**/
$$.transform = function(htmlOptions) {
	htmlOptions.toString = toAttributeString;
	if(htmlOptions.flashvars) htmlOptions.flashvars.toString = toFlashvarsString;
	return '<embed ' + String(htmlOptions) + '/>';		
};

/**
 *
 * Flash Player 9 Fix (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
 *
**/
if (window.attachEvent) {
	window.attachEvent("onbeforeunload", function(){
		__flash_unloadHandler = function() {};
		__flash_savedUnloadHandler = function() {};
	});
}

 
 // js p. ************************************************************************************************

$(document).ready(function(){
   // Your code here

	$('#open-cb-form').click(function(event){
	
		event.preventDefault();
		$('#cf').toggle();
	
	});
	
	$('.portalpage-flashbannerhome').before('<a style="display:block;position:absolute;width:320px;height:200px;" href="/cnt/nl/content/nieuws/cashbackaktie"><img src="/syscontent/shim.png" style="width:320px;height:200px;" /></a>');
	
	$('#legamaster-cashback_groot-1.swf').live('click',function(){ window.location.href = "/cnt/nl/content/nieuws/cashbackaktie" });
	
	$('a#actievoorwaarden-link').click(function(event){
	
		//alert('opening');
		window.open( $(this).attr('href') , 'voorwaarden', 'location=1,status=1,scrollbars=1,width=550,height=400');
		event.preventDefault();
		return false;
	
	});
	
	
	
	$('#CashbackformulierPostForm').submit(function(){
	
		var senddata = $(this).serialize();
		var vurl = $(this).attr('action');
		$.ajax({ 
			   async : true, 
			   data : senddata,
			   type : 'post',
			   url: vurl, 
			   success: function(returndata){
					if( returndata )
					{
						$('#returnmessage').html(returndata);
					}
			}
		});
		return false;
													
	});

   	$('#page').pngFix();
	
	$('.cms-tekst-html p img').each(function(){
		var st = $(this).attr('style');
		//alert(st);
		if(st == "float: left;") // tiny does this to images
		{
			$(this).attr('style', st+';margin-right:10px;');
		}
	});
	
	$('.form-field-help-block').each(function(){
		
		var closetext = $('#help-text-close-window').html();
		$('<a class="form-field-help-block-helper" href="#'+$(this).attr('id')+'">?</a>').insertBefore(this);
		$('<a href="#" class="hide-parent">'+closetext+'</a>').appendTo(this);
	
	});
	
	$('a.form-field-help-block-helper').click(function(event){
		event.preventDefault();
		var block = $(this).attr('href');
		$('.form-field-help-block').hide();
		$(block).show().addClass('open');
	});
	
	$('a.hide-parent').click(function(event){
		event.preventDefault();
		$(this).parent().hide();
	});
	
	// eerste de fix, want hidden werkt de fix niet goed
	$('.cake-sql-log').hide();

	$('#content-menu > ul > li.education > a').each(function(){
		$('<span class="menu-activator"><span>menu</span></span><div class="clear"></div>').insertAfter(this);
		$('.menu-activator').hide();	   
		}
	);
	
	$('#content-menu > ul > li.business > a').each(function(){
		$('<span class="menu-activator"><span>menu</span></span><div class="clear"></div>').insertAfter(this);
		$('.menu-activator').hide();	
		}
	);


	$('.menu-activator').hover(
		
		function(){
				$(this).addClass('active');
				$(this).parent().find('ul').show();
				$(this).parent().find('li ul').hide();
		},
		function(){
				//$('#content-menu ul li ul').hide();
		}
	);
	
	$('#content-menu > ul > li').hover(

									 
		function(){
			
				if( $(this).hasClass('education') )
				{
				$(this).addClass('edu_open');
				$(this).find('> a').css('width','94px').css('float','left');
				$(this).find('.menu-activator').show();
				return;	
				}
				
				if($(this).hasClass('business'))
				{
					$(this).addClass('bus_open');
					$(this).find('> a').css('width','94px').css('float','left');
					$(this).find('.menu-activator').show();
					return;
				}

				$('#content-menu ul li').removeClass('edu_open');
				$('#content-menu ul li').removeClass('bus_open');
				$('#content-menu ul li').removeClass('open');
				$('#content-menu ul li ul').hide();
				
				$(this).addClass('open');

				$(this).find('ul').show();
				//$(this).find('ul').show('fast');
				$(this).find('li ul').hide();
		},
		function(){
				//$(this).removeClass('open');
				$('#content-menu ul li').removeClass('edu_open');
				$('#content-menu ul li').removeClass('bus_open');
				$('#content-menu ul li').removeClass('open');
				$('#content-menu ul li ul').hide();
				
				if( $(this).hasClass('education') )
				{
					$(this).find('> a').css('width','100%');
				}
				if( $(this).hasClass('business') )
				{
					$(this).find('> a').css('width','100%');
				}
				$(this).find('.menu-activator').removeClass('active').hide();
				
		}
	);


/* 
zorgen dat het uitgeklapte menu onder bus end edu weer weggaat als de eerte a geraakt wordt
*/
	$('#content-menu > ul > li.education > a').hover(
		function(){
			
		$('#content-menu ul li ul').hide();	
		$(this).parent().find('.menu-activator').removeClass('active');	
		},
		function(){}
	);	
	
	$('#content-menu > ul > li.business > a').hover(
		function(){
			
		$('#content-menu ul li ul').hide();	
		$(this).parent().find('.menu-activator').removeClass('active');	
		},
		function(){}
	);	
	
	/*
	de tabsnav is voor de specs / acces / detail tab bladen bij producten
	*/
	
	$('ul#tabsnav li a').click(function(event){
		event.preventDefault();
		$('ul#tabsnav li').removeClass('active');
		$(this).parent('li').addClass('active');
		var target = $(this).attr('rel');
		$('#main-content .tab-target').hide();
		$('#'+target).show();
										
	});
	
	
	/*
	$('.flv').media( { width: 400, height: 320, flashvars: {image: '/content/3m-logo.jpg'}, autoplay: false } );
	*/
	$('ul.movies li').click(function(){
	
		var link = $(this).find('a:first').attr('href');
		document.location = link;
	});
	
	$('.flv').media( { width: 400, height: 320, autoplay: false} );
	
	$('.singlemovie').media( { wmode:'opaque', allowfullscreen: true, width: 500, height: 302, flashvars: {autostart:true}  } );
	
	//.media( { width: 500, height: 300},{autoPlay: 'true', autoStart: 'true'} );
	//autostart=true
	$('.portalpagemovie').each(function(){
		var pimage = $(this).attr('rel');
		$(this).media( { width: 300, height: 190, flashvars: {image: pimage, autostart:false}  } );	
		$(this).hide();
	});
	
	
	
	$('.content-display-home #carrousel').each(function(){
		
		var xmladres = $(this).find('#productxmladres').attr('class');
		var langiso = $('html').attr('xml:lang');
		var interest = 'general';
		
		$(this).flash(
			{ 
			src: '/content/swf/carrousel.swf',
			flashvars: {background:1, interest: interest, productxml: xmladres, lang: langiso},
			width: 940,
			height: 350,
			wmode: 'opaque',
			quality: 'high',
			align: 'middle',
			play: 'true',
			loop: 'true',
			scale: 'showall',
			devicefont: 'false',
			menu: 'true',
			allowFullScreen: 'false',
			allowScriptAccess:'sameDomain',
			salign: ''
			},
			{ version: 6 }
		);
	});
	
	
	$('.education #carrousel').each(function(){
		
		var xmladres = $(this).find('#productxmladres').attr('class');
		var langiso = $('html').attr('xml:lang');
		var interest = 'education';
		
		$(this).flash(
			{ 
			src: '/content/swf/carrousel.swf',
			flashvars: {background:2, interest: interest, productxml: xmladres, lang: langiso},
			width: 940,
			height: 260,
			wmode: 'opaque',
			quality: 'high',
			align: 'middle',
			play: 'true',
			loop: 'true',
			scale: 'showall',
			devicefont: 'false',
			menu: 'true',
			allowFullScreen: 'false',
			allowScriptAccess:'sameDomain',
			salign: ''
			},
			{ version: 6 }
		);
	});
	
	
	$('.business #carrousel').each(function(){
		
		var xmladres = $(this).find('#productxmladres').attr('class');
		var langiso = $('html').attr('xml:lang');
		var interest = 'business';
		
		$(this).flash(
			{ 
			src: '/content/swf/carrousel.swf',
			flashvars: {background:3, interest: interest, productxml: xmladres, lang: langiso},
			width: 940,
			height: 260,
			wmode: 'opaque',
			quality: 'high',
			align: 'middle',
			play: 'true',
			loop: 'true',
			scale: 'showall',
			devicefont: 'false',
			menu: 'true',
			allowFullScreen: 'false',
			allowScriptAccess:'sameDomain',
			salign: ''
			},
			{ version: 6 }
		);
	});
	
	$('.business #flash-app .flash-app-inline').each(
	function(){
		
			var movielink = $(this).attr('id');
			var movieadres = '/content/swf/'+movielink;
			var ecardparam = null;
			var langiso = $('html').attr('xml:lang');
			var interest = 'business';
			var questionxml = '/content/swf/'+langiso+'/questions.xml';
			
			if ($('#ecardparam').size() > 0 )
			{
				ecardparam = $('#ecardparam').html();	
				//alert(ecardparam);
			}
			
			$(this).flash(
				{ 
				src: movieadres,
				flashvars: {background: 3, interest: interest, ecard: ecardparam, lang: langiso, questionxml: questionxml},
				width: 715,
				height: 405,
				wmode: 'opaque',
				id: 'ecardmovie',
				name: 'ecardmovie',
				quality: 'high',
				align: 'middle',
				play: 'true',
				loop: 'true',
				scale: 'showall',
				devicefont: 'false',
				menu: 'true',
				allowFullScreen: 'false',
				allowScriptAccess:'sameDomain',
				salign: ''
				},
				{ version: 6 }
			);
		}
	);
	
	
	$('.education #flash-app .flash-app-inline').each(
													  	
	function(){
		
			var movielink = $(this).attr('id');
			var movieadres = '/content/swf/'+movielink;
			var ecardparam = null;
			var langiso = $('html').attr('xml:lang');
			var interest = 'education';
			var questionxml = '/content/swf/'+langiso+'/questions.xml';
			
			if ($('#ecardparam').size() > 0 )
			{
				ecardparam = $('#ecardparam').html();	
			}
		
		
			$(this).flash(
				{ 
				src: movieadres,
				flashvars: {background: 2, interest: interest, ecard: ecardparam, lang: langiso, questionxml: questionxml},
				width: '100%',
				height: 405,
				wmode: 'opaque',
				id: 'ecardmovie',
				name: 'ecardmovie',
				quality: 'high',
				align: 'middle',
				play: 'true',
				loop: 'true',
				scale: 'showall',
				devicefont: 'false',
				menu: 'true',
				allowFullScreen: 'false',
				allowScriptAccess:'sameDomain',
				salign: ''
				},
				{ version: 6 }
			);
		
		
		}
	);
	
	
	$('.education #flash-app .flash-app-selector-2010').each(
													  	
	function(){
		
			var movielink = $(this).attr('id');
			var movieadres = '/content/swf/'+movielink;
			var langiso = $('html').attr('xml:lang');
			var interest = 'education';
			var thisurl = document.location.toString();
			var questionxml = thisurl+'.xml';
		
			$(this).flash(
				{ 
				src: movieadres,
				flashvars: {background: 2, interest: interest, lang: langiso, questionxml: questionxml},
				width: '100%',
				height: 405,
				wmode: 'opaque',
				id: 'selector2010movie',
				name: 'selector2010movie',
				quality: 'high',
				align: 'middle',
				play: 'true',
				loop: 'true',
				scale: 'showall',
				devicefont: 'false',
				menu: 'true',
				allowFullScreen: 'false',
				allowScriptAccess:'sameDomain',
				salign: ''
				},
				{ version: 6 }
			);
		
		
		}
	);
	
	
		
	$('.business #flash-app .flash-app-selector-2010').each(
													  	
	function(){
		
			var movielink = $(this).attr('id');
			var movieadres = '/content/swf/'+movielink;
			var langiso = $('html').attr('xml:lang');
			var interest = 'business';
			var thisurl = document.location.toString();
			var questionxml = thisurl+'.xml';
		
			$(this).flash(
				{ 
				src: movieadres,
				flashvars: {background: 3, interest: interest, lang: langiso, questionxml: questionxml},
				width: '100%',
				height: 405,
				wmode: 'opaque',
				id: 'selector2010movie',
				name: 'selector2010movie',
				quality: 'high',
				align: 'middle',
				play: 'true',
				loop: 'true',
				scale: 'showall',
				devicefont: 'false',
				menu: 'true',
				allowFullScreen: 'false',
				allowScriptAccess:'sameDomain',
				salign: ''
				},
				{ version: 6 }
			);
		
		
		}
	);


	
	$('.portalpage-flashbanner').each(
													  	
	function(){
		
			var movielink = $(this).attr('id');
			var movieadres = '/content/files/swf/'+movielink;
		
			$(this).flash(
				{ 
				src: movieadres,
				width: 320,
				height: 250,
				wmode: 'opaque',
				quality: 'high',
				align: 'middle',
				play: 'true',
				loop: 'true',
				scale: 'showall',
				devicefont: 'false',
				menu: 'true',
				allowFullScreen: 'false',
				allowScriptAccess:'sameDomain',
				salign: ''
				},
				{ version: 6 }
			);
		
		
		}
	);


	$('.portalpage-flashbannerhome').each(
													  	
	function(){
		
			var movielink = $(this).attr('id');
			var movieadres = '/content/files/swf/'+movielink;
		
			$(this).flash(
				{ 
				src: movieadres,
				width: 320,
				height: 200,
				wmode: 'opaque',
				quality: 'high',
				align: 'middle',
				play: 'true',
				loop: 'true',
				scale: 'showall',
				devicefont: 'false',
				menu: 'true',
				allowFullScreen: 'false',
				allowScriptAccess:'sameDomain',
				salign: ''
				},
				{ version: 6 }
			);
		
		
		}
	);

		
	$('#sort-and-categorize input').change(
			function()
			{
				if( $(this).attr('checked') == true )
				{
					var group = $(this).val();
					$('#beelden-list li.'+group).show();
				}
				else
				{
					var group = $(this).val();
					$('#beelden-list li.'+group).hide();
					$('#beelden-list li.'+group+' input').val('');
				}
			}
	);
	
	$('input#downloadlink').click(function(){
	    $("#downloaddata").css('display','none');
	    $("#downloaddata input").remove();
		$("#beelden-select-form input").clone().appendTo("#downloaddata");
	});
	
		
	$('#users-aanmelden').hide();	
	
	$('#registreer a').click(function(event){
	  event.preventDefault();
		$('#users-login').hide();
		$('#users-aanmelden').show('slow');
	});
	
	$('#aanmelden-terug a').click(function(event){
	   event.preventDefault();
		$('#users-aanmelden').hide();
		$('#users-login').show('slow');
	});	
	
	$('p#upload a').click(function(event){
	  event.preventDefault();
		$('#users-upload-link').hide();
		$('#users-upload').show('slow');
	});
	
	
/*
	$('#flashbig').click(function(event){
		event.preventDefault();
		$('#content-title').hide();
		$('#section-navigation').hide();
		$('#content').css('width','950px');
		$('#main-content').css('width','950px');
		$('#ecardmovie').css('width','950px');
		$('#ecardmovie').css('height','500px');
	});
*/

	validateForms();

	$('#language-menu ul').hover(
		function(){
		//event.preventDefault();
		$('#language-menu ul').addClass('active');
		//$('#language-menu li').show();
		},
		
		function(){
		//event.preventDefault();
		$('#language-menu ul').removeClass('active');
		//$('#language-menu li').show();
		}
	
	
	);

	$('#productcategory-list li').hover(
		function(){
		$(this).addClass('hover');
		},
		function(){
		$(this).removeClass('hover');
		}
	);

	$('#productcategory-list li').click(function(){
	 var link = $(this).find('a').attr('href');
	 document.location.href = link;
	});

	/* dus */
	$('#section-navigation li.productcategorie').each(
		function(){
			var subitems = $(this).find('ul.products-menu li').length;
			//alert(subitems);
			if(subitems > 1)
			{
				$(this).addClass('extendable');	
				$(this).find('> a > span').prepend('+ ');
			}
			else if(subitems == 0)
			{
				$(this).hide();	
			}
			else
			{
				var thref = $(this).find('.products-menu li a').eq(0).attr('href');
				//alert (thref);
				$(this).find('> a').attr('href', thref );
			}
		}
	);
	
	
	$('#section-navigation li a.active span').each(function(){

		if(! $(this).closest("li").hasClass('extendable') )
		{
			$(this).prepend('&gt; ');
		}
	});
	
	$('#section-navigation li.cashbackactie a.cashbackaktie span').wrapInner('<span />');


	$('#section-navigation li.extendable').hover(
		function(){
		$(this).find('ul.products-menu').show('fast');
		},
		function(){
		$(this).find('ul.products-menu').hide('fast');
		}
	);
	
	$('.smallvisual a').click(function(event){
		event.preventDefault();
		$('#bigvisual').show();
	});

	$('#bigvisual img').click(function(){
	
		$('#bigvisual').hide();
	
	});


	$('#openflexform').click(function(event)
	{
		$('#sendflexmail').show().addClass('opened');
		$('#theflexform').show();
		$('#flexmailsuccesmessage').hide();
		event.preventDefault();	
	});


	$('#sendflexmail form').submit(function()
	{
		// send ajax
		if( $(this).hasClass('isvalid') )
		{
			$('#theflexform').hide();
		 	var formdata = ($(this).serialize());
			var thisurl = document.location.toString().replace('display','send');
			$.post(thisurl, formdata ,function(data) {
	 		 
			 	if( data == "OK")
				{
					//$('#flexmailsuccesmessage').show();
					alert('message was sent!');
					//window.setTimeout( $.closeDOMWindow() , 2500);
				}
				else
				{
					alert('message not send, please try again.')
					//$('#theflexform').show();
					//$('#DOMWindow').html(data);	
				}		
			});	
		}
		return false;
	});
 
});


$(window).load(function () {
  // run code
	$('#product-list li a').fauxColumnHeights(3);
	$('#product-list li h2').fauxColumnHeights(3);
	$('#product-list li').fauxColumnHeights(3);
	$('#productcategory-list li div.image').fauxColumnHeights(30);
	$('#productcategory-list li').fauxColumnHeights(30);

});

