﻿function JowbaFixedAppAPI()
{
}

JowbaFixedAppAPI.prototype = 
{
    CURRENT_PREVIEW_PANEL: null,
    CURRENT_JOB_PAGE: 1,
    CURRENT_COMPANY_PAGE: 1,
    JOB_PER_PAGE: 5,
    COMPANY_PER_PAGE: 2,
    MAX_JOB_COUNT: 1,
    MAX_JOB_PAGE: 1,
    MAX_COMPANY_COUNT: 1,
    MAX_COMPANY_PAGE: 1,
    APP_ID: 1,
    COMPANY_ID_LIST: [],
    APP_THEME: "Orange",
    SEARCH: "",

    // Load YUI
    LoadLibrary: function(companyList)
    {
        var restCall = this.RestCall;
        var appId = this.APP_ID;
        var companyList = this.COMPANY_ID_LIST;
        var search = this.SEARCH;

        this.WriteBasePanel();

        var loader = new YAHOO.util.YUILoader(
        {
            require: ["connection", "animation"],
            loadOptional: true,
            onSuccess: function()
            {
                var query = (search.length > 0 ? "s=" + search : "cl=" + companyList.join(","));
                restCall("http://www.startuply.com/API/FixedApp/Jobs/List.aspx?" + query + "&callback=jowbaApi" + appId + ".BuildJobTable");
                restCall("http://www.startuply.com/API/FixedApp/Companies/List.aspx?" + query + "&callback=jowbaApi" + appId + ".BuildCompanyTable");
            }
        });

        loader.insert();
    },

    WriteBasePanel: function()
    {
        document.write(
            "<div style=\"width:160px;\">" +
                "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/header.png);background-repeat:no-repeat;width:160px;height:28px;border-width:0px;\" alt=\"\" /></div>" +
                "<div style=\"width:160px;\">" +
                    "<div style=\"float:left;position:relative;\"><div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabJobsActive.png);width:57px;height:25px;\"><div onclick=\"jowbaApi" + this.APP_ID + ".SwitchTab(this, 1);\" style=\"cursor:pointer;position:absolute;left:5px;top:0px;height:20px;width:50px;\"></div></div></div>" +
                    "<div style=\"float:left;position:relative;\"><div id=\"JOWBA_COMPANY_TAB_" + this.APP_ID + "\" style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabCompaniesEmpty.png);width:103px;height:25px;\"><div onclick=\"jowbaApi" + this.APP_ID + ".SwitchTab(this, 2);\" style=\"cursor:pointer;position:absolute;left:1px;top:0px;height:20px;width:79px;\"></div></div></div>" +
                "</div>" +
                "<div style=\"clear:both;\"></div>" +

                "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/body.png);background-repeat:repeat-y;width:160px;font-family:Arial;font-size:11px;\">" +

                    "<div style=\"padding:0px 10px;\">" +
                        "<div style=\"overflow:hidden;width:100%;\">" +

                            "<div id=\"JOWBA_JOB_PANEL_" + this.APP_ID + "\" style=\"position:relative;width;140px;overflow:hidden;\">" +

                                "<div style=\"padding:20px 0px;text-align:center;\">Loading... Please wait...</div>" +

                            "</div>" +

                            "<div id=\"JOWBA_COMPANY_PANEL_" + this.APP_ID + "\" style=\"display:none;position:relative;width;140px;overflow:hidden;\">" +

                                "<div style=\"padding:20px 0px;text-align:center;\">Loading... Please wait...</div>" +

                            "</div>" +

                        "</div>" +
                    "</div>" +

                "</div>" +

                "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/footer.png);text-align:center;width:160px;height:39px;font:10px arial;line-height:30px;\">&copy; Startuply - <a href=\"http://www.startuply.com/Apps/\" style=\"text-decoration:none;color:#3879d9;\" onclick=\"this.target='_blank';\">Grab This!</a></div>" +
            "</div>" +
            "<div id=\"JOWBA_JOB_DETAIL_PANEL_" + this.APP_ID + "\" style=\"display:none;position:absolute;font-family:Arial;font-size:10px;width:227px;\"></div>"
        );
    },

    // Switch between company/job tab
    SwitchTab: function(tab, tabId)
    {
        var panel = tab.parentNode.parentNode.parentNode;
        var divs = panel.getElementsByTagName("div");

        if(tabId == 1)
        {
            divs[1].style.backgroundImage = divs[1].style.backgroundImage.replace(/Inactive.png/g, "Active.png");
            divs[4].style.backgroundImage = divs[4].style.backgroundImage.replace(/Active.png/g, "Inactive.png");
            document.getElementById("JOWBA_JOB_PANEL_" + this.APP_ID).style.display = "";
            document.getElementById("JOWBA_COMPANY_PANEL_" + this.APP_ID).style.display = "none";
        }
        else
        {
            divs[1].style.backgroundImage = divs[1].style.backgroundImage.replace(/Active.png/g, "Inactive.png");
            divs[4].style.backgroundImage = divs[4].style.backgroundImage.replace(/Inactive.png/g, "Active.png");
            document.getElementById("JOWBA_JOB_PANEL_" + this.APP_ID).style.display = "none";
            document.getElementById("JOWBA_COMPANY_PANEL_" + this.APP_ID).style.display = "";
        }

        // Hide detail
        this.CloseDetailPanel();
    },

    // Next job page
    NextPage: function(link, panelId)
    {
        var countPanel = link.parentNode.getElementsByTagName("span")[0];

        switch(panelId)
        {
            case 1:
                if(this.CURRENT_JOB_PAGE < this.MAX_JOB_PAGE)
                {
                    this.CURRENT_JOB_PAGE++;
                    this.TurnPage(panelId, this.CURRENT_JOB_PAGE);
                    
                    var start = (this.CURRENT_JOB_PAGE - 1) * this.JOB_PER_PAGE + 1;
                    var end = this.CURRENT_JOB_PAGE * this.JOB_PER_PAGE;
                    
                    if(end > this.MAX_JOB_COUNT) end = this.MAX_JOB_COUNT;
                    
                    countPanel.innerHTML = start + " - " + end;
                }
                break;
            case 2:
                if(this.CURRENT_COMPANY_PAGE < this.MAX_COMPANY_PAGE)
                {
                    this.CURRENT_COMPANY_PAGE++;
                    this.TurnPage(panelId, this.CURRENT_COMPANY_PAGE);
                    
                    var start = (this.CURRENT_COMPANY_PAGE - 1) * this.COMPANY_PER_PAGE + 1;
                    var end = this.CURRENT_COMPANY_PAGE * this.COMPANY_PER_PAGE;
                    
                    if(end > this.MAX_COMPANY_COUNT) end = this.MAX_COMPANY_COUNT;
                    
                    countPanel.innerHTML = start + " - " + end;
                }
                break;
        }
    },

    // Previous job page
    PreviousPage: function(link, panelId)
    {
        var countPanel = link.parentNode.getElementsByTagName("span")[0];

        switch(panelId)
        {
            case 1:
                if(this.CURRENT_JOB_PAGE > 1)
                {
                    this.CURRENT_JOB_PAGE--;
                    this.TurnPage(panelId, this.CURRENT_JOB_PAGE);

                    var start = (this.CURRENT_JOB_PAGE - 1) * this.JOB_PER_PAGE + 1;
                    var end = this.CURRENT_JOB_PAGE * this.JOB_PER_PAGE;
                    
                    if(end > this.MAX_JOB_COUNT) end = this.MAX_JOB_COUNT;
                    
                    countPanel.innerHTML = start + " - " + end;
                }
                break;
            case 2:
                if(this.CURRENT_COMPANY_PAGE > 1)
                {
                    this.CURRENT_COMPANY_PAGE--;
                    this.TurnPage(panelId, this.CURRENT_COMPANY_PAGE);

                    var start = (this.CURRENT_COMPANY_PAGE - 1) * this.COMPANY_PER_PAGE + 1;
                    var end = this.CURRENT_COMPANY_PAGE * this.COMPANY_PER_PAGE;
                    
                    if(end > this.MAX_COMPANY_COUNT) end = this.MAX_COMPANY_COUNT;
                    
                    countPanel.innerHTML = start + " - " + end;
                }
                break;
        }
    },

    // Turn to specified job page
    TurnPage: function(panelId, page)
    {
        var attributes = {
            left: { to: (page - 1) * -140 }
        };

        var anim = new YAHOO.util.Anim(document.getElementById("JOWBA_" + (panelId == 1 ? "JOB" : "COMPANY") + "_PANEL_" + this.APP_ID).getElementsByTagName("div")[0], attributes, 0.3, YAHOO.util.Easing.easeOut);
        anim.animate();
        
        // Hide detail
        this.CloseDetailPanel();
    },

    // Api call to server
    RestCall: function(url)
    {
        var header = document.getElementsByTagName("head")[0];
        var scriptObj = document.createElement("script");

        // Add script object attributes
        scriptObj.setAttribute("type", "text/javascript");
        scriptObj.setAttribute("charset", "utf-8");
        scriptObj.setAttribute("src", url);
        
        header.appendChild(scriptObj);
    },
    
    // Build company table
    BuildCompanyTable: function(resultSet)
    {
        var compPanel = document.getElementById("JOWBA_COMPANY_PANEL_" + this.APP_ID);
        var tab = document.getElementById("JOWBA_COMPANY_TAB_" + this.APP_ID);
        
        if(resultSet.data.length >= 2) tab.style.backgroundImage = "url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabCompaniesInactive.png)";

        if(resultSet.data.length == 0)
        {
            compPanel.innerHTML = "<div style=\"padding:20px 0px;text-align:center;\">No company found.</div>";
        }
        else
        {
            this.MAX_COMPANY_COUNT = resultSet.data.length;
            this.MAX_COMPANY_PAGE = Math.floor(this.MAX_COMPANY_COUNT / this.COMPANY_PER_PAGE);
            if(this.MAX_COMPANY_PAGE * this.COMPANY_PER_PAGE < this.MAX_COMPANY_COUNT) this.MAX_COMPANY_PAGE++;

            var width = (this.MAX_COMPANY_COUNT > this.COMPANY_PER_PAGE ? this.MAX_COMPANY_PAGE * 140 : 140);
            
            // Company data
            var html = "<div style=\"width:" + width + "px;position:relative;\">\n";

            html += "<div style=\"width:140px;overflow:hidden;float:left;\">\n\n";
            for(var i=0; i<this.MAX_COMPANY_COUNT; i++)
            {
                // Industry list
                var industry = "";
                var industryLen = 0;
                for(var j=0; j<resultSet.data[i].industry.length; j++)
                {
                    industryLen += resultSet.data[i].industry[j].name.length;

                    if(industryLen > 25)
                    {
                        if (j + 1 < resultSet.data[i].industry.length) industry += " ...";
                        break;
                    }

                    industry += ", <a href=\"" + resultSet.data[i].industry[j].link + "\" style=\"text-decoration:none;color:#3879d9;\" onclick=\"this.target='_blank';\">" + resultSet.data[i].industry[j].name + "</a>";
                }
                
                // Build html
                if(i > 0 && i % this.COMPANY_PER_PAGE == 0) html += "</div>\n\n\n<div style=\"width:140px;float:left;\">\n\n";

                html +=
                "<div style=\"padding:10px 0px;width:140px;overflow:hidden;border-bottom:dotted #ddc6ab 1px;\" onmouseover=\"this.style.backgroundColor='#f1f1f1';\" onmouseout=\"this.style.backgroundColor='';\">" +
                    "<div style=\"padding:5px 0px;background-image:url(" + resultSet.data[i].logo + ");background-repeat:no-repeat;background-position:center center;\"><a href=\"" + resultSet.data[i].link + "\" style=\"text-decoration:none;display:block;width:100%;height:60px;\" onclick=\"this.target='_blank';\">&nbsp;</a></div>" +
                    "<div style=\"font-weight:bold;padding-top:5px;\"><a href=\"" + resultSet.data[i].link + "\" style=\"text-decoration:none;color:#3879d9;\" onclick=\"this.target='_blank';\">" + resultSet.data[i].name + "</a></div>" +
                    "<div style=\"padding:5px 0px;font-family:verdana;\">" + (resultSet.data[i].profile.length > 0 ? resultSet.data[i].profile : "<span style=\"color:#999;font-style:italic;\">No profile provided...</span>") + "</div>" +
                    "<div>" +
                        "<strong>Industry:</strong> " +
                        (industry.length > 0 ? industry.substr(2) : "<span style=\"color:#999;font-style:italic;\">No industry selected...</span>") +
                    "</div>" +
                "</div>";
            }

            html += "</div>\n\n";

            html += "<div style=\"clear:both;\"></div></div>";

            // Pagination
            html +=
            "<div style=\"text-align:center;border-bottom:1px #ddc6ab dotted;color:#5b5b5b;padding:5px 0px;\">" +
                "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowLeft.gif\" style=\"width:9px;height:9px;cursor:pointer;\" alt=\"\" onclick=\"jowbaApi" + this.APP_ID + ".PreviousPage(this,2);\" />" +
                "&nbsp; <span>1 - " + (this.MAX_COMPANY_PAGE > 1 ? this.COMPANY_PER_PAGE : this.MAX_COMPANY_COUNT) + "</span> of " + this.MAX_COMPANY_COUNT + " &nbsp;" +
                "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowRight.gif\" style=\"width:9px;height:9px;cursor:pointer;\" alt=\"\" onclick=\"jowbaApi" + this.APP_ID + ".NextPage(this,2);\" />" +
            "</div>";
            
            compPanel.innerHTML = html;
        }
    },

    // Build job table
    BuildJobTable: function(resultSet)
    {
        var jobPanel = document.getElementById("JOWBA_JOB_PANEL_" + this.APP_ID);

        if(resultSet.data.length == 0)
        {
            jobPanel.innerHTML = "<div style=\"padding:20px 0px;text-align:center;\">No job opening at this time, check back later.</div>";
        }
        else
        {
            this.MAX_JOB_COUNT = resultSet.data.length;
            this.MAX_JOB_PAGE = Math.floor(this.MAX_JOB_COUNT / this.JOB_PER_PAGE);
            if(this.MAX_JOB_PAGE * this.JOB_PER_PAGE < this.MAX_JOB_COUNT) this.MAX_JOB_PAGE++;

            var width = (this.MAX_JOB_COUNT > this.JOB_PER_PAGE ? this.MAX_JOB_PAGE * 140 : 140);

            // Job data
            var html = "<div style=\"width:" + width + "px;position:relative;\">\n";

            html += "<div style=\"width:140px;overflow:hidden;float:left;\">\n\n";
            for(var i=0; i<this.MAX_JOB_COUNT; i++)
            {
                if(i > 0 && i % this.JOB_PER_PAGE == 0) html += "</div>\n\n\n<div style=\"width:140px;float:left;\">\n\n";

                html +=
                "<div style=\"padding:5px 0px;width:140px;overflow:hidden;border-bottom:dotted #ddc6ab 1px;\" onmouseover=\"this.style.backgroundColor='#f1f1f1';jowbaApi" + this.APP_ID + ".GetOverview(this," + resultSet.data[i].company.id + "," + resultSet.data[i].job.branchId + "," + resultSet.data[i].job.id + ");\" onmouseout=\"this.style.backgroundColor='';\">" +
                    "<div style=\"margin-bottom:5px;font-family:Arial;font-size:12px;font-weight:bold;color:#333;\">" + resultSet.data[i].job.title + "</div>" +
                    "<div style=\"background-image:url(http://www.startuply.com/api/Image/Resize.aspx?type=logo&id=" + resultSet.data[i].company.id + "&w=50&h=33);background-repeat:no-repeat;padding-left:55px;line-height:33px;white-space:nowrap;\">" +
                        "<a href=\"" + resultSet.data[i].company.link + "\" style=\"text-decoration:none;color:#3879d9;\" onclick=\"this.target='_blank';\">" + resultSet.data[i].company.name + "</a>" +
                    "</div>" +
                "</div>\n\n";
            }

            html += "</div>\n\n";

            html += "<div style=\"clear:both;\"></div></div>";

            // Pagination
            html +=
            "<div style=\"text-align:center;border-bottom:1px #ddc6ab dotted;color:#5b5b5b;padding:5px 0px;\">" +
                "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowLeft.gif\" style=\"width:9px;height:9px;cursor:pointer;\" alt=\"\" onclick=\"jowbaApi" + this.APP_ID + ".PreviousPage(this,1);\" />" +
                "&nbsp; <span>1 - " + (this.MAX_JOB_PAGE > 1 ? this.JOB_PER_PAGE : this.MAX_JOB_COUNT) + "</span> of " + this.MAX_JOB_COUNT + " &nbsp;" +
                "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowRight.gif\" style=\"width:9px;height:9px;cursor:pointer;\" alt=\"\" onclick=\"jowbaApi" + this.APP_ID + ".NextPage(this,1);\" />" +
            "</div>";

            jobPanel.innerHTML = html;
        }
    },
    
    
    ///// OVERVIEW PANEL /////
    
    // Close detail panel
    CloseDetailPanel: function()
    {
        var item = document.getElementById("JOWBA_JOB_DETAIL_PANEL_" + this.APP_ID);
        var applyOpacity = this.ApplyOpacity;

        function callback()
        {
            item.style.display = "none";
            applyOpacity(item, 100);
        }
        
        if(typeof(item.style.filter) == "undefined")
        {
            this.FadeOut(item, 100, 0, 20, 1, callback);
        }
        else
        {
            item.style.display = "none";
        }
    },
    
    // Overview panel switch tab
    OverViewSwitchTab: function(mainPanel, tabId)
    {
        var divs = mainPanel.getElementsByTagName("div");
        var index = 0;
        
        // Switch tab
        for(var i=0; i<divs.length; i++)
        {
            if(divs[i].className && divs[i].className == "JOWBA_OVERVIEW_TAB")
            {
                divs[i].style.backgroundImage = (index == tabId - 1 ? divs[i].style.backgroundImage.replace(/Inactive.png/g, "Active.png") : divs[i].style.backgroundImage.replace(/Active.png/g, "Inactive.png"));
                index++;
            }
        }

        // Switch content
        index = 0;
        divs = mainPanel.getElementsByTagName("div");
        for(var i=0; i<divs.length; i++)
        {
            if(divs[i].className && divs[i].className == "JOWBA_OVERVIEW_PANEL")
            {
                divs[i].style.display = (index == tabId - 1 ? "" : "none");
                index++;
            }
        }
    },
    
    // Show overview photo
    OverviewDisplayPhoto: function(img, id, desc)
    {
        var panel = img.parentNode.parentNode;
        var divs = panel.getElementsByTagName("div");
        
        divs[2].style.backgroundImage = "url(http://www.startuply.com/API/Image/Resize.aspx?t=photo&id=" + id + "&w=160&h=180)";
        divs[3].innerHTML = desc;
    },
    
    // Item mouse hover, get overview
    GetOverview: function(item, companyId, branchId, jobId)
    {
        if(this.CURRENT_PREVIEW_PANEL) this.CURRENT_PREVIEW_PANEL.style.display = "none";

        var panel = document.getElementById("JOWBA_JOB_DETAIL_PANEL_" + this.APP_ID);
        panel.style.display = "";
        panel.style.textAlign = "left";
        
        if(panel.parentNode != document.body)
        {
            document.body.appendChild(panel.parentNode.removeChild(panel));
            panel.style.zIndex = 500;
        }

        if(panel)
        {
            if(item.__previewPanel)
            {
                item.__previewPanel.style.display = "";
                this.CURRENT_PREVIEW_PANEL = item.__previewPanel;
            }
            else
            {
                var container = document.createElement("div");
                container.id = "JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + branchId + "_" + jobId;
                panel.appendChild(container);
                this.CURRENT_PREVIEW_PANEL = item.__previewPanel = container;

                this.RestCall("http://www.startuply.com/API/FixedApp/Jobs/Get.aspx?cid=" + companyId + "&bid=" + branchId + "&jid=" + jobId + "&callback=jowbaApi" + this.APP_ID + ".CreateOverview");
            }
        }

        panel.style.left = (this.LeftPosition(item) - 220) + "px"
        panel.style.top = (this.TopPosition(item)) + "px"
    },
    
    // Hide overview
    HideOverview: function(item)
    {
        item.__previewPanel.style.display = "none";
    },
    
    // Create overview panel
    CreateOverview: function(resultSet)
    {
        var panel = document.getElementById("JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id);
        var html = "";

        if(panel)
        {
            html += this.CreateOverviewPanelIconHtml(resultSet);
            html += "<div style=\"float:left;\">";
            html += this.CreateOverviewPanelOverviewHtml(resultSet);
            html += this.CreateOverviewPanelExperienceHtml(resultSet);
            html += this.CreateOverviewPanelAboutHtml(resultSet);
            html += this.CreateOverviewPanelPhotoHtml(resultSet);
            html += this.CreateOverviewPanelApplyHtml(resultSet);
            html += "</div>";
            html += "<div style=\"clear:both;\"></div>";

            panel.innerHTML = html;
        }
    },
    
    // Create overview icon panel
    CreateOverviewPanelIconHtml: function(resultSet)
    {
        var index = 1;

        var html =
        "<div style=\"float:left;padding-top:20px;\">" +

            "<div style=\"position:relative;left:7px;\">" +

                "<div class=\"JOWBA_OVERVIEW_TAB\" style=\"cursor:pointer;width:27px;height:32px;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabSideActive.png);margin-bottom:2px;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(this.parentNode.parentNode.parentNode," + (index++) + ");\">" +
                    "<div style=\"padding:7px 0px 0px 7px;\"><img src=\"http://www.startuply.com/Apps/Images/ico/icoInfo1.gif\" width=\"16\" height=\"20\" alt=\"\" /></div>" +
                "</div>" +

                (resultSet.data.job.responsibilities.length > 0 || resultSet.data.job.experience.length > 0 ?
                "<div class=\"JOWBA_OVERVIEW_TAB\" style=\"cursor:pointer;width:27px;height: 32px;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabSideInactive.png);margin-bottom:2px;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(this.parentNode.parentNode.parentNode," + (index++) + ");\">" +
                    "<div style=\"padding:7px 0px 0px 7px;\"><img src=\"http://www.startuply.com/Apps/Images/ico/icoInfo2.gif\" width=\"16\" height=\"20\" alt=\"\" /></div>" +
                "</div>" : "") +

                "<div class=\"JOWBA_OVERVIEW_TAB\" style=\"cursor:pointer;width:27px;height: 32px;background: url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabSideInactive.png);margin-bottom:2px;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(this.parentNode.parentNode.parentNode," + (index++) + ");\">" +
                    "<div style=\"padding:7px 0px 0px 7px;\"><img src=\"http://www.startuply.com/Apps/Images/ico/icoCompany.gif\" width=\"16\" height=\"20\" alt=\"\" /></div>" +
                "</div>" +

                (resultSet.data.photo.length > 0 ?
                "<div class=\"JOWBA_OVERVIEW_TAB\" style=\"cursor:pointer;width:27px;height: 32px;background: url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabSideInactive.png);margin-bottom:2px;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(this.parentNode.parentNode.parentNode," + (index++) + ");\">" +
                    "<div style=\"padding:7px 0px 0px 7px;\"><img src=\"http://www.startuply.com/Apps/Images/ico/icoPhoto.gif\" width=\"16\" height=\"20\" alt=\"\" /></div>" +
                "</div>" : "") +

                "<div class=\"JOWBA_OVERVIEW_TAB\" style=\"cursor:pointer;width:27px;height: 32px;background: url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/tabSideInactive.png);margin-bottom:2px;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(this.parentNode.parentNode.parentNode," + (index) + ");\">" +
                    "<div style=\"padding:7px 0px 0px 7px;\"><img src=\"http://www.startuply.com/Apps/Images/ico/icoApply.gif\" width=\"16\" height=\"20\" alt=\"\" /></div>" +
                "</div>" +

            "</div>" +

        "</div>";
        
        document.getElementById("JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id).__applyPanelId = index;
        
        return html;
    },
    
    // Create overview panel HTML
    CreateOverviewPanelOverviewHtml: function(resultSet)
    {
        var skillsArray = resultSet.data.job.skills.split("\n");
        var skills = "";
        
        for(var i=0; i<skillsArray.length; i++)
        {
            if(skillsArray[i].length > 0) skills += "<div style=\"background-image:url(http://www.startuply.com/App_Themes/Default/Images/Common/ListItem.gif);background-repeat:no-repeat;background-position:-5px top;padding-left: 15px;\">" + skillsArray[i] + "</div>";
        }
        
        var html =
        "<div style=\"\" class=\"JOWBA_OVERVIEW_PANEL\">" +

            "<div style=\"width:200px;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabHeader.png);background-repeat:no-repeat;\">" +
                
                "<div style=\"padding:10px 15px;font-weight:bold;\">" +

                    "<div style=\"float:right;margin:0px 10px;cursor:pointer;color:#3879d9;font-weight:bold;\" onclick=\"jowbaApi" + this.APP_ID + ".CloseDetailPanel();\">X</div>" +

                    "<div style=\"font-size:12px;padding-bottom:2px;\"><a href=\"" + resultSet.data.job.link + "\" style=\"color:#333;text-decoration:none;\" onclick=\"this.target='_blank';\">" + resultSet.data.job.title + "</a></div>" +
                    "<span style=\"color:#999;\">at " + resultSet.data.company.name + " in " + resultSet.data.branch.address + "</span>" +
                    
                    "<div style=\"clear:both;\"></div>" +

                "</div>" +

            "</div>" +

            "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabContent.png);background-repeat:repeat-y;width:199px;min-height:150px;font-family:Verdana;\">" +

                "<div style=\"padding:0px 25px 10px 15px;\">" +

                    (resultSet.data.job.overview.length == 0 && skills.length == 0 ?
                    "<div style=\"height:250px;\"></div>" : "") +

                    (resultSet.data.job.overview.length > 0 ?
                    "<div style=\"font-family:arial;font-size:12px;font-weight:bold;color:#333;border-top:dotted #ddc6ab 1px;padding:10px 0px;\">Overview:</div>" +
                    "<div style=\"line-height:18px;padding-bottom:10px;width:100%;overflow:hidden;\">" +
                        (resultSet.data.job.overview.substring(resultSet.data.job.overview.length - 3) == "..." ? resultSet.data.job.overview.substring(0, resultSet.data.job.overview.length - 3) + "<a href=\"" + resultSet.data.job.link + "\" style=\"color:#3879d9;text-decoration:none;\" onclick=\"this.target='_blank';\">...</a>" : resultSet.data.job.overview) +
                    "</div>" : "") +

                    (skills.length > 0 ?
                    "<div style=\"font-family:arial;font-size:12px;font-weight:bold;color:#333;border-top:dotted #ddc6ab 1px;padding:10px 0px;\">Skills we're looking for:</div>" +
                    "<div style=\"line-height:18px;width:100%;overflow:hidden;\">" +
                        (resultSet.data.job.skills.substring(resultSet.data.job.skills.length - 3) == "..." ? resultSet.data.job.skills.substring(0, resultSet.data.job.skills.length - 3) + "<a href=\"" + resultSet.data.job.link + "\" style=\"color:#3879d9;text-decoration:none;\" onclick=\"this.target='_blank';\">...</a>" : resultSet.data.job.skills) +
                    "</div>" : "") +

                "</div>" +

            "</div>" +

            "<div style=\"width:199px;height:38px;overflow:hidden;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabFooter.png);background-repeat:no-repeat;\">" +
                "<div style=\"padding:0px 25px 10px 15px;font-weight:bold;text-align:center;font-size:140%;\">" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding-right:10px;padding-top:7px;\">" +
                        "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowRight.gif\" width=\"9\" height=\"9\" alt=\"\" /> <span style=\"color:#457d14;cursor:pointer;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "'), document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "').__applyPanelId);\">Apply Now</span>" +
                    "</div>" +
                "</div>" +
            "</div>" +
        "</div>";

        return html;
    },

    // Create experience panel HTML
    CreateOverviewPanelExperienceHtml: function(resultSet)
    {
        if(resultSet.data.job.responsibilities.length == 0 && resultSet.data.job.experience.length == 0) return "";
        
        var responsibilitiesArray = resultSet.data.job.responsibilities.split("\n");
        var responsibilities = "";
        
        for(var i=0; i<responsibilitiesArray.length; i++)
        {
            if(responsibilitiesArray[i].length > 0) responsibilities += "<div style=\"background-image:url(http://www.startuply.com/App_Themes/Default/Images/Common/ListItem.gif);background-repeat:no-repeat;background-position:-5px top;padding-left: 15px;\">" + responsibilitiesArray[i] + "</div>";
        }
        
        var experienceArray = resultSet.data.job.experience.split("\n");
        var experience = "";
        
        for(var i=0; i<experienceArray.length; i++)
        {
            if(experienceArray[i].length > 0) experience += "<div style=\"background-image:url(http://www.startuply.com/App_Themes/Default/Images/Common/ListItem.gif);background-repeat:no-repeat;background-position:-5px top;padding-left: 15px;\">" + experienceArray[i] + "</div>";
        }
        
        var html =
        "<div style=\"display:none;\" class=\"JOWBA_OVERVIEW_PANEL\">" +
            "<div style=\"width:200px;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabHeader.png);background-repeat:no-repeat;\">" +

                "<div style=\"padding:10px 15px;font-weight:bold;\">" +

                    "<div style=\"float:right;margin:0px 10px;cursor:pointer;color:#3879d9;font-weight:bold;\" onclick=\"jowbaApi" + this.APP_ID + ".CloseDetailPanel();\">X</div>" +

                    "<div style=\"font-size:12px;padding-bottom:2px;\"><a href=\"" + resultSet.data.job.link + "\" style=\"color:#333;text-decoration:none;\" onclick=\"this.target='_blank';\">" + resultSet.data.job.title + "</a></div>" +
                    "<span style=\"color:#999;\">at " + resultSet.data.company.name + " in " + resultSet.data.branch.address + "</span>" +

                    "<div style=\"clear:both;\"></div>" +

                "</div>" +

            "</div>" +

            "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabContent.png);background-repeat:repeat-y;width:199px;min-height:150px;font-family:Verdana;\">" +
                
                "<div style=\"padding:0px 25px 10px 15px;\">" +

                    (resultSet.data.job.responsibilities.length > 0 ?
                    "<div style=\"font-family:arial;font-size:12px;font-weight:bold;color:#333;border-top:dotted #ddc6ab 1px;padding:10px 0px;\">Your Responsibilities:</div>" +
                    "<div style=\"line-height:18px;padding-bottom:10px;width:100%;overflow:hidden;\">" +
                        (resultSet.data.job.responsibilities.substring(resultSet.data.job.responsibilities.length - 3) == "..." ? resultSet.data.job.responsibilities.substring(0, resultSet.data.job.responsibilities.length - 3) + "<a href=\"" + resultSet.data.job.link + "\" style=\"color:#3879d9;text-decoration:none;\" onclick=\"this.target='_blank';\">...</a>" : resultSet.data.job.responsibilities) +
                    "</div>" : "") +

                    (resultSet.data.job.experience.length > 0 ?
                    "<div style=\"font-family:arial;font-size:12px;font-weight:bold;color:#333;border-top:dotted #ddc6ab 1px;padding:10px 0px;\">Experience:</div>" +
                    "<div style=\"line-height:18px;width:100%;overflow:hidden;\">" +
                        (resultSet.data.job.experience.substring(resultSet.data.job.experience.length - 3) == "..." ? resultSet.data.job.experience.substring(0, resultSet.data.job.experience.length - 3) + "<a href=\"" + resultSet.data.job.link + "\" style=\"color:#3879d9;text-decoration:none;\" onclick=\"this.target='_blank';\">...</a>" : resultSet.data.job.experience) +
                    "</div>" : "") +

                "</div>" +

            "</div>" +

            "<div style=\"width:199px;height:38px;overflow:hidden;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabFooter.png);background-repeat:no-repeat;\">" +
                "<div style=\"padding:0px 25px 10px 15px;font-weight:bold;text-align:center;font-size:140%;\">" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding-right:10px;padding-top:7px;\">" +
                        "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowRight.gif\" width=\"9\" height=\"9\" alt=\"\" /> <span style=\"color:#457d14;cursor:pointer;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "'), document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "').__applyPanelId);\">Apply Now</span>" +
                    "</div>" +
                "</div>" +
            "</div>" +
        "</div>";

        return html;
    },
    
    // Create about panel HTML
    CreateOverviewPanelAboutHtml: function(resultSet)
    {
        var html =
        "<div style=\"display:none;\" class=\"JOWBA_OVERVIEW_PANEL\">" +
            "<div style=\"width:200px;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabHeader.png);background-repeat:no-repeat;\">" +

                "<div style=\"padding:10px 15px;font-weight:bold;\">" +

                    "<div style=\"float:right;margin:0px 10px;cursor:pointer;color:#3879d9;font-weight:bold;\" onclick=\"jowbaApi" + this.APP_ID + ".CloseDetailPanel();\">X</div>" +

                    "<div style=\"font-size:12px;color:#333;padding-bottom:2px;\">About " + resultSet.data.company.name + "</div>" +
                    (resultSet.data.company.website.length > 0 ? "<a href=\"http://" + resultSet.data.company.website + "\" onclick=\"this.target='_blank';\" style=\"text-decoration:none;color:#3879d9;\">Visit our web site</a>" : "&nbsp;") +

                    "<div style=\"clear:both;\"></div>" +

                "</div>" +
                
            "</div>" +

            "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabContent.png);background-repeat:repeat-y;width:199px;min-height:150px;font-family:Verdana;\">" +
                
                "<div style=\"padding:0px 25px 10px 15px;\">" +

                    "<table cellpadding=\"0\" cellspacing=\"0\" style=\"font-size:100%;width:159px;\">" +
                        "<tr style=\"border-top:dotted #ddc6ab 1px;\">" +
                            "<td style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;white-space:nowrap;\"><img src=\"http://www.startuply.com/Apps/Images/ico/icoNote1.png\" width=\"10\" height=\"10\" alt=\"\" /> Employees:</td>" +
                            "<td style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;font-weight:bold;color:#999;\">" + resultSet.data.company.employees + "</td>" +
                        "</tr>" +
                        "<tr style=\"border-top:dotted #ddc6ab 1px;\">" +
                            "<td style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;white-space:nowrap;\"><img src=\"http://www.startuply.com/Apps/Images/ico/icoNote1.png\" width=\"10\" height=\"10\" alt=\"\" /> Funding:</td>" +
                            "<td style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;font-weight:bold;color:#999;\">" + resultSet.data.company.fundings + "</td>" +
                        "</tr>" +
                    "</table>" +

                    "<div style=\"font-family:arial;font-size:12px;font-weight:bold;color:#333;border-top:dotted #ddc6ab 1px;padding:10px 0px;\">About Us:</div>" +
                    "<div style=\"line-height:18px;width:100%;overflow:hidden;\">" +
                        (resultSet.data.company.overview.substring(resultSet.data.company.overview.length - 3) == "..." ? resultSet.data.company.overview.substring(0, resultSet.data.company.overview.length - 3) + "<a href=\"" + resultSet.data.company.link + "\" style=\"color:#3879d9;text-decoration:none;\" onclick=\"this.target='_blank';\">...</a>" : resultSet.data.company.overview) +
                    "</div>" +

                "</div>" +

            "</div>" +

            "<div style=\"width:199px;height:38px;overflow:hidden;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabFooter.png);background-repeat:no-repeat;\">" +
                "<div style=\"padding:0px 25px 10px 15px;font-weight:bold;text-align:center;font-size:140%;\">" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding-right:10px;padding-top:7px;\">" +
                        "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowRight.gif\" width=\"9\" height=\"9\" alt=\"\" /> <span style=\"color:#457d14;cursor:pointer;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "'), document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "').__applyPanelId);\">Apply Now</span>" +
                    "</div>" +
                "</div>" +
            "</div>" +
        "</div>";

        return html;
    },

    // Create photo panel HTML
    CreateOverviewPanelPhotoHtml: function(resultSet)
    {
        if(resultSet.data.photo.length == 0) return "";
        
        var photo = "";
        
        for(var i=0; i<resultSet.data.photo.length; i++)
        {
            photo += "<img style=\"width:24px;height:24px;margin:0px 1px;\" src=\"http://www.startuply.com/API/Image/Resize.aspx?f=crop&t=photo&id=" + resultSet.data.photo[i].id + "&w=24&h=24\" alt=\"\" onmouseover=\"jowbaApi" + this.APP_ID + ".OverviewDisplayPhoto(this, " + resultSet.data.photo[i].id + ",'" + resultSet.data.photo[i].description.replace(new RegExp("\"", "ig"), "\\\"") + "');\" />";
        }
        
        var html =
        "<div style=\"display:none;\" class=\"JOWBA_OVERVIEW_PANEL\">" +
            "<div style=\"width:200px;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabHeader.png);background-repeat:no-repeat;\">" +

                "<div style=\"padding:10px 15px;font-weight:bold;\">" +

                    "<div style=\"float:right;margin:0px 10px;cursor:pointer;color:#3879d9;font-weight:bold;\" onclick=\"jowbaApi" + this.APP_ID + ".CloseDetailPanel();\">X</div>" +

                    "<div style=\"font-size:12px;color:#999;padding-bottom:2px;\">Photo of:</div>" +
                    "<div style=\"font-size:12px;color:#333;\">" + resultSet.data.company.name + "</div>" +
                
                    "<div style=\"clear:both;\"></div>" +

                "</div>" +

            "</div>" +

            "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabContent.png);background-repeat:repeat-y;width:199px;min-height:150px;font-family:Verdana;\">" +
                
                "<div style=\"padding:0px 25px 10px 15px;\">" +

                    "<div style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;\">" +
                        photo +
                    "</div>" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;\">" +
                        "<div style=\"background-image:url(http://www.startuply.com/API/Image/Resize.aspx?t=photo&id=" + resultSet.data.photo[0].id + "&w=160&h=180);width:160px;height:180px;\"></div>" +
                    "</div>" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;line-height:18px;\">" +
                        resultSet.data.photo[0].description +
                    "</div>" +

                "</div>" +

            "</div>" +

            "<div style=\"width:199px;height:38px;overflow:hidden;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabFooter.png);background-repeat:no-repeat;\">" +
                "<div style=\"padding:0px 25px 10px 15px;font-weight:bold;text-align:center;font-size:140%;\">" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding-right:10px;padding-top:7px;\">" +
                        "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowRight.gif\" width=\"9\" height=\"9\" alt=\"\" /> <span style=\"color:#457d14;cursor:pointer;\" onclick=\"jowbaApi" + this.APP_ID + ".OverViewSwitchTab(document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "'), document.getElementById('JOWBA_JOB_OVERVIEW_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "').__applyPanelId);\">Apply Now</span>" +
                    "</div>" +
                "</div>" +
            "</div>" +
        "</div>";

        return html;
    },
    
    CreateOverviewPanelApplyHtml: function(resultSet)
    {
        var html =
        "<div style=\"display:none;\" class=\"JOWBA_OVERVIEW_PANEL\">" +
            "<form action=\"http://www.startuply.com/Jobs/Ajax/SendResume.aspx\" method=\"post\" enctype=\"multipart/form-data\" style=\"margin:0px;padding:0px;\">" +

            "<div style=\"width:200px;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabHeader.png);background-repeat:no-repeat;\">" +
                
                "<div style=\"padding:10px 15px;font-weight:bold;\">" +

                    "<div style=\"float:right;margin-right:10px;cursor:pointer;color:#3879d9;font-weight:bold;\" onclick=\"jowbaApi" + this.APP_ID + ".CloseDetailPanel();\">X</div>" +

                    "<div style=\"font-size:12px;color:#999;padding-bottom:2px;\">Apply For:</div>" +
                    "<div style=\"font-size:12px;color:#333;\">" + resultSet.data.job.title + "</div>" +
                
                    "<div style=\"clear:both;\"></div>" +

                "</div>" +

            "</div>" +

            "<div style=\"background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabContent.png);background-repeat:repeat-y;width:199px;font-family:Verdana;\">" +

                "<div style=\"padding:0px 25px 10px 15px;\">" +

                    "<div style=\"border-top:dotted #ddc6ab 1px;padding:10px 0px;line-height:18px;\">" +
                        "To apply, please fill out the following information." +
                    "</div>" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding:5px 0px;\">" +
                        "<input name=\"firstName\" type=\"text\" style=\"border:solid #ccc 1px;padding:2px;width:150px;font-family:Arial;font-size:110%;margin-bottom:5px;\" value=\"First name...\" onclick=\"if(!this.__edited) {this.value = ''; this.__edited = true;}\" />" +
                        "<br />" +
                        "<input name=\"lastName\" type=\"text\" style=\"border:solid #ccc 1px;padding:2px;width:150px;font-family:Arial;font-size:110%;margin-bottom:5px;\" value=\"Last name...\" onclick=\"if(!this.__edited) {this.value = ''; this.__edited = true;}\" />" +
                        "<br />" +
                        "<input name=\"email\" type=\"text\" style=\"border:solid #ccc 1px;padding:2px;width:150px;font-family:Arial;font-size:110%;margin-bottom:5px;\" value=\"Email...\" onclick=\"if(!this.__edited) {this.value = ''; this.__edited = true;}\" />" +
                        "<br />" +
                        "<textarea name=\"coverLetter\" style=\"border:solid #ccc 1px;padding:2px;width:150px;height:100px;font-family:Arial;font-size:110%;margin-bottom:5px;\" onclick=\"if(!this.__edited) {this.value = ''; this.__edited = true;}\">Cover letter here...</textarea>" +
                        "<br />" +
                        "<div style=\"margin-bottom:5px;\">Select your resume:</div>" +
                        "<input name=\"resumeFile\" type=\"file\" size=\"9\" style=\"border:solid #ccc 1px;padding:2px;width:150px;font-family:Arial;font-size:110%;\" value=\"\" />" +

                        "<input name=\"jobTitle\" type=\"hidden\" value=\"" + resultSet.data.job.title + "\" />" +
                        "<input name=\"jobId\" type=\"hidden\" value=\"" + resultSet.data.job.id + "\" />" +
                        "<input name=\"branchId\" type=\"hidden\" value=\"" + resultSet.data.branch.id + "\" />" +
                    "</div>" +

                "</div>" +

            "</div>" +

            "<div style=\"width:199px;height:38px;overflow:hidden;background-image:url(http://www.startuply.com/Apps/Images/theme" + this.APP_THEME + "/sideTabFooter.png);background-repeat:no-repeat;\">" +
                "<div style=\"padding:0px 25px 10px 15px;font-weight:bold;text-align:center;font-size:140%;\">" +
                    "<div style=\"border-top:dotted #ddc6ab 1px;padding-right:10px;padding-top:7px;\">" +
                        "<img src=\"http://www.startuply.com/Apps/Images/ico/icoArrowRight.gif\" width=\"9\" height=\"9\" alt=\"\" /> <span style=\"color:#457d14;cursor:pointer;\" onclick=\"jowbaApi" + this.APP_ID + ".SendResume(this," + resultSet.data.branch.id + "," + resultSet.data.job.id + ");\">Submit Resume</span>" +
                    "</div>" +
                "</div>" +
            "</div>" +

            "</form>" +
        "</div>" +
        
        "<div style=\"width:1px;height:1px;position:absolute;overflow:hidden;left:-100px;\"><iframe id=\"sendResumeFrame_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "\" name=\"sendResumeFrame_" + this.APP_ID + "_" + resultSet.data.branch.id + "_" + resultSet.data.job.id + "\"></iframe></div>";

        return html;
    },

    // Get top position of an object
    TopPosition: function(obj)
    {
        var top = obj.offsetTop;
        var container = obj.offsetParent;
        
        while(container)
        {
            top += container.offsetTop;
            container = container.offsetParent;
        }
        
        return top;
    },

    // Get bottom position of an object
    BottomPosition: function(obj)
    {
        var top = obj.offsetTop;
        var container = obj.offsetParent;
        
        while(container)
        {
            top += container.offsetTop;
            container = container.offsetParent;
        }
        
        return (top + obj.offsetHeight);
    },

    // Get left position of an object
    LeftPosition: function(obj)
    {
        var left = obj.offsetLeft;
        var container = obj.offsetParent;
        
        while(container)
        {
            left += container.offsetLeft;
            container = container.offsetParent;
        }
        
        return left;
    },
    
    // Apply opacity to object
    ApplyOpacity: function(object, opacity)
    {
        var opaVal = 0;
        
        try
        {
            opaVal = parseInt(opacity);
        }
        catch(e)
        {
            opaVal = 100;
        }

        if(opaVal > 100)
            opaVal = 100;
        else if(opaVal < 0)
            opaVal = 0;
        
        if(object.style.MozOpacity != null)
        {
            object.style.MozOpacity = opaVal / 100;
        }
        else if(object.style.opacity != null)
        {
            object.style.opacity = opaVal / 100;
        }
        //else if(object.style.filter != null)
        //{
        //    object.style.zoom = 1;
        //    object.style.filter = "alpha(opacity=" + opaVal + ")";
        //}
    },

    // Fade out object
    FadeOut: function(object, startOpacity, endOpacity, opacityDecrement, timeout, callback)
    {
        var SetOpacity = this.ApplyOpacity;

        SetOpacity(object, startOpacity);

        var currentOpacity = startOpacity;

        function doAnimation()
        {
            currentOpacity -= opacityDecrement;
            
            if(currentOpacity < endOpacity)
            {
                SetOpacity(object, endOpacity);
                if(callback) callback();
                
                clearInterval(evnt);
            }
            else
            {
                SetOpacity(object, currentOpacity);
            }
        }

        var evnt = setInterval(doAnimation, timeout);
    },

    SendResume: function(button, branchId, jobId)
    {
        var form = button.parentNode.parentNode.parentNode.parentNode;
        var inputs = form.getElementsByTagName("input");
        var trimFunc = this.Trim;
        
        if(this.Trim(inputs[0].value).length == 0 || this.Trim(inputs[1].value).length == 0)
        {
            alert("Please enter your first and last name.");
            return;
        }
        else if(this.Trim(inputs[2].value).length == 0)
        {
            alert("Please enter your email.");
            return;
        }
        else if(this.Trim(inputs[3].value).length == 0)
        {
            alert("Please select the resume file you want to send.");
            return;
        }

        var frameId = "sendResumeFrame_" + this.APP_ID + "_" + branchId + "_" + jobId;

        form.encoding = "multipart/form-data";
        form.target = frameId;
        form.submit();

        alert("Resume sent!");
        button.onclick = function()
        {
            alert("You've already applied for this job.");
        }
    },

    Trim: function(string)
    {
        return string.replace(new RegExp("^[\\s]+", "ig"), "").replace(new RegExp("[\\s]+$", "ig"), "");
    }
}
