

// 'opens' and 'closes' a div, also alternates the + - button control
function ShowHide(elementName, buttonName)
{
    if (document.getElementById(elementName).style.display=='none')
    {
        document.getElementById(elementName).style.display='block';    
        document.getElementById(buttonName).src='/css/buttons/switch_minus.gif';    
    }
    else
    {
        document.getElementById(elementName).style.display='none';    
        document.getElementById(buttonName).src='/css/buttons/switch_plus.gif';    
    }
}

// prerequisite is jquery
// fades an element out
function FadeOut(element)
{
    $("#"+element).fadeOut();
}

// prerequisite is jquery
// fades an element in
function FadeIn(element) {
    $("#" + element).fadeIn();
}


// prerequisite is jquery
// hides the element
function Hide(element) {
    $("#" + element).hide();
}




/* Can be used to give the user a mesage about navigation away from a page */
var isDirty;
isDirty = 0;      
function setDirty() 
{
    isDirty = 1;
    closeFlash();
}
function unsetDirty() {
    isDirty = 0;
}

/* Supress the dirty check if you have some intra page navigation that you want to allow */
var suppressDirtyCheck;
suppressDirtyCheck = 0;
function setDirtySuppression() {
    suppressDirtyCheck = 1;
}

function checkSave() 
{            
    return ("Discard Your Changes?\nYou have made changes on this page and not saved them.\nClicking OK will discard your changes");
}


        
// close any flashes after 15 secs
window.setTimeout("closeFlash();", 30000);
function closeFlash()
{                            
    $("#flashPanel").fadeOut("slow", null);
}

// hide any saved dives after 15 secs
window.setTimeout("closeSavedNotification();", 30000);

function closeSavedNotification() 
{
    $(".saved-div").fadeOut("slow", null);            
}





$(document).ready(function () {

    $("#aspnetForm").validate(
    {
        ignore: ":not(:visible)"
    });


    $.validator.addMethod(
        "ukDate",
        function (value, element) {
            if (value != "") {
                return value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/);
            }
            else {
                return true;
            }
        },
        "Please enter a date in the format dd/mm/yyyy"
    );





    $(".makesDirty").change(function () {
        ChangesMade();
        closeFlash();
    });



    $(".focusDirty").focus(function () {
        ChangesMade();
    });


    $(".initiallyHidden").hide();


          

    $(".datepicker").datepicker({
        dateFormat: 'dd/mm/yy',
        firstDay: 1,
        showOn: "button",
        buttonImage: "/CSS/Icons/Calendar.gif",
        buttonImageOnly: true
    });



            



});

                 


