﻿//<!--

var mouseX = 0
var mouseY = 0
var visibleItem = ""
var checkDivPos = false
var jobId
var IE = document.all ? true : false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY

var SaveThisDialogBox

function checkDate(sender, args) {
    if (sender._selectedDate < new Date()) {
        alert("You cannot select a day earlier than today!")
        sender._selectedDate = new Date()
        // set the date back to the current date
        sender._textbox.set_Value(sender._selectedDate.format(sender._format))
    }
}

function getMouseXY(e) {
    try {
        if (IE) {
            mouseX = event.clientX
            mouseY = event.clientY
        } else {
            mouseX = e.pageX
            mouseY = e.pageY
        }

        if (mouseX < 0) { mouseX = 0 }
        if (mouseY < 0) { mouseY = 0 }
        return true
    } catch (e) {

    }
}

function openWindow(url, name, width, height) {
    popupWin = window.open(url, name, 'scrollbars=YES,width=750,height=500')
}

function ShowSaveThisJobDialogBox(me, jobid) {
    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SaveThisJob(jobid, SucceededSaveThisJobCallback, FailedCallback)
}


function SucceededSaveThisJobCallback() {
    SaveThisJobDialogBox = document.getElementById('SaveThisJob')
    SaveThisJobDialogBox.style.display = 'block'
    SaveThisJobDialogBox.style.top = mouseY - 10
    SaveThisJobDialogBox.style.left = mouseX - 200 
	
}

//Save jobe notes//			
function saveJobNotes(jobid) {
    SaveThisJobTxt = document.getElementById('SaveThisJobTxtBox').value
    if (SaveThisJobTxt == "") {
        alert("Please, provie a brief note to attach to the job");
        return false;
    }

    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SaveThisJobNote(jobid, SaveThisJobTxt, SucceededJobNoteCallback, FailedCallback)
}



function SucceededJobNoteCallback() {
        SaveThisJobDialogBox.style.display = "none";
        alert("Your note  has been saved successfully")
}


//END Save jobe notes//		


function ShowSaveThisSearchDialogBox(me) {
    //saveThisJobSearch()
    SaveThisJobDialogBox = document.getElementById('SaveSearchingCreteria')
    SaveThisJobDialogBox.style.display = 'block'
    SaveThisJobDialogBox.style.top = mouseY - 10
    SaveThisJobDialogBox.style.left = mouseX - 200
}



function saveThisJobSearch(searchName, notificationAlert) {

    if (searchName == "") {
        alert("Please provide a name for this search");
        return false;
    }

    if (notificationAlert == "") {
        alert("Please provide a notification date");
        return false;
    }
    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SaveThisJobSearch(searchName, notificationAlert, SucceededJobSearchCallback, FailedJobSearchCallBack)

}
function SucceededJobSearchCallback(result) {
    alert("Information has been saved successfully.")
}
function FailedJobSearchCallBack(error) {
    alert("error")           
	    return false;
}


function saveThisResumeSearch(searchName, notificationAlert) {

    if (searchName == "") {
        alert("Please provide a name for this search");
        return false;
    }

    if (notificationAlert == "") {
        alert("Please provide a notification date");
        return false;
    }
    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SaveThisResumeSearch(searchName, notificationAlert, SucceededResumeSearchCallback, FailedResumeSearchCallBack)

}
function SucceededResumeSearchCallback(result) {
    alert("Information has been saved successfully.")
}
function FailedResumeSearchCallBack(error) {
    alert(error.get_message())
	    return false;
}




function saveThisSpSearch(searchName, notificationAlert) {
    if (searchName == "" ) {
        alert("Provide a name for this search");
        return false;
    }

    if (notificationAlert == "") {
        alert("Provide a notification date");
        return false;
    }
   
    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SaveThisSpSearch(searchName, notificationAlert, SucceededCallback, FailedCallback)
  
}

function SucceededCallback(result) {
    alert("Information has been saved successfully.")
}

function FailedCallback(error) {
    alert(error.get_message())
	    return false;
}


function ShowSaveThisResumeDialogBox(me, resumeid) {
    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SaveThisResume(resumeid, SucceededSaveThisResumeCallback(resumeid), FailedCallback);
}

function SucceededSaveThisResumeCallback(resumeid) {
   // SaveThisResume(resumeid);
    SaveThisResumeDialogBox = document.getElementById('SaveThisResume');
    SaveThisResumeDialogBox.style.display = 'block';
    SaveThisResumeDialogBox.style.top = mouseY - 10;
    SaveThisResumeDialogBox.style.left = mouseX - 200;
}


//Save jobe notes//			
function saveResumeNotes(resumeid) {

    SaveThisResumeTxt = document.getElementById('SaveThisResumeTxtBox').value
    if (SaveThisResumeTxt == "") {
        alert("A brief note is required");
        return false;
    }

    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SaveThisJobNote(resumeid, SaveThisResumeTxt, SucceededResumeNoteCallback, FailedCallback)
}

function SucceededResumeNoteCallback() {
    SaveThisResumeDialogBox.style.display = "none";
    alert("Your note  has been saved successfully")
}


// ajax  searchMyJobs
function searchMyResumes(ProfileItem_ID, ResumeSearchResultPageID) {
    // alert(JobSearchResultPageID);

    var redirectUrl = "resumeSearchResult.aspx?pageID=" + ResumeSearchResultPageID
    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SearchMyProfile(ProfileItem_ID, 'ResumeSearch', savedSearchCallback(redirectUrl), InValidEmailCallback)
}


function ShowSaveThisSPSearchDialogBox(me) {
    SaveThisJobDialogBox = document.getElementById('SaveSearchingCreteria')
    SaveThisJobDialogBox.style.display = 'block'
    SaveThisJobDialogBox.style.top = mouseY - 10
    SaveThisJobDialogBox.style.left = mouseX - 70
}


function ShowSaveThisJobTrainingDialogBox(me, id) {
    SaveThisJobTraining(id)
    SaveThisJobTrainingDialogBox = document.getElementById('SaveThisJobTraining')
    SaveThisJobTrainingDialogBox.style.display = 'block'
    SaveThisJobTrainingDialogBox.style.top = mouseY - 10
    SaveThisJobTrainingDialogBox.style.left = mouseX - 200


}

//END Save jobe notes//	

function checkUniqueEmail(emailTextBox) {
    if (emailTextBox.value == "") {
        alert("Provide a valid email");
        return false;
    }

    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.CheckIfUserExists(emailTextBox.value, ValidEmailCallback, InValidEmailCallback)
}

function ValidEmailCallback(result) {
    //If e-mail doesn't exists, do nothing
   // alert("Information has been saved successfully.")
}

function InValidEmailCallback(error,emailTextBox) {
    //alert(error.get_message());
    return false;
}

// ajax  searchMyJobs
function searchMyJobs(ProfileItem_ID, JobSearchResultPageID) {
    var redirectUrl = "jobSearchResult.aspx?pageID=" + JobSearchResultPageID;
    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.SearchMyProfile(ProfileItem_ID, 'jobSearch', savedSearchCallback(redirectUrl), InValidEmailCallback)


}

function savedSearchCallback(redirectUrl) {
    document.location = redirectUrl
}


	function logOff(redirectUrl) {
   		reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.LogOff(SucceededLogOffCallback(redirectUrl))
    }

    function SucceededLogOffCallback(result,redirectUrl) {

        alert( result + " Logoff successfully");
        document.location = "/?logOff";
    
    }

    function hideShowLogOff(loggOfBtn_div, soSiteUserid) {
      if (!Number(soSiteUserid) > 0) {
            loggOfBtn_div.style.display = "none"
        } else {
            soSiteUserid = Number(soSiteUserid)
            if (typeof (soSiteUserid) != "number") {
                loggOfBtn_div.style.display = "none"
            } else {
                loggOfBtn_div.style.display = "block"
            }

        }
}


function show_div(E) {
    var A = document.getElementById(E);
    var C = window.innerWidth;
    var D = window.innerHeight;

    //must display block first to have clientWidth and clientHeight
    A.style.display = "block";

    var elementWidth = A.clientWidth;
    var elementHeight = A.clientHeight;

    A.style.top = String(Math.round((D - elementHeight) / 2)) + "px";
    A.style.left = String(Math.round((C - elementWidth) / 2)) + "px";
}

function launchEmail(email, emailVars) {
    if (email == '') {
        alert("Email is not available.")
        return
    }

    reqValue = Hyperonix.CMS.Forms.MyAbilityLinks.DecryptEmail(email, SucceededDecryptemailCallback, FailedCallback, emailVars)
    
}
function SucceededDecryptemailCallback(result, emailVars) {
	   if (result == '') {
        alert("Email is not available.")
        return
    }
    location.href = "mailto:" + result + "?" + emailVars
}


function getSelText(editorid) {
    var editor = $find(editorid);


    var editPanel = Sys.Extended.UI.HTMLEditor.LastFocusedEditPanel;
    var designPanel = editPanel.get_activePanel();
    var htmlText;
    // Ensure focus in design panel   
    designPanel.focusEditor();

    var sel = designPanel._getSelection();
    var _content = designPanel.get_content();

    var popleft=((document.body.clientWidth - 440) / 2)+window.screenLeft;
    var poptop=(((document.body.clientHeight - 460) / 2))+window.screenTop-40;
		
	window.open("management/ajaxwebeditor/addEditImage.aspx?folderPath=images","Upload","scrollbars=no,width=550,height=580,resizable=yes,status=yes,toolbar=no, left="+popleft+",top="+poptop)


   
}   


