var elem_changed = false;
$(document).ready(function(){

	$('form').change(function(){

		elem_changed = true;
	});
	$('a').click(function(){

		if(elem_changed == true){

			if($(this).attr('class') == undefined || $(this).attr('class').indexOf('view_positions') == -1){

				if( $.confirm( $.language('Data has changed continue without save?') ) == true){

					elem_changed = false;
					return true;
				}
				return false;
			}
		}
	});

	$('[name=search]').keypress(function(key){

		if(key.keyCode == 13){

			window.location.href = '?model=language&page=language&search='+this.value+($('[name=equals]').attr('checked') == 'checked' ? '&equals=1' : '');
		}
	});
	$('.truncate').click(function(){

		if( $.confirm($.language('truncate')) == true ){

			window.location.href = '?model=language&page=language&action=truncate';
		}
		return false;
	});
	$('[name=delete_language]').click(function(){

		if( $.confirm() == true ){

			return true;
		}
		return false;
	});

	var top = $(window).height()/2;
	$('.buttons').css({'top' : top+'px'});
});