jQuery(document).ready(function($){
	
	// make a nice first li text in the menu
	$('#iWantToMenuContainer ul').prepend('<li><a href="#" onClick="return false">- select -</a></li>');
		
	// add the >> when there's a submenu
	$('#leftMenu ul ul ul').parent('li').children('a').append('<span style="color:#2C4E94;">&nbsp;&nbsp;&nbsp;&#187;</span>');
	
	
	$('#sendOverId').change(function(){
		var postid = $('#sendOverId option:selected').val();
		$('#hidePagesTextArea').append(','+postid);
	});

	$('.showAllEventDates .trigger').click(function() {
		var trigg = $(this).parent('.showAllEventDates').attr('id');
		var ids = trigg.split('_');
		var id = ids[1];
		
		var aed = $('#allDates_'+id);
		if(aed.is(':visible')) {
			aed.fadeOut();
			$(this).text('all dates');
		} else {
			aed.fadeIn();
			$(this).text('hide dates');
		}
		return false;
	});
	
	$('.singleEntry a').each(function(){
		var url = $(this).attr('href');
		if(url.lastIndexOf('.pdf') != -1) //cmbTheme defined in page header
			$(this).after('&nbsp; <img class="pdfIcon" src="'+cmbTheme+'/i/pdf-bullet.png" alt="" />');
	});
	
	/*
	function resizeText(multiplier) {
		if (document.body.style.fontSize == "")
			document.body.style.fontSize = "1em";
		document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.1) + "em";
		$.ajax({
			type: 'GET',
			url: cmbTheme+'/ajax.php',
			data: 'setTextSize='+document.body.style.fontSize	
		});
	}
	
	$("#plusText").click(function(){
		resizeText(1);
		return false;
	});
	$("#minusText").click(function(){
		resizeText(-1);
		return false;
	});
	*/
	//$('p').html('<b style="color:red;">'+parseFloat($('body').css('font-size'))+'</b>');
	
	$("#plusText").click(function(){
	
		var currSz = parseFloat($('body').css('font-size'));		
		Math.round(currSz);
		
		//$('p').html('<b style="color:red;">'+currSz+'</b>');
		
		if($.browser.msie)
			currSz++;
		else
			currSz = currSz + .7;
			
		$('body').css('font-size',currSz);
		
		$.ajax({
			type: 'GET',
			url: cmbTheme+'/ajax.php',
			data: 'setTextSize='+currSz	
		});
		
		return false;
	
	});
	
	$("#minusText").click(function(){
		
		var currSz = parseFloat($('body').css('font-size'));		
		Math.round(currSz);
		
		//$('p').html('<b style="color:red;">'+currSz+'</b>');
		if($.browser.msie)
			currSz--;
		else
			currSz = currSz - .7;
			
		$('body').css('font-size',currSz);
		
		$.ajax({
			type: 'GET',
			url: cmbTheme+'/ajax.php',
			data: 'setTextSize='+currSz	
		});
		
		return false;
	});
	
	
	$("#hideSidebar").click(function(){
		if($(this).hasClass('showSidebar')) {
			$(this).addClass('hideSidebar');
			$(this).removeClass('showSidebar');
			$("#pageText").animate({width:535},350,'swing',function(){$("#rightCol").fadeIn('fast')});
			$.ajax({
				type: 'GET',
				url: cmbTheme+'/ajax.php',
				data: 'setSideBar=show'	
			});
			return false
		} else {
			$(this).addClass('showSidebar');
			$(this).removeClass('hideSidebar');
			$("#rightCol").fadeOut('medium',function(){$("#pageText").animate({width:710},350)});

			$.ajax({
				type: 'GET',
				url: cmbTheme+'/ajax.php',
				data: 'setSideBar=hide'	
			});
			return false
		}
	});
	
	$('#searchBar input[name="s"]').focus(function(){
			$(this).val('');
			$(this).css({'color':'#000','font-style':'normal'});
	});
	$('#searchBar input[name="s"]').blur(function(){
			if($(this).val() == '')
				$(this).val('search for...');
			
			$(this).css({'color':'gray','font-style':'italic'});
	});
	
	
});

