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

	Package: FestivalWWW 2009
	Title: Default JS file
	File: festivalwww.js
	Version: 1.0
	Date/Time: 2009-07-20 14:45
	Author name: Adal Hernandez Fraile
	Author organisation: AFFIRMA
	Author URI: www.affirma.nu
	Author contact details: <support [at] affirma [dot] nu>
	Copyright: (c) 2009 Adal Hernandez Fraile // AFFIRMA
	Acknowledgements:
					- mootools Core & More libraries: http://mootools.net/
					- Google Ajax Feed API: http://code.google.com/apis/ajaxfeeds/
					- gAjax RSS Feeds Displayer: http://www.dynamicdrive.com/
					- AJAX Loader: http://ajaxload.info/

	Description: Default JS file used at festivalwww.nl

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

window.addEvent("domready", function() {

	Application = new Controller();

	Application.init();


});


Controller = new Class({

		Implements: [Options, Events],
        options: {
			siteBaseURI : $$('base')[0].get('href'),
			blogFeedBaseURI : $$('link[rel=service.post]').get('href'),
			ajaxRequestSuffix : '/raw',
			draggablesHighestZIndex : 3,
			paginationLimit : 5
        },
        init: function(){
			this.setupSiteNav();
			this.activateContest();
			this.activateNewsletterSubscribe();
			this.loadTweets();
			this.gaTrack();
        },
		setupSiteNav: function(){
			this.activateHomeLink();
			this.setupDraggables();
			this.activateExternalImgLinks();
		},
		activateHomeLink: function(){
			$$('#logo_block').addEvents({
				'click': function (e){
					Application.hideDraggables();
					Application.deactivateAllMenuItems();
				}
			});
		},
		setupDraggables: function(options){

			$$('#draggables div.draggable').each(function(o){
				new Drag.Move(o, {
					handle: $(o).getElement('div.draggable_header div.draggable_mover_container')
				});

			});

			$$('#programme_menu li a').each(function(o){
				$(o).addEvents({'click' : function(event){

							Application.deactivateAllMenuItems();
							Application.activateMenuItem($$(o)[0]);
							Application.activateMenuItem($$('#main_menu li a#programme')[0]);
							Application.activateMenuItem($$('a#programme_draggable_'+$$(o)[0].get('id'))[0]);


							targetURI = $(o).get('href').replace(Application.options.siteBaseURI, '');
							targetURI = targetURI.replace(/programme\//g, '');
							if(targetURI.indexOf('/')!=-1){
								hrefSplit = targetURI.split('/');
								targetURI = hrefSplit[0];
							}
							switch(targetURI){
								case 'exhibitions': targetURI = 'Exposities';
													break;
								case 'performances': targetURI = 'Performances';
													break;
								case 'street-art': targetURI = 'Beeldende%20kunst%20op%20straat';
													break;
								case 'fashion':	targetURI = 'Mode';
												break;
								case 'dance-drink-eat': targetURI = 'Dansen%20/%20drinken%20/%20eten';
													break;
								case 'children': targetURI = 'Kinderen';
													break;
							}

							$('programme_draggable_navigation').setStyle('display', 'block');
							$('programme_draggable_header').getElements('img.draggable_toggler')[0].set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_p.gif');
							$('programme_draggable_header').getElements('img.draggable_toggler')[0].set('state', 'toggled');

							programmeLabelfeed=new gfeedfetcher("programme_draggable_content", 'programme_item_title', "");
							programmeLabelfeed.addFeed("FestivalWWW Programma / "+targetURI, Application.options.blogFeedBaseURI+'?category='+targetURI);
							programmeLabelfeed.displayoptions("description");
							programmeLabelfeed.setentrycontainer("h2");
							programmeLabelfeed.filterfeed(Application.options.paginationLimit, "date");
							programmeLabelfeed.init();

							Application.bringDraggableToForeground($('programme_draggable'));
							event.stop();
						}
				});

			});

			$$('#programme_draggable_navigation span a').each(function(o){
				$(o).addEvents({'click' : function(event){

							Application.deactivateAllMenuItems();
							Application.activateMenuItem($$(o)[0]);
							Application.activateMenuItem($$('#main_menu li a#programme')[0]);
							menuItemId=$$(o)[0].get('id').replace(/programme_draggable_/g,'');
							if($$('#programme_menu li a#'+menuItemId)[0]!=null){
								Application.activateMenuItem($$('#programme_menu li a#'+menuItemId)[0]);
							}

							targetURI = $(o).get('href').replace(Application.options.siteBaseURI, '');
							targetURI = targetURI.replace(/programme\//g, '');
							if(targetURI.indexOf('/')!=-1){
								hrefSplit = targetURI.split('/');
								targetURI = hrefSplit[0];
							}
							switch(targetURI){
								case 'exhibitions': targetURI = 'Exposities';
													break;
								case 'performances': targetURI = 'Performances';
													break;
								case 'street-art': targetURI = 'Beeldende%20kunst%20op%20straat';
													break;
								case 'fashion':	targetURI = 'Mode';
												break;
								case 'dance-drink-eat': targetURI = 'Dansen%20/%20drinken%20/%20eten';
													break;
								case 'children': targetURI = 'Kinderen';
													break;
								case 'do-it': targetURI = 'Doen';
													break;
								case 'a-z': targetURI = 'Programma';
													break;
							}

							programmeLabelfeed2=new gfeedfetcher("programme_draggable_content", 'programme_item_title', "");
							programmeLabelfeed2.addFeed("FestivalWWW Programma / "+targetURI, Application.options.blogFeedBaseURI+'?category='+targetURI);
							programmeLabelfeed2.displayoptions("description");
							programmeLabelfeed2.setentrycontainer("h2");
							programmeLabelfeed2.filterfeed(Application.options.paginationLimit, "date");
							programmeLabelfeed2.init();

							Application.bringDraggableToForeground($('programme_draggable'));
							event.stop();
						}
				});

			});

			$$('#main_menu li a').each(function(o){
				$(o).addEvents({'click' : function(event){

							Application.deactivateAllMenuItems();
							Application.activateMenuItem($$(o)[0]);

							targetURI = $(o).get('href').replace(Application.options.siteBaseURI, '');
							if(targetURI.indexOf('/')!=-1){
								hrefSplit = targetURI.split('/');
								targetURI = hrefSplit[0];
							}

							switch(targetURI){
								case 'programme':
								case 'news':
											if(targetURI=='programme'){
												$('programme_draggable_navigation').setStyle('display', 'block');
											}
											feedLabel = (targetURI=='programme')?'Programma':'Nieuws';
											feedContainer = targetURI+'_draggable_content';
											itemClass = targetURI+'_item_title';
											feed=new gfeedfetcher(feedContainer, itemClass, "");
											feed.addFeed("FestivalWWW "+feedLabel, Application.options.blogFeedBaseURI+'?category='+feedLabel);
											feed.displayoptions("description "+((targetURI=='news')?"date":""));
											feed.setentrycontainer("h2");
											feed.filterfeed(Application.options.paginationLimit, "date");
											feed.init();

											break;
								case 'festival_info':
								case 'participants':
								case 'press':
								case 'archive':new Request.HTML({
														method: 'get',
														url: Application.options.siteBaseURI+targetURI+Application.options.ajaxRequestSuffix,
														onRequest: function() {
															Application.diplayAjaxLoader($$('#'+o.id+'_draggable_content'));
														},
														onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript) {
															$$('#'+o.id+'_draggable_content').set('html', responseHTML);
															Application.activateExternalImgLinks();

														},
														onFailure: function(xhr) {
															Application.displayMsg($$('#'+o.id+'_draggable_content'), 'error');
														}
													}).send();
													break;
							}
							$(targetURI+'_draggable_header').getElements('img.draggable_toggler')[0].set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_p.gif');
							$(targetURI+'_draggable_header').getElements('img.draggable_toggler')[0].set('state', 'toggled');
							Application.bringDraggableToForeground($(o.id+'_draggable'));
							event.stop();
						}
				});

			});

			$$('#service_menu li a').each(function(o){
				$(o).addEvents({'click' : function(event){

							Application.deactivateAllMenuItems();
							Application.activateMenuItem($$(o)[0]);

							targetURI = $(o).get('href').replace(Application.options.siteBaseURI, '');
							if(targetURI.indexOf('/')!=-1){
								hrefSplit = targetURI.split('/');
								targetURI = hrefSplit[0];
							}
							new Request.HTML({
								method: 'get',
								url: Application.options.siteBaseURI+targetURI+Application.options.ajaxRequestSuffix,
								onRequest: function() {
									Application.diplayAjaxLoader($$('#'+o.id+'_draggable_content'));
								},
								onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript) {
									$$('#'+o.id+'_draggable_content').set('html', responseHTML);
									Application.activateExternalImgLinks();

								},
								onFailure: function(xhr) {
									Application.displayMsg($$('#'+o.id+'_draggable_content'), 'error');
								}
							}).send();
							$(targetURI+'_draggable_header').getElements('img.draggable_toggler')[0].set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_p.gif');
							$(targetURI+'_draggable_header').getElements('img.draggable_toggler')[0].set('state', 'toggled');
							Application.bringDraggableToForeground($(o.id+'_draggable'));
							event.stop();
						}
				});

			});

			$$('.draggable_mover').each(function(o){
				$(o).addEvents({'mouseover' : function(event){
							$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/drag_a.gif');

						},
						'mouseout' : function(event){
							$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/drag_p.gif');

						}
				});
			});

			$$('.draggable_toggler').each(function(o){
				$(o).addEvents({'mouseover' : function(event){
								if($(o).get('state')){
									if($(o).get('state')=='toggled'){
										$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_a.gif');
									} else if($(o).get('state')=='untoggled') {
										$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/untoggle_a.gif');
									}
								} else {
									$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_a.gif');
								}

							},
							'mouseout' : function(event){
								if($(o).get('state')){
									if($(o).get('state')=='toggled'){
										$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_p.gif');
									} else if($(o).get('state')=='untoggled') {
										$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/untoggle_p.gif');
									}
								} else {
									$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_p.gif');
								}

							},'click' : function(event){

								if($(o).get('state')){
									if($(o).get('state')=='toggled') {
										$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/untoggle_p.gif');
										$(o).set('state', 'untoggled');
										$($(o).getOffsetParent().id+'_content').setStyle('display', 'none');
										if($(o).getOffsetParent().id=='programme_draggable')
											$($(o).getOffsetParent().id+'_navigation').setStyle('display', 'none');
									} else {
										$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/toggle_p.gif');
										$(o).set('state', 'toggled');
										$($(o).getOffsetParent().id+'_content').setStyle('display', 'block');
										if($(o).getOffsetParent().id=='programme_draggable')
											$($(o).getOffsetParent().id+'_navigation').setStyle('display', 'block');
									}
								} else {
									$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/untoggle_p.gif');
									$(o).set('state', 'untoggled');
									$($(o).getOffsetParent().id+'_content').setStyle('display', 'none');
									if($(o).getOffsetParent().id=='programme_draggable')
											$($(o).getOffsetParent().id+'_navigation').setStyle('display', 'none');
								}


							}
				});
			});

			$$('.draggable_closer').each(function(o){
				$(o).addEvents({'mouseover' : function(event){
							$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/close_a.gif');

						},
						'mouseout' : function(event){
							$(o).set('src', Application.options.siteBaseURI+'templates/festivalwww_2009/img/close_p.gif');

						}, 'click' : function(event){
							Application.deactivateAllMenuItems();
							draggableContainer = $$(o)[0];
							draggableContainer = draggableContainer.getOffsetParent();
							new Fx.Reveal(draggableContainer).dissolve();
							draggableContainer.addEvents({'click' : function(event){
									draggableId = draggableContainer.get('id').replace(/_draggable/g, "");
									if(draggableId.indexOf('service_disruption')==-1){
										Application.deactivateMenuItem($$('#'+draggableId)[0]);
									}
									event.stop();
								}
							});
						}
				});
			});

		},
		bringDraggableToForeground : function(o){
			Application.options.draggablesHighestZIndex++;
			$(o).setStyle('z-Index',Application.options.draggablesHighestZIndex);
			$(o).setStyle('display', 'block');
			$(o).addEvents({'click' : function(event){
					Application.options.draggablesHighestZIndex++;
					$(o).setStyle('z-Index',Application.options.draggablesHighestZIndex);
					draggableId = $(o).get('id').replace(/_draggable/g, "");
					if(draggableId != 'programme')
						Application.deactivateAllMenuItems();
					else
						Application.deactivateAllMenuItems('programme');
					if(draggableId.indexOf('service_disruption')==-1)
						Application.activateMenuItem($$('#'+draggableId)[0]);
				}
			});
		},
		drawAccordion: function(feedContainerId){
			accordion = new Accordion('div#'+feedContainerId+' h2.atStart', 'div#'+feedContainerId+' div.atStart', {
				opacity: false,
				duration: 2000,
				transition: Fx.Transitions.Expo.easeOut,
				display: 0,
				show: 0,
				onActive: function(toggler, element){
						toggler.addClass('toggle-hilite');
				},
				onBackground: function(toggler, element){
					toggler.removeClass('toggle-hilite');
				}
			});
			Application.activateExternalImgLinks();
		},
		hideDraggables: function(){
			$$('.draggable').each(function(o){
				new Fx.Reveal($(o)).dissolve();

			});

		},
		activateMenuItem: function(o){
			$(o).addClass('active');

		},
		deactivateMenuItem: function(o){
			$(o).removeClass('active');

		},
		deactivateAllMenuItems: function(excludedType){

			if(excludedType!='programme') {
				$$('#programme_menu li a').each(function(obj1){
					$(obj1).removeClass('active');
				});
			}

			$$('#main_menu li a').each(function(obj2){
				$(obj2).removeClass('active');
			});

			$$('#service_menu li a').each(function(obj3){
				$(obj3).removeClass('active');
			});

			if(excludedType!='programme') {
				$$('#programme_draggable_navigation span a').each(function(obj4){
					$(obj4).removeClass('active');
				});
			}

		},
		activateExternalImgLinks: function(){

			$$('a img').each(function(o){
				$(o).getParent().addEvent('mouseover', function(event){
					$(o).getParent().setStyle('background-color', 'transparent');}
				);

			});

			$$('div#programme_content a img').each(function(o){
				$(o).getParent().set('target','_blank');
			});

			$$('div#programme_draggable_content div.element a img').each(function(o){
				$(o).getParent().set('target','_blank');
			});

			$$('div#programme_draggable_content div.element p a img').each(function(o){
				$(o).getParent().set('target','_blank');
			});

			$$('div#news_content a img').each(function(o){
				$(o).getParent().set('target','_blank');

			});

			$$('div#news_draggable_content div.element a img').each(function(o){
				$(o).getParent().set('target','_blank');
			});

			$$('div#news_draggable_content div.element p a img').each(function(o){
				$(o).getParent().set('target','_blank');
			});

			$$('div.content_column div a img').each(function(o){
				$(o).getParent().addEvent('mouseover', function(event){
					$(o).getParent().setStyle('background-color', 'transparent');}
				);
			});


		},
		activateContest: function(){
			$$('#contest_phrase').each(function(o){
				$(o).addEvents({
					'click': function(e){
								if($(o).get('value')=="Ik..."){
									$(o).set('value', '');
								}
								$$('div#contest_hidden_fields').setStyle('display', 'block');
							}
					,'blur': function(e){
								if($(o).get('value') == null || $(o).get('value').length == 0){
									$(o).set('value', 'Ik...');
								}
							}
				});

			});
			$$('#contest_name').each(function(o){
				$(o).addEvents({
					'click': function(e){
								if($(o).get('value')=="je naam"){
									$(o).set('value', '');
								}
							}
					,'blur': function(e){
								if($(o).get('value') == null || $(o).get('value').length == 0){
									$(o).set('value', 'je naam');
								}
							}
				});

			});
			$$('#contest_email').each(function(o){
				$(o).addEvents({
					'click': function(e){
								if($(o).get('value')=="je emailadres"){
									$(o).set('value', '');
								}
							}
					,'blur': function(e){
								if($(o).get('value') == null || $(o).get('value').length == 0){
									$(o).set('value', 'je emailadres');
								}
							}
				});

			});
			$$('#contest').each(function(o){
				$(o).addEvent('submit', function(e){
					validFrm = true;
					isEmpty = new InputValidator('required', {
					  errorMsg: false,
					  test: function(field){
						return ((field.get('value') == null) || (field.get('value').length == 0));
					  }
					});
					containsDefaultValue = new InputValidator('validate-not-default', {
					  errorMsg: false,
					  test: function(field, value){
						return (field.get('value') == value);
					  }
					});
					isTooLong = new InputValidator('validate-too-long', {
					  errorMsg: false,
					  test: function(field){
						return (field.get('value').length > 100);
					  }
					});
					isValidEmail = new InputValidator('validate-email', {
					  errorMsg: false,
					  test: function(field){
						return (field.get('value').search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
					  }
					});
					if(isEmpty.test($("contest_email")) || isEmpty.test($("contest_name")) || isEmpty.test($("contest_phrase"))
						|| containsDefaultValue.test($("contest_email"), 'je emailadres')
						|| containsDefaultValue.test($("contest_name"), 'je naam')
						|| containsDefaultValue.test($("contest_phrase"), 'Ik...') ){
						validFrm = false;
						Application.displayMsg($('contest_validation'), 'error', 'Alle velden zijn verplicht!');
					}
					if(validFrm && isTooLong.test($("contest_phrase"))){
						validFrm = false;
						Application.displayMsg($('contest_validation'), 'error', 'Je bericht mag maximaal 100 tekens bevatten!');
					}
					if(validFrm && !isValidEmail.test($("contest_email"))){
						validFrm = false;
						Application.displayMsg($('contest_validation'), 'error', 'Ongeldig e-mailadres!');
					}
					if(validFrm){
						$(o).set('send', {
							url: Application.options.siteBaseURI+$(o).get('action')+Application.options.ajaxRequestSuffix,
							method: 'post',
							onRequest: function() {
								Application.diplayAjaxLoader($('contest_validation'));
							},
							onComplete: function(response) {
								Application.displayMsg($('contest_validation'), 'successfull', response);
								$(o).reset();
								$$('div#contest_hidden_fields').setStyle('display', 'none');
							},
							onFailure: function(xhr) {
								Application.displayMsg($('contest_validation'), 'error');
								$$('div#contest_hidden_fields').setStyle('display', 'block');
							}
						});
						$(o).send();
						e.stop();
					}
					e.stop();
				});
			});
			customTips = $$('.tooltip');
			toolTips = new Tips(customTips, {
				showDelay: 500,
				hideDelay: 0,
				className: 'contest_tooltip',
				offsets: {
					'x': 24,
					'y': 0
				},
				fixed: true,
				onShow: function(toolTipElement){
					toolTipElement.setStyle('display', 'block');
					toolTipElement.fade(1);
				},
				onHide: function(toolTipElement){
					toolTipElement.setStyle('display', 'block');
					fadeIt = function(){
						this.fade(0);
					};
					fadeIt.delay(5000, toolTipElement);
				}
			});
			$('contest_tooltip').store('tip:text', 'Wanneer ben jij over je grens gegaan? Vertel ons over een mooie/ ontroerende/ welgemeende/ ondoordachte grensoverschrijding. (maximaal 100 tekens).<br /><br />De beste inzendingen plaatsen we op de homepage.<br /><br />Nieuwsgierig naar alle inzendingen? Klik dan <a href="http://twitter.com/grenzen_www" target="_blank">hier</a>');

		},
		loadTweets: function(){
			new Asset.javascript('http://twitter.com/statuses/user_timeline/grenzen_www.json?callback=Application.displayTweets&count=2');
		},
		displayTweets: function(twitters){
		  var statusHTML = [];
		  for (var i=0; i<twitters.length; i++){
			var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
			  return '<a href="'+url+'">'+url+'</a>';
			});
			statusHTML.push('<div class="tweet_container"><div class="tweet_container_top"></div><div class="tweet_phrase">'+status+'</div><div class="tweet_container_bottom"></div></div>');
		  }
		  $$('div#twitter_block').set('html', statusHTML.join(''));

		},
		activateNewsletterSubscribe: function(){

			$$('#newsletter').each(function(o){
				$(o).addEvent('submit', function(e){
					validFrm = true;
					isEmpty = new InputValidator('required', {
					  errorMsg: false,
					  test: function(field){
						return ((field.get('value') == null) || (field.get('value').length == 0));
					  }
					});
					isValidEmail = new InputValidator('validate-email', {
					  errorMsg: false,
					  test: function(field){
						return (field.get('value').search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
					  }
					});
					if(isEmpty.test($("e-mail")) || isEmpty.test($("voornaam")) || isEmpty.test($("achternaam"))){
						validFrm = false;
						Application.displayMsg($('newsletter_validation'), 'error', 'Alle velden zijn verplicht!');
					}
					if(!isValidEmail.test($("e-mail"))){
						validFrm = false;
						Application.displayMsg($('newsletter_validation'), 'error', 'Ongeldig e-mailadres!');
					}
					if(validFrm){
						$(o).set('send', {
							url: Application.options.siteBaseURI+$(o).get('action')+Application.options.ajaxRequestSuffix,
							method: 'post',
							onRequest: function() {
								Application.diplayAjaxLoader($('newsletter_validation'));
							},
							onComplete: function(response) {
								Application.displayMsg($('newsletter_validation'), 'successfull', response);
							},
							onFailure: function(xhr) {
								Application.displayMsg($('newsletter_validation'), 'error');
							}
						});
						$(o).send();
						e.stop();
					}
					e.stop();
				});
			});
		},
		diplayAjaxLoader: function(o){
			$$(o).set('html', '<div align="center" style="padding-top: 10px"><img src="'+Application.options.siteBaseURI+'templates/festivalwww_2009/img/ajax-loader.gif" alt="bezig met gegevens laden" /></div>');
			$$(o).setStyle('display', 'block');
		},
		displayMsg: function(o, msgType, msg){
			className = (msgType)?'class="'+msgType+'"':'';
			msg = (msgType=='successfull' || (msgType=='error' && msg))?msg:'Curieus, er is iets misgegaan...<br />Probeer het nu nog eens.';
			$$(o).set('html', '<div '+className+'>'+msg+'</div>');
			$$(o).setStyle('display', 'block');
		},
		displayPaginatedFeed: function (feed, direction){
			containerType=feed.feedcontainer.id.split('_');
			itemClass = containerType[0]+'_item_title';
			if(direction=='left'){
				feed.startIndex=feed.startIndex-Application.options.paginationLimit;
			} else {
				feed.startIndex=feed.startIndex+Application.options.paginationLimit;
			}
			if(feed.feedurls.toString().indexOf('&')>-1){
				feedURLBaseSplitted = feed.feedurls.toString().split('&');
				feedURLBase = feedURLBaseSplitted[0];
			} else {
				feedURLBase = feed.feedurls;
			}
			url = feedURLBase+'&start-index='+feed.startIndex;
			paginatedFeed=new gfeedfetcher(feed.feedcontainer.id, itemClass, "", feed.startIndex);
			paginatedFeed.addFeed("FestivalWWW ", url);
			paginatedFeed.displayoptions("description");
			paginatedFeed.setentrycontainer("h2");
			paginatedFeed.filterfeed(Application.options.paginationLimit, "date");
			paginatedFeed.init();

		},
		displayFeedTunners: function(feed){
			containerType=feed.feedcontainer.id.split('_');
			tunnerLeftText=(containerType[0]=='programme')?'vorige pagina':'nieuwere berichten';
			tunnerRightText=(containerType[0]=='programme')?'volgende pagina':'eerdere berichten';
			feedTunners = '<div id="'+containerType[0]+'_ajaxLoader" align="center" style="padding-top: 10px"><img src="'+Application.options.siteBaseURI+'templates/festivalwww_2009/img/ajax-loader.gif" alt="bezig met gegevens laden" /></div><div class="feed_tunner"><div id="feed_tunner_left_wrapper"><a id="'+containerType[0]+'_feed_tunner_left" style="display: none">'+tunnerLeftText+'</a></div><div id="feed_tunner_right_wrapper"><a id="'+containerType[0]+'_feed_tunner_right" style="display: none">'+tunnerRightText+'</a></div></div>';

			$(feed.feedcontainer.id).set('html', $(feed.feedcontainer.id).get('html')+feedTunners);
			if(feed.feedurls.toString().indexOf('&')>-1){
				feedURLBaseSplitted = feed.feedurls.toString().split('&');
				feedURLBase = feedURLBaseSplitted[0];
			} else {
				feedURLBase = feed.feedurls;
			}
			if(feed.startIndex-Application.options.paginationLimit>=1){
				var feed1 = new google.feeds.Feed(feedURLBase+'&start-index='+(feed.startIndex-Application.options.paginationLimit)+'&max-results=5');
				feed1.load(function(result1) {
					if (!result1.error) {
						document.getElementById(containerType[0]+'_ajaxLoader').style.display = 'none';
						document.getElementById(containerType[0]+'_feed_tunner_left').style.display = (result1.feed.entries.length>0)?'inline':'none';
						document.getElementById(containerType[0]+'_feed_tunner_left').onclick=function(){
							Application.displayPaginatedFeed(feed, 'left');
						}
					} else {
						document.getElementById(containerType[0]+'_ajaxLoader').style.display = 'none';
					}

				});
			}
			var feed2 = new google.feeds.Feed(feedURLBase+'&start-index='+(feed.startIndex+Application.options.paginationLimit)+'&max-results=5');
			feed2.load(function(result2) {
				if (!result2.error) {
						document.getElementById(containerType[0]+'_ajaxLoader').style.display = 'none';
						document.getElementById(containerType[0]+'_feed_tunner_right').style.display = (result2.feed.entries.length>0)?'inline':'none';
						document.getElementById(containerType[0]+'_feed_tunner_right').onclick=function(){
						Application.displayPaginatedFeed(feed, 'right');
					}
				} else {
					document.getElementById(containerType[0]+'_ajaxLoader').style.display = 'none';
				}
			});

		},
		displayServiceDisruptionMsg: function(level){
			var msg = '';
			switch(level){
				case 1:	msg = 'Delen van de website zijn tijdelijk niet beschikbaar.<br />Excuses voor het ongemak, probeer het later nog een keer.';
						break;
				case 2: msg = 'Door overweldigende belangstelling is de website festivalwww.nl tijdelijk niet beschikbaar.<br />Bezoek onze <a href="http://festivalwww.hyves.nl/" target="_blank">hyves</a>, <a href="http://www.facebook.com/profile.php?id=100000072054487&hiq=witte%2Cde%2Cwith&ref=search" target="_blank">facebook</a> of <a href="http://festivalwww.blogspot.com" target="_blank">weblog</a> voor actuele informatie over festival De Wereld van Witte de With.<br />Excuses voor het ongemak.';
						break;
			}
			$$('#service_disruption_draggable')[0].setStyle('display', 'block');
			$$('#service_disruption_draggable_content')[0].set('html', msg);
			Application.bringDraggableToForeground($('service_disruption_draggable'));
		},
		gaTrack: function(){
			var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
			new Asset.javascript(gaJsHost + "google-analytics.com/ga.js", {
				onload: function() {
					var pageTracker = _gat._getTracker("UA-2562525-1");
					pageTracker._initData();
					pageTracker._trackPageview();
				}
			});
		}
});