$(document).ready(function() {
	$('.blank').attr('target','_blank')
						   
	$('.newsletter .input input').focus(function(){
		if ( $(this).attr('value') == 'Vul hier je e-mail adres in'){
			$(this).attr('value','');
			$(this).addClass('act');
		}
	})

	$('.newsletter .input input').blur(function(){
		if ( $(this).attr('value') == ''){
			$(this).attr('value','Vul hier je e-mail adres in');
			$(this).removeClass('act');
		}
	})
	
	$('.newsletter .submit input').hover(
		function(){ $(this).addClass('hover');},
		function(){ $(this).removeClass('hover');}
	)

	Cufon.replace('.slogan');
	Cufon.replace('h3.title');
	Cufon.replace('.listing .time');
	Cufon.replace('.tags');
	Cufon.replace('.dayname');
	Cufon.replace('.day');
	Cufon.replace('.news h2, .news h1');
	Cufon.replace('.donate h2');
	Cufon.replace('.sponsors h2');
	
	$(".thumbs").scrollable({circular:false, size:7, speed:800, clickable:false}).mousewheel().navigator();
//	var scroller = 	$(".thumbs").scrollable({circular:false, size:7, speed:800, clickable:false}).mousewheel().navigator();
//	$(".thumbs").data("scrollable").seekTo(image_id,0);
	/* set left col to minimum height of right col */
	setEqualHeightCols();

	$('.gallery .thumbs a').click(function(){
		$('.gallery .overlay .title').text($(this).attr('title'));
		$('.gallery .overlay img').attr('src',$(this).attr('rel'));
		return false;
	})
	
	$('.tabs a').click(function(){
		if(!$(this).parent().hasClass('active')){
			$('.tabs .item').removeClass('active');
			$(this).parent().addClass('active');

			if($(this).hasClass('about')){
				$('.tababout').removeClass('hidden');
				$('.tabprogram').addClass('hidden');
			} else {
				$('.tabprogram').removeClass('hidden');
				$('.tababout').addClass('hidden');
			}
		}
		return false;
	})
	
	$('.submit').click(function(){
		submit_onclick('frm_newsletter',true);
		return false;
	})
	if ($('#video').size() > 0) {
		var flashvars = {
			 projectURL: PROJECT_URL + '/flash/',
			 screen: PROJECT_URL + '/images/video_screen.png',
			 video: PROJECT_URL + 'flash/video' + video_id + '.flv',
			 autoStart: false
			};
			var params = {
			 menu: "false",
			 allowFullScreen: true,
			 wmode: "transparent"
			};
			var attributes = {
			};
		swfobject.embedSWF(flashvars.projectURL + "videoplayer.swf", "video", "480px", "384px", "8.0.0", "expressInstall.swf", flashvars, params, attributes);
	}

	$('.donate input[type=radio]').click(function(){
		if ($(this).attr('name') == 'defaultamount'){
			if ($(this).val() == 'anders'){
				$('#useramount').attr('title','Vul een bedrag in');
				$('#useramount').attr('onblur','chckField(this,this.title)');
				$('#useramount').select();
			}else{
				$('#useramount').attr('title','');
				$('#useramount').attr('onblur','');
				$('#useramount').removeClass('error');
				$('#marker_useramount').html('');
			}
		};
	})
	
	$('#disclaimer').click(function(){
		if ($(this).attr('checked') == true){
			$('#valid_disclaimer').removeClass('error')
		}
	})
})

function openItem(id){
	$('#'+id + ' .details').slideDown();
	$('#'+id).addClass('active');
}

function closeItem(id){
	$('#'+ id + ' .details').slideUp(function(){
		$('#'+id).removeClass('active');
	});
}

function setEqualHeightCols(){
	var leftHeight = $('.left').height();
	var rightHeight = $('.right').height();

	//compare left to right, if right heigher than left set height
	if(leftHeight < rightHeight && $('.home').size == 0){
		//if left contains content block, set height to content block 
		if($('.left').find('.content').size()==1) {
			var pagingHeight = 0;
			//if content block contains paging, subtract paging
			if($('.left').find('.paging').size()>0){ pagingHeight = 40;}
			$('.left').find('.content').height(rightHeight - 83 - pagingHeight);
		} else {
			$('.left').children().height(rightHeight-21);
		}
	}
}
