﻿function tellerror()
{
    return true;
}

function GetObject(objName)
{
    return document.getElementById(objName);
}

window.onerror = tellerror;

function ShowStep(theStep)
{
    document.getElementById("divRegStep1").style.display = "none";
    document.getElementById("divRegStep2").style.display = "none";
    document.getElementById("divRegStep3").style.display = "none";
    
    document.getElementById(theStep).style.display = "block";
}

function SaveCVDetails()
{
    if(GetObject("ctl00_bodyContent_ddlProfession").selectedIndex == 0 || GetObject("ctl00_bodyContent_ddlProfession").value == "")
    {
        alert("Please select a profession from the list provided");
    }
    else if(GetObject("txtName").value.length <= 0)
    {
        alert("Please enter your name");
    }
    else if(GetObject("txtContactNumber").value.length <= 0)
    {
        alert("Please enter a contact number");
    }
    else if(GetObject("txtEmail").value.length <= 0)
    {
        alert("Please enter an email address");
    }
    else
    {
        DownUnderJobs.Web.AjaxWebMethods.SaveCVRegistrationDetails(GetObject("ctl00_bodyContent_ddlProfession").value, GetObject("txtName").value, GetObject("txtContactNumber").value, GetObject("txtEmail").value, OnSaveCVDetails);
    }
}

function OnSaveCVDetails(theValue)
{
    //document.getElementById("divRegStep1").style.display = "none";
    //document.getElementById("divRegStep2").style.display = "block";
    //document.getElementById("divRegStep3").style.display = "none";
    location.href = "RegisterResume.aspx?rcvid=" + theValue;
    //GetObject("ctl00_bodyContent_txtCVRegistrationID").value = theValue;
}

function OnSaveResume()
{
    document.getElementById("divRegStep1").style.display = "none";
    document.getElementById("divRegStep2").style.display = "none";
    document.getElementById("divRegStep3").style.display = "block";
}

function SaveCVAdditionalInfo()
{
    var appliedForVisa = false;
    var flyInFlyOut = false;
    var ausLocationOfInterest = "";
    
    appliedForVisa = GetObject("rbVisa").checked;
    flyInFlyOut = GetObject("rbFlyInFlyOut").checked;
    
    if(GetObject("cbSydMet").checked)
        ausLocationOfInterest += "SydMet::";
    if(GetObject("cbPerMet").checked)
        ausLocationOfInterest += "PerMet::";
    if(GetObject("cbBriMet").checked)
        ausLocationOfInterest += "BriMet::";
    if(GetObject("cbMelMet").checked)
        ausLocationOfInterest += "MelMet::";
    if(GetObject("cbSydReg").checked)
        ausLocationOfInterest += "SydReg::";
    if(GetObject("cbPerReg").checked)
        ausLocationOfInterest += "PerReg::";
    if(GetObject("cbBriReg").checked)
        ausLocationOfInterest += "BriReg::";
    if(GetObject("cbMelReg").checked)
        ausLocationOfInterest += "MelReg::";
    if(GetObject("cbMelReg").checked)
        ausLocationOfInterest += "MelReg::";
    if(GetObject("cbNoPref").checked)
        ausLocationOfInterest += "NoPref::";
        
    DownUnderJobs.Web.AjaxWebMethods.SaveCVRegistrationAdditionalInfo(GetObject("ctl00_bodyContent_txtCVRegistrationID").value, appliedForVisa, flyInFlyOut, GetObject("taIdealRole").value, GetObject("txtOrigin").value, ausLocationOfInterest, GetObject("txtDedicatedConsultant").value, GetObject("ddlHearAboutUs").value, OnSaveCVAdditionalInfo); 
}

function OnSaveCVAdditionalInfo()
{
    //document.getElementById("divRegStep1").style.display = "none";
    //document.getElementById("divRegStep2").style.display = "none";
    //document.getElementById("divRegStep3").style.display = "none";
    //document.getElementById("divRegStep4").style.display = "block";
    
    location.href = "RegisterCompleted.aspx";
}

function SaveNominationDetails()
{
    if(GetObject("txtNomineeFirstName").value.length <= 0)
    {
        alert("Please enter the first name of the person you are nominating");
    }
    else if(GetObject("txtNomineeSurname").value.length <= 0)
    {
        alert("Please enter the surname of the person you are nominating");
    }
    else if(GetObject("txtNomineeEmail").value.length <= 0)
    {
        alert("Please specify an email address for the person you are nominating");
    }
    else if(GetObject("txtNomineePhone").value.length <= 0)
    {
        alert("Please enter a contact phone number for the person you are nominating");
    }
    else if(GetObject("ctl00_bodyContent_ddlAreaOfExpertise").value.length <= 0)
    {
        alert("Please select an area of expertise for the person you are nominating");
    }
    else
    {
        var professionDescription = "";
        
        for(x=0; x<GetObject("ctl00_bodyContent_ddlAreaOfExpertise").options.length; x++)
        {
            if(GetObject("ctl00_bodyContent_ddlAreaOfExpertise").options[x].selected)
                professionDescription = GetObject("ctl00_bodyContent_ddlAreaOfExpertise").options[x].text;
        }
    
        DownUnderJobs.Web.AjaxWebMethods.SaveNomination(GetObject("txtNomineeFirstName").value, GetObject("txtNomineeSurname").value, GetObject("txtNomineeEmail").value, GetObject("txtNomineePhone").value,  GetObject("ctl00_bodyContent_ddlAreaOfExpertise").value, GetObject("txtFirstName").value, GetObject("txtSurname").value, GetObject("txtEmail").value, GetObject("txtPhone").value, professionDescription, OnSaveNominationDetails);
    }
}

function OnSaveNominationDetails()
{

    GetObject("divNominationDetails").style.display = "none";
    GetObject("divNominationThankyou").style.display = "block";
}

function OpenApplyOnline(jobRefNo, consultantEmail, consultantName, position)
{
    position = position.replace("<b>","");
    position = position.replace("</b>","");
    position = position.replace("<B>","");
    position = position.replace("</B>","");
    position = position.replace("<strong>","");
    position = position.replace("</strong>","");
    position = position.replace("<STRONG>","");
    position = position.replace("</STRONG>","");
    position = position.replace("<i>","");
    position = position.replace("</i>","");
    position = position.replace("<I>","");
    position = position.replace("</I>","");
    position = position.replace("&","::amp::");
    
    window.open("ApplyOnline.aspx?jobRefNo=" + jobRefNo + "&conName=" + consultantName + "&conEmail=" + consultantEmail + "&position=" + position, "ApplyOnline", "left=100, top=100, scrollbars=false, address=false, width=640, height=480");
}

function OpenSendToAFriend(jobRefNo, consultantEmail, consultantName, position)
{
    window.open("EmailToAFriend.aspx?jobRefNo=" + jobRefNo + "&conName=" + consultantName + "&conEmail=" + consultantEmail + "&position=" + position, "ApplyOnline", "left=100, top=100, scrollbars=false, address=false, width=400, height=300");
}