$(document).ready(function(){

	$('.confirm').live('click', function(){
		if(confirm('Are you sure you want to do that?'))
			return true;
		else
			return false;
	});

	$('.confirm_leave').live('click', function(){
		if(confirm('Are you sure you want to leave the page? If you\'ve made any changes they will be lost unless you press save.'))
			return true;
		else
			return false;
	});

	$(".external").click(function(){
		var newWindow = window.open(this.getAttribute('href'), '_blank');
		if (newWindow) {
			if (newWindow.focus) {
				newWindow.focus();
				return false;
			}
		} else {
			return true;
		}
	});

	$('.changeAction').change(function(){
		$(this).parent('form').submit();
	});

	// Datepicker
	$('.datepicker').datepicker({
		numberOfMonths: 3,
		showAnim: 'blind',
		hideAnim: 'blind'
	});

	if(window.location.hash == '#preview')
	{
		var w = window.location.href;
		w = w.split('/');
		var newWindow = window.open('http://my.seechicagodance.com/campaign/' + w[5], '_blank');
		if (newWindow) {campaigns/edit
			if (newWindow.focus) {
				newWindow.focus();
				return false;
			}
		} else {
			return true;
		}
	}
	
});
