/*
 * Copyright : (c) 2010 Webfish
 * Website   : http://www.webfish.nl
 * Email     : info@webfish.nl
 * -------------------------------------------------------------------------
 *   $Id: functions.js 28 2010-12-21 15:28:58Z martin $
 * -------------------------------------------------------------------------
 */

function appendOnLoadAlert(str_msg)
{
	var appendOnLoadAlert_oldOnload = (window.onload) ? window.onload : function () { };
	window.onload = function () {appendOnLoadAlert_oldOnload();alert(str_msg);}
}

var str_prev = null;
function toggleItem(str_item)
{
	if (str_prev != null)
	{
		$(str_prev).toggle();
	}
	if (str_prev == str_item)
	{
		str_prev = null;
	}
	else
	{
		$(str_item).toggle();
		str_prev = str_item;
	}

	return false;
}

Cufon.replace('h1, h2, div#header ol li a', { hover: true, fontFamily: 'Garamond Premiere Pro' });
Cufon.replace('div#carousel ol li p, ol#submenu li a, div#footer span.right', { hover: true, fontFamily: 'Neutra Text SC' });

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

$('div#projectDetail div#image ul li a').live('click', function(){
	var $img = $('div#projectDetail div#image img#image_large');
	var $img_desc = $('div#projectDetail div#image p#image_desc');

	var img_src = $img.attr('src');
	img_src = img_src.substr(0, img_src.indexOf('/large_'))+'/large_'+($(this).attr('href').substr(1));
	$img.attr('src', img_src);

	$img_desc.html($(this).attr('rel'));

	$(this).blur();

	return false;
});

$('document').ready(function(){
	if ($('div#carousel ol').length)
	{
		$('div#carousel ol').carouFredSel({
			items    : 1,
			direction: 'left',
			circular : true,
			scroll   : {
				items   : 1,
				duration: 1000
			}
		});
		$('div#carousel ol li').show();
	}

	$('#submitProject').hide();
	$('#werkveld').change(function(){
		$(this).parents('form').submit();
	});

	$('div#photo ul li a').colorbox({
		current:false,//'foto {current} van {total}',
		onComplete:function(){
			Cufon.replace('#cboxTitle, #cboxPrevious, #cboxNext, #cboxCurrent', { fontFamily: 'Garamond Premiere Pro' });
		}
	});
});

