$(function()
{
$( 'input[class*=initialvalue]' ).map( function()
{
var classes = $( this ).attr( 'class' ).split( ' ' );
var value = '';
for ( var i=0; i<classes.length; i++ )
{
if ( classes[ i ].indexOf( 'initialvalue-' ) == 0 )
{
value = classes[ i ].substring( classes[ i ].indexOf( '-' ) + 1 ).replace( /_/g, ' ' );
break;
}
}
if ( !$( this ).attr( 'value' ) )
$( this ).attr( 'value', value );
$( this )
.bind( 'focusfield', function() { if ( $( this ).attr( 'value' ) == value ) $( this ).attr( 'value', '' ); })
.bind( 'blurfield', function() { if ( !$( this ).hasClass( 'focus' ) && $( this ).attr( 'value' ) == '' ) { $( this ).attr( 'value', value ); } })
.focus( function() { $( this ).addClass( 'focus' ); $( this ).trigger( 'focusfield' ); })
.blur( function() { $( this ).removeClass( 'focus' ); $( this ).trigger( 'blurfield' ); })
.parents( 'form' )
.bind( 'beforesubmit', function() { $( this ).find( 'input[class*=initialvalue]' ).trigger( 'focusfield' ); })
.bind( 'aftersubmit', function() { $( this ).find( 'input[class*=initialvalue]' ).trigger( 'blurfield' ); })
.submit( function() { $( this ).trigger( 'beforesubmit' ) } );
});
});
$( function()
{
$( '#SearchVacancies form' )
.bind( 'updateSubmitButtonCount', function()
{
return;
var theForm = $( this );
var count = 0;
theForm
.trigger( 'beforesubmit' )
.ajaxSubmit({
url: theForm.attr( 'baseActionUrl' ).replace( '__DUMMY__', 'GetResultCount' ),
type: 'get',
success: function( responseText, statusText )
{
theForm
.find( 'input[type=submit]' )
.attr( 'value', 'Zoeken (' + responseText + ')' );
}
})
.trigger( 'aftersubmit' )
.find( 'input[type=submit]' );
})
.find( 'select, input' )
.attr( 'autocomplete', 'off' )
.change( function() 
{ 
$( this )
.parents( 'form:first' )
.trigger( 'updateSubmitButtonCount' ); 
})
.focus( function()
{
$( this ).trigger( 'getAutosuggest' );
})
.blur( function( evt )
{
$( this ).trigger( 'closeAutosuggest' );
})
.bind( 'closeAutosuggest', function()
{
if ( !window.autoSuggestElement )
return;
if ( window.autoSuggestElement.allowClose == false )
return;
window.autoSuggestElement.remove();
})
.keyup( function() 
{
if ( window.searchTimeout )
clearTimeout( window.searchTimeout );
var field = $( this );
window.searchTimeout = setTimeout( function() 
{ 
field
.trigger( 'getAutosuggest' )
.change();
}, 400 );
})
.map( function()
{
if ( $( this ).attr( 'class' ).indexOf( 'autosuggest-' ) < 0 )
return;
var classes = $( this ).attr( 'class' ).split( ' ' );
var callbackAction = '';
for ( var i=0; i<classes.length; i++ )
{
if ( classes[ i ].indexOf( 'autosuggest-' ) == 0 )
{
callbackAction = classes[ i ].substring( classes[ i ].indexOf( '-' ) + 1 );
break;
}
}
var theForm = $( this ).parents( 'form:first' );
$( this )
.attr( 'autosuggest_url', theForm.attr( 'baseActionUrl' ).replace( '__DUMMY__', callbackAction ) )
.bind( 'getAutosuggest', function()
{
var theField = $( this );
if ( window.autoSuggestElement )
window.autoSuggestElement.remove();
if ( !$( this ).attr( 'value' ) )
return;
theForm
.trigger( 'beforesubmit' )
.ajaxSubmit({
url: theField.attr( 'autosuggest_url' ),
type: 'get',
success: function( responseText, statusText )
{
var responseObject = responseText ? eval( '(' + responseText + ')' ) : new Object();
window.autoSuggestElement = $( '<ul class="SearchSuggestionList"></ul>' );
for ( var key in responseObject )
{
$( '<li><a href="javascript: void(0)" title="' + responseObject[ key ] + '"><strong>' + responseObject[ key ].substring( 0, theField.attr( 'value' ).length ) + '</strong>' + responseObject[ key ].substring( theField.attr( 'value' ).length ) + '</a></li>' )
.appendTo( window.autoSuggestElement );
}
if ( window.autoSuggestElement.find( 'li' ).length < 1 )
{
window.autoSuggestElement.remove();
return;
}
window.autoSuggestElement.allowClose = true;
window.autoSuggestElement
.prependTo( 'body' )
.css( 'position', 'absolute' )
.css( 'z-index', '99999999' )
.css( 'left', theField.offset().left )
.css( 'top', theField.offset().top + theField.outerHeight() )
.css( 'background', '#FFF' )
.css( 'border', '1px solid #CCC' )
.css( 'text-align', 'left' )
.css( 'overflow', 'auto' )
.css( 'overflow-x', 'hidden' )
.map( function()
{
var minHeight = 150;
var minWidth = theField.width() + 20;
if ( $( this ).height() > minHeight ) $( this ).css( 'height', minHeight );
if ( $( this ).width() < minWidth ) $( this ).css( 'width', minWidth )
$( this ).mousedown( function() { window.autoSuggestElement.allowClose = false; } );
$( document ).click( function() 
{
if ( window.autoSuggestElement.allowClose == false )
{
window.autoSuggestElement.allowClose = true; 
theField.blur(); 
}
});
});
window.autoSuggestElement
.find( 'li' )
.mousedown( function()
{
theField
.attr( 'value', $( this ).find( 'a' ).attr( 'title' ) )
.change()
.blur();
})
window.autoSuggestElement
.find( 'a' )
.css( 'display', 'block' )
.css( 'padding', '.3em .5em' );
}
})
.trigger( 'aftersubmit' )
});
});
});
$(function() {
$( ".Hoverable tr, .Hoverable li, .Editable li, .Clickable, .ButtonContainer" )
.hover(
function()
{
$( this ).addClass( "Hover" );
},
function()
{
$( this ).removeClass( "Hover" );
}
);
});
$(function() {
$( "table.Selectable tr" )
.click(
function()
{
$(this).toggleClass( "Active" );
}
);
});
$(function () {
$('dl.Collapsable > dt a')
.click(function () {
var dd = $(this).parent().next('dd:first');
var li = $(this).parent().parent().parent();
dd.toggle();
$(this).css(
'font-weight',
(dd.css('display') != 'none' ? 'bold' : 'normal')
);
li.toggleClass('Collapsed');
return false;
})
.click()
.click();
});
$(function () {
$( ".Clickable" )
.click( function () {
window.location = $( this ).find( "a" ).attr( "href" );
return false;
});
});
