function pkContextCMSConstructor() 
{
  this.onSubmitHandlers = new Object();
  this.registerOnSubmit = function (slotId, callback) 
  {
    if (!this.onSubmitHandlers[slotId])
    {
      this.onSubmitHandlers[slotId] = [ callback ];
      return;
    }
    this.onSubmitHandlers[slotId].push(callback);
  };
  this.callOnSubmit = function (slotId)
  {
    handlers = this.onSubmitHandlers[slotId];
    if (!handlers)
    {
      return;
    }
    for (i = 0; (i < handlers.length); i++)
    {
      handlers[i](slotId);
    }
  }
}

pkContextCMS = new pkContextCMSConstructor();


/* This handles search inputs sidewide */
$(document).ready(function() {
	
	if ($('#pk-context-cms-search-pages input.pk-search-field').attr('value') == '') {
		$('#pk-context-cms-search-pages input.pk-search-field').attr('value' , 'Search');
	}
		
	$('#pk-context-cms-search-pages input.pk-search-field').focus(function(){
		if ($(this).attr('value') == 'Search') {
			$(this).attr('value' , '');
		}
	});

	$('#pk-context-cms-search-pages input.pk-search-field').blur(function(){
		if ($(this).attr('value') == '') {
			$(this).attr('value' , 'Search');
		}
	});
	
	$('#pk-context-cms-contents-container-footer .pk-context-cms-add-slot-controls').remove(); //Remove slot controls for footer because it's global 
	$('input[type="checkbox"], input[type="radio"]').css('width','auto'); //Override CSS for some browsers
	
});

