var makeEqualHeight = function(el1, el2) {
  var h1 = $(el1).height();
  var h2 = $(el2).height();
  if(h1 > h2) {
    $(el2).height(h1);
  } else {
    // need to do this in case already equal
    if(h2 > h1) {
      $(el1).height(h2);
    } 
  }
}

$(document).ready(function() {
	hs.graphicsDir = '/includes/css/highslideGraphics/';
	hs.outlineType = 'rounded-white';
	hs.showCredits = false;
	hs.enableKeyListener = false;

	/* Update current year copyright */
	var today = new Date();
	var tYear = today.getFullYear();
	$('#future-link a').text('Upcoming Schedule');
	$('#curYear').text(tYear);
	var curLoc = location.href;
	$('input[name=\"contactSource\"]').setValue(curLoc);
	if($('#mbrRSVPForm')) {
		$('#mbrRSVPForm').validate();
	}
	var pgTitle = document.title;
	if(pgTitle.search('About') != -1) {
		$('#aboutjhtc').addClass('selected');
	}
	else if(pgTitle.search('Past') != -1) {
		$('#pastevents').addClass('selected');
	}
	else if(pgTitle.search('Member Websites') != -1) {
		$('#membersites').addClass('selected');
	}
	else if(pgTitle.search('Committee Volunteers') != -1) {
    	jQuery.validator.addMethod("phone", function(phone_number, element) {
        phone_number = phone_number.replace(/\s+/g, ""); 
    	return this.optional(element) || phone_number.length > 9 &&
    		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
    	}, "Please specify a valid phone number");
		$("#cvForm").validate();
	}
	if($('#calLinks .webcal')) {
	  $('#calLinks .webcal').click(
	    function() {
	      url = this.target
        window.open(url,'calendar','toolbar=yes, menubar=yes, location=yes, status=yes, scrollbars=yes,resizable=yes, width=800, height=600, left=0, top=0');
	    });
	}
	if($('#rightBlock')) {
	  $('.eventPhotos img').click(function() {
	    return hs.htmlExpand(this, { align: 'center' })
	  });
	  makeEqualHeight('#midColumn', '#sidebar_r');
    // makeEqualHeight('#content', '.rightBlock');
	}
});

hs.Expander.prototype.onInit = function (sender) {
	document.getElementById(sender['contentId']).style.display='block';
}