	//open links in new window (target=_blank)
	var hostname = window.location.hostname,
	links = document.getElementsByTagName('a'),
	pattern = /^https?:\/\/(www.)?/i;
	 
	for(var i=0, len = links.length; i<len; i++) {
	  if(pattern.test(links[i].href) && links[i].href.toLowerCase().indexOf(hostname) == -1){
	    links[i].target = "_blank";
	    links[i].className += ' external';
	  }
	}
	
(function($){
	var Site = {
	  Events: {
	  	yearInit: function(e) {
	  		var prevYear = '';
	      $('ul.eme_events_list li .year').each(function() {
	      	var currentYear = $(this).html();
	      	if (currentYear == prevYear) { $(this).hide(); }
	      	prevYear = currentYear;
	      });
	      $('ul.eme_events_list').parent().prev().addClass('events-index-title');
	  	}
		}
	};
	
	$(document).ready(function() {
		Site.Events.yearInit();
	});

	$('#navigation ul li.current-menu-item a').after('<span class="arrow"></span>');
	
	//slideshow
	$('#slideshow').cycle({ 
    fx:     'fade',
    timeout: 7000, 
    pager:  '#slide-pager',
		fastOnEvent: true
  });
	
	//events
	//$('#box-events .box-content').scrollable({ circular: true, mousewheel: true }).navigator();

//clear form fields on focus
$('textarea, input:text').bind('focus click', function(){
		if (this.value == this.defaultValue) {
		this.value = '';
		}
	}).bind('blur', function(){
		if (this.value == '') {
		this.value = this.defaultValue;
		}
	});


//contact form 	

$('div#wpcf7-f1-p11-o1 li.text:eq(2) label').append('<em title="Required">*</em>');
$('div#wpcf7-f1-p11-o1 li.text:eq(2) label em').hide();

$('div#wpcf7-f1-p11-o1 .checkboxes .checkbox').click(function(){
	 // If checked
	 if ($('div#wpcf7-f1-p11-o1 .checkboxes .checkbox').is(':checked'))  {
	 	 $('div#wpcf7-f1-p11-o1 li.text:eq(2) label em').show();
		 
		 $('div#wpcf7-f1-p11-o1 .phone input').blur(function() {
		    if( !$(this).val() ) {
		          $(this).after('<span class="wpcf7-not-valid-tip">Please fill the required field.</span>');
		    } else {
				 $('div#wpcf7-f1-p11-o1 .phone .wpcf7-not-valid-tip').remove();
			}
		});

	 }
	 else {
		// $('div#wpcf7-f1-p11-o1 .phone input').removeClass('wpcf7-validates-as-required');
		// $('div#wpcf7-f1-p11-o1 .phone .wpcf7-not-valid-tip').remove();
		 $('div#wpcf7-f1-p11-o1 li.text:eq(2) label em').hide();
		 
		 $('div#wpcf7-f1-p11-o1 .phone input').blur(function() {
		    if( !$(this).val() ) {
		          //$(this).after('<span class="wpcf7-not-valid-tip">Please fill the required field.</span>');
				  $('div#wpcf7-f1-p11-o1 .phone .wpcf7-not-valid-tip').remove();
		    }
		});
	 }
 }); 

//stupid replace of date for "switch to rich" event
// $('body.page-id-89 dl.details-event dd:nth-child(2)').replaceWith('<dd>Every Thursday 1:00 PM, and the first Saturday of Every Month</dd>');

$('div.post-date').css('display', 'none');
$('div.hentry-wrapp').css('width', '600px');

})(jQuery);
