LayoutLinker = function(form){
	self._form = null;
	self._hasLinks = null;
	
	// constructor
	self.init = function(form){
	
		self._form = form;
		self._form.addModifyListener(self);
		if ($(".layoutLink").length) {
			self._hasLinks = true;
		}
		else {
			self._hasLinks = false;
		}
		
		// manually call this for initial setup
		self.notifyModified()
	}
	
	self.notifyModified = function(){
		// if no layout links found first time, skip the function as the form used has no layout links
		if (self._hasLinks) {

			$(".layoutLink").each(function(){
				var self = this;
				
				// manually call thickbox on click
				
				$(self).unbind('click');
				$(self).bind('click', function(){
					var parentElement = self;
					
					// find first div above the link
					while (parentElement.parentNode && parentElement.tagName != 'DIV') {
						parentElement = parentElement.parentNode;
					}
					parentId = $(parentElement).attr('id');
					
					// call thickbox
					tb_show(null, $(self).attr('href') + '?layoutParentId=' + parentId + '&TB_iframe=true&height=auto&width=700', null);
					
					// stop lable click from checking radio button
					return false;
				});				
			});
		}
	}	
		
	self.init(form);
}
