$(document).ready(function(){

	//Tab functionality
	$('div.domtab > div#modernbricksmenu > ul.domtabs').each(function(){
		$(this).tabs( $(this).parents('div.domtab').children('div#modernbricksmenuline').nextAll() );
	});

	//Popup code
	$('a.Popup').bind('click',function(){ return false;});
	$('a.Popup').click(function(){		
		var URL = $(this).attr('href');
		var wPos = URL.indexOf('w=');
		var hPos = URL.indexOf('h=');
		var width;
		var height;
		if (wPos != -1) {        
		    width = URL.substr(wPos+2,4);        
		} else {
		    width = 600;
		}
		if (hPos != -1) {        
		    height = URL.substr(hPos+2,4);        
		} else {
		    height = 600;
		}
		
		var parameters = 'height='+height+', width='+width+', scrollbars=yes, location=no, menubar=no';
		
		window.open(URL, 'CalendarPopup', parameters); 
	});
	
	//Show javascript only elements
	$('.script-only').each(function() {
		$(this).css('display','block');
	});
	$('.script-only-i').each(function() {
		$(this).css('display','inline');
	});
	$('.script-hide').each(function() {
		$(this).hide();								
	});
	
	//Assign toggle functionality
	$('a.toggle').each(function() {
		$(this).bind("click", function() {return false;});
		$(this).click(function() {
			var id = $(this).attr('href').substr(1);			
			//var target = $('div.toggle').filter(function () {return $(this).id('title') == id;});
			var target = $('div#'+id);
			$(target).slideToggle();
		});
	});
	$('div.toggle').css('display','none');
});