jQuery.noConflict();

// Expandable Divs

jQuery(document).ready(function()
{
  //hide all elements with class description
  jQuery("#concerts").find(".description").hide();
  //show next concert
  jQuery("#next_concert > .description").show();
  //show special event
  jQuery("#special > .description").show();

  //change color and cursor when hovering concerts' header
  jQuery("#concerts").find(".header").hover(
    function(){jQuery(this).addClass("hover");},
    function(){jQuery(this).removeClass("hover");}
  );

  //toggle the component with class description
  jQuery("#concerts").find(".header").click(function()
  {
    jQuery(this).next(".description").slideToggle(200);
  });

  //show the "toggle_all" div
  jQuery("#toggle_all").show();

  //change color and cursor when hovering "toggle_all"
  jQuery("#toggle_all").hover(
    function(){jQuery(this).addClass("hover");},
    function(){jQuery(this).removeClass("hover");}
  );

  //toggle all components with class "description"
  jQuery("#toggle_all").click(function()
  {
    if (jQuery(this).text() == "see all") {
      jQuery("#concerts").find(".description").slideDown(200);
      jQuery(this).text("hide all");
    } else {
      jQuery("#concerts").find(".description").slideUp(200);
      jQuery(this).text("see all");
    }
  });
});


// Fancybox Flyers

jQuery(document).ready(function() {

  /* This is basic - uses default settings */

  jQuery("a.fancy").fancybox({
    'centerOnScroll': false,
    'hideOnContentClick': true,
    'overlayShow': true,
    'easingIn': 600,
    'zoomSpeedIn': 600,
    'zoomSpeedOut': 600,
    'overlayOpacity': 0.6
  });

  /* Using custom settings */

  jQuery("a#inline").fancybox({
    'hideOnContentClick': true
  });

  jQuery("a.group").fancybox({
    'zoomSpeedIn': 300,
    'zoomSpeedOut': 300,
    'overlayShow': false
  });

});


// this creates an animated scrolling for all anchor links in the same page

jQuery(document).ready(function() {
  function filterPath(string) {
    return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'');
  }
  var locationPath = filterPath(location.pathname);
  jQuery('a[href*="#"]').each(function() {
    var thisPath = filterPath(this.pathname) || locationPath;
    if (  locationPath == thisPath && (location.hostname == this.hostname || !this.hostname) && this.hash.replace(/#/,'') ) {
      var $target = jQuery(this.hash), target = this.hash;
      if (target) {
        var targetOffset = $target.offset().top;
        jQuery(this).click(function(event) {
          event.preventDefault();
          jQuery('html, body').animate({scrollTop: targetOffset}, 500, function() {
            location.hash = target;
          });
        });
      }
    }
  });
});

// Newsletter form
jQuery(document).ready(function() {
  jQuery("#myForm").show();
});
// var form = "<form id=\"myForm\" action=\"add.php\" method=\"get\"><div id=\"form_box\"><input type=\"text\" id=\"email\" name=\"email\" value=\"Email\" onfocus=\"this.value=\'\';\" />  <!-- spanner -->  <input type=\"submit\" name=\"subscribe\" id=\"subscribe\" value=\"OK\" /></div></form>";

	window.addEvent('domready', function(){
		$('myForm').addEvent('submit', function(e) {
			new Event(e).stop();
			var log = $('log_res').empty().addClass('ajax-loading');
			this.send({
				update: log,
				onComplete: function() {
					log.removeClass('ajax-loading');
				}
			});
		});
	});
