$(window).load(function()
{
DD_roundies.addRule('.button, .lselected, .formButton, .reportButton', '4px', true);
DD_roundies.addRule('.submitButton, .filterButton, .inputContainer, .selectContainer, .dateContainer, .radioContainer, .multipleContainer, .dashPanel, .textareaContainer, .timeContainer, #metaerror', '5px', true);
DD_roundies.addRule('#meta h2', '7px 7px 0 0', true);
DD_roundies.addRule('#subNav', '0 0 7px 7px', true);
DD_roundies.addRule('#userInfo', '0 0 5px 5px', true);
DD_roundies.addRule('#content', '7px 0 7px 7px', true);
if(!$.browser.msie)
{
  DD_roundies.addRule('.section, .question', '5px', true);  
  DD_roundies.addRule('h4', '3px', true);
}

   if($('#login_container').length == 0){
       DD_roundies.addRule('#feedback', '5px', true);
   }

   if($('#login_container').length > 0){
        DD_roundies.addRule('.login', '7px', true);
   }

   // convert the campaign branch select to a combo select
   if($('#campaign_branch').length > 0){
       $('#campaign_branch').comboselect({ sort: 'both', addbtn: '+',  rembtn: '-' });
   }

   if($('#feedback').length > 0){
       setTimeout("$('#feedback').fadeOut('slow')",5000)
   }

});

function saveCampaign()
{
    if($("#remove_check").val() == 1)
    {
        if($("#id").val() != ""){
            if(confirm('WARNING : If you have removed branches from the campaign, any form allocations and filled out forms for those branches will be deleted. Are you sure you want to continue?'))
            {
                $("#editForm").submit();
            }
        }
        else
        {
           $("#editForm").submit();
        }
    }
    else
    {
        $("#editForm").submit();
    }
}


function saveCampaignForm()
{
    if($("#due_date").val() == "")
    {
        if (confirm('Are you sure you don\'t want to add a due date to this form?'))
        {
            $("#editForm").submit();
        }
    }
    else
    {
            $("#editForm").submit();
    }
}

function deleteForm()
{
    if(confirm('Are you sure you want to delete this form? This will also remove the form allocation.')){
            $('#delete').val(1);
            $('#editForm').submit();
    }
}

function finaliseForm()
{
    if(confirm('Are you sure you want to save and finalise this form? You will no longer be able to edit it.')){
            $('#finalise').val(1);
            $('#editForm').submit();
    }
}

function scoreType(button)
{
    if(button == "pass")
    {
        $('#threshold').show(500);
    }
    else if(button == "percentage")
    {
        $('#threshold').hide(500);
    }
}

function submitNewFillout()
{
    if(confirm('WARNING : CREATING A FILLOUT LINK WILL DELETE ANY MANUALLY ALLOCATED AND FILLED OUT FORMS')){
        if(confirm('ARE YOU SURE YOU WANT TO CONTINUE?')){
            $('#editForm').submit();
        }
    }
}
