$(document).ready(function(){

	$('#apps select, #exchange select, #mobsense select').change(function(){
		window.location = $(this).val();
	});

    if($('form.niceform').size()){
        initNiceforms();
    }

    $('a[rel=external]').click(function(){
        window.open(this.href, '_blank');
        return false;
    });
    $('a.request-banner-delete-confirm').click(function(){
        return confirm('Do you really want to delete this creative?');
    });

    $('a.confirm-itunes-account-delete').click(function(){
        return confirm('Do you really want to delete this account?');
    });

    $('#mobsense .dashboard a').click(function(){
        var $dashboard = $(this).parents().find('.dashboard');
        $dashboard.find('tr.hidden, a.more, a.less').toggle();
        return false;
    })

    $('a#add-feature-group').click(function(){
        $('#add-feature-group-form').show();
        $('a#cancel-add-feature-group').show();
        $('a#add-feature-group').hide();
		$('#id_name').focus();
        return false;
    });

    $('a#cancel-add-feature-group').click(function(){
        $('#add-feature-group-form').hide();
        $('a#cancel-add-feature-group').hide();
        $('a#add-feature-group').show();
        return false;
    });
	
	$('h2#collapse_sdk_integration_header').click(function(){
        $('div#sdk_integration_body').hide();
		$('h2#collapse_sdk_integration_header').hide();
		$('h2#expand_sdk_integration_header').show();
        return false;
    });
	
	$('h2#expand_sdk_integration_header').click(function(){
        $('div#sdk_integration_body').show();
		$('h2#collapse_sdk_integration_header').show();
		$('h2#expand_sdk_integration_header').hide();
        return false;
    });
	
	$('h2#collapse_itunes_integration_header').click(function(){
        $('div#itunes_integration_body').hide();
		$('h2#collapse_itunes_integration_header').hide();
		$('h2#expand_itunes_integration_header').show();
        return false;
    });
	
	$('h2#expand_itunes_integration_header').click(function(){
        $('div#itunes_integration_body').show();
		$('h2#collapse_itunes_integration_header').show();
		$('h2#expand_itunes_integration_header').hide();
        return false;
	});
});
