function setupToggleRelationships(relObj){
	function getDisplayValue(object, value){
		if(object.attr('type') == 'radio' || object.attr('type') == 'checkbox'){
			return object.attr('checked') && value == "checked" ? "block" : "none";
		}else if(object.is('input') || object.is('select') || object.is('textarea')){
			return object.val() == value ? "block" : "none";
		}else{
			return object.html() && object.html().toLowerCase() == value ? "block" : "none";
		}
	}
	
	for(var i in relObj){
		var rel = relObj[i];
		$(rel['section']).css('display', getDisplayValue($(rel['field']), rel['value']));
		$(rel["field"]).data("toggleData", rel);
		$(rel["field"]).change(function(){
			var rel = $(this).data('toggleData');
			$(rel['section']).css('display', getDisplayValue($(this), rel['value']));
		});
	}
}

$(document).ready(function(){
	
	$('.placeholder').placeholdr();

	$("#unit-image-gallery li a").colorbox && $("#unit-image-gallery li a").colorbox();


	$('.help').each(function(){
		var hint = $(this).parent().children('.hint');
		hint.css('display', 'none');
		var content = hint.html();
		$(this).qtip({
			tip: 'leftMiddle',
			content: content,
			show: 'mouseover',
			hide: 'mouseout',
			style: {width: 330,'background':'#00A6E2', 'padding':'10px','border':'0px', 'color':'#ffffff' }

		})
	});
	
	$.fn.qtip.styles.infoTooltip = {
		tip: 'leftMiddle',
		border: { width: 0, radius: 0, color: '#000' },
		width: { max: 320 },
		background: '#000',
		color: '#FFF'
	};
	$("#unit-flickr-gallery li a, #unit-social-profiles li a").css('cursor','pointer').each(function(){
		$text = $(this).find('img').length ? $(this).find('img').attr('title') : $(this).attr('title');
		$(this).qtip( {
			content: $text,
			position: { corner: {
				tooltip: 'bottomMiddle',
				target: 'topMiddle'
			}, target: "mouse" },
			border: { width: 0, radius: 4 },
			hide: { effect: { length: 0 } },
			adjust: { screen: true },
			style: {
				tip: true,
				name: 'infoTooltip'
			},
			show: { effect: { length: 0 } }
		});
	});

	// IE also limits the width of dropdown lists when the dropdown has a fixed width
	if ($.browser.msie) $('select.wide')
		.bind('focus mouseover', function() { $(this).addClass('expand').removeClass('clicked'); })
		.bind('click', function() { $(this).toggleClass('clicked'); })
		.bind('mouseout', function() { if (!$(this).hasClass('clicked')) { $(this).removeClass('expand'); }})
		.bind('blur', function() { $(this).removeClass('expand clicked'); });

})
