﻿//
var animationPanel;
function PageStart() {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Begin);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(End);
}
function Begin(sender, args) {
    jQuery('input').blur();
    sender._postBackSettings.sourceElement.disabled = true
    animationPanel = "." + sender._postBackSettings.sourceElement.getAttribute("rel");
    jQuery('html, body').animate({
        scrollTop: jQuery('body').offset().top
    }, 2000);
    jQuery(animationPanel).slideUp(1500);
    jQuery(".loader").fadeIn("fast");
}
function End(sender, args) {
    animationPanel = "." + sender._postBackSettings.sourceElement.getAttribute("rel");
    jQuery(".loader").fadeOut("fast");
    jQuery(animationPanel).slideDown("fast");
}
//

function testLogin() {
    var f = document.forms[0];
    ISLOnline.Login.login(
					f.username.value,
					f.password.value,
					function (info) {
					    info.getPage('isllight-start').redirect();
					},
					function (error) {
					    document.getElementById('feedbackLogin').innerHTML = error.getDescription();
					}
			)
}
function testJoin() {
    //var f = document.forms[1];
    var f = jQuery('input[rel="isl_input"]')[0]
    if (f.value.length > 0) {
        ISLOnline.Join.getSessionInfoByCode(
				    f.value,
				    function (info) {
				        var e = document.getElementById('feedbackJoin');
				        e.style.backgroundColor = '';
				        e.innerHTML = '';
				        e.appendChild(document.createTextNode(info.getAttribute('supporterName') + ' - ' + info.getAttribute('sessionCode')));
				        e.appendChild(document.createElement('br'));
				        var b = document.createElement('a');
				        //b.type = 'button';
				        b.name = 'join';
				        //b.value = 'Start';
				        b.innerHTML = 'Start';
                        b.href = 'javascript:void(0);';
				        b.onclick = function () { info.join() };
				        e.appendChild(b);
				        jQuery("#feedbackJoin").show("fast");
				    },
				    function (error) {
				        var e = jQuery("#feedbackJoin")[0];
				        //e.style.backgroundColor = 'red';
				        e.innerHTML = error.getDescription();
				        jQuery("#feedbackJoin").show("fast");
				    }
		    )
    }
}
