$(document).ready(function(){
	$('.filterList a').click(filter2);				   
	$('.career_categories .career').hover(hoverOverCareer, hoverOutCareer);
	$( ".datepicker" ).datepicker({dateFormat: 'dd/mm/yy'});
	$( ".dialog" ).dialog({
			height: 250,
			width: 500,
			modal: true,
			buttons: {
				Close: function() {
					$( this ).dialog( "close" );
				}
			}
	});
});
function filter2(){
	if($(this).hasClass('active')){
		var id = $(this).parent().attr('id'),
			letter = $(this).text().toLowerCase();
		$('#'+id+'-filter .filter').hide();
		$('#'+id+'-filter .filter.'+letter).show();
	}
	else{
		return false;
	}
}
function hoverOverCareer(){
	$(this).find('.img-top').animate({'margin-top':'-130'});
}
function hoverOutCareer(){
	$(this).find('.img-top').animate({'margin-top':'0'});
}
function toggle(div){
	$('#'+div).slideToggle();	
}

var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialog = new Object;

ModalDialog.value = '';
ModalDialog.eventhandler = '';

var refreshing = false;

function refresh_page(){
	if (refreshing == false) {
		var url = document.location.href;
		refreshing = true;
		
		if (url.substr(url.length - 1) == "#") {
			url = url.substr(0, url.length - 1);
		}
		
		document.location.replace(url);
	}
}

function ModalDialogMaintainFocus()
{
	try
	{
		if (ModalDialogWindow.closed)
		{
			window.clearInterval(ModalDialogInterval);
			eval(ModalDialog.eventhandler);
			return;
		}

//			ModalDialogWindow.focus();
	}
	catch (everything)
	{

	}
}

function ModalDialogRemoveWatch()
{
	ModalDialog.value = '';
	ModalDialog.eventhandler = '';
}

function ModalDialogShow(page_to_show, do_refresh)
{
	var do_refresh = (do_refresh == null) ? true : do_refresh;

	ModalDialogRemoveWatch();

	if(do_refresh === true)
	{
		ModalDialog.eventhandler = "refresh_page()";
	}

	var args='width=800,height=610,left=325,top=300,toolbar=0,';
	args += 'location=0,status=0,menubar=0,scrollbars=1,resizable=0'; 

	ModalDialogWindow=window.open("","",args);
	ModalDialogWindow.document.open('');
	ModalDialogWindow.document.location = page_to_show;
	ModalDialogWindow.document.close();
	ModalDialogWindow.focus();
	ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()", 5);
}
function updateDropdown(me, div){
	var items = $(me).find('option:selected').attr('class');
	if(items == ''){
		$('#'+div).find('option').show();
	}
	else{
		$('#'+div).find('option').hide();
		$('#'+div).find('.'+items.replace(/,/g,',.')).show();
	}
}
