﻿var sceneID = 1;
var audioToLoad = "";
var currentURL = "";
var currentEmail = "";
var timer1;
var isPlaying = true;
var CurrentJobID = 0;
var currentClickAction = "";

function LoadMovie(sceneIndex, audioName, clickAction, actionIndex)
{
    loadScene(sceneIndex);
    stopSpeech();
    audioToLoad = audioName;
    
    currentClickAction = clickAction;
    
    if(clickAction == "J")
    {
        GetObject("divDisableButtons").style.display = "none";
        GetObject("divApplyOnline").style.display = "block";
        GetObject("divEmailFriend").style.display = "block";
        DisplayTV();
        CurrentJobID = actionIndex;
        GetObject("divContactDetails").style.display = "none";
        GetObject("divMovie").style.display = "block";
        PersonnelConcept.Web.AjaxMethods.LoadJob(actionIndex, OnLoadJob);
    }
    else
    {
        GetObject("divDisableButtons").style.display = "block";
        GetObject("divApplyOnline").style.display = "none";
        GetObject("divEmailFriend").style.display = "none";
    }
}

function OnLoadJob(objectArray)
{
   GetObject("ctl00_MainContentArea_txtMobileMessage").value = objectArray[5];
   //GetObject("ctl00_MainContentArea_txtEmailMessage").value = objectArray[4];
   GetObject("hrefPodCast").href = "storage/audio/" + objectArray[11];
   GetObject("hrefGoWeb").href = objectArray[10];
   GetObject("divReadContent").innerHTML = "<span class='body_txt'>" + objectArray[3] + "</span>";
   GetObject("divJobTitle").innerHTML = "<h3>" + objectArray[2] + "</h3>";
   currentEmail = objectArray[4];
   GetObject("divContactDetailsContent").innerHTML = "<span class='contactDetailsTextBold'>INTERESTED.....?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><p/><center></center>Survey all options..... either:<ul style=\"text:align:justify;\"><li>Click '<a href='javascript:OpenApplyOnline();' class='contactDetailsText'>Apply Online</a>'</li><li><a href='mailto:" + objectArray[12] + "' class='contactDetailsText'>" + objectArray[12] + "</a></li><li>" + objectArray[14] + " " + objectArray[13] + " Confidential</li><li>visit <a href='" + objectArray[10] + "' target=new class='contactDetailsText'>" + objectArray[10].replace("http://","") + "</a></li></ul><br/><center><span class='disclaimerText'>* OralJobs.com.au and " + objectArray[10].replace("http://www.","") + " are Specialist Recruitment divisions of the Personnel Concept<br/><i>Leaders in Specialist Recruitment</i></span></center>";
   //GetObject("divContactDetailsContent").innerHTML = "<span class='contactDetailsTextBold'>INTERESTED.....?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><p/>Survey all options!<br/>Click '<a href='javascript:OpenApplyOnline();' class='contactDetailsText'>Apply Online</a>' or email resume to <a href='mailto:" + objectArray[12] + "' class='contactDetailsTextBlue'>" + objectArray[12] + "</a><br/>For a confidential chat call " + objectArray[14] + " on<br/>" + objectArray[13] + " or visit our text based site <a href='" + objectArray[10] + "' target=new class='contactDetailsTextGreen'>" + objectArray[10].replace("http://","") + "</a><p/>&nbsp;<br/><span class='disclaimerText'>* OralJobs.com.au and " + objectArray[10].replace("http://www.","") + " are Specialist Recruitment divisions of the Personnel Concept<br/><i>Leaders in Specialist Recruitment</i></span>";
   GetObject("tdJobDetails").innerHTML = "<strong>Job Details: </strong>" + objectArray[5];
}

function PlayNoAction()
{
    stopSpeech();
    LoadAudio("NoAction");
}

function ClearTimeout()
{
    clearTimeout("timer1");
}

function vh_sceneLoaded(sceneIndex)
{
    if(audioToLoad.length != 0)
        LoadAudio(audioToLoad);
        
    curURL = window.location.href;
    if(curURL.toLowerCase().search("viewemailavatar.aspx") > 0)
    {
        SetHairColor();
        SetSkinColor();
        Speak();
    }
}

function vh_talkEnded()
{
    //timer1 = setTimeout("PlayNoAction();", 60000);
    //GetObject("divMovie").style.display = "none";
    if(currentClickAction == "J")
    {
        GetObject("divContactDetails").style.display = "block";
        GetObject("divMovie").style.display = "none";
    }
}

function LoadAudio(audioName)
{
    sayAudio(audioName);
}

function RestartSpeech()
{
    stopSpeech();
    
    if(currentClickAction == "J")
    {
        GetObject("divContactDetails").style.display = "none";
        GetObject("divMovie").style.display = "block";
    }
    
    //if(audioToLoad.length != 0)
    //    LoadAudio(audioToLoad);
    //else
    //{
        replay(1);
    //}
}

function Si_RestartSpeech()
{
    stopSpeech();

    if(audioToLoad.length != 0)
        LoadAudio(audioToLoad);
    else
    {
        replay(1);
    }
    
//    stopSpeech();
//    
//    replay(1);
}

function PlayPauseSpeech()
{
    freezeToggle();
    if(isPlaying)
    {
        isPlaying = false;
        GetObject("imgPlayButton").src = "images/PlayerControls_PauseButton.gif";
    }
    else
    {
        isPlaying = true;
        GetObject("imgPlayButton").src = "images/PlayerControls_PlayButton.gif";
    }
}

function Si_PlayPauseSpeech()
{
    freezeToggle();
    if(isPlaying)
    {
        isPlaying = false;
        GetObject("imgPlayButton").src = "images/si_Player_PauseButton.gif";
    }
    else
    {
        isPlaying = true;
        GetObject("imgPlayButton").src = "images/si_Player_PlayButton.gif";
    }
}

function OpenURL()
{
    window.open(currentURL);
}

function SwapButtonImage(obj, mode)
{
    if(mode == "Over")
        obj.src = "images/" + obj.id + "_" + mode + ".gif";
    else
        obj.src = "images/" + obj.id + ".gif";
}

function DisplayTV()
{
    if(GetObject("divContactDetails").style.display == "block")
        GetObject("divContactDetails").style.display = "block";
    else
        GetObject("divMovie").style.display = "block";
        
    GetObject("divSendSMS").style.display = "none";
    GetObject("divReadJob").style.display = "none";
    
    if(!isPlaying)
        freezeToggle();
    
    isPlaying = true;
    GetObject("imgPlayButton").src = "images/PlayerControls_PlayButton.gif";
}

function DisplaySendSMS()
{
    GetObject("divMovie").style.display = "none";
    GetObject("divSendSMS").style.display = "block";
    GetObject("divReadJob").style.display = "none";
    
    if(isPlaying)
        freezeToggle();
    isPlaying = false;
    GetObject("imgPlayButton").src = "images/PlayerControls_PauseButton.gif";
}

function DisplayReadJob()
{
    GetObject("divMovie").style.display = "none";
    GetObject("divSendSMS").style.display = "none";
    GetObject("divReadJob").style.display = "block";
    
    if(isPlaying)
        freezeToggle();
    isPlaying = false;
    GetObject("imgPlayButton").src = "images/PlayerControls_PauseButton.gif";
}

function tellerror()
{
    return true;
}

function GetObject(objName)
{
    return document.getElementById(objName);
}

window.onerror = tellerror;

function SendEmail()
{
    PersonnelConcept.Web.AjaxMethods.SendEmail(GetObject("ctl00_MainContentArea_txtEmailTo").value, GetObject("ctl00_MainContentArea_txtEmailFrom").value, GetObject("ctl00_MainContentArea_txtEmailMessage").value, currentEmail, SendEmailComplete);
}

function SendEmailComplete()
{
    alert("All done");
}

function ResetSMS()
{
    GetObject("txtMobileTo").value = "";
    GetObject("txtMobileFrom").value = "";
    GetObject("txtMobileMessage").value = "";
}

function SendSMS()
{
    if(GetObject("ctl00_MainContentArea_txtMobileTo").value == "" || GetObject("ctl00_MainContentArea_txtMobileTo").value.length > 10)
    {
        alert("Please enter a valid mobile phone number to send your SMS to");
    }
    else if(GetObject("ctl00_MainContentArea_txtMobileFrom").value == "" || GetObject("ctl00_MainContentArea_txtMobileFrom").value.length > 10)
    {
        alert("Please enter a valid mobile phone number to send your SMS from");
    }
    else if(GetObject("ctl00_MainContentArea_txtMobileMessage").value == "" || GetObject("ctl00_MainContentArea_txtMobileMessage").value.length > 160)
    {
        alert("Please make sure your SMS message is between 1 and 160 characters");
    }
    else
    {
        PersonnelConcept.Web.AjaxMethods.SendSMS(GetObject("ctl00_MainContentArea_txtMobileTo").value, GetObject("ctl00_MainContentArea_txtMobileFrom").value, GetObject("ctl00_MainContentArea_txtMobileMessage").value, SendSMSComplete);
    }
}

function SendSMSComplete()
{
    alert("Your SMS has been sent");
}

var pageTimer = null;

//pageTimer = setTimeout("PlayNoAction();", 60000);

function ShowOralFunSection(toDisplay)
{
    GetObject("divOralFunWelcome").style.display = "none";
    GetObject("divJokeOfTheDay").style.display = "none";
    
    GetObject(toDisplay).style.display = "block";
}
  
function PlayJoke(jokeRow)
{
    if(sceneID != 15)
    {
        sceneID = 15;
        loadScene(15);
        stopSpeech();
        audioToLoad = jokeRow.getMember("SitePalAudioName").get_text();
    }
    else
    {
        stopSpeech();
        sayAudio(jokeRow.getMember("SitePalAudioName").get_text());
    }
    GetObject("divJokeOfTheDayIntro").style.display = "none";
    GetObject("divJokeOfTheDayPlayer").style.display = "block";
    GetObject("divJokeOfTheDayTitle").innerHTML = jokeRow.getMember("JokeTitle").get_text();
    GetObject("divJokeOfTheDayText").innerHTML = jokeRow.getMember("JokeText").get_text();
    
}

var startingVolumePosition = 50;
var startingVolumeLevel = 7;
var isMute = false;

function AdjustVolume(direction)
{
    if(direction == "up")
    {
        if(startingVolumeLevel < 10)
        {
            startingVolumePosition = startingVolumePosition - 17;
            startingVolumeLevel++;
            GetObject("divVolumeCover").style.clip = "rect(" + startingVolumePosition + "px 60px 220px 0px)";
            setPlayerVolume(startingVolumeLevel);
        }
    }
    else if(direction == "down")
    {
        if(startingVolumeLevel > 0)
        {
            startingVolumePosition = startingVolumePosition + 17;
            startingVolumeLevel--;
            GetObject("divVolumeCover").style.clip = "rect(" + startingVolumePosition + "px 60px 220px 0px)";
            setPlayerVolume(startingVolumeLevel);
        }
    }
}

function OpenApplyOnline()
{
    window.open("ApplyOnline.aspx?JobID=" + CurrentJobID, "ApplyOnline", "menubar=0,resizable=0,width=350,height=460");
}

function OpenEmailJob()
{
    window.open("EmailJob.aspx?JobID=" + CurrentJobID, "EmailJob", "menubar=0,resizable=0,width=350,height=460");
}

function GoWebSite()
{
    curURL = window.location.href;
    if(curURL.search("default.aspx") > 0)
    {
        var theAnswer = confirm("You are about to be taken to the Personnel Concept in a new browser window");
        if(theAnswer)
        {
            window.open("http://www.personnelconcept.com.au", "PersonnelConcept");
        }
    }
    else
        location.href = "default.aspx";
}

function DisplayPageView(multiPageID, pageViewID)
{
    eval(multiPageID + ".setPageId('" + pageViewID + "')");
}

function MuteAudio()
{
    if(isMute)
    {
        GetObject("imgAudioIcon").src = "admin/images/Btn_Audio_Over.jpg";
        setPlayerVolume(startingVolumeLevel);
        isMute = false;
    }
    else
    {
        GetObject("imgAudioIcon").src = "admin/images/Btn_Audio_Over_Mute.jpg";
        setPlayerVolume(0);
        isMute = true;
    }
}

function GoSector(section)
{
    curURL = window.location.href;
    if(curURL.search("default.aspx") > 0)
    {
        switch(section)
        {
            case "Accountant Jobs":
                LoadMovie(5, '', '', 0);ShowJobBrowser('AccountantJobs.com.au');
                break;
            case "Construct Jobs":
                LoadMovie(4, '', '', 0);ShowJobBrowser('ConstructJobs.com.au');
                break;
            case "Engineer Jobs":
                LoadMovie(7, '', '', 0);ShowJobBrowser('EngineerJobs.com.au');
                break;
            case "IT and T Jobs":
                LoadMovie(6, '', '', 0);ShowJobBrowser('ITandTJobs.com.au');
                break;
            case "Mine Jobs":
                LoadMovie(2, '', '', 0);ShowJobBrowser('MineJobs.com.au');
                break;
        }
    }
    else
    {
        location.href = "default.aspx?mode=" + section;
    }
}

function ShowJobBrowser(section)
{
    GetObject("divContactDetails").style.display = "none";  
    GetObject("divSendSMS").style.display = "none";
    GetObject("divReadJob").style.display = "none";
    GetObject("divMovie").style.display = "block";
    GetObject("divFaces").style.display = "none";
    GetObject("divJobBrowser").style.display = "block";
    GetObject("divFaceButtons").style.display = "block";
    NavBar1.collapseAll();
    itemCollection = NavBar1.get_items();
    switch(section)
    {
        case "AccountantJobs.com.au":
            itemCollection.getItem(0).set_expanded(true);
            break;
        case "ConstructJobs.com.au":
            itemCollection.getItem(1).set_expanded(true);
            break;
        case "EngineerJobs.com.au":
            itemCollection.getItem(2).set_expanded(true);
            break;
        case "ITandTJobs.com.au":
            itemCollection.getItem(3).set_expanded(true);
            break;
        case "MineJobs.com.au":
            itemCollection.getItem(4).set_expanded(true);
            break;
            default:break;
    }
}

function ValidateIpodForm()
{
    if(GetObject("ctl00_MainContentArea_txtName").value.length == 0)
    {
        alert("Please enter your name");
        return false;
    }
    else if(GetObject("ctl00_MainContentArea_txtEmail").value.length == 0)
    {
        alert("Please enter your email address");
        return false;
    }
    else if(GetObject("ctl00_MainContentArea_txtContactNumber").value.length == 0)
    {
        alert("Please enter your phone number");
        return false;
    }
    else
    {
        SubmitIpodForm();
    }
}

function SubmitIpodForm()
{
    PersonnelConcept.Web.AjaxMethods.SubmitIpodEntry(GetObject("ctl00_MainContentArea_txtName").value, 
        GetObject("ctl00_MainContentArea_txtEmail").value,
        GetObject("ctl00_MainContentArea_txtContactNumber").value, 
        GetObject("ctl00_MainContentArea_txtComments").value, OnSubmitIpodForm);
}

function OnSubmitIpodForm()
{
    GetObject("divWinIpodForm").style.display = "none";
    GetObject("divWinIpodThankyou").style.display = "block";
}

function LoadText(textID, obj)
{
    var textToLoad = "";
    
    switch(textID)
    {
        case "CANDIDATES_INTRO":
            textToLoad = "<span style=\"color:#000000;\">Oral</span><span style=\"color:#d30000;\">Jobs</span>.com.au provides you with an audio version of some available jobs from <span style=\"color:#d30000;\">Person</span><span style=\"color:#000000;\">nel Concept</span>. <p/>For a comprehensive overview of opportunities in your direct specialisation, visit the <span style=\"color:#d30000;\">Person</span><span style=\"color:#000000;\">nel Concept</span>’s network of industry specific websites listed below on this page.<p/>Have a look at them, they too are a world first.";
            break;
        case "CANDIDATES_DONT_LET_GUILT":
            textToLoad = "Often when you make a decision to resign your current employer will make a counter offer to retain you, whether it is through an increase in salary, title or accountability.  Research conducted worldwide indicates that 80% of people who accept a counter offer will leave their company within 6 months as nothing really changes. Follow your instinct and don’t let guilt cloud your decision to make a move.";        
            break;
        case "CANDIDATES_DONT_SELL_YOUR_SOUL":
            textToLoad = "Making a career decision is ranked in the top three of most important decisions. Some recruitment companies demand exclusivity from unsuspecting candidates. It is absurd in this candidate short market for a candidate to be pressured or subjected to fear tactics to submit to such exclusivity. Do you look for a house through one real estate agent, think about it. Candidates work with us exclusively by choice.";        
            break;
        case "CANDIDATES_OVERSEAS":
            textToLoad = "";        
            break;
        case "CLIENTS_COST_VS_PRICE":
            textToLoad = "The biggest cost in recruitment is not the money spent on recruiting a person it is the productivity loss that companies could sustain by taking on a lower performing candidate. <p/>As no 2 candidates are ever the same, fees should not be the determining factor when procuring talent. <p/>Like with most acquisitions, function and features are evaluated long before price. Too often companies limit access to exceptional candidates to reduce costs.<p/>An exceptional Engineer, Accountant or IT professional generates hundreds of thousands of dollars in fact millions of dollars in a year.<p/>Every day we see companies taking a 60% performer rather than 90% performers because of a fee difference of $3 000. <p/>Don’t sacrifice productivity for price. Widen your access to candidates.";        
            break;
        case "CLIENTS_PREF_SUPPLIERS":
            textToLoad = "It is respected and understood why companies have preferred suppliers. Every Preferred Supplier agreement has a clause that allows for a company to operate outside the preferred relationships in the event that the preferred supplier cannot find the right person. <p/>Should we not be one of your preferred suppliers, we offer companies the freedom of a non-obligatory choice.  <p/>As we are rewarded only on success and not effort we are compelled to provide quality candidates.";        
            break;
        case "CLIENTS_WIN_WIN":
            textToLoad = "Irrespective of source, you want the best candidate for the job. You and I are truly unique. Like you and I candidates educate and gain experience themselves. The source that delivers the candidate, whether it be word of mouth, electronic media or from preferred suppliers, becomes secondary to the need to hire the potentially best performing candidate for the job.<p/>We only charge for the commencement of the candidate, therefore we only make money in accuracy, a WIN WIN for all parties. Use us as a free non obligatory comparative.";        
            break;
        case "CLIENTS_COMP_IS_INEVITABLE":
            textToLoad = "Due to the existence job boards, candidates today at the push of a button apply to multiple job ads within minutes, it should therefore be expected that the candidates you see today is also being considered by your competitors. <p/>To become the employer of choice, we advise you focus on speed and employer branding when favouring a candidate.";        
            break;
        case "CANDIDATES_SEAL_THE_DEAL":
            textToLoad = "In this highly competitive and candidate short market, avoid disappointment and wasted effort by quickly securing your offer in writing.<p/>Sending your paperwork to use immediately after a verbal offer eliminates the risk of counter offers and other options. Seal the deal.";        
            break;
    }
    
    GetObject(obj).innerHTML = textToLoad;
}

function SendJokeSMS()
{
    if(GetObject("ctl00_MainContentArea_txtMobileTo").value == "" || GetObject("ctl00_MainContentArea_txtMobileTo").value.length > 10)
    {
        alert("Please enter a valid mobile phone number to send your SMS to");
    }
    else if(GetObject("ctl00_MainContentArea_txtMobileFrom").value == "" || GetObject("ctl00_MainContentArea_txtMobileFrom").value.length > 10)
    {
        alert("Please enter a valid mobile phone number to send your SMS from");
    }
    else
    {
        // Week 1
        //PersonnelConcept.Web.AjaxMethods.SendSMS(GetObject("ctl00_MainContentArea_txtMobileTo").value, GetObject("ctl00_MainContentArea_txtMobileFrom").value, "Boy asks a pirate why he has an eye patch. A bird shat in my eye. Surely that does not blind, no but it was the first day with my new hook - www.oraljobs.com.au", SendSMSComplete);
        
        // Week 2
        PersonnelConcept.Web.AjaxMethods.SendSMS(GetObject("ctl00_MainContentArea_txtMobileTo").value, GetObject("ctl00_MainContentArea_txtMobileFrom").value, "A little boy was lost. \"I can't find my dad\" he said to a policeman \"What's he like?\" the policeman asked \"Woman and beer\" the boy replied - www.oraljobs.com.au", SendSMSComplete);
        
    }
}

function ValidateJokeForm()
{
    if(GetObject("ctl00_MainContentArea_txtJokeName").value.length == 0)
    {
        alert("Please enter your name");
        return false;
    }
    else if(GetObject("ctl00_MainContentArea_txtJokeEmail").value.length == 0)
    {
        alert("Please enter your email address");
        return false;
    }
    else if(GetObject("ctl00_MainContentArea_txtJokePhone").value.length == 0)
    {
        alert("Please enter your phone number");
        return false;
    }
    else
    {   
        SubmitJokeForm();
    }
}

function SubmitJokeForm()
{

    PersonnelConcept.Web.AjaxMethods.SubmitJokeEntry(GetObject("ctl00_MainContentArea_txtJokeText").value,
        GetObject("ctl00_MainContentArea_txtJokeName").value, 
        GetObject("ctl00_MainContentArea_txtJokeEmail").value,
        GetObject("ctl00_MainContentArea_txtJokePhone").value, OnSubmitJokeForm);
}

function OnSubmitJokeForm()
{
    GetObject("divJokeForm").style.display = "none";
    GetObject("divJokeThankyou").style.display = "block";
}

function OpenDisclaimer()
{
    window.open("Disclaimer.aspx", "Disclaimer", "scrollbars=1,menubar=0,resizable=0,width=350,height=460");
}

function OpenPrivacy()
{
    window.open("Privacy.aspx", "PrivacyPolicy", "scrollbars=1,menubar=0,resizable=0,width=350,height=460");
}

function ValentinesRegisterReset()
{
    GetObject("ctl00_MainContentArea_txtRegisterName").value = "";
    GetObject("ctl00_MainContentArea_txtRegisterEmail").value = "";
    GetObject("ctl00_MainContentArea_txtRegisterPhone").value = "";
    GetObject("ctl00_MainContentArea_txtRegisterText").value = "";
}

function ValidateValentinesRegisterForm()
{
    if(GetObject("ctl00_MainContentArea_txtRegisterName").value.length == 0)
    {
        alert("Please enter your name");
        return false;
    }
    else if(GetObject("ctl00_MainContentArea_txtRegisterEmail").value.length == 0)
    {
        alert("Please enter your email address");
        return false;
    }
    else
    {   
        SubmitValentinesRegisterForm();
    } 
}

function SubmitValentinesRegisterForm()
{
    PersonnelConcept.Web.AjaxMethods.SaveRegisteredUser(GetObject("ctl00_MainContentArea_txtRegisterName").value,
        GetObject("ctl00_MainContentArea_txtRegisterEmail").value, 
        GetObject("ctl00_MainContentArea_txtRegisterPhone").value,
        GetObject("ctl00_MainContentArea_txtRegisterText").value,
        "Valentines", OnSubmitValentinesRegisterForm);
}

function OnSubmitValentinesRegisterForm()
{
    alert("Thank you, your details have been registered with OralJobs.com.au");
}

function CreateAnAvatarRegisterReset()
{
    GetObject("ctl00_MainContentArea_txtRegisterName").value = "";
    GetObject("ctl00_MainContentArea_txtRegisterEmail").value = "";
    GetObject("ctl00_MainContentArea_txtRegisterPhone").value = "";
    GetObject("ctl00_MainContentArea_txtRegisterText").value = "";
}

function ValidateCreateAnAvatarForm()
{
    if(GetObject("ctl00_MainContentArea_txtRegisterName").value.length == 0)
    {
        alert("Please enter your name");
        return false;
    }
    else if(GetObject("ctl00_MainContentArea_txtRegisterEmail").value.length == 0)
    {
        alert("Please enter your email address");
        return false;
    }
    else
    {   
        SubmitCreateAnAvatarRegisterForm();
    }
}

function SubmitCreateAnAvatarRegisterForm()
{
    PersonnelConcept.Web.AjaxMethods.SaveRegisteredUser(GetObject("ctl00_MainContentArea_txtRegisterName").value,
        GetObject("ctl00_MainContentArea_txtRegisterEmail").value, 
        GetObject("ctl00_MainContentArea_txtRegisterPhone").value,
        GetObject("ctl00_MainContentArea_txtRegisterText").value,
        "Valentines", OnSubmitCreateAnAvatarRegisterForm);
}

function OnSubmitCreateAnAvatarRegisterForm()
{
    alert("Thank you, your details have been registered with OralJobs.com.au");
}