//jQuery.noConflict();

// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }

};

jQuery(document).ready(function($) {
		 
	/* calendar modifications --------------- */
	/* ====================================== */
	var cal = $(".calendar-table .calnk a").each(function(){
		//log(  $(this)[0].firstChild.textContent );
		$(this)[0].firstChild.textContent = "";
		$(this).find("span").eq(0).before("<div class='calendar_icon'><div>");
	});
	
	$(".calendar-table td.not(.calendar-date-switcher) br").remove();
	
	$(".calendar-table span").each(function (i) {
		$(this).html($(this).html().replace('*',''));
	});
	$(".calendar-table .event").each(function (i) {
		var spans = $(this).children('span');
		$(this).html(spans);
	});
	
	$(".calendar-date-switcher").each(function() {
		$(this).delay(400).show();
		log( $(this).css("display") );
	});

	


	$('#menu').lavaLamp({
			fx: 'easeOutBack',
			speed:500
	}); 

	$("#logo")
			.add("#wrapper")
			.add("#header")
			.add("#top_blue_shape")
			.add("#menu li")
			.add("#content")
			.add("#sidebar ul")
			.add("#footer")
			.addClass("png_bg");
			
	 //jQuery.preloadCssImages();
	 
	 $(".social-links a").attr("target", "_blank");


	// search box behaviour
	var searchBox = $("#newsletter input.textBox");
	var searchBoxDefault = searchBox.attr("value");
	

	searchBox.focus(function(){
		$(this).addClass('active');
		if($(this).attr("value") == searchBoxDefault)
			$(this).attr("value", "");
	});	
	searchBox.blur(function(){
		$(this).removeClass('active');
		if($(this).attr("value") == "") $(this).attr("value", searchBoxDefault);
	});
    
    
    
    // fancybox
	$(".fancy").fancybox({
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'overlayShow': true,
        'overlayOpacity': 0.8,
        'overlayColor': "#000",
        'padding' : "3"
	});
    
    // remove unnecesary RSS icon - otherwise it would require hacking WP core
    //  files
    $(".rsswidget img").remove();
        
  $('div#side').click(function(){
    if( $(this).data('state') === 'hidden' ) {
      var content = $('#side_content');
      log(content.width());
      $(this).animate({"right": +content.width()+"px"}, {queue:false, duration: 500});
      content.animate({"right": "0px"}, {queue:false, duration: 500});
      $(this).data('state', 'visible')
    }
    else{
      var content = $('#side_content');
      //$('#contactForm_outer').animate({"marginLeft": "-=390px"}, "slow");
      $('#side_content').animate({"right": "-"+content.width()+"+px"}, {queue:false, duration: 500});
      //$(this).animate({"marginLeft": "-=387px"}, "slow").animate({"marginLeft": "+=5px"}, "fast");
      $(this).animate({"right": "0px"}, {queue:false, duration: 500});
      $(this).data('state', 'hidden');
    }
  });

});

