﻿


SAOSS_Method = 'Empty';

function Company() {




}


/*-------------------------------------|  START: AJAX File Upload  |--------------------------------------------------------------------*/



/*-------------------------------------|  FINISH: AJAX File Upload  |--------------------------------------------------------------------*/





/*-------------------------------------|  START: Twitter  |--------------------------------------------------------------------*/

//$('<div id="Twitter">').appendTo("body").click(function() { alert("Open Twitter"); });
//$('#Twitter').mouseover(function() {$(this).css('background-image', 'url(/Images/TwitterWink.png)');$(this).mouseout(function() { $(this).css('background-image', 'url(/Images/TwitterOpen.png)'); });});

//function Blink() {$('#Twitter').css('background-image', 'url(/Images/TwitterClosed.png)');setTimeout(openEyes, 200);}
//function openEyes() { $('#Twitter').css('background-image', 'url(/Images/TwitterOpen.png)');}

//var TwitterBlink = setInterval(Blink, 5000);


var _0x5ab3 = ["\x4F\x70\x65\x6E\x20\x54\x77\x69\x74\x74\x65\x72", "\x63\x6C\x69\x63\x6B", "\x62\x6F\x64\x79", "\x61\x70\x70\x65\x6E\x64\x54\x6F", "\x3C\x64\x69\x76\x20\x69\x64\x3D\x22\x54\x77\x69\x74\x74\x65\x72\x22\x3E", "\x62\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x2D\x69\x6D\x61\x67\x65", "\x75\x72\x6C\x28\x2F\x49\x6D\x61\x67\x65\x73\x2F\x54\x77\x69\x74\x74\x65\x72\x57\x69\x6E\x6B\x2E\x70\x6E\x67\x29", "\x63\x73\x73", "\x75\x72\x6C\x28\x2F\x49\x6D\x61\x67\x65\x73\x2F\x54\x77\x69\x74\x74\x65\x72\x4F\x70\x65\x6E\x2E\x70\x6E\x67\x29", "\x6D\x6F\x75\x73\x65\x6F\x75\x74", "\x6D\x6F\x75\x73\x65\x6F\x76\x65\x72", "\x23\x54\x77\x69\x74\x74\x65\x72", "\x75\x72\x6C\x28\x2F\x49\x6D\x61\x67\x65\x73\x2F\x54\x77\x69\x74\x74\x65\x72\x43\x6C\x6F\x73\x65\x64\x2E\x70\x6E\x67\x29"]; $(_0x5ab3[4])[_0x5ab3[3]](_0x5ab3[2])[_0x5ab3[1]](function() { alert(_0x5ab3[0]); }); $(_0x5ab3[11])[_0x5ab3[10]](function() { $(this)[_0x5ab3[7]](_0x5ab3[5], _0x5ab3[6]); $(this)[_0x5ab3[9]](function() { $(this)[_0x5ab3[7]](_0x5ab3[5], _0x5ab3[8]); }); }); function Blink() { $(_0x5ab3[11])[_0x5ab3[7]](_0x5ab3[5], _0x5ab3[12]); setTimeout(openEyes, 200); }; function openEyes() { $(_0x5ab3[11])[_0x5ab3[7]](_0x5ab3[5], _0x5ab3[8]); }; var TwitterBlink = setInterval(Blink, 5000);

/*-------------------------------------|  FINISH: Twitter  |--------------------------------------------------------------------*/



//-------------------------------------|  START: 118499 Bubble    |-----------------------------------------------------------

function clearBubble() {
    SAOSS_Module = '118499'; SAOSS_Method = 'clearBubble';

    Bubble.style.display = 'none';

}
function hideBubble() {
    SAOSS_Module = '118499'; SAOSS_Method = 'hideBubble';

    //alert('clearBubble');
    playSound(0);
    setTimeout("clearBubble(Bubble);", 100)
    
}
function showBubble() {
    SAOSS_Module = '118499'; SAOSS_Method = 'showBubble';

    //alert('showBubble');
    
    Bubble.style.top = '100px';
    Bubble.style.top = '100px';
    Bubble.style.display = 'block';

    playSound();    //Plays the default or preferred jingle;
}
function doBubbleTags() {
    SAOSS_Module = '118499'; SAOSS_Method = 'doBubbleTags';
//alert('doBubbleTags');
    var Tags = document.getElementsByTagName('b');

    for (var i = 0; i < Tags.length; i++) {

        if (Tags[i].className == 'A499') {
            var inn = Tags[i].innerHTML;
            if (inn === '499') {
                //alert(inn);
                //Add Handler
                Tags[i].onmouseover = showBubble;
                Tags[i].onmouseout = hideBubble;
                Tags[i].onclick = showBubble; 
                inn = null;
            };
        };
    };
};


var Bubble = Object;

function doBubbles() {
    SAOSS_Module = '118499'; SAOSS_Method = 'doBubbles';

    var B = document.body
    Bubble = document.createElement('div');
    Bubble.id = 'LittleBubble';

    setTimeout("document.body.appendChild(Bubble);", 100)

    //We then need to apply the ShowBubble function to all <a> tags of class:A499

    doBubbleTags();

}




//-------------------------------------|  FINISH: 118499 Bubble  |-----------------------------------------------------------




//-------------------------------------|  START: Charity Poster Selector  |-----------------------------------------------------------//


function doCharityPoster(Me){   //These functions only work with the Downloads Page

    var Charity = Me.options[Me.selectedIndex].text;
    var IDX = Me.options[Me.selectedIndex].value;
    doUpdatePosters(IDX);

};
function doUpdatePosters(IDX) { //This function fills the Poster DIV's with new Images

    
   for (var i = 0; i <= 6; i++) {
       //$("#CP" + i).css("background-image", "url(/Downloads/Images/" + IDX + "/CP" + i + ".png)");
       $('#CP' + i).empty();
       $('<div onclick="TestOO(' + i + ')" title="Download"></div><a href="/Downloads/PDFs/' + IDX + '/CP' + i + '.pdf" target="_blank"><img src="/Downloads/Images/' + IDX + '/CP' + i + '.png" alt="Barnardos Poster" /></a>').appendTo('#CP' + i);

    };

    //We need to implement tracking so we can assess activity. 
    
};
function TestOO(IDX) {alert("Test Images " + IDX); }

//-------------------------------------|  FINISH: Charity Poster Selector  |-----------------------------------------------------------//




//-------------------------------------|  START: Keypad  |-----------------------------------------------------------//

var KeysOn = false;
function InitialiseKepad() {
    //alert('InitialiseKepad');
    $('#Keypad').mouseenter(function() {
        doKeypadMouseIn();
    })
    $('#Keypad').mouseleave(function() {
        doClearKeypad()
    })

    doSetKeys();
    
    //onkeydown $('#target').click();

}
function doKeypadMouseIn() {

    //$('#Keypad').css('background-color', 'blue');
    
}
function doClearKeypad() {

    //Clear up all events, variables...
    //$('#Keypad').css('background-color', 'red');

}
function doSetKeys() {
    if(KeysOn){return};
    var Delay = 100;

    $('#BTN1').click(function() { SetNum('1'); setTimeout(function() { $('#BTN1').mouseup(); }, Delay); })
    $('#BTN2').click(function() { SetNum('2'); setTimeout(function() { $('#BTN2').mouseup(); }, Delay); })
    $('#BTN3').click(function() { SetNum('3'); setTimeout(function() { $('#BTN3').mouseup(); }, Delay); })
    $('#BTN4').click(function() { SetNum('4'); setTimeout(function() { $('#BTN4').mouseup(); }, Delay); })
    $('#BTN5').click(function() { SetNum('5'); setTimeout(function() { $('#BTN5').mouseup(); }, Delay); })
    $('#BTN6').click(function() { SetNum('6'); setTimeout(function() { $('#BTN6').mouseup(); }, Delay); })
    $('#BTN7').click(function() { SetNum('7'); setTimeout(function() { $('#BTN7').mouseup(); }, Delay); })
    $('#BTN8').click(function() { SetNum('8'); setTimeout(function() { $('#BTN8').mouseup(); }, Delay); })
    $('#BTN9').click(function() { SetNum('9'); setTimeout(function() { $('#BTN9').mouseup(); }, Delay); })
    $('#BTN0').click(function() { SetNum('0'); setTimeout(function() { $('#BTN0').mouseup(); }, Delay); })

    $('#BTNS').click(function() { $('#BTNS').mousedown(); $('#MP_CP_Mobile').text('07'); $('#MP_CP_Mobile').css('color', '#CCCCCC'); doSetKeys(); setTimeout(function() { $('#BTNS').mouseup(); }, 200); });
    $('#BTNH').click(function() { $('#BTNH').mousedown(); $('#MP_CP_Mobile').text(Left($('#MP_CP_Mobile').text(), Len($('#MP_CP_Mobile').text()) - 1)); setTimeout(function() { $('#BTNH').mouseup(); }, Delay); });
    $('#BTNS').mousedown(function() { $(this).css('background-color', 'Green'); })
    $('#BTNS').mouseup(function() { $(this).css('background-color', 'Gray'); })
    $('#BTNH').mousedown(function() { $(this).css('background-color', 'Green'); })
    $('#BTNH').mouseup(function() { $(this).css('background-color', 'Gray'); })
    
    for (var i = 0; i <= 12; i++) {

        $('#BTN' + i).mousedown(function() { $(this).css('background-color', 'Yellow'); })
        $('#BTN' + i).mouseup(function() { $(this).css('background-color', 'Gray'); })

    }

    //$('body').keyup(function() { $(this).css('background-color', 'Gray'); })
    //$('#BTN' + i).keydown(function() { $(this).css('background-color', 'Yellow'); })

    var xTriggered = 0;
    $('body').keypress(function(event) {
        if (event.keyCode == '13') {
            event.preventDefault();
        } else {
            var N = 0;
            switch (event.which) {
                case 49: { N = 1; break; }
                case 50: { N = 2; break; }
                case 51: { N = 3; break; }
                case 52: { N = 4; break; }
                case 53: { N = 5; break; }
                case 54: { N = 6; break; }
                case 55: { N = 7; break; }
                case 56: { N = 8; break; }
                case 57: { N = 9; break; }
                case 58: { N = 0; break; }
                default: { }
            }
            $('#BTN' + N).mousedown(); 
            $('#BTN' + N).click();
            
            $('#BTN' + N).keyup(function() { $(this).css('background-color', 'Gray'); });

        }
        xTriggered++;
    });

   

    
    KeysOn = true;
}
function SetNum(NUM) {
    
    if ($('#MP_CP_Mobile').text() == '') {
        if (NUM != '0'){
            alert('Mobile number MUST start with a ZERO');
            return;
        }
    }
    if ($('#MP_CP_Mobile').text() == '0') {
        if (NUM != '7') {
            alert('The second number is always a 7');
            return;
        }
    }

    if (Len($('#MP_CP_Mobile').text()) == 10) {
        $('#MP_CP_Mobile').css('color', 'Green');
        $('#NTick').css("background-image", "url(/Downloads/Images/Tick.png)");
        //$('#MP_CP_Mobile').css('font-size', '1em');
    }

    if (Len($('#MP_CP_Mobile').text()) > 10) {
       doClearButtons(NUM);
    } else {
        $('#MP_CP_Mobile').text($('#MP_CP_Mobile').text() + NUM);
    }
}
function doClearButtons(NUM) {
    //$('#Keypad DIV.Number').unbind("click");       //.click(function() { SetNum('1'); })
    $('#MP_CP_Mobile').text('07' + NUM);
    $('#MP_CP_Mobile').css('color', '#CCCCCC');
    //$('#MP_CP_Mobile').css('font-size', '0.8em');
    $('#NTick').css("background-image", "none");
    $('#BTNS').click();
    //KeysOn = false;
}

function Pause(numberMillis) {
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
}
function SendCard() {
    var SMSN = $('#MP_CP_Mobile').text();
    alert('Sending to ' + SMSN);
}
    
$(document).ready(function() {
    InitialiseKepad()
});


//-------------------------------------|  FINISH: Keypad  |-----------------------------------------------------------//





//--------------------------------------------------------|    END: Module    |------------------------------------------------------//

(typeof SAOSS_AddModule != 'undefined') ? SAOSS_AddModule('118499 Module', '1.0', false,'118499 Feature Module') : '';   //Add this Module to the Modules Array (Tracking)

//window.onload = fixMeffyIE;  //Call Setup Method - Any Setup routine MUST call Global.Setup()

doBubbles();
