﻿/*****************************************************
Date:           03/22/2009
Author:         Siu leung
Description:    Calls the default browser 
                print functionality.
TODO:           See if Ektron has a better way
                to manage and print stuff out.
*****************************************************/
function Print() 
{
    window.print();
}


/*****************************************************
Date:           04/05/2009
Author:         Siu leung
Description:    Closes the browser window.
*****************************************************/
function CloseBrowser() 
{
    window.close();
}


/*****************************************************
Date:           04/05/2009
Author:         Siu leung
Description:    Opens up a modal window for client user
                to browse for the respective file
                to upload.
*****************************************************/
function UploadFile(fileType, curJobID) 
{
    var url = "";

    if (fileType.toUpperCase() == "COVER LETTER")
        url = "FileUpload.aspx?fileType=CoverLetter";
    else
        url = "FileUpload.aspx?fileType=Resume";

    //window.open(url, "", "width=350, height=200, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no");

    var imageUrls =
    {
        "header.Title": ""
    };

//    var ajaxOptions =
//    {
//        method  : "post",
//        url     : "http://dev.GuidanceSoftware.com/HBS.aspx",
//        data    : "H=ApplyJob_H&B=ApplyJob_B&S=ApplyJob_S&id=" + curJobID,
//        hdnSubmitButtonID : "hdnSubmitButton"
//    };

    Guidance.UI.showDialogWindow3('', 632, 200, url, imageUrls, "hdnSubmitButton");
}


/*****************************************************
Date:           04/09/2009
Author:         Siu leung
Description:    Stores or removes job ids based on
                user clicks.
*****************************************************/
function StoreJobIDs(chkBox, hdnAvailJobCtrlID, jobID) 
{
    var hdnAvailJobCtrl = document.getElementById(hdnAvailJobCtrlID);

    if (chkBox != null &&
        hdnAvailJobCtrl != null)
    {
        var key = "*" + jobID + "*,";

        // If true, add new id
        // otherwise delete id.
        if (chkBox.checked)
            hdnAvailJobCtrl.value += key;
        else
            hdnAvailJobCtrl.value = hdnAvailJobCtrl.value.replace(key, "");
    }
}


/*****************************************************
Date:           04/19/2009
Author:         Siu leung
Description:    Initialize state of panels and click
                events of the object that will fire
                the click event.
*****************************************************/
function TogglePanel(pnlID, lnkID)
{
    if (pnlID != null &&
        pnlID != "" &&
        lnkID != null &&
        lnkID != "") 
    {
        var lnkObj = $(lnkID);
        var pnlObj = $(pnlID);
        
        if( lnkObj != null &&
            pnlObj != null )
        {
            // Similar to the onload event of the
            // window but does not wait for every
            // asset to load i.e. images, before the
            // onload event can fire.  Instead, 
            // execution of page initialization
            // occurs after all HTML is loaded in 
            // browser, for the domready event.
            window.addEvent("domready", function() 
            {
                // Create the Fx.Reveal object with 
                // options.
                var partnerSlide = new Fx.Reveal(pnlObj,
                {
                    duration: 1000,
                    //transition: Fx.Transitions.Bounce.easeIn,
                    link: "cancel"
                });
                
                // Intially hide the panels
                partnerSlide.dissolve();

                // Remove the class for initial
                // state of the page (first load)
                if (lnkObj.parentNode != null)
                    lnkObj.parentNode.className = "";

                // Add click event to link obj, in
                // this case is the [+]/[-]. This 
                // way, the event occurs on the 
                // same instance of the object.
                lnkObj.addEvent("click", function(e) 
                {
                    // Stops both propogation of
                    // the event up to the parent
                    // elements and the default
                    // behavior of the current
                    // element.
                    e.stop();

                    if (lnkObj.innerHTML == "[+]") 
                    {
                        lnkObj.innerHTML = "[-]";
                        partnerSlide.reveal();
                        lnkObj.parentNode.className = "Partner_Toggle";
                    }
                    else 
                    {
                        lnkObj.innerHTML = "[+]";
                        partnerSlide.dissolve();
                        lnkObj.parentNode.className = "";
                    }
                });
            });
        }
    }
}


/*****************************************************
Date:           04/27/2009
Author:         James Heacock
Description:    Coppies the innerHTML from the Source, into the Target using the element ID's
*****************************************************/
function ShowInnerHtml_ID(SourceID, TargetID) 
{
    var SourceObj = document.getElementById(SourceID);
    var TargetObj = document.getElementById(TargetID);
    ShowInnerHtml_Obj(SourceObj, TargetObj);
}


/*****************************************************
Date:           04/27/2009
Author:         James Heacock
Description:    Coppies the innerHTML from the Source object, into the Target object
*****************************************************/
function ShowInnerHtml_Obj(SourceObj, TargetObj) {

    TargetObj.innerHTML = SourceObj.innerHTML;
}


/*****************************************************
Date:           04/30/2009
Author:         Siu leung
Description:    Call ajax function to refresh parent
                window.
*****************************************************/
function CallAjax(ajaxOptions) {

    var XHR = new Request(ajaxOptions);
    XHR.send({ url: ajaxOptions["url"] });
}


/*****************************************************
Date:           04/30/2009
Author:         Siu leung
Description:    Simulate a form submission.
*****************************************************/
function SimulateSubmit( hdnButtonID ) {

    var hdnSubmitButton = window.parent.document.getElementById(hdnButtonID);
    
    if( hdnSubmitButton != null )
        hdnSubmitButton.click();
}