﻿// JScript File

function ShareFacebook(urlLink, title) 
{
    window.open('http://www.facebook.com/sharer.php?u='+urlLink+'&t='+title,'facebookshare','toolbar=0,status=0,width=600,height=450');
}

function Shortlist(JobID) {
    ShowPopUp('/PopUp/ShortList.aspx?JobID='+JobID, 350, 400);
}

function MySeekJobs_Shortlist(JobID) {
    ShowPopUp('/PopUp/ShortList.aspx?Refresh=1&JobID='+JobID, 350, 400);
}

function JobPreference(path) {
    ShowPopUp('/PopUp/JobPreference.aspx?'+path + '&' + Math.random(), 300, 500);
}

function JobPreference_Remove(SearchID) {
    ShowPopUp('/PopUp/JobPreference_Remove.aspx?SearchID='+SearchID, 220, 440);
}

function JobAlert(path) {
    ShowPopUp('/PopUp/JobAlert.aspx?'+path, 300, 520);
}

function Shortlist_Remove(JobID) {
    ShowPopUp('/PopUp/Shortlist_Remove.aspx?JobID='+JobID, 180, 380);
}

function Application_Remove(JobID) {
    ShowPopUp('/PopUp/Application_Remove.aspx?JobID='+JobID, 180, 380);
}

function ScheduleJob(JobID) {
    ShowPopUp('/PopUp/Schedule.aspx?JobID='+JobID, 350, 440);
}

function ScheduleJob_Remove(JobID) {
    ShowPopUp('/PopUp/Schedule_Remove.aspx?JobID='+JobID, 180, 380); 
}

function GetScrollTop()
{
    var d = document;
    if(!isNaN(d.body.scrollTop) && d.body.scrollTop != 0)return d.body.scrollTop;
    if(d.documentElement.scrollTop != 0)return d.documentElement.scrollTop;
    return 0;
}

function window_scroll()
{
    var PopUpBG = document.getElementById("PopUpBG");
    if (PopUpBG) {
        if (PopUpBG.style.display != "none")
        {
            AdjustPopUpPosition()
        }
    }
}
window.onscroll = window_scroll;

var HEIGHT;
var WIDTH;

function AdjustPopUpPosition()
{
    var xMax, yMax, xOffset, yOffset;
    var xMax = document.documentElement.clientWidth;
    var yMax = document.documentElement.clientHeight;
    if (xMax < WIDTH) WIDTH = xMax;
    if (yMax < HEIGHT) HEIGHT = yMax;
    scrollMax = GetScrollTop();
    yOffset = (yMax - HEIGHT) /2 + scrollMax;
    xOffset = (xMax - WIDTH) / 2 + document.documentElement.scrollLeft;

    var iFrame = document.getElementById("PopUpFrame");
    var PopUpBG = document.getElementById("PopUpBG");

    PopUpBG.style.display = "";
    PopUpBG.style.top = scrollMax + "px";
    PopUpBG.style.zIndex = 1;

    iFrame.style.display = "";
    iFrame.style.top = yOffset + 'px';
    iFrame.style.left = xOffset + 'px';
    iFrame.style.width = WIDTH + 'px';
    iFrame.style.height = HEIGHT + 'px';
    iFrame.style.zIndex = 1;
}

function ShowPopUp(Url, height, width)
{
    WIDTH = width;
    HEIGHT = height;
    AdjustPopUpPosition();
    var iFrame = document.getElementById("PopUpFrame");

/*
        var browser = navigator.appVersion; //find the browser name 
        if(browser.toLowerCase().match('msie') != null || browser.toLowerCase().match('apple') != null) 
            document.getElementById(DivIFrame).style.height = height - 15 + "px";
        else
            document.getElementById(DivIFrame).height = height - 15 + "px";
*/

    iFrame.src = Url;
//        document.all.popuptable.style.height = height - 15 + "px";


}

function HidePopUp()
{
    var PopUpBG = document.getElementById("PopUpBG");
    var iFrame = document.getElementById("PopUpFrame");
    iFrame.src = "";
    PopUpBG.style.display = "none";
    iFrame.style.display = "none";
}
