/*

	Scripts for CityBooks
	Copyright:  Netlash <http://www.netlash.com>
	author:     Johan Ronsse johan@netlash.com>

*/

// Adds a class focus to input[type="text"] and textarea when focused
function focusfix(selector, className) {
	$(selector).focus(function() {
		$(this).addClass(className);
	});
	// Removes class when focus is lost
	$(selector).blur(function() {
		$(this).removeClass(className);
	});
}

$(document).ready(function() {

	// IE6 and IE7, IE8 as IE7
	if ($.browser.msie && $.browser.version.substr(0,1)<9) {
		// Missing CSS selector support IE6, IE7
		$('.pipedNav li:first-child').addClass('firstChild');
		$('.newsList .article:last-child, .figureList li:last-child, .browseListLarge li:last-child, .meta ul li:last-child').addClass('lastChild');

		// Add bullets to contributors
		$('.contributors dd:not(:last-child)').append('<span class="bullet">.</span>');
	}

	// IE6
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		// Apply focusfix
		focusfix('input.inputText', 'focus');
		focusfix('textarea', 'focus');
	}

	// Fix the a/img problem
	$("#content a > img, .columnMiddle a > img").parent().css('border', 'none');
	$("#content a > strong > img").parent().parent().css('border', 'none');
	
	if($('.columnRight').hasClass('open')) 	$('.textToggle').show();
	else $('.textToggle').hide();

	
	// set pointer mouse
	$('.textClicker').css('cursor', 'pointer');
	
	// clicker
	$('.textClicker').bind('click', function()
	{
		$(this).parent().parent().find('.textToggle').toggle(0, function()
		{
			if($(this).parent().hasClass('open')) $(this).parent().removeClass('open');
			else $(this).parent().addClass('open');
		});
	});
});
