/*
 * Copyright : (c) 2011 Webfish
 * Website   : http://www.webfish.nl
 * Email     : info@webfish.nl
 * -------------------------------------------------------------------------
 *   $Id: functions.js 71 2011-08-01 12:13:32Z caspar $
 * -------------------------------------------------------------------------
 */

function inputOnfocus(objInput, strDefault)
{
	if (objInput.value == strDefault)
		objInput.value = '';
	else
		objInput.select();

	return true;
}

function inputOnblur(objInput, strDefault)
{
	if (objInput.value == '')
		objInput.value = strDefault;

	return true;
}

Cufon.replace('h1, h2, h3, div#home span, ol#friends li a span, div#page div.left > span');

$(function(){
	$('a[rel=external]').attr('target', '_blank');

//	$('#twitter div ul').cycle({
//		delay:6000,
//		speed:3000
//	});

	$('div#carousel').cycle({
		fx:'fade',
		speed:2000,
		timeout:6000
	});

	if ($('div#album').length)
	{
		var colorbox_options = {
			transition:'none',
			initialWidth:'800px',
			initialHeight:'600px',
			width:'800px',
			height:'600px',
			current:'Afbeelding {current} van {total}',
			previous:'Vorige afbeelding',
			next:'Volgende afbeelding',
			close:'Sluit venster'
		};

		var prev_rel = '';
		$('div#album ol ol li.thumb a').each(function(){
			var large_link = $('<a href="'+this.href+'" rel="'+this.rel+'"></a>').addClass('enlarge');
			if (prev_rel != this.rel)
			{
				prev_rel = this.rel;
				large_link.addClass('active');
			}
			this.href = this.href.replace('large_', 'overview_');
			$(this).removeAttr('rel').addClass('thumb').before(large_link);
		});

		$('div#album ol ol li.thumb a.thumb').live('click', function(){
			var container = $(this).parent().parent().parent();
			$('div.detail a img', container).attr('src', this.href);
			$('a.active', $(this).parent().parent()).removeClass('active');
			$(this).prev().addClass('active');
			return false;
		});

		$('div#album ol ol').each(function(){
			$('li.thumb a.enlarge', this).colorbox(colorbox_options);
			var container = $(this).parent();
			$('div.detail a.enlarge', container).click(function(){
				$('a.active.enlarge', container).trigger('click');
				return false;
			});
		});
	}


	if ($('form#contact').length)
	{
		$('input#friend').change(function(){
			$('ul#friendlist').toggle(this.checked);
		}).trigger('change');
	}
});
