/* 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Udviklet af: HUSET G (http://husetg.dk/)
URL: bramming-esbjerg-ribe.esbjergkommune.dk/
Oprettet: 09-02-2009
?ndret: 16-02-2009
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/


$(document).ready(function() { 
	// Show-hide functions on city links
	//$('.container .links').children('ul').hide().end().children('h3').css('cursor', 'pointer').click(function(){ $(this).toggleClass('open').next().stop(true, true).toggle("normal"); });
	$('.container .links').children('ul').hide().end().children('h3').css('cursor', 'pointer').click(function(){ 
	$(this).toggleClass('open').next().stop(true, true).toggle("normal"); 
	$(this).children("img").attr("src", ($(this).hasClass("open")?"files/system/design/images/bg-link-popicon_down.png":"files/system/design/images/bg-link-popicon_up.png") ); 
	}).prepend('<img src="files/system/design/images/bg-link-popicon_up.png" style="position:relative; top: 5px; margin-right: 5px" />');

	// Frontpage Picture rotation
	if ($('.city-column').length > 0) { // Check om vi er p? forsiden
		// Column 1
		var value = Math.floor( $('.paragraph-hidden').eq(0).find('img').length * Math.random() );
		var val = $('.paragraph-hidden').eq(0).find('img').eq(value).attr("src")
		$('#col-1 img').attr("src", val );
		// Column 2
		var value = Math.floor( $('.paragraph-hidden').eq(1).find('img').length * Math.random() );
		var val = $('.paragraph-hidden').eq(1).find('img').eq(value).attr("src")
		$('#col-2 img').attr("src", val );
		// Column 3
		var value = Math.floor( $('.paragraph-hidden').eq(2).find('img').length * Math.random() );
		var val = $('.paragraph-hidden').eq(2).find('img').eq(value).attr("src")
		$('#col-3 img').attr("src", val );
	}
	
	// Clear input fields
	$("input.clear").each(function(){ $(this).data("text",$(this).attr("value"));
	}).focus(function(){ if ( $.trim($(this).attr("value")) == $(this).data("text") ) $(this).attr("value", "");
	}).blur(function(){ if ( $.trim($(this).attr("value")) == "" && !$(this).hasClass("once") ) $(this).attr("value", $(this).data("text"));
	});
	
	// Media search headlines (optgroups)
	/*
	var option = $('#media-search-select');
	if (option) {
		$('option:contains(Esbjerg)', option).before('<optgroup label="Esbjerg"/>').remove();
		$('option:contains(Ribe)', option).before('<optgroup label="Ribe"/>').remove();
		$('option:contains(Bramming)', option).before('<optgroup label="Bramming"/>').remove();
	}
	$('.city-images li').filter(function(i){ if( i%3 == 0) return true; }).before('<div style="clear:both;"></div>');
	*/
});
$(window).load(function () {
	// Equalize heights 
	$(".city-column").equalHeights(); 
});
