﻿function check_search(theform) {
    if (theform.keyword.value == "") {
        alert("Please enter the keyword.");
        theform.keyword.focus;
        return false;

    }
    if (theform.type.value.indexOf("?") == -1) {
        theform.action = theform.type.value;
        theform.type.value = "";
    }
    else {
        theform.action = theform.type.value.substring(0, theform.type.value.indexOf("?"));
        theform.kind.value = theform.type.value.substring(theform.type.value.indexOf("=") + 1, theform.type.value.indexOf("=") + 2);
        theform.type.value = "";
    }
    return true;
}
function get_messenger(emailID) {
    // Test #1: Launch with no email variable value causing the user to have to select another user to interact with.
    var msn_obj = CheckMessenger();
    if (is_msn_on_tag) {
        if (msn_obj == null)
            return true;
        else {
            LaunchMSN(msn_obj, emailID);
            return false;
        }
    }
    else {
        location = '/en/le_msg.aspx';
        return false;

    }
}

function LaunchMSN(obj, emailID) {
    if (obj != null) {
        location = 'msnim:chat?contact=' + emailID;
        //obj.LaunchApp('', emailID);
    }
}
function CheckMessenger() {
    eval('try {obj = new ActiveXObject("MSNMessenger.P4QuickLaunch"); } catch (e) {obj = null;}');
    if (obj == null)
        return null;
    else
        return obj;
}

var is_msn_on_tag = false;
function showpresence(presence) {
    var innerFrame = document.getElementById('innerFrame');
    var innerFrame_login = document.getElementById('innerFrame_login');
    var statusIcon = document.createElement('img');
    statusIcon.style.border = 'none';
    statusIcon.algin = 'absbottom';
    statusIcon.src = presence.icon.url;
    statusIcon.width = presence.icon.width;
    statusIcon.height = presence.icon.height;
    //statusIcon.alt = presence.statusText;
    //statusIcon.title = presence.statusText;

    var displayName = document.createElement('span');
    //displayName.style.fontFamily = 'Tahoma, Verdana, sans-serif';
    displayName.style.fontSize = '9pt';
    displayName.style.color = 'orange';
    displayName.title = presence.displayName;

    var statusText = document.createElement('span');
    //statusText.style.fontFamily = 'Tahoma, Verdana, sans-serif';
    statusText.style.fontSize = '9pt';
    //statusText.title =presence.statusText;
    if (presence.statusText != 'Offline') {
        is_msn_on_tag = true;
        statusText.style.color = 'lime';
        statusText.style.fontweight = 'bold';
    }
    else
        statusText.style.color = 'gray';



    if ((displayName.innerText !== undefined) && (statusText.innerText !== undefined)) {

        //displayName.innerText = presence.displayName;
        //statusText.innerText ='('+ presence.statusText+')';
        if (presence.statusText != 'Offline') {
            displayName.innerText = 'Customer Service';
            statusText.innerText = '(Online)';
            document.getElementById('chang_state').innerHTML = '<img src="/en/style/2007/online.jpg" border="0" alt="MSN Online">';
        }
        else {
            displayName.innerText = 'Customer Service';
            statusText.innerText = '(offline)';
            document.getElementById('chang_state').innerHTML = '<img src="/en/style/2007/off.jpg" border="0" alt="MSN Offline">';
        }

    }
    else if ((displayName.textContent != undefined) && (statusText.textContent !== undefined)) {
        //displayName.textContent == presence.displayName;
        //statusText.textContent =='('+ presence.statusText+')';
        if (presence.statusText != 'Offline') {
            displayName.textContent = 'Customer Service';
            statusText.textContent = '(Online)';
            document.getElementById('chang_state').innerHTML = '<img src="/en/style/2007/online.jpg" border="0" alt="MSN Online">';
        }
        else {
            displayName.textContent = 'Customer Service';
            statusText.textContent = '(offline)';
            document.getElementById('chang_state').innerHTML = '<img src="/en/style/2007/off.jpg" border="0" alt="MSN Offline">';
        }
    }

    var br = document.createElement('br');

    innerFrame.appendChild(statusIcon);
    //innerFrame.appendChild(br);
    innerFrame.appendChild(displayName);
    //innerFrame.appendChild(br);
    innerFrame.appendChild(statusText);
}