jQuery(document).ready(function(){
		/** add handler onfocus to remove blur effect **/
		jQuery('a').bind( 'click', function () { this.blur() } ) ;
		jQuery('a').bind( 'focus', function () { this.blur() } ) ;
		$boxes = jQuery('div.views-grid div.boxes div.content');
		$boxes.syncHeight();
		$boxes = jQuery('div.view-grid-page div.content');
		$boxes.syncHeight();
		$boxes = jQuery('div.view-Trainings  div.boxes div.content');
		$boxes.syncHeight();
		$boxes = jQuery('div.boxes-grid div.boxes div.content');
		$boxes.syncHeight();
		/**
		jQuery('a.lightbox-processed').each(function(){
			jQuery(this).simpletip({ 
				content : '<div class="calendar-calendar"><div class="calendar-tooltip">' + this.title + '</div></div>',
				persistent : false ,
				position : ["","-20"],
			});
	})
	**/
		
	   
		//jQuery('a.lightbox-processed img').css('display','block').after('<img class="magnifify" alt="Lightbox"  src="' + Drupal.settings.theme_path + '/images/gfx/icon_magnify.png" />');
		jQuery('div.editable').each(function(){
			$this = jQuery(this);
			classToRead = this.className.split(' ') ;

			if ( classToRead == '' ) return ;
			var objRegExp = /edit-node-(\d+)\s/;
			
			var start = this.className.search(objRegExp);
			if ( !(start > 0) ) return ;
			nid = this.className.substring(start) ;
			var objRegExp = /(\s)/;
			var end = nid.search(objRegExp);
			nid = nid.substring(10,end) ;
			
			$parent = $this.parent().eq(0) ;
			try {
				var position = $parent.position();
				var width	 = $parent.width();
				css = 'position : absolute; top :' + ( position.top + 6 ) + 'px; left : ' + ( position.left - 27 + width ) + 'px;';
				$this.append('<a  class="ajax-edit-node-link" href="' + Drupal.settings.basePath + 'node/'+ nid +'/edit" style="'+css+'"><span>EDIT</span></a>');
			} catch (err){
				return ;
			}
		});
});


(function($) {
	$.fn.syncHeight = function(settings) {
		var max = 0;
		var browser_id = 0;
		var property = [
		   ['min-height','0px'],
			['height','1%']
		];

		// check for IE6 ...
		if($.browser.msie && $.browser.version < 7){
			browser_id = 1;
		}
		
		// get maximum element height ...
		$(this).each(function() {
			// fallback to auto height before height check ...
			$(this).css(property[browser_id][0],property[browser_id][1]);
			var val=$(this).height();
			if(val > max){
			   max = val;
			}
		});
		
		// set synchronized element height ...
 		$(this).each(function() {
  			$(this).css(property[browser_id][0],max+'px');
		});
		return this;
	};	
})(jQuery);
