﻿$(document).ready(function() {
});

function sendMessage() {
    var email = document.getElementById("edtEmail");
    var text = document.getElementById("edtText");
    if (isEmail(email.value) && (text.value!="")) {
        var nameBox = $("#edtName");
        var name = "";
        if (nameBox.length > 0) {
            name = nameBox.attr('value');
        }
        var timeOffset = getTimeOffset();
        $('#messageBox').show();
        $('#messageBody').hide();
        $('#messageBox').attr('innerHTML', '<span style="color: Green; width: 100%; margin-top: 0pt;">Thank you for contacting us! <br> <b>We will get in touch with you shortly.</b></span>');

        $.ajax({
            type: "POST",
            url: "/ajaxhandler.aspx",
            data: {
                "requestType": "contactEmail",
                "email": email.value,
                "text": text.value,
                "name": name,
                "timeOffset": timeOffset
            },
            success: function(data) {
                if (data != "True") {
                    $('#messageBox').attr('innerHTML', data);
                    $('#messageBody').show();
                }
                $('#messageBox').show();
            },
            error: function() {
                $('#messageBox').show();
                $('#messageBody').show();
                $('#messageBox').attr('innerHTML', '<span style=\"color: Red; width: 100%; margin-top: 10px; display: block;\"><b>Error sending email.</b></span>');
            }
        });
    } else {
        $('#messageBox').attr('innerHTML', '<span style=\"color: Red; width: 100%; margin-top: 0pt;\"><b>Please specify <br> valid Email and message text.</b></span>');
        $('#messageBox').show();
    }
    return false;
}

function checkSkype() {
    $('li.skypecheck').html('<a href="skype:htmlcut?chat"><img src="http://mystatus.skype.com/mediumicon/htmlcut" class="border_img_none" width="18" height="18" alt="Skype" /></a> <a href="skype:htmlcut?chat">htmlcut</a>');
}


