var connectLink;
var linkURl;
initialize();
function initialize() {
    $('#connectButton').click(function () {
        window.location.href = connectLink;
    });

    $('#profileConnectButton').click(function () {
//        alert();
        linkURl = document.getElementById('linkURL').value;
        window.location.href = linkURl;
    });
}

//$('#profileConnectButton').click(function () {
//    linkURl = document.getElementById('linkURL').value;
//    alert(linkURl);
//    window.location.href = linkURl;
//});


//function checkForAction(url, action, message, ID) {
//    alert();
//}
function checkForLinkAction(url, action, message, ID) {
    swal({
        title: "",
        text: message + ' ? ',
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: '#80c12c',
        cancelButtonText: "No",
        confirmButtonText: "Yes",
        closeOnConfirm: true,
        closeOnCancel: true
    },
    function (isConfirm) {
        if (isConfirm) {
            serverPage = url;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
//                alert(xmlhttp.readyState);
//                alert(xmlhttp.status);
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                {
//                    alert(xmlhttp.responseText);
                    if (xmlhttp.responseText == '1') {
                        tt_alert('You tried to some illegal action If You Need Any Help please contact with Talhatraining help desk');
                    } else {
                        document.getElementById("sActions" + ID).innerHTML = xmlhttp.responseText;
                        initialize();
                    }

                }
            }
            xmlhttp.send(null);
        } else {
            return;
        }

    });
}

function tt_alert(message) {
    swal({
        title: "",
        text: message,
        type: "warning",
        closeOnConfirm: true,
        showCancelButton: true,
        confirmButtonColor: '#80c12c',
        cancelButtonText: "No",
        closeOnCancel: true
    },
    function () {
    });
}
