﻿/**
Fix for:
http://www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=12838
**/
function OnChanged(sender, args)
{
    sender.get_clientStateField().value = sender.saveClientState();
}

function ClickButtonOnEnter(findButtonId)
{
    // IE Only.
    if(event.keyCode == 13) 
    {
        event.returnValue = false;
        document.getElementById(findButtonId).click();
    } 
    else 
    {
        event.cancelBubble = true; 
    }
}

function EnterAsTab() 
{
    if (event.keyCode==13) 
    {
        event.keyCode=9;
        return event.keyCode; 
    }
}

function OpenPopupContractorProfile(id)
{
    window.open('../Popups/ContractorProfile.aspx?id=' + id, 'ContractorProfile', 'width=550,height=300,scrollbars=yes,resizable=yes');
    return false;
}

function SelectSubContractor(clientIdSubId, 
                             subId, 
                             clientIdSubName, 
                             subName)
{        
    document.getElementById(clientIdSubId).value = subId;
    document.getElementById(clientIdSubName).innerHTML = subName;
    $find("popupFindSub").hide();
    return false;
}

function OpenPopupFindApprentice(idClientId,
                                 nameClientId)
{    
    $find("popupFindApprentice").show();
    
    document.getElementById("hdnIdClientId").value = idClientId;
    document.getElementById("hdnNameClientId").value = nameClientId;
    
    return false;
}

function SelectApprentice(apprenticeId, 
                          apprenticeName)
{
    var clientIdApprenticeId = document.getElementById("hdnIdClientId").value; 
    var clientIdApprenticeName = document.getElementById("hdnNameClientId").value; 
    
    document.getElementById(clientIdApprenticeId).value = apprenticeId;
    document.getElementById(clientIdApprenticeName).innerHTML = apprenticeName;
    $find("popupFindApprentice").hide();
    return false;
}

function PopupApprenticeNotFound()
{
    $find("popupFindApprentice").hide();
    $find("popupTechnicalHelp").show();
    
    return false;
}

function pageLoad() 
{
    $(document).ready(function() {
        //hide the all of the element with class msg_body
        $(".msg_body").hide();
        //toggle the componenet with class msg_body
        $(".msg_head").click(function() {
            $(this).next(".msg_body").slideToggle(600);
        });
    });
}
