	var lastel = null;
	function seterror(el){
		$('#'+el).css('border','1px solid #FF9999');
		$('#'+el).css('backgroundColor','#FFBFBF');
		Elem = document.getElementById(el);
		yPos = eval(Elem).offsetTop;
		//alert( yPos )
		$(document).scrollTo(yPos);
		lastel = el;
	}
	
	function removeerror(el){	
		$('#form-error').remove();
		$('#'+el).css('border','1px solid #D4D3E7');
		$('#'+el).css('backgroundColor','');
		DrawBackground();
	}
	
	function alerd(msg){
		$('#form-error').remove();
		$('#'+lastel).append('<div id="form-error">'+msg+'</div>')
	}
	
	jQuery(function($){
		$.datepicker.regional['nl'] = {clearText: 'Wissen', clearStatus: '',
			closeText: 'Sluiten', closeStatus: '',
			prevText: 'Terug', prevStatus: '',
			nextText: 'Vooruit', nextStatus: '',
			currentText: 'Vandaag', currentStatus: '',
			monthNames: ['Januari','Februari','Maart','April','Mei','Juni',
			'Juli','Augustus','September','Oktober','November','December'],
			monthNamesShort: ['Jan','Feb','Maa','Apr','Mei','Jun',
			'Jul','Aug','Sep','Okt','Nov','Dec'],
			monthStatus: '', yearStatus: '',
			weekHeader: 'Wk', weekStatus: '',
			dayNames: ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'],
			dayNamesShort: ['Zon','Maa','Din','Woe','Don','Vri','Zat'],
			dayNamesMin: ['Zo','Ma','Di','Wo','Do','Vr','Za'],
			dayStatus: 'DD', dateStatus: 'D, M d',
			dateFormat: 'dd-mm-yy', firstDay: 0, 
			initStatus: '', isRTL: false};
		$.datepicker.setDefaults($.datepicker.regional['nl']);
	});
	
	function quick_edit(pageid){
		//get the contents from the page
		var contents = $('#center-kolom').load('/site/modules/pages/quick_edit.php?pid='+pageid);
		//show an editor with the contents
		
		//save the contents from the editor to the database
	}
	
	$(document).ready(function(){
		//$(".roundcont").corner("10px");
		//$(".round").corner("round 10px")
		$(".roundsucces").corner("round 8px").parent().css('padding', '2px').corner("round 10px");
		$(".rounderror").corner("round 8px").parent().css('padding', '2px').corner("round 10px");
		//$(".round5").corner("5px");
		$('.ui-accordion-jquery').accordion({collapsible:true});
		$('.ui-tabs-jquery').tabs();
$('.ui-buttons').button();
		
		$('#helper-meel').append('<span><a href="mailto:info@vastelastenbond.nl">info@vastelastenbond.nl</a></span>');
		
		if(jQuery.browser.mobile){
			$('#helper-phone').append('<a href="tel:+31407200200"><span>040-7200200</span></a>');
		}else{
			$('#helper-phone').append('<span>040-7200200</span>');
		}

		$(".tweet").tweet({
		        join_text: "auto",
		        username: "vastelastenbond",
		        //avatar_size: 32,
		        intro_text:false,
		        count: 3,
		        auto_join_text_view: "Ongeveer,",
		        auto_join_text_default: "zeiden wij,", 
		        auto_join_text_ed: "wij",
		        auto_join_text_ing: "wij waren",
		        auto_join_text_reply: "wij reageerde",
		        auto_join_text_url: "we were checking out",
		        loading_text: "Bezig met laden van tweets..."
		      });		
	});	
	
	function toggle(el){
		$("#"+el).toggle("slow");
		$("#"+el).css('backgroundColor','white');
		$("#"+el).css('padding', '5px');
		DrawBackground();
	}
	
	function overimage(el,img){
		el.src = '/nieuw/images/' + img
	}

	function checkinput_nieuwsbrief()
	{
		//email adres controle
		re=/[a-zA-Z0-9\-_]+@[a-zA-Z0-9\-_][a-zA-Z0-9\-_]+\.[a-zA-Z0-9\-_][a-zA-Z0-9\-_]+/;
		if(!document.nieuwsbrief_form.emailadres_nieuwsbrief.value.match(re))
		{
			alert('Vul een geldig emailadres in a.u.b.');
			document.nieuwsbrief_form.emailadres_nieuwsbrief.select();
			return false;
		}
		//alert('U bent nu geabonneerd op onze nieuwsbrief.');
		//document.nieuwsbrief_form.submit();
		return true;
	}
		
	function openwin(src){
		var w = 480, h = 300;
		
		if (document.all) {
		   /* the following is only available after onLoad */
		   w = document.body.clientWidth;
		   h = document.body.clientHeight;
		}
		else if (document.layers) {
		   w = window.innerWidth;
		   h = window.innerHeight;
		}
		
		var popW = 630, popH = 500;
		
		var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		
		var chatwin = window.open(src, 'popup','location=1,resizable=yes,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
		chatwin.focus();
	}
	
	function showsubmenu(id){
		
	}

	
	/**
	 * jQuery.browser.mobile (http://detectmobilebrowser.com/)
	 *
	 * Copyright (c) 2010 Chad Smith (http://twitter.com/chadsmith)
	 * Dual licensed under the MIT and GPL licenses.
	 * http://www.opensource.org/licenses/mit-license.php
	 * http://www.opensource.org/licenses/gpl-license.php
	 *
	 * jQuery.browser.mobile will be true if the browser is a mobile device
	 *
	 **/
	(function(a){jQuery.browser.mobile=/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);
	
	
$(document).ready(function(){  
	$(".round").backgroundCanvas();


});

// Draw the background  on load and resize
$(window).load(function () 
{ 
	DrawBackground(); 
});

$(window).resize(function()
{
	DrawBackground(); 
});

$(window).click(function()
		{
			DrawBackground(); 
		});

function DrawBackground()
{
	$(".round").backgroundCanvasPaint(Demo1BackgroundPaintFkt); 
}



function Demo1BackgroundPaintFkt(context, width, height, canvas, $canvas, $canvasDiv, $content, $element ) 
{
		var options = {x:0, height: height, width: width, radius:14,  border: 0 };
		var backgroundGradient = context.createLinearGradient(0, 0, 0, height - 2);
		backgroundGradient.addColorStop(0 ,'#EEEEFF');
		backgroundGradient.addColorStop(1, '#AAAAFF');
		context.fillStyle = "#9999EF";
		
		// Draw the blue border rectangle 
		$.canvasPaint.roundedRect(context,options);
		
		// Draw the gradient filled inner rectangle
		options.border = 1;
		context.fillStyle = backgroundGradient; 
		$.canvasPaint.roundedRect(context,options);
}	

var aantal_pakketen_int = null;

function hide_all(name){
	
	$('.'+name).toggle();
	update_pakket_aantal();
}

function update_pakket_aantal(){
	var options_count = 0;
	$('.option_box').each(function(){
		if( this.style.display != 'none' )
			options_count++;	
	})
	$('#aantal_pakketen_int').html( options_count );
	
	//var order = $('#order').val() == ""? null: $('#order').val().split(",");
	var rightorder = new Array(6,34);
	//var order = rightorder == ""? null: rightorder.split(",");
    //$('#packages-list').reOrder(rightorder, 'package_');	
}

function hide_min_speed(speed){	
	$('.option_box').each(function(){
		$(this).show();
	})
	for(x=0; x < speed;x++){
		$('.downspeed_'+ x).hide();
	}
	update_pakket_aantal();
}

function reposition_things(){

	//get an array of the matching DOM elements   
	var liItems = $(".Tele2").get();
	var upc34 = $('#package_34').html();
	//alert(upc)
	//iterate through this array in reverse order    
	for(var i = liItems.length - 1; i >= 0; --i){
		//get the html
		var box = $(liItems[i]).html();
		//$(liItems[i]).remove();
		//prepend it to the list of packages
		//$('#package-list').prepend('<div class="option_box Tele2 downspeed_20">'+ box + '</div>');
		//$('#package-list').prepend(upc34);
	}
	
	
	
	
}

function close_pakket(me){
	$(me).parent().parent().fadeOut('slow', function() {
	    // Animation complete.
		update_pakket_aantal();	
		DrawBackground();
	  });
}

(function($) {

	$.fn.reOrder = function(array, prefix) {
	  return this.each(function() {
	    prefix = prefix || "";

	    if (array) {    
	      for(var i=0; i < array.length; i++) 
	        array[i] = $('#' + prefix + array[i]);

	      $(this).empty();  

	      for(var i=0; i < array.length; i++)
	        $(this).append(array[i]);      
	    }
	  });    
	}
	})(jQuery);


//check flash player
//check flash player

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";

if (navigator.plugins && navigator.plugins.length){

   x = navigator.plugins["Shockwave Flash"];
   if (x){

      flashinstalled = 2;
      if (x.description){

         y = x.description;
         flashversion = y.charAt(y.indexOf('.')-1);
      }
   }else
	   
      flashinstalled = 1;

   if (navigator.plugins["Shockwave Flash 2.0"]){

      flashinstalled = 2;
      flashversion = 2;
   }
}else if (navigator.mimeTypes && navigator.mimeTypes.length){

   x = navigator.mimeTypes['application/x-shockwave-flash'];
   if (x && x.enabledPlugin)
      flashinstalled = 2;
   else
      flashinstalled = 1;
}else

   MSDetect = "true";


if (flashinstalled == 2){

   if (flashversion)
	   
	   $(document).ready(function(){
		   	$('#flash_bespaar_btn').show();
	   		$('#alt_link_besparen').hide('fast');
	   });
   
   else

	   $(document).ready(function(){
		   $('#flash_bespaar_btn').show();
	   		$('#alt_link_besparen').hide('fast');
	   });
}

else if (flashinstalled == 1)$(document).ready(function(){
	$('#flash_bespaar_btn').hide();
		$('#alt_link_besparen').show('fast');
})
else{ 
	$('#alt_link_besparen').hide('fast'); 
$('#flash_bespaar_btn').show();
}


/*PAGINATION*/
/**
 * This jQuery plugin displays pagination links inside the selected elements.
 * 
 * This plugin needs at least jQuery 1.4.2
 *
 * @author Gabriel Birke (birke *at* d-scribe *dot* de)
 * @version 2.1
 * @param {int} maxentries Number of entries to paginate
 * @param {Object} opts Several options (see README for documentation)
 * @return {Object} jQuery Object
 */
(function($){
    /**
     * @class Class for calculating pagination values
     */
    $.PaginationCalculator = function(maxentries, opts) {
	this.maxentries = maxentries;
	this.opts = opts;
    }
    
    $.extend($.PaginationCalculator.prototype, {
	/**
	 * Calculate the maximum number of pages
	 * @method
	 * @returns {Number}
	 */
	numPages:function() {
	    return Math.ceil(this.maxentries/this.opts.items_per_page);
	},
	/**
	 * Calculate start and end point of pagination links depending on 
	 * current_page and num_display_entries.
	 * @returns {Array}
	 */
	getInterval:function(current_page)  {
	    var ne_half = Math.floor(this.opts.num_display_entries/2);
	    var np = this.numPages();
	    var upper_limit = np - this.opts.num_display_entries;
	    var start = current_page > ne_half ? Math.max( Math.min(current_page - ne_half, upper_limit), 0 ) : 0;
	    var end = current_page > ne_half?Math.min(current_page+ne_half + (this.opts.num_display_entries % 2), np):Math.min(this.opts.num_display_entries, np);
	    return {start:start, end:end};
	}
    });
    
    // Initialize jQuery object container for pagination renderers
    $.PaginationRenderers = {}
    
    /**
     * @class Default renderer for rendering pagination links
     */
    $.PaginationRenderers.defaultRenderer = function(maxentries, opts) {
	this.maxentries = maxentries;
	this.opts = opts;
	this.pc = new $.PaginationCalculator(maxentries, opts);
    }
    $.extend($.PaginationRenderers.defaultRenderer.prototype, {
	/**
	 * Helper function for generating a single link (or a span tag if it's the current page)
	 * @param {Number} page_id The page id for the new item
	 * @param {Number} current_page 
	 * @param {Object} appendopts Options for the new item: text and classes
	 * @returns {jQuery} jQuery object containing the link
	 */
	createLink:function(page_id, current_page, appendopts){
	    var lnk, np = this.pc.numPages();
	    page_id = page_id<0?0:(page_id<np?page_id:np-1); // Normalize page id to sane value
	    appendopts = $.extend({text:page_id+1, classes:""}, appendopts||{});
	    if(page_id == current_page){
		lnk = $("<span class='current'>" + appendopts.text + "</span>");
	    }
	    else
	    {
		lnk = $("<a>" + appendopts.text + "</a>")
		.attr('href', this.opts.link_to.replace(/__id__/,page_id));
	    }
	    if(appendopts.classes){ lnk.addClass(appendopts.classes); }
	    lnk.data('page_id', page_id);
		return lnk;
	},
	// Generate a range of numeric links 
	appendRange:function(container, current_page, start, end, opts) {
	    var i;
	    for(i=start; i<end; i++) {
		this.createLink(i, current_page, opts).appendTo(container);
	    }
	},
	getLinks:function(current_page, eventHandler) {
	    var begin, end,
	    interval = this.pc.getInterval(current_page),
			np = this.pc.numPages(),
			fragment = $("<div class='pagination'></div>");
			
			// Generate "Previous"-Link
			if(this.opts.prev_text && (current_page > 0 || this.opts.prev_show_always)){
			    fragment.append(this.createLink(current_page-1, current_page, {text:this.opts.prev_text, classes:"prev"}));
			}
			// Generate starting points
			if (interval.start > 0 && this.opts.num_edge_entries > 0)
			{
			    end = Math.min(this.opts.num_edge_entries, interval.start);
			    this.appendRange(fragment, current_page, 0, end, {classes:'sp'});
			    if(this.opts.num_edge_entries < interval.start && this.opts.ellipse_text)
			    {
				jQuery("<span>"+this.opts.ellipse_text+"</span>").appendTo(fragment);
			    }
			}
			// Generate interval links
			this.appendRange(fragment, current_page, interval.start, interval.end);
			// Generate ending points
			if (interval.end < np && this.opts.num_edge_entries > 0)
			{
			    if(np-this.opts.num_edge_entries > interval.end && this.opts.ellipse_text)
			    {
				jQuery("<span>"+this.opts.ellipse_text+"</span>").appendTo(fragment);
			    }
			    begin = Math.max(np-this.opts.num_edge_entries, interval.end);
			    this.appendRange(fragment, current_page, begin, np, {classes:'ep'});
			    
			}
			// Generate "Next"-Link
			if(this.opts.next_text && (current_page < np-1 || this.opts.next_show_always)){
			    fragment.append(this.createLink(current_page+1, current_page, {text:this.opts.next_text, classes:"next"}));
			}
			$('a', fragment).click(eventHandler);
			return fragment;
	}
    });
				
				// Extend jQuery
				$.fn.pagination = function(maxentries, opts){
				    
				    // Initialize options with default values
				    opts = jQuery.extend({
					items_per_page:10,
					num_display_entries:11,
					current_page:0,
					num_edge_entries:0,
					link_to:"#",
					prev_text:"Prev",
					next_text:"Next",
					ellipse_text:"...",
					prev_show_always:true,
					next_show_always:true,
					renderer:"defaultRenderer",
					callback:function(){return false;}
				    },opts||{});
				    
				    var containers = this,
				    renderer, links, current_page;
				    
				    /**
				     * This is the event handling function for the pagination links. 
				     * @param {int} page_id The new page number
				     */
				    function paginationClickHandler(evt){
					var links, 
					new_current_page = $(evt.target).data('page_id'),
				     continuePropagation = selectPage(new_current_page);
				     if (!continuePropagation) {
					 evt.stopPropagation();
				     }
				     return continuePropagation;
				    }
				    
				    /**
				     * This is a utility function for the internal event handlers. 
				     * It sets the new current page on the pagination container objects, 
				     * generates a new HTMl fragment for the pagination links and calls
				     * the callback function.
				     */
				    function selectPage(new_current_page) {
					// update the link display of a all containers
					containers.data('current_page', new_current_page);
			links = renderer.getLinks(new_current_page, paginationClickHandler);
			containers.empty();
			links.appendTo(containers);
			// call the callback and propagate the event if it does not return false
			var continuePropagation = opts.callback(new_current_page, containers);
			return continuePropagation;
				    }
				    
				    // -----------------------------------
				    // Initialize containers
				    // -----------------------------------
				    current_page = opts.current_page;
				    containers.data('current_page', current_page);
		// Create a sane value for maxentries and items_per_page
		maxentries = (!maxentries || maxentries < 0)?1:maxentries;
		opts.items_per_page = (!opts.items_per_page || opts.items_per_page < 0)?1:opts.items_per_page;
		
		if(!$.PaginationRenderers[opts.renderer])
		{
		    throw new ReferenceError("Pagination renderer '" + opts.renderer + "' was not found in jQuery.PaginationRenderers object.");
		}
		renderer = new $.PaginationRenderers[opts.renderer](maxentries, opts);
		
		// Attach control events to the DOM elements
		var pc = new $.PaginationCalculator(maxentries, opts);
		var np = pc.numPages();
		containers.bind('setPage', {numPages:np}, function(evt, page_id) { 
		    if(page_id >= 0 && page_id < evt.data.numPages) {
			selectPage(page_id); return false;
		    }
		});
		containers.bind('prevPage', function(evt){
		    var current_page = $(this).data('current_page');
		if (current_page > 0) {
		    selectPage(current_page - 1);
		}
		return false;
		});
containers.bind('nextPage', {numPages:np}, function(evt){
    var current_page = $(this).data('current_page');
    if(current_page < evt.data.numPages - 1) {
	selectPage(current_page + 1);
    }
    return false;
});

// When all initialisation is done, draw the links
links = renderer.getLinks(current_page, paginationClickHandler);
containers.empty();
links.appendTo(containers);
// call callback function
opts.callback(current_page, containers);
				} // End of $.fn.pagination block
				
				})(jQuery);
				
