var enableSifr = true;
	
// prevent queue timeout
if (typeof Xajax != 'undefined')
	window.setInterval("xajax_UpdateActivity()", 270000);

$(function() {
	/**
	 * anchors (external/popup) 
	 */
	var oPopWin = null;
	
	$("a[rel='external']").click(function(){window.open(this.href); return false});
	$("a[rel='popup']").click(function(){
		popWin = new PopupWindow();
		popWin.anchor = $(this);
		popWin.width = 500;
		popWin.height = 500;
		if (popWin.spawn())
			return false;
	});
	
	// IR
	$("#mainMenu > ul > li > a").ImageReplace();	
	
	// Img overlay
	$("body.informatie #pageImageContainer img").ImageOverlay();
	
	// hoofmenu vertikaal
	var menuVertical = new DickerFisch('#mainMenu',{Effect:0});
	
	// ie6 fix selects<>dropmenu
	if ($.browser.msie && parseFloat($.browser.version) < 7) {
		$('#mainMenu ul>li:gt(3):has(ul)').hover(function(){
			$('#formCalendar select').css('visibility', 'hidden');
		},
		function(){
			$('#formCalendar select').css('visibility', 'visible');
		});
	}
	
	// default teksten voor zoeken
	sDefaultZoekTxt = 'trefwoord...';
	$("#formZoekenInput").focus(function(){
		if (this.value == sDefaultZoekTxt)
			this.value = '';
	});
	$("#formZoekenInput").blur(function(){
		if (this.value == '')
			this.value = sDefaultZoekTxt;
	});
	
	
	// default teksten voor nieuwsbriefaanmelden.
	
	sDefaultEmailTxt = 'Vul hier uw e-mailadres in...';
	$("#formNieuwsbriefAanmeldenEmail").focus(function(){
		if (this.value == sDefaultEmailTxt)
			this.value = '';
	});
	$("#formNieuwsbriefAanmeldenEmail").blur(function(){
		if (this.value == '')
			this.value = sDefaultEmailTxt;
	});
	$(".overzichtItem").hover(
	  function () {        
		 $(this).find("div[className^='flash']").addClass("flashJS");	
	  },
	  function () {
	     $(this).find("div[className^='flash']").removeClass("flashJS");		 
	  }
	);
		
	
	// MouseOver effect op submit buttons
	
	$('input.txtLink').hover(function() {
			$(this).addClass('txtLinkHover');
		}, function() {
	  	$(this).removeClass('txtLinkHover');
		}); 
		$('input.button, input.buttonlb, input.buttonld').hover(function() {
			$(this).addClass('btnHover');
		}, function() {
	  	$(this).removeClass('btnHover');
		}); 	
	$('input.buttonrb').hover(function() {
			$(this).addClass('btnHoverrb');
		}, function() {
	  	$(this).removeClass('btnHoverrb');
		}); 
	$('input.buttonText').hover(function() {
			$(this).addClass('btnHoverText');
		}, function() {
	  	$(this).removeClass('btnHoverText');
		});	
	$('.buttonlb').hover(function() {
			$(this).addClass('btnNormaalHover');
		}, function() {
	  	$(this).removeClass('btnNormaalHover');
		});		
	$('input.btnWinkelwagentje').hover(function() {
			$(this).attr('src', '/images/btn_winkelwagentje_over.png');
		}, function() {
	  	$(this).attr('src', '/images/btn_winkelwagentje.png');
		});	
	
	$('div.overzichtItem').hover(function() {
		$(this).addClass('overzichtItemHover');
	}, function() {
  		$(this).removeClass('overzichtItemHover');
	});	
	
	
	// voorstelling items clickable
	$('#bodyVoorstellingen .progOverzicht li').click(function(){
		var href = $(this).find('.progArtiest a').attr('href');
		window.location.href = href;
	});
	$('#bodyVoorstellingen .progOverzicht li input,#bodyVoorstellingen .progOverzicht li a').click(function(e){
		e.stopPropagation();
	});	
});



/**
 * Image Replace
 * Appends some spans to selection, so with css nice IR can happen
 * @author arjen
 *
 *
 */

jQuery.fn.ImageReplace = function() {
	this.each(function() {
		$(this).addClass('ir');
		$(this).append('<span class="ir-aid"></span>');
	});
}


/**
 * PopupWindow object
 * spwans/handles popup windows
 * 
 * @author arjen
 * 
 * dependancies: jQuery 1.2.x
 */

function PopupWindow() {
	this.width = 500;
	this.height = 500;
	this.container = $(window);
	this.offsetLeft = 0;
	this.offsetTop = 0;
	this.menubar = true;
	this.location = false;
	this.resizable = true;
	this.scrollbars = true;
	this.status = true;
	this.name = 'popupWindow';
	this.url = ''; 
}
PopupWindow.prototype.prepare = function () {
	oAnchor = this.anchor;
	if (typeof oAnchor.data('popWinObject') == 'object') {
		oPopWin = oAnchor.data('popWinObject');
		if (!oPopWin.closed)
			oPopWin.close();	
	}
	sHref = oAnchor.attr('href');
	if (sHref.indexOf('?') > -1)
		sHref += '&';
	else
		sHref += '?';	
	sHref += 'popup=true';
	this.url = sHref;
}
PopupWindow.prototype.spawn = function() {
	this.prepare();
	var x = this.container.width() / 2 - (this.width/2);
    var y = this.container.height() / 2 - (this.hegiht/2);
	if (x < 0) x = 0;
	if (y < 0) y = 0;
	this.offsetLeft = x;
	this.offsetTop = y;
	
	oPopWin = window.open(this.url, this.name, 'width='+this.width+',height='+this.height+',left='+this.offsetLeft+',top='+this.offsetTop);
	
	if (typeof oPopWin != 'undefined') {
		this.anchor.data('popWinObject', oPopWin);
		//popupWindows.push(oPopWin);
		return true;
	}
	return false;
}



/**
 * sIFR
 */
if (enableSifr && typeof sIFR != "undefined") {

	var swissNarrow = {
		src: '/flash/swissNarrow.swf',
		ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
	};
	sIFR.useStyleCheck = true;
	sIFR.activate(swissNarrow);
	
	sIFR.replace(swissNarrow, {
		selector: 'body.sifr-default .progInfo-tekst .flash1',
		wmode: 'transparent',
		css: ['.sIFR-root { font-size: 20px; }', 'a { text-decoration: none; }', 'a:link { color: #93ae16; }', 'a:hover { color: #300020; }']
	});
	sIFR.replace(swissNarrow, {
		selector: '.progInfo-tekst .flash4',
		wmode: 'transparent',
		css: ['.sIFR-root { font-size: 20px; }', 'a { text-decoration: none; }', 'a:link { color: #93ae16; }', 'a:hover { color: #300020; }']
	});
	sIFR.replace(swissNarrow, {
		selector: 'body.sifr-voorstelling .progInfo-tekst .flash1, #reserveer .progInfo-tekst .flash1',
		wmode: 'transparent',
		css: ['.sIFR-root { font-size: 20px; color: #93ae16; }', 'span { color: #93ae16; }']
	});
	sIFR.replace(swissNarrow, {
		selector: '.progDatum .flash2',
		wmode: 'transparent',
		css: ['.sIFR-root { font-size: 14px; color: #ffffff; text-align: center; }', 'span { color: #ffffff; }']
	});
	sIFR.replace(swissNarrow, {
		selector: '.progInfo-tekst .flash3',
		wmode: 'transparent',
		css: ['.sIFR-root { font-size: 20px; color: #AF4B76; }', 'span { color: #AF4B76; }']
	});
	
	sIFR.replace(swissNarrow, {
		selector: '.mijntheater .progInfo-tekst .flash1',
		wmode: 'transparent',
		css: ['.sIFR-root { font-size: 20px; color: #AF4B76; }', 'a { text-decoration: none; }', 'a:link { color: #93ae16; }', 'a:hover { color: #300020; }']
	});
	
}

/**
 * Image Overlay
 * 
 * @version 1.0.0-Isala-1.0.0
 * @author arjen
 */

jQuery.fn.ImageOverlay = function(options) {
	var defaults = {
		type: 'simple'
	}
	var options = $.extend(defaults, options);

	// need proper png support
	/*
	if ($.browser.msie && parseFloat($.browser.version) < 7)
		return false;	
	*/
	
	this.each(function(){
		var $this = $(this);			
		$this
			.wrap('<span class="imgOverlayWrap"/>')
			.after('<span class="imgOverlayAid"/>')
			.parent()
			.width($this.width())
			.height($this.height())
			.end();
	});
}